From: Murashov G. <Mur...@se...> - 2008-07-23 08:31:10
|
Hi. Could you tell me, please, how function openvrml::node_type::create_node() is supposed to be used? I'm asking, because I'm little bit confused that one get shared_ptr< scope > as parameter and openvrml::node use shared_ptr inside, but node::scope() and scene::root_scope() return scope& and scope*. Is it bug? Another question: everywhere, working with object openvrml::node, intrusive_ptr is used, but openvrml::scope::find_node() returns openvrml::node*. Although in this case safe work is possible, I think that it is not in right way. Gleb. |
From: Braden M. <br...@en...> - 2008-07-23 09:28:43
|
On Wed, 2008-07-23 at 12:31 +0400, Murashov Gleb wrote: > Hi. > > Could you tell me, please, how function > openvrml::node_type::create_node() is supposed to be used? > I'm asking, because I'm little bit confused that one get shared_ptr< > scope > as parameter and openvrml::node use shared_ptr inside, but > node::scope() and scene::root_scope() return scope& and scope*. > Is it bug? No. Nodes participate in ownership of scopes. There's not a reason to propagate ownership of scopes to other types of objects. node_type::create_node is a rather low-level operation from OpenVRML's perspective. That is not to say that you shouldn't be using it; just be aware that browser::create_vrml_from_stream may be an appropriate alternative. > Another question: everywhere, working with object openvrml::node, > intrusive_ptr is used, but openvrml::scope::find_node() returns > openvrml::node*. Although in this case safe work is possible, I think > that it is not in right way. You can safely construct an intrusive_ptr from a raw pointer whenever you need to create an owning pointer. (Notwithstanding, of course, the potential to create ownership cycles--which you are responsible for avoiding/accommodating.) -- Braden McDaniel e-mail: <br...@en...> <http://endoframe.com> Jabber: <br...@ja...> |
From: Murashov G. <Mur...@se...> - 2008-08-08 13:13:55
|
On Wed, 2008-07-23, Braden McDaniel wrote: > node_type::create_node is a rather low-level operation from OpenVRML's > perspective. That is not to say that you shouldn't be using it; just > be aware that browser::create_vrml_from_stream may be an appropriate alternative. I've used browser::create_vrml_from_stream successfully, but I can't understand, which scope got created node. field_value_listener< mfnode >& fvl_add = group_node->event_listener< mfnode >("addChildren"); std::stringstream sss; sss << "DEF main_TS TouchSensor {}"; mfnode::value_type nodes_for_mfnode = browser.create_vrml_from_stream(sss); mfnode mfn(nodes_for_mfnode); fvl_add.process_event(mfn, 0.0); ... node* f_n = root_scope.find_node("main_TS"); // f_n == 0 :( TouchSensor is created and works, but created node doesn't appear in root_scope. Where can I find that? Is there any possibility to manage this? Getting back to node_type::create_node(). If we can't use this function outside library, it would be better to remove this one from public interface? Another thing. I've found small bug in openvrml-xembed and mozilla-plugin interaction. And I don't know how bug-tracking have to be used, so I write here. =) openvrml-0.17.6\mozilla-plugin\src\openvrml.cpp : 442 command << "new-stream " << ptrdiff_t(stream) << ' ' << type << ' ' << stream->url << '\n'; openvrml-0.17.6\mozilla-plugin\src\openvrml.cpp : 460 command << "destroy-stream " << ptrdiff_t(stream) << '\n'; Signed type ptrdiff_t is using. openvrml-0.17.6\src\openvrml-xembed\main.cpp : 149-151 size_t stream_id; std::string type, url; command_line_stream >> stream_id >> type >> url; openvrml-0.17.6\src\openvrml-xembed\main.cpp : 172-173 size_t stream_id; command_line_stream >> stream_id; Unsigned type size_t is using. That was reason my system crash during plug-in initialization. This happens from time to time. Gleb. |
From: Braden M. <br...@en...> - 2008-08-09 04:52:45
|
Murashov Gleb wrote: > > On Wed, 2008-07-23, Braden McDaniel wrote: >> node_type::create_node is a rather low-level operation from OpenVRML's > >> perspective. That is not to say that you shouldn't be using it; just >> be aware that browser::create_vrml_from_stream may be an appropriate > alternative. > > I've used browser::create_vrml_from_stream successfully, but I can't > understand, which scope got created node. > > field_value_listener< mfnode >& fvl_add = > group_node->event_listener< mfnode >("addChildren"); > > std::stringstream sss; > sss << "DEF main_TS TouchSensor {}"; > mfnode::value_type nodes_for_mfnode = > browser.create_vrml_from_stream(sss); > > mfnode mfn(nodes_for_mfnode); > fvl_add.process_event(mfn, 0.0); > > ... > > node* f_n = root_scope.find_node("main_TS"); > // f_n == 0 :( > > TouchSensor is created and works, but created node doesn't appear in > root_scope. Where can I find that? Is there any possibility to manage > this? openvrml::scope corresponds to a lexical scope for DEF/USE names. As such, the nodes created from create_vrml_from_stream have their own root scope that is distinct from the scene's. The only way to get to this scope is through a node (i.e., openvrml::node::scope). Can you tell me more about what you're trying to accomplish? Perhaps there's another approach that would work better. > Getting back to node_type::create_node(). If we can't use this function > outside library, it would be better to remove this one from public > interface? I don't know of anything that prevents this function from being usable by clients of libopenvrml. It just doesn't present the simplest interface for creating nodes from VRML text. > Another thing. I've found small bug in openvrml-xembed and > mozilla-plugin interaction. And I don't know how bug-tracking have to be > used, so I write here. =) OpenVRML uses the SourceForge tracker. Don't worry too much about getting the bug categorization exactly right; that can generally be adjusted ad hoc. > openvrml-0.17.6\mozilla-plugin\src\openvrml.cpp : 442 > command << "new-stream " << ptrdiff_t(stream) << ' ' << type << > ' ' << stream->url << '\n'; > openvrml-0.17.6\mozilla-plugin\src\openvrml.cpp : 460 > command << "destroy-stream " << ptrdiff_t(stream) << '\n'; > > Signed type ptrdiff_t is using. > > openvrml-0.17.6\src\openvrml-xembed\main.cpp : 149-151 > size_t stream_id; > std::string type, url; > command_line_stream >> stream_id >> type >> url; > openvrml-0.17.6\src\openvrml-xembed\main.cpp : 172-173 > size_t stream_id; > command_line_stream >> stream_id; > > Unsigned type size_t is using. > > That was reason my system crash during plug-in initialization. This > happens from time to time. Hm... Good point. This really should use size_t consistently. This is probably worth going ahead and fixing; however, I'm in the middle of ripping out this pipe-based custom IPC solution in favor of D-Bus interfaces. -- Braden McDaniel e-mail: <br...@en...> <http://endoframe.com> Jabber: <br...@ja...> |
From: Braden M. <br...@en...> - 2008-08-11 03:19:29
|
Braden McDaniel wrote: > Murashov Gleb wrote: >> >> On Wed, 2008-07-23, Braden McDaniel wrote: >>> node_type::create_node is a rather low-level operation from OpenVRML's >>> perspective. That is not to say that you shouldn't be using it; just >>> be aware that browser::create_vrml_from_stream may be an appropriate >> alternative. >> >> I've used browser::create_vrml_from_stream successfully, but I can't >> understand, which scope got created node. >> >> field_value_listener< mfnode >& fvl_add = >> group_node->event_listener< mfnode >("addChildren"); >> >> std::stringstream sss; >> sss << "DEF main_TS TouchSensor {}"; >> mfnode::value_type nodes_for_mfnode = >> browser.create_vrml_from_stream(sss); >> >> mfnode mfn(nodes_for_mfnode); >> fvl_add.process_event(mfn, 0.0); >> >> ... >> >> node* f_n = root_scope.find_node("main_TS"); >> // f_n == 0 :( >> >> TouchSensor is created and works, but created node doesn't appear in >> root_scope. Where can I find that? Is there any possibility to manage >> this? > > openvrml::scope corresponds to a lexical scope for DEF/USE names. As > such, the nodes created from create_vrml_from_stream have their own root > scope that is distinct from the scene's. The only way to get to this > scope is through a node (i.e., openvrml::node::scope). I was very tired when I wrote the above response. In case it's not clear, you can get the root scope associated with the nodes read from the stream as follows: const openvrml::scope & s = nodes_for_mfnode[0]->scope(); You can then use openvrml::scope::find_node on s as you do with root_scope in the code above. Of course, if all you want is a pointer to main_TS, "nodes_for_mfnode[0]" is a perfectly reasonable way to get it (in this case). -- Braden McDaniel e-mail: <br...@en...> <http://endoframe.com> Jabber: <br...@ja...> |