diff --git a/source/inochi2d/core/nodes/package.d b/source/inochi2d/core/nodes/package.d index bffbc32..a3b8473 100644 --- a/source/inochi2d/core/nodes/package.d +++ b/source/inochi2d/core/nodes/package.d @@ -91,6 +91,9 @@ private: @Name("lockToRoot") bool lockToRoot_; + @Ignore + string nodePath_; + protected: /** @@ -208,6 +211,14 @@ public: */ string name = "Unnamed Node"; + /** + Name of node as a null-terminated C string + */ + const(char)* cName() { + import std.string : toStringz; + return name.toStringz; + } + /** Returns the unique identifier for this node */ @@ -384,6 +395,25 @@ public: return vec3(cm * vec4(0, 0, 0, 1)); } + /** + Gets the path to the node. + */ + final + string getNodePath() { + import std.array : join; + if (nodePath_.length > 0) return nodePath_; + + string[] pathSegments; + Node parent = this; + while(parent !is null) { + pathSegments = parent.name ~ pathSegments; + parent = parent.parent; + } + + nodePath_ = "/"~pathSegments.join("/"); + return nodePath_; + } + /** Gets the depth of this node */ @@ -455,6 +485,7 @@ public: enum OFFSET_START = size_t.min; enum OFFSET_END = size_t.max; final void insertInto(Node node, size_t offset) { + nodePath_ = null; import std.algorithm.mutation : remove; import std.algorithm.searching : countUntil;