Anonymous avatar Anonymous committed 1afee4e

test2.py can work

Comments (0)

Files changed (2)

     for joint in world.joint_list:
         render_joint(joint,surface,joint_color)        
 
-def init_world1():
-    w = physics.World()
-    w.gravity = 0+1j
-    body1 = physics.Body()
-    body1.bind_rect_shape(2,2,0)
-    body1.position = 20, 10
-    body1.velocity = 1,0
-    body1.restitution = 3.0
-    w.add_body(body1)
-    body2 = physics.Body()
-    body2.bind_rect_shape(2,2,0)
-    body2.position = 20, 20
-    body2.velocity = -1, 0
-    body1.restitution = 3.0
-    w.add_body(body2)
-    joint1 = physics.DistanceJoint(body1,1)
-    joint1.anchor1 = 5+0j
-    joint1.anchor2 = 20+0j
-    w.add_joint(joint1)
-    joint2 = physics.DistanceJoint(body1,body2,1)
-    joint2.anchor1 = 5+0j
-    joint2.anchor2 = 5+0j
-    w.add_joint(joint2)
-    return w
+
     
 
 def init_world():
     joint1.anchor2 = 0+0j
     w.add_joint(joint1)
     joint2 = physics.DistanceJoint(body1,body2,1)
-    joint2.anchor1 = 1+0j
-    joint2.anchor2 = 1+0j
+    joint2.anchor1 = 0+0j
+    joint2.anchor2 = 0+0j
     w.add_joint(joint2)
     return w
 

src/pgJointObject.c

 	0                           /* tp_del */
 };
 
+void PG_SolveDistanceJointVelocity(pgJointObject* joint,double stepTime);
 void PG_DistanceJointInit(pgDistanceJointObject* joint)
 {
+	joint->joint.SolveConstraintVelocity = PG_SolveDistanceJointVelocity;
 	joint->distance = 10.0;
 	PG_Set_Vector2(joint->anchor1,0,0);
 	PG_Set_Vector2(joint->anchor2,0,0);
 	body2->fRotation += dAngleV2;
 	body1->fAngleVelocity += (dAngleV1 / stepTime);
 	body2->fAngleVelocity += (dAngleV2 / stepTime);
-	temp = c_get_length(c_diff(PG_GetGlobalPos(body1,&joint->anchor1),PG_GetGlobalPos(body2,&joint->anchor2)));
+	/*temp = c_get_length(c_diff(PG_GetGlobalPos(body1,&joint->anchor1),PG_GetGlobalPos(body2,&joint->anchor2)));
 	temp -= joint->distance; 
-	printf("%f\n",temp);
+	printf("%f\n",temp);*/
 
 
 	////body1->cBiasLV = c_sum(body1->cBiasLV,dvBody1);
 		}
 		else
 		{
+			
 			_PG_DistanceJoint_ComputeOneDynamic(body1,&pJoint->anchor2,&pJoint->anchor1,pJoint->distance,stepTime);
 
 			/*double a,b,c,d,e,f,k;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.