[Bf-blender-cvs] [841ade3] master: BGE: Add missing documentation and attribute constraint_type for ConstraintWrapper

HG1 noreply at git.blender.org
Fri Jul 18 07:52:54 CEST 2014


Commit: 841ade32bee1ce9128b98c11d0fc3ae6d74aaf86
Author: HG1
Date:   Thu Jul 17 22:50:51 2014 -0700
https://developer.blender.org/rB841ade32bee1ce9128b98c11d0fc3ae6d74aaf86

BGE: Add missing documentation and attribute constraint_type for ConstraintWrapper

1. Add attribute to get the constraint type.
2. Add missing documentation for getParent, setParam, constraint_id in bge.types.KX_ConstraintWrapper.rst.
3. Add missing documentation for GENERIC_6DOF_CONSTRAINT and flag bit in bge.constraints.rst.
4. Fix typo in CcdPhysicsEnvironment.cpp

Reviewers: moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D654

===================================================================

M	doc/python_api/rst/bge.constraints.rst
M	doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
M	source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
M	source/gameengine/Ketsji/KX_ConstraintWrapper.h
M	source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

===================================================================

diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst
index 4d3e4ce..018be96 100644
--- a/doc/python_api/rst/bge.constraints.rst
+++ b/doc/python_api/rst/bge.constraints.rst
@@ -28,6 +28,7 @@ Physics Constraints (bge.constraints)
    - :class:`ANGULAR_CONSTRAINT`
    - :class:`CONETWIST_CONSTRAINT`
    - :class:`VEHICLE_CONSTRAINT`
+   - :class:`GENERIC_6DOF_CONSTRAINT`
 
    :type constrainttype: int
 
@@ -49,7 +50,7 @@ Physics Constraints (bge.constraints)
    :arg axisZ: Z axis
    :type axisZ: float
 
-   :arg flag: .. to do
+   :arg flag: 128 to disable collision between linked bodies
    :type flag: int
 
 .. attribute:: error
@@ -368,3 +369,10 @@ Physics Constraints (bge.constraints)
       Constraint type to be used with function :class:`createConstraint`
 
    .. to do
+
+.. data:: GENERIC_6DOF_CONSTRAINT
+
+   .. note::
+      Constraint type to be used with function :class:`createConstraint`
+
+   .. to do
diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
index c266751..f513f50 100644
--- a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
+++ b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintWrapper.rst
@@ -11,8 +11,131 @@ base class --- :class:`PyObjectPlus`
 
    .. method:: getConstraintId(val)
 
-      Returns the contraint's ID
+      Returns the contraint ID
 
-      :return: the constraint's ID
+      :return: the constraint ID
       :rtype: integer
 
+   .. method:: setParam(axis, value0, value1)
+
+      Set the contraint limits
+
+      :arg axis:
+      :type axis: integer
+
+   .. note::
+      For each axis:
+      * Lowerlimit == Upperlimit -> axis is locked
+      * Lowerlimit > Upperlimit -> axis is free
+      * Lowerlimit < Upperlimit -> axis it limited in that range
+
+      PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
+      axis = 3 is a constraint limit, with low/high limit value
+
+         * 3: X axis angle
+
+      :arg value0 (min): Set the minimum limit of the axis
+      :type value0: float
+      :arg value1 (max): Set the maximum limit of the axis
+      :type value1: float
+
+      PHY_CONE_TWIST_CONSTRAINT = 3:
+      axis = 3..5 are constraint limits, high limit values
+         * 3: X axis angle
+         * 4: Y axis angle
+         * 5: Z axis angle
+
+      :arg value0 (min): Set the minimum limit of the axis
+      :type value0: float
+      :arg value1 (max): Set the maximum limit of the axis
+      :type value1: float
+
+      PHY_GENERIC_6DOF_CONSTRAINT = 12:
+      axis = 0..2 are constraint limits, with low/high limit value
+         * 0: X axis position
+         * 1: Y axis position
+         * 2: Z axis position
+
+      axis = 3..5 are relative constraint (Euler) angles in degrees
+         * 3: X axis angle
+         * 4: Y axis angle
+         * 5: Z axis angle
+
+      :arg value0 (min): Set the minimum limit of the axis
+      :type value0: float
+      :arg value1 (max): Set the maximum limit of the axis
+      :type value1: float
+
+      axis = 6..8 are translational motors, with value0=target velocity, value1 = max motor force
+         * 6: X axis position
+         * 7: Y axis position
+         * 8: Z axis position
+
+      axis = 9..11 are rotational motors, with value0=target velocity, value1 = max motor force
+         * 9: X axis angle
+         * 10: Y axis angle
+         * 11: Z axis angle
+
+      :arg value0 (speed): Set the linear velocity of the axis
+      :type value0: float Range: -10,000.00 to 10,000.00
+      :arg value1 (force): Set the maximum force limit of the axis
+      :type value1: float Range: -10,000.00 to 10,000.00
+
+      axis = 12..14 are for linear springs on each of the position of freedom
+         * 12: X axis position
+         * 13: Y axis position
+         * 14: Z axis position
+
+      axis = 15..17 are for angular springs on each of the degrees of freedom
+         * 15: X axis angle
+         * 16: Y axis angle
+         * 17: Z axis angle
+
+      :arg value0 (stiffness): Set the stiffness of the spring
+      :type value0: float
+      :arg value1 (damping): Tendency of the spring to return to it's original position
+      :type value1: float
+                    1.0 = springs back to original position (no damping)
+                    0.0 = don't springs back
+
+   .. method:: getParam(axis)
+
+      Get the contraint position or euler angle of a generic 6DOF constraint
+
+      :arg axis:
+      :type axis: integer
+
+      axis = 0..2 are linear constraint values
+         * 0: X axis position
+         * 1: Y axis position
+         * 2: Z axis position
+
+      :return: position
+      :rtype: float
+
+      axis = 3..5 are relative constraint (Euler) angles in degrees 
+         * 3: X axis angle
+         * 4: Y axis angle
+         * 5: Z axis angle
+
+      :return: angle
+      :rtype: float
+
+   .. attribute:: constraint_id
+
+      Returns the contraint ID  (read only)
+
+      :type: integer
+
+   .. attribute:: constraint_type
+
+      Returns the contraint type (read only)
+
+      :type: integer
+
+         * 1 = POINTTOPOINT_CONSTRAINT
+         * 2 = LINEHINGE_CONSTRAINT
+         * 3 = ANGULAR_CONSTRAINT (aka LINEHINGE_CONSTRAINT)
+         * 4 = CONETWIST_CONSTRAINT
+         * 11 = VEHICLE_CONSTRAINT
+         * 12 = GENERIC_6DOF_CONSTRAINT
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index 793324f..29d9276 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -114,6 +114,7 @@ PyMethodDef KX_ConstraintWrapper::Methods[] = {
 
 PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
 	KX_PYATTRIBUTE_RO_FUNCTION("constraint_id", KX_ConstraintWrapper, pyattr_get_constraintId),
+	KX_PYATTRIBUTE_RO_FUNCTION("constraint_type", KX_ConstraintWrapper, pyattr_get_constraintType),
 	{ NULL }	//Sentinel
 };
 
@@ -123,4 +124,10 @@ PyObject *KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_P
 	return self->PyGetConstraintId();
 }
 
+PyObject *KX_ConstraintWrapper::pyattr_get_constraintType(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+	KX_ConstraintWrapper* self = static_cast<KX_ConstraintWrapper*>(self_v);
+	return PyLong_FromLong(self->m_constraintType);
+}
+
 #endif // WITH_PYTHON
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
index eafc45b..b7124c7 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h
@@ -49,6 +49,7 @@ public:
 	KX_PYMETHOD(KX_ConstraintWrapper,GetParam);
 
 	static PyObject *pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+	static PyObject *pyattr_get_constraintType(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 #endif
 
 private:
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 3e0b99e..db2c212 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -2094,7 +2094,7 @@ void	CcdPhysicsEnvironment::SetConstraintParam(int constraintId,int param,float
 
 			case 12: case 13: case 14: case 15: case 16: case 17:
 			{
-				//param 13-17 are for motorized springs on each of the degrees of freedom
+				//param 12-17 are for motorized springs on each of the degrees of freedom
 					btGeneric6DofSpringConstraint* genCons = (btGeneric6DofSpringConstraint*)typedConstraint;
 					int springIndex = param-12;
 					if (value0!=0.f)




More information about the Bf-blender-cvs mailing list