Tutorial #03: Pong - "Dashed Midline" doesn't need of AddGraphNode? - Flávio San - 25 Nov 2015
Hello!
I know that when I use AddGraphNode the engine does automatically clear the GraphNode when OnDeInit is called.
In the Tutorial #03: Pong the "Dashed Midline" is not using AddGraphNode, but only mBallTransform.GetReference(root, "line_"+Util::UInt32ToString(i));.
My question is: "Dashed Midline" doesn't need use AddGraphNode to clear the memory?
Tutorial #01: Cube Wrote:In order to manage references in a more comfortable way, the BaseProcessor class offers the convenient method AddGraphNode(). This method keeps track of all requested references and passes the responsibility of removing references on to the BaseProcessor itself. All tracked references are released automatically, when the BaseProcessor's destructor is called.
RE: Tutorial #03: Pong - "Dashed Midline" doesn't need of AddGraphNode? - Ketschak - 25 Nov 2015
Using AddGraphNode() has the advantage that RemoveReference() is called automatically for each node when the BaseProcessor's destructor is called and that we easily can verify if all references are valid with the AreGraphNodesValid() method.
However, in this case we ourself take care to remove the requested references:
// GetReference gets a reference and increases the reference counter
mBallTransform.GetReference(root, "line_"+Util::UInt32ToString(i));
mBallTransform->SetPositionY(-20.0 + (maxInstances/2 - i)*40);
// RemoveReference removes the reference and decreases the reference counter
mBallTransform.RemoveReference();
RE: Tutorial #03: Pong - "Dashed Midline" doesn't need of AddGraphNode? - Flávio San - 25 Nov 2015
OK! I'm still in the early tutorials and maybe I'm being rushed! From what I understand, in this example the "Dashed Midline" are just data in video memory, so, I'll just need to clear my video memory.
Murl Engine gives support for the user to make these cleanings in video memory?
(25 Nov 2015, 8:59)Ketschak Wrote: Using AddGraphNode() has the advantage that RemoveReference() is called automatically for each node when the BaseProcessor's destructor is called and that we easily can verify if all references are valid with the AreGraphNodesValid() method.
However, in this case we ourself take care to remove the requested references:
// GetReference gets a reference and increases the reference counter
mBallTransform.GetReference(root, "line_"+Util::UInt32ToString(i));
mBallTransform->SetPositionY(-20.0 + (maxInstances/2 - i)*40);
// RemoveReference removes the reference and decreases the reference counter
mBallTransform.RemoveReference();
RE: Tutorial #03: Pong - "Dashed Midline" doesn't need of AddGraphNode? - Ketschak - 25 Nov 2015
This has nothing to do with video memory.
The nodes in the scene graph can be referenced by multiple objects - e.g. the renderer, the logic class ...
We use reference counting for each node to track how many references are hold by other objects.
If you obtain a reference with GetReference() you must make sure that you also call RemoveReference() when you are finished. Thats all.
AddGraphNode() does not clear the graph node, it just collects the node and when the destructor is called, it calls RemoveReference() for each collected node. Its usually simply more convenient to use AddGraphNode() but it is not mandatory required.
RE: Tutorial #03: Pong - "Dashed Midline" doesn't need of AddGraphNode? - Flávio San - 25 Nov 2015
Ok, I will study more the engine to see how far the API allows me to do what I want.
Best Regards!
(25 Nov 2015, 19:06)Ketschak Wrote: This has nothing to do with video memory.
The nodes in the scene graph can be referenced by multiple objects - e.g. the renderer, the logic class ...
We use reference counting for each node to track how many references are hold by other objects.
If you obtain a reference with GetReference() you must make sure that you also call RemoveReference() when you are finished. Thats all.
AddGraphNode() does not clear the graph node, it just collects the node and when the destructor is called, it calls RemoveReference() for each collected node. Its usually simply more convenient to use AddGraphNode() but it is not mandatory required.
|