shithub: tinygl

Download patch

ref: 3100557ad67bb72d7ad9a7bd2c8ff041d6008210
parent: e1a86db17238fd177e7b413825fc17991328532f
author: gek169 <gek169>
date: Mon May 10 07:10:12 EDT 2021

Automatic commit.

--- a/include-demo/chade.h
+++ b/include-demo/chade.h
@@ -97,6 +97,10 @@
 		if(world->ents[i] == NULL){
 			world->ents[i] = ent;
 			world->world.bodies[i] = &ent->body;
+			if(world->n_ents <= i){
+				world->n_ents = i + 1;
+				world->world.nbodies = i+1;
+			}
 			return i;
 		}
 	}
@@ -104,9 +108,16 @@
 
 }
 
-static inline void ChadWorld_RemoveEntity(ChadWorld* world, unsigned long index){
-	if(index < (unsigned long)world->max_ents && index > 0)
-		{world->ents[index] = NULL;world->world.bodies[index] = NULL;}
+static inline void ChadWorld_RemoveEntityByPointer(ChadWorld* world,  ChadEntity* ent){
+	for(long i = 0; i < world->max_ents; i++)
+		if(world->ents[i] == ent) {
+			world->ents[i] = NULL;
+			world->world.bodies[i] = NULL;
+		}
+	//recalculate n_ents
+	for(long i = 0; i < world->max_ents; i++)
+		if(world->ents[i]) 
+			{world->n_ents = i + 1;world->world.nbodies = i+1;}
 }
 
 
@@ -117,9 +128,10 @@
 		if(world->ents[i]){
 			glPushMatrix();
 				/*build the transformation matrix*/
-				glTranslatef(world->ents[i]->body.v.d[0],
-							world->ents[i]->body.v.d[1],
-							world->ents[i]->body.v.d[2]);
+				glTranslatef(	world->ents[i]->body.shape.c.d[0],
+								world->ents[i]->body.shape.c.d[1],
+								world->ents[i]->body.shape.c.d[2]
+							);
 				glMultMatrixf(world->ents[i]->body.localt.d);
 				/*Render that shizzle!*/
 				glCallList(