[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17002] trunk/blender/source: Fix bug in rigid body constraint buttons drawing, and while we are at it, add 'Collision' button to disable collisions between bodies, linked between constraint.

Erwin Coumans blender at erwincoumans.com
Fri Oct 10 07:12:58 CEST 2008


Revision: 17002
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17002
Author:   erwin
Date:     2008-10-10 07:12:57 +0200 (Fri, 10 Oct 2008)

Log Message:
-----------
Fix bug in rigid body constraint buttons drawing, and while we are at it, add 'Collision' button to disable collisions between bodies, linked between constraint.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_constraint_types.h
    trunk/blender/source/blender/src/buttons_object.c
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
    trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
    trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
    trunk/blender/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
    trunk/blender/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h

Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h	2008-10-10 05:12:57 UTC (rev 17002)
@@ -520,6 +520,7 @@
 
 /* Rigid-Body Constraint */
 #define CONSTRAINT_DRAW_PIVOT 0x40
+#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
 
 /* important: these defines need to match up with PHY_DynamicTypes headerfile */
 #define CONSTRAINT_RB_BALL		1

Modified: trunk/blender/source/blender/src/buttons_object.c
===================================================================
--- trunk/blender/source/blender/src/buttons_object.c	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/blender/src/buttons_object.c	2008-10-10 05:12:57 UTC (rev 17002)
@@ -1497,16 +1497,20 @@
 				int offsetY = 150;
 				int textButWidth = ((width/2)-togButWidth);
 				
-				uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic (experimental)%x12",//|Extra Force%x6",
-												*xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
                 height = 140;
 				if (data->type==CONSTRAINT_RB_GENERIC6DOF)
 					height = 270;
 				if (data->type==CONSTRAINT_RB_CONETWIST)
 					height = 200;
 				
-                uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
-				
+				uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
+
+				uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic (experimental)%x12",//|Extra Force%x6",
+												*xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
+
+				uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "Collision", *xco+155, *yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Enable Collision Between Linked Bodies"); 				
+
+
 				uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", *xco, *yco-50, 130, 18, &data->tar, "Child Object");
 				uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", *xco+135, *yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation"); 				
 				
@@ -1586,6 +1590,7 @@
 						uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); 
 					uiBlockEndAlign(block);
 				}
+				
 			}
 			break;
 		case CONSTRAINT_TYPE_CLAMPTO:

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-10-10 05:12:57 UTC (rev 17002)
@@ -2478,7 +2478,7 @@
 								(float)dat->pivY,(float)dat->pivZ,
 								(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
 								(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
-								(float)axis2.x(),(float)axis2.y(),(float)axis2.z());
+								(float)axis2.x(),(float)axis2.y(),(float)axis2.z(),dat->flag);
 							if (constraintId)
 							{
 								//if it is a generic 6DOF constraint, set all the limits accordingly

Modified: trunk/blender/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp	2008-10-10 05:12:57 UTC (rev 17002)
@@ -435,7 +435,7 @@
 			PHY_IPhysicsController* physctrl2 = (PHY_IPhysicsController*) physicsid2;
 			if (physctrl) //TODO:check for existance of this pointer!
 			{
-				int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ);
+				int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
 				
 				KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
 				

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp	2008-10-10 05:12:57 UTC (rev 17002)
@@ -33,6 +33,7 @@
 
 #include "PHY_IMotionState.h"
 
+#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
 
 bool useIslands = true;
 
@@ -882,13 +883,16 @@
 						const btVector3& linearMinLimits,
 						const btVector3& linearMaxLimits,
 						const btVector3& angularMinLimits,
-						const btVector3& angularMaxLimits
+						const btVector3& angularMaxLimits,int flags
 )
 {
 
+	bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
+
 	//we could either add some logic to recognize ball-socket and hinge, or let that up to the user
 	//perhaps some warning or hint that hinge/ball-socket is more efficient?
 	
+	
 	btGeneric6DofConstraint* genericConstraint = 0;
 	CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef;
 	CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther;
@@ -918,7 +922,7 @@
 	if (genericConstraint)
 	{
 	//	m_constraints.push_back(genericConstraint);
-		m_dynamicsWorld->addConstraint(genericConstraint);
+		m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
 
 		genericConstraint->setUserConstraintId(gConstraintUid++);
 		genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT);
@@ -1488,11 +1492,14 @@
 													float pivotX,float pivotY,float pivotZ,
 													float axisX,float axisY,float axisZ,
 													float axis1X,float axis1Y,float axis1Z,
-													float axis2X,float axis2Y,float axis2Z
+													float axis2X,float axis2Y,float axis2Z,int flags
 													)
 {
 
+	bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
 
+
+
 	CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0;
 	CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1;
 
@@ -1683,7 +1690,7 @@
 					pivotInA);
 			}
 
-			m_dynamicsWorld->addConstraint(p2p);
+			m_dynamicsWorld->addConstraint(p2p,disableCollisionBetweenLinkedBodies);
 //			m_constraints.push_back(p2p);
 
 			p2p->setUserConstraintId(gConstraintUid++);
@@ -1753,7 +1760,7 @@
 			if (genericConstraint)
 			{
 				//m_constraints.push_back(genericConstraint);
-				m_dynamicsWorld->addConstraint(genericConstraint);
+				m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
 				genericConstraint->setUserConstraintId(gConstraintUid++);
 				genericConstraint->setUserConstraintType(type);
 				//64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1819,7 +1826,7 @@
 			if (coneTwistContraint)
 			{
 				//m_constraints.push_back(genericConstraint);
-				m_dynamicsWorld->addConstraint(coneTwistContraint);
+				m_dynamicsWorld->addConstraint(coneTwistContraint,disableCollisionBetweenLinkedBodies);
 				coneTwistContraint->setUserConstraintId(gConstraintUid++);
 				coneTwistContraint->setUserConstraintType(type);
 				//64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1858,7 +1865,7 @@
 			hinge->setAngularOnly(angularOnly);
 
 			//m_constraints.push_back(hinge);
-			m_dynamicsWorld->addConstraint(hinge);
+			m_dynamicsWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies);
 			hinge->setUserConstraintId(gConstraintUid++);
 			hinge->setUserConstraintType(type);
 			//64 bit systems can't cast pointer to int. could use size_t instead.

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h	2008-10-10 05:12:57 UTC (rev 17002)
@@ -127,7 +127,7 @@
 			float pivotX,float pivotY,float pivotZ,
 			float axisX,float axisY,float axisZ,
 			float axis1X=0,float axis1Y=0,float axis1Z=0,
-			float axis2X=0,float axis2Y=0,float axis2Z=0
+			float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
 			);
 
 
@@ -139,7 +139,7 @@
 			const btVector3& linearMinLimits,
 			const btVector3& linearMaxLimits,
 			const btVector3& angularMinLimits,
-			const btVector3& angularMaxLimits
+			const btVector3& angularMaxLimits,int flags
 			);
 
 		virtual void	setConstraintParam(int constraintId,int param,float value,float value1);

Modified: trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp	2008-10-10 05:12:57 UTC (rev 17002)
@@ -92,8 +92,7 @@
 int			DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
 		float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
 			float axis1X,float axis1Y,float axis1Z,
-			float axis2X,float axis2Y,float axis2Z
-
+			float axis2X,float axis2Y,float axis2Z,int flag
 		)
 {
 	

Modified: trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
===================================================================
--- trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h	2008-10-10 02:59:09 UTC (rev 17001)
+++ trunk/blender/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h	2008-10-10 05:12:57 UTC (rev 17002)
@@ -58,7 +58,7 @@
 			float pivotX,float pivotY,float pivotZ,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list