Browse Source

fixed bug where loading an object would override previous objects

iver 7 months ago
parent
commit
75a4df5edd

BIN
builds/final binaries/librasteriver.so


BIN
builds/final binaries/main.bin


+ 5 - 5
src/RasterIver/source code/rasteriver.c

@@ -473,11 +473,6 @@ int malloc_objects(int objects, char **file_names, char **allocated_file_names,
             
             fclose(file);
         }
-
-            object_file_offsets[i * 5 + 0] = 0;
-            object_file_offsets[i * 5 + 1] = 0;
-            object_file_offsets[i * 5 + 2] = 0;
-            object_file_offsets[i * 5 + 3] = 0;
     }
 
     face_count = malloc_face_count;
@@ -736,6 +731,11 @@ RI_objects RI_RequestObjects(RI_newObject *RI_ObjectBuffer, int RI_ObjectsToRequ
             textures_size += texture_width * texture_height;
         }
 
+        loading_object_current_faces_count = object_file_offsets[i_object * 5 + 0];
+        loading_object_current_verticies_count = object_file_offsets[i_object * 5 + 1];
+        loading_object_current_normals_count = object_file_offsets[i_object * 5 + 2];
+        loading_object_current_uvs_count = object_file_offsets[i_object * 5 + 3];
+
         if (object_file_offsets[i_object * 5 + 4] > 0){
             debug(RI_DEBUG_HIGH, "Loading Object at Triangle Index: %f", objects[base + 10]);
             debug(RI_DEBUG_HIGH, "Loading Object at Vertex Index: %f", objects[base + 11]);

+ 4 - 4
src/launch program/main.c

@@ -29,14 +29,14 @@ int main(){
 
     RI_newObject object_buffer[6] = {
         {-300, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
+        {0, 0, 1000,         0, 0, 0, -9999999,  100, 100, 100,     "objects/test_guy_hd.obj", "textures/test_guy_texture.png"},
+        {100, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
+        {300, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/test_guy_hd.obj", "textures/test_guy_texture.png"},
         {300, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
-        {300, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
-        {300, 0, 1000,       0, 0, 0, -9999999,          100, 100, 100,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
-        {0, 0, 15,         0, 0, 0, -9999999,  1, 1, 1,     "objects/test_guy_hd.obj", "textures/test_guy_texture.png"},
         {0, 0, 300,      0, 0.0, 0, -9999999,          50, 50, 50,  "objects/rotated_cube.obj", "textures/bill_mcdinner.png"},
     };
 
-    RI_objects objects = RI_RequestObjects(object_buffer, 1);
+    RI_objects objects = RI_RequestObjects(object_buffer, 4);
 
     while (RI_IsRunning() == RI_RUNNING){
         RI_Tick();