]> Dogcows Code - chaz/yoink/blobdiff - src/Scene.cc
sockets documentation and cleanup
[chaz/yoink] / src / Scene.cc
index 918ff5250b843c8c8b0020b3935ab848e07cf4ae..16e1aef55b210903fff7caeb2e65bb4fb344df55 100644 (file)
@@ -177,19 +177,19 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
                int detail = 3;
                settings.get("detail", detail);
-               script.push(detail); script.set("detail");
+               script.globals().setField("detail", detail);
 
-               script.push(1); script.set("LOW");
-               script.push(2); script.set("MEDIUM");
-               script.push(3); script.set("HIGH");
+               script.globals().setField("LOW",    1);
+               script.globals().setField("MEDIUM", 2);
+               script.globals().setField("HIGH",   3);
 
-               script.push(X); script.set("X");
-               script.push(Y); script.set("Y");
-               script.push(Z); script.set("Z");
+               script.globals().setField("X", X);
+               script.globals().setField("Y", Y);
+               script.globals().setField("Z", Z);
 
-               script.push(Quad::LEFT);  script.set("LEFT");
-               script.push(Quad::RIGHT); script.set("RIGHT");
-               script.push(Quad::TOP);   script.set("TOP");
+               script.globals().setField("LEFT",  Quad::LEFT);
+               script.globals().setField("RIGHT", Quad::RIGHT);
+               script.globals().setField("TOP",   Quad::TOP);
        }
 
 
@@ -207,26 +207,17 @@ struct Scene::Impl : public Mf::Manager<Impl>
        }
 
 
-       static int loadBox(Mf::Script& script, Mf::Aabb<3>& aabb)
+       static int loadBox(Mf::Script& script, Mf::Aabb3& aabb)
        {
                script[1].requireTable();
                script[2].requireTable();
-               script.setSize(2);
 
-               for (int i = 1; i <= 2; ++i)
-               {
-                       for (int j = 1; j <= 3; ++j)
-                       {
-                               script[i].pushField(j);
-                       }
-               }
-
-               script[3].get(aabb.min[0]);
-               script[4].get(aabb.min[1]);
-               script[5].get(aabb.min[2]);
-               script[6].get(aabb.max[0]);
-               script[7].get(aabb.max[1]);
-               script[8].get(aabb.max[2]);
+               script[1].pushField(1).get(aabb.min[0]);
+               script[1].pushField(2).get(aabb.min[1]);
+               script[1].pushField(3).get(aabb.min[2]);
+               script[2].pushField(1).get(aabb.max[0]);
+               script[2].pushField(2).get(aabb.max[1]);
+               script[2].pushField(3).get(aabb.max[2]);
 
                return 0;
        }
@@ -247,7 +238,6 @@ struct Scene::Impl : public Mf::Manager<Impl>
        int translate(Mf::Script& script)
        {
                Mf::Vector3 vec;
-
                script[1].requireNumber().get(vec[0]);
                script[2].requireNumber().get(vec[1]);
                script[3].requireNumber().get(vec[2]);
@@ -261,7 +251,7 @@ struct Scene::Impl : public Mf::Manager<Impl>
 
        int scale(Mf::Script& script)
        {
-               int size = script.getSize();
+               int size = script.stackSize();
 
                if (size == 1)
                {
@@ -285,7 +275,7 @@ struct Scene::Impl : public Mf::Manager<Impl>
                }
                else
                {
-                       script.getTop().throwError("wrong number of arguments");
+                       script.top().raise("wrong number of arguments");
                }
 
                return 0;
@@ -316,19 +306,16 @@ struct Scene::Impl : public Mf::Manager<Impl>
                Mf::Script::Slot        table = script[1].requireTable();
 
                int width  = 1;
-               int height = 1;
-               int nTiles = 0;
-
                table.get(width, "width");
 
-               nTiles = table.getLength();
+               int nTiles = table.length();
                if (nTiles % width != 0)
                {
-                       table.throwError("invalid number of tiles");
+                       table.raise("invalid number of tiles");
                }
 
-               if (width == 0) table.throwError("width field must not be zero");
-               height = nTiles / width;
+               if (width == 0) table.raise("width field must not be zero");
+               int height = nTiles / width;
 
                Mf::Vector3             vertices[height+1][width+1];
 
This page took 0.022878 seconds and 4 git commands to generate.