Przeglądaj źródła

Added convert_local2stage and convert_stage2local with const raw pointers.

Neo7k 10 lat temu
rodzic
commit
a984055fec
2 zmienionych plików z 19 dodań i 3 usunięć
  1. 17 3
      oxygine/src/Actor.cpp
  2. 2 0
      oxygine/src/Actor.h

+ 17 - 3
oxygine/src/Actor.cpp

@@ -1286,10 +1286,10 @@ namespace oxygine
         }
     }
 
-    Vector2 convert_global2local_(Actor* child, Actor* parent, Vector2 pos)
+    Vector2 convert_global2local_(const Actor* child, const Actor* parent, Vector2 pos)
     {
         if (child->getParent() && child->getParent() != parent)
-            pos = convert_global2local(child->getParent(), parent, pos);
+            pos = convert_global2local_(child->getParent(), parent, pos);
         /*
         Actor *p = child->getParent();
         if (p && child != parent)
@@ -1304,7 +1304,7 @@ namespace oxygine
         return convert_global2local_(child.get(), parent.get(), pos);
     }
 
-    Vector2 convert_local2global_(Actor* child, Actor* parent, Vector2 pos)
+    Vector2 convert_local2global_(const Actor* child, const Actor* parent, Vector2 pos)
     {
         while (child && child != parent)
         {
@@ -1327,6 +1327,13 @@ namespace oxygine
         return convert_local2global(actor, root, pos);
     }
 
+    Vector2 convert_local2stage(const Actor* actor, const Vector2& pos, const Actor* root)
+    {
+        if( !root )
+            root = getStage().get();
+        return convert_local2global_(actor, root, pos);
+    }
+
     Vector2 convert_stage2local(spActor actor, const Vector2& pos, spActor root)
     {
         if (!root)
@@ -1334,6 +1341,13 @@ namespace oxygine
         return convert_global2local(actor, root, pos);
     }
 
+    Vector2 convert_stage2local(const Actor* actor, const Vector2& pos, const Actor* root )
+    {
+        if( !root )
+            root = getStage().get();
+        return convert_global2local_(actor, root, pos);
+    }
+
     Renderer::transform getGlobalTransform(spActor child, spActor parent)
     {
         Renderer::transform t;

+ 2 - 0
oxygine/src/Actor.h

@@ -377,7 +377,9 @@ namespace oxygine
     Vector2 convert_local2global(spActor child, spActor parent, const Vector2& pos);//deprecated, use convert_local2stage
 
     Vector2 convert_local2stage(spActor child, const Vector2& pos, spActor root = 0);
+    Vector2 convert_local2stage(const Actor* child, const Vector2& pos, const Actor* root = 0);
     Vector2 convert_stage2local(spActor child, const Vector2& pos, spActor root = 0);
+    Vector2 convert_stage2local(const Actor* child, const Vector2& pos, const Actor* root = 0);
 
     /**Deprecated*/
     inline Vector2 convert_local2root(spActor child, const Vector2& pos, spActor root = 0) { return convert_local2stage(child, pos, root); }