Jump to content

clearNode()


photo

Recommended Posts

int clearNode( const char * name )

Clears a cache of a given node.

Arguments

  • const char * name - Path to the *.node file.

Return value

1 if the cache is cleared successfully; otherwise, 0.

 

Example)

ObjectMeshStaticPtr node1 = ObjectMeshStatic::cast(NodeReference::cast(node)->getReference());         

…       //node1 editing........

 

World::get()->clearNode(node);      //  <------- it's mean that The Nordreference returns to the state of before editing??

Link to comment

Hi Dongju,

Caching of nodes is used to speed up loading process, if a node was added to cache during loading operation, the next time when you try to load it from the file you'll simply get a clone of a cached node, instead of parsing the *.node file and retrieving data once again.

Nodes are added to cache on loading, when the second argument of loadNode() is set to 1 (default value):

World::get()->loadNode("mynode.node",1);

When you call clearNode() the node will be removed from cache, and the next time you try to load it the *.node file will be parsed again to get node's data. So, it has nothing to do with restoring the initial state of a NodeReference after modifying it.

When you modify a NodeReference via code, the corresponding *.node file actually remains unchanged until you call World::get()->saveNode() (the same way as you would click Apply when modifying an instance of a NodeReference in the Editor). After saving your changes to a *.node file, you won't get your initial state back.

Thank you!

  • Like 1
Link to comment

thank you for your answer.

 

then, What is the function same as pressing the Cancel button after editing?

Pressing Cancel in the editor returns to the original state.

Link to comment
×
×
  • Create New...