ecere/src/com; gfx; gui: Temporary patches for alignment issues
[sdk] / ecere / src / gfx / 3D / Object.ec
index 89d7c08..3ab47ae 100644 (file)
@@ -6,14 +6,14 @@ public enum FrustumPlacement { outside, inside, intersecting };
 
 public class ObjectFormat
 {
-   class_data char * extension;
-   class_property char * extension
+   class_data const char * extension;
+   class_property const char * extension
    {
       set { class_data(extension) = value; }
       get { return class_data(extension); }
    }
 
-   virtual bool ::Load(Object object, char * fileName, DisplaySystem displaySystem);
+   virtual bool ::Load(Object object, const char * fileName, DisplaySystem displaySystem);
 };
 
 // TODO: Review these:
@@ -654,7 +654,7 @@ public:
       }
    }
 
-   bool Load(char * fileName, char * type, DisplaySystem displaySystem)
+   bool Load(const char * fileName, const char * type, DisplaySystem displaySystem)
    {
       char ext[MAX_EXTENSION];
       subclass(ObjectFormat) format;
@@ -662,10 +662,7 @@ public:
       bool result = false;
 
       if(!type && fileName)
-      {
-         type = GetExtension(fileName, ext);
-         strlwr(type);
-      }
+         type = strlwr(GetExtension(fileName, ext));
 
       for(link = class(ObjectFormat).derivatives.first; link; link = link.next)
       {
@@ -696,7 +693,7 @@ public:
       }
    }
 
-   Object Find(char * name)
+   Object Find(const char * name)
    {
       if(this && name)
       {
@@ -750,9 +747,9 @@ public:
       return null;
    }
 
-   bool AddName(Object object, char * name)
+   bool AddName(Object object, const char * name)
    {
-      bool result;
+      bool result = false;
       if(this)
       {
          char * newName = CopyString(name);
@@ -770,7 +767,7 @@ public:
    {
       bool result = false;
 
-      if(!children.first)
+      if(!children.first && this.flags.ownMesh)
          result = true;
       else
       {
@@ -857,7 +854,7 @@ public:
             while(true)
             {
                int nIndices = 0;
-               PrimitiveGroupType type;
+               PrimitiveGroupType type = (PrimitiveGroupType)-1;
                Material material = null;
                bool foundGroup = false;
 
@@ -926,7 +923,7 @@ public:
                                     newGroup.indices32[nIndices++] = group.indices32[c] + vertexOffset;
                               else
                                  for(c = 0; c<group.nIndices; c++)
-                                    newGroup.indices[nIndices++] = group.indices[c] + (uint16)vertexOffset;
+                                    newGroup.indices[nIndices++] = (uint16)(group.indices[c] + vertexOffset);
                            }
                         }
                         vertexOffset += objectMesh.nVertices;
@@ -947,7 +944,7 @@ public:
                                        newGroup.indices32[nIndices++] = group.indices32[c] + vertexOffset;
                                  else
                                     for(c = 0; c<group.nIndices; c++)
-                                       newGroup.indices[nIndices++] = group.indices[c] + (uint16)vertexOffset;
+                                       newGroup.indices[nIndices++] = (uint16)(group.indices[c] + vertexOffset);
                               }
                            }
                            vertexOffset += child.mesh.nVertices;
@@ -1267,7 +1264,7 @@ public:
    property Camera camera { get { return camera; } }; // Fix this with inheritance? camera inherit from Object?
    property Object firstChild { get { return children.first; } };
    property Object next { get { return next; } };
-   property char * name { get { return name; } };
+   property const char * name { get { return name; } };
    property Matrix matrix { get { value = matrix; } };
    property Object cameraTarget { set { cameraTarget = value; } get { return cameraTarget; } };
    property OldList * tracks { /* set { tracks = value; } */ get { return &tracks; } };
@@ -1276,7 +1273,7 @@ public:
 private:
    Object()
    {
-      children.offset = (uint)&((Object)0).prev;
+      children.offset = (uint)(uintptr)&((Object)0).prev;
       transform.scaling = { 1, 1, 1 };
       transform.orientation = { 1,0,0,0 };
       flags.transform = true;
@@ -1310,7 +1307,7 @@ private:
 
          if(flags.camera && cameraTarget)
          {
-            // DeterMine angle to look at target
+            // Determine angle to look at target
             Vector3D position, direction;
             if(flags.root || !parent)
                position = transform.position;
@@ -1516,7 +1513,8 @@ private:
    unsigned startFrame, endFrame;
    int frame;
    Vector3Df pivot;
-   Transform transform;
+
+   public Transform transform;
    Matrix matrix;
    Matrix localMatrix;
    void * tag;