Commits

minz  committed 462dd53

  • Participants
  • Parent commits 1afee4e
  • Branches physics

Comments (0)

Files changed (3)

 #include <GL/glut.h>
 #include <math.h>
 
-#define HEIGHT 600
-#define WIDTH 600
+#define HEIGHT 800
+#define WIDTH 800
 
 /*-------------------------------˛âĘÔš¤žß----------------------------*/
 
 
 void TestBasic5Init()
 {
-#define  BODY_NUM  1
+#define  BODY_NUM  4
 
 	int i;
 	pgBodyObject* body[BODY_NUM + 1];
 	pgJointObject* joint[BODY_NUM];
 	pgVector2 a1,a2;
-	PG_Set_Vector2(a1,5,0);
+	PG_Set_Vector2(a1,0,0);
 	PG_Set_Vector2(a2,0,0);
 
 	s_world = PG_WorldNew();
 	s_world->fStepTime = 0.03;
-	PG_Set_Vector2(s_world->vecGravity,0,0)
+	PG_Set_Vector2(s_world->vecGravity,0,10)
 
 
-	body[0] = NULL;
-	for (i = 1;i < BODY_NUM + 1;i++)
+	for (i = 0;i < BODY_NUM;i++)
 	{
 		body[i] = PG_BodyNew();
-		PG_Bind_RectShape(body[i], 20, 20, 0);
-		PG_Set_Vector2(body[i]->vecPosition,10,(-i*50))
+		if (i != BODY_NUM - 1)
+		{
+			PG_Bind_RectShape(body[i], 20, 20, 0);
+		}
+		else
+		{
+			PG_Bind_RectShape(body[i], 20, 100, 0);
+		}
+		
+		
 			//PG_Set_Vector2(body[i]->vecLinearVelocity,50,0)
 			PG_AddBodyToWorld(s_world,body[i]);
 	}
+	PG_Set_Vector2(body[0]->vecPosition,200,0)
+	PG_Set_Vector2(body[1]->vecPosition,200,100)
+	PG_Set_Vector2(body[2]->vecPosition,300,200)
+	PG_Set_Vector2(body[3]->vecPosition,300,200)
+	body[0]->bStatic = 1;
+	body[3]->bStatic = 1;
+	
 
+	//PG_Set_Vector2(body[BODY_NUM]->vecLinearVelocity,20,60)
 
-	PG_Set_Vector2(body[BODY_NUM]->vecLinearVelocity,20,60)
 
-	i = 0;
-	joint[i] = PG_DistanceJointNew(body[i+1],body[i],0,50,a1,a2);
-	PG_AddJointToWorld(s_world,joint[i]);
-	for (i = 1;i < BODY_NUM;i++)
+	for (i = 0;i < BODY_NUM - 2;i++)
 	{
 		joint[i] = PG_DistanceJointNew(body[i],body[i+1],0,50,a1,a2);
 		PG_AddJointToWorld(s_world,joint[i]);
 	PG_AddJointToWorld(s_world,joint);
 }
 
+
+
 //===============================================
 
 void InitWorld()
 {
-	TestBasic4Init();
+	TestBasic5Init();
 }
 
 int main (int argc, char** argv)

File src/pgShapeObject.c

 				if(c_equal(&pf, &gp[i]))
 					has_ip[i] = 1;
 				else
+				{
+					//assert(0);
 					contacts[(*size)++] = pf;
+				}
 			}
 			if(valid_pt)
 			{
 				if(c_equal(&pt, &gp[i1]))
 					has_ip[i1] = 1;
 				else
+				{
+					//assert(0);
 					contacts[(*size)++] = pt;
+				}
 			}
 		}
 	}
 	for(i = 0; i < 4; ++i)
 		if(has_ip[i])
+		{
+			//assert(0);
 			contacts[(*size)++] = gp[i];
+		}
 
 	return !apart;
 }
 	pAcc->real = pAcc->imag = 0;
 	pSplitAcc = PyObject_Malloc(sizeof(pgVector2));
 	pSplitAcc->real = pSplitAcc->imag = 0;
+
+	//for test
+	//printf("face id: %d; csize: %d\n", face_id, csize);
+
 	for(i = 0; i < csize; ++i)
 	{
 		contact = (pgContact*)PG_ContactNew(ref, inc);

File src/pgWorldObject.c

 		{
 			incBody = (pgBodyObject*)(PyList_GetItem(world->bodyList, j));
 			if(refBody->bStatic && incBody->bStatic) continue;
+			
 			if(PG_IsOverlap(&(refBody->shape->box), &(incBody->shape->box), 1e-8))
 			{
+				
 				PG_AppendContact(refBody, incBody, world->contactList);
 			}
 		}
 	}
 
 	contact_cnt = PyList_Size(world->contactList);
+	if (contact_cnt)
+	{
+		printf("contact_cnt:%d\n",contact_cnt);
+	}
+	
 	for(j = 0; j < MAX_ITERATION; ++j)
 	{
 		//clear bias