diff options
140 files changed, 915 insertions, 1121 deletions
diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst index ed965c3dfc1..3cca22e9cff 100644 --- a/doc/python_api/rst/bge.constraints.rst +++ b/doc/python_api/rst/bge.constraints.rst @@ -2,12 +2,33 @@ Physics Constraints (bge.constraints) ===================================== +Bullet Physics provides collision detection +and rigid body dynamics for the Blender Game Engine. + +Features: + +- Vehicle simulation. +- Rigid body constraints: hinge and point to point (ball socket). +- Access to internal physics settings, + like deactivation time, and debugging features + .. module:: bge.constraints +.. note:: Note about parameter settings + + Since this API is not well documented, it can be unclear what kind of values to use for setting parameters. + In general, damping settings should be in the range of 0 to 1 and + stiffness settings should not be much higher than about 10. + Examples -------- +.. seealso:: + + For more examples of Bullet physics and how to use them + see the `pybullet forum <https://pybullet.org/Bullet/phpBB3/viewforum.php?f=17>`__. + .. include:: __/examples/bge.constraints.py :start-line: 1 :end-line: 4 @@ -333,4 +354,3 @@ Constraint type to be used with :func:`createConstraint`. .. data:: GENERIC_6DOF_CONSTRAINT .. to do - diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index f24cc3f998c..b043f53e413 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -35,4 +35,3 @@ Types :glob: bge.types.* - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst index 9b95a5ba611..c761a0d4e44 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ActionActuator.rst @@ -1,8 +1,6 @@ BL_ActionActuator(SCA_IActuator) ================================ -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: BL_ActionActuator(SCA_IActuator) @@ -75,4 +73,3 @@ base class --- :class:`SCA_IActuator` The name of the property that is set to the current frame number. :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst index 579186ac1d6..d60782dde32 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureActuator.rst @@ -1,8 +1,6 @@ BL_ArmatureActuator(SCA_IActuator) ================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: BL_ArmatureActuator(SCA_IActuator) @@ -58,4 +56,3 @@ base class --- :class:`SCA_IActuator` The influence this actuator will set on the constraint it controls. :type: float. - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst index 14a9ebe9ef3..0200c9c513b 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureBone.rst @@ -1,8 +1,6 @@ BL_ArmatureBone(PyObjectPlus) ============================= -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: BL_ArmatureBone(PyObjectPlus) diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst index 07220534b28..d8fcfa8cbe4 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureChannel.rst @@ -1,8 +1,6 @@ BL_ArmatureChannel(PyObjectPlus) ================================ -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: BL_ArmatureChannel(PyObjectPlus) @@ -275,4 +273,3 @@ base class --- :class:`PyObjectPlus` .. note:: You can read the result of the calculation in rotation or euler_rotation attributes after setting this attribute. - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst index 1a4370945c1..8a62d2d688f 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureConstraint.rst @@ -1,8 +1,6 @@ BL_ArmatureConstraint(PyObjectPlus) =================================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: BL_ArmatureConstraint(PyObjectPlus) @@ -126,4 +124,3 @@ base class --- :class:`PyObjectPlus` Additional mode for IK constraint. Currently only used for Distance constraint: :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst index 8389affe8a9..336ae29daac 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ArmatureObject.rst @@ -1,8 +1,6 @@ BL_ArmatureObject(KX_GameObject) ================================ -.. module:: bge.types - base class --- :class:`KX_GameObject` .. class:: BL_ArmatureObject(KX_GameObject) @@ -31,4 +29,3 @@ base class --- :class:`KX_GameObject` This action is unecessary if a KX_ArmatureActuator with mode run is active or if an action is playing. Use this function in other cases. It must be called on each frame to ensure that the armature is updated continously. - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst b/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst index a389f68ee04..53544978482 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_Shader.rst @@ -1,8 +1,6 @@ BL_Shader(PyObjectPlus) ======================= -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: BL_Shader(PyObjectPlus) @@ -227,4 +225,3 @@ base class --- :class:`PyObjectPlus` .. method:: validate() Validate the shader object. - diff --git a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst b/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst index 4bb3d273cb9..4c8d113ad87 100644 --- a/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.BL_ShapeActionActuator.rst @@ -1,8 +1,6 @@ BL_ShapeActionActuator(SCA_IActuator) ===================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: BL_ShapeActionActuator(SCA_IActuator) diff --git a/doc/python_api/rst/bge_types/bge.types.CListValue.rst b/doc/python_api/rst/bge_types/bge.types.CListValue.rst index ca4cdc44bf5..e47cf351f60 100644 --- a/doc/python_api/rst/bge_types/bge.types.CListValue.rst +++ b/doc/python_api/rst/bge_types/bge.types.CListValue.rst @@ -1,8 +1,6 @@ CListValue(CPropValue) ====================== -.. module:: bge.types - base class --- :class:`CPropValue` .. class:: CListValue(CPropValue) @@ -69,4 +67,3 @@ base class --- :class:`CPropValue` .. warning:: The id can't be stored as an integer in game object properties, as those only have a limited range that the id may not be contained in. Instead an id can be stored as a string game property and converted back to an integer for use in from_id lookups. - diff --git a/doc/python_api/rst/bge_types/bge.types.CPropValue.rst b/doc/python_api/rst/bge_types/bge.types.CPropValue.rst index 7be28c1e006..67fc2c4fafd 100644 --- a/doc/python_api/rst/bge_types/bge.types.CPropValue.rst +++ b/doc/python_api/rst/bge_types/bge.types.CPropValue.rst @@ -1,11 +1,8 @@ CPropValue(CValue) ================== -.. module:: bge.types - base class --- :class:`CValue` .. class:: CPropValue(CValue) This class has no python functions - diff --git a/doc/python_api/rst/bge_types/bge.types.CValue.rst b/doc/python_api/rst/bge_types/bge.types.CValue.rst index 52906de5576..3255471daf2 100644 --- a/doc/python_api/rst/bge_types/bge.types.CValue.rst +++ b/doc/python_api/rst/bge_types/bge.types.CValue.rst @@ -1,8 +1,6 @@ CValue(PyObjectPlus) ==================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: CValue(PyObjectPlus) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst index a7123eb5c9d..ca617395a69 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_ArmatureSensor.rst @@ -1,8 +1,6 @@ KX_ArmatureSensor(SCA_ISensor) ============================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: KX_ArmatureSensor(SCA_ISensor) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst b/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst index ece2a65af71..fd3bbc58a7c 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_BlenderMaterial.rst @@ -1,8 +1,6 @@ KX_BlenderMaterial(PyObjectPlus) ================================ -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_BlenderMaterial(PyObjectPlus) @@ -182,4 +180,3 @@ base class --- :class:`PyObjectPlus` :return: the material's index :rtype: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst b/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst index ac5ab4b5fe5..8c8c68fc051 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_Camera.rst @@ -1,8 +1,6 @@ KX_Camera(KX_GameObject) ======================== -.. module:: bge.types - base class --- :class:`KX_GameObject` .. class:: KX_Camera(KX_GameObject) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst index bc5efed4b08..14cf1e47070 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_CameraActuator.rst @@ -1,8 +1,6 @@ KX_CameraActuator(SCA_IActuator) ================================ -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_CameraActuator(SCA_IActuator) @@ -44,4 +42,3 @@ base class --- :class:`SCA_IActuator` the object this actuator tracks. :type: :class:`KX_GameObject` or None - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst index adff6e0a2ad..df95b842b5d 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_CharacterWrapper.rst @@ -1,8 +1,6 @@ KX_CharacterWrapper(PyObjectPlus) ================================= -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_CharacterWrapper(PyObjectPlus) @@ -42,4 +40,3 @@ base class --- :class:`PyObjectPlus` .. method:: jump() The character jumps based on it's jump speed. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst index 498990449fe..56c87cc110e 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_ConstraintActuator.rst @@ -1,8 +1,6 @@ KX_ConstraintActuator(SCA_IActuator) ==================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_ConstraintActuator(SCA_IActuator) 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 d9f03395c34..77eec6bde78 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 @@ -1,8 +1,6 @@ KX_ConstraintWrapper(PyObjectPlus) ================================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_ConstraintWrapper(PyObjectPlus) @@ -140,4 +138,3 @@ base class --- :class:`PyObjectPlus` - :class:`~bge.constraints.CONETWIST_CONSTRAINT` - :class:`~bge.constraints.VEHICLE_CONSTRAINT` - :class:`~bge.constraints.GENERIC_6DOF_CONSTRAINT` - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst index ca35ff49a08..f02609af0fa 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_FontObject.rst @@ -1,8 +1,6 @@ KX_FontObject(KX_GameObject) ============================ -.. module:: bge.types - base class --- :class:`KX_GameObject` .. class:: KX_FontObject(KX_GameObject) @@ -29,4 +27,3 @@ base class --- :class:`KX_GameObject` The text displayed by this Font object. :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst index 54702c5318d..a36c49d57e2 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_GameActuator.rst @@ -1,8 +1,6 @@ KX_GameActuator(SCA_IActuator) ============================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_GameActuator(SCA_IActuator) @@ -20,4 +18,3 @@ base class --- :class:`SCA_IActuator` The mode of this actuator. Can be on of :ref:`these constants <game-actuator>` :type: Int - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst index c5729fd5b19..2797e8ef361 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_GameObject.rst @@ -1,8 +1,6 @@ KX_GameObject(SCA_IObject) ========================== -.. module:: bge.types - base class --- :class:`SCA_IObject` .. class:: KX_GameObject(SCA_IObject) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst b/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst index a37b4dad585..3e7d370476e 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_LibLoadStatus.rst @@ -1,8 +1,6 @@ KX_LibLoadStatus(PyObjectPlus) ============================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_LibLoadStatus(PyObjectPlus) @@ -48,4 +46,3 @@ base class --- :class:`PyObjectPlus` The amount of time, in seconds, the lib load took (0 until the operation is complete). :type: float - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst index 6748df13873..ca4e4eaf1b3 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_LightObject.rst @@ -1,8 +1,6 @@ KX_LightObject(KX_GameObject) ============================= -.. module:: bge.types - base class --- :class:`KX_GameObject` .. class:: KX_LightObject(KX_GameObject) @@ -161,4 +159,3 @@ base class --- :class:`KX_GameObject` .. note:: Higher values result in a more focused light source. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst index 13fb3263a59..c009db17e4d 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_MeshProxy.rst @@ -1,8 +1,6 @@ KX_MeshProxy(SCA_IObject) ========================= -.. module:: bge.types - base class --- :class:`SCA_IObject` .. class:: KX_MeshProxy(SCA_IObject) @@ -131,4 +129,3 @@ base class --- :class:`SCA_IObject` :type uv_index: integer :arg uv_index_from: optional uv index to copy from, -1 to transform the current uv. :type uv_index_from: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst index cc3ce49d0a5..e0fe32baa2b 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_MouseActuator.rst @@ -1,8 +1,6 @@ KX_MouseActuator(SCA_IActuator) ==================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_MouseActuator(SCA_IActuator) @@ -100,4 +98,3 @@ base class --- :class:`SCA_IActuator` The current rotational offset caused by the mouse actuator in degrees. :type: list (vector of 2 floats) - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst index 0600a4b5aae..1d7eb007c1e 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_MouseFocusSensor.rst @@ -1,8 +1,6 @@ KX_MouseFocusSensor(SCA_MouseSensor) ==================================== -.. module:: bge.types - base class --- :class:`SCA_MouseSensor` .. class:: KX_MouseFocusSensor(SCA_MouseSensor) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst b/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst index 5c73d0aa1d3..00d51108937 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_NavMeshObject.rst @@ -1,8 +1,6 @@ KX_NavMeshObject(KX_GameObject) =============================== -.. module:: bge.types - base class --- :class:`KX_GameObject` .. class:: KX_NavMeshObject(KX_GameObject) @@ -44,4 +42,3 @@ base class --- :class:`KX_GameObject` Rebuild the navigation mesh. :return: None - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst index 995e645b979..91969dfc79d 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_NearSensor.rst @@ -1,8 +1,6 @@ KX_NearSensor(KX_TouchSensor) ============================= -.. module:: bge.types - base class --- :class:`KX_TouchSensor` .. class:: KX_NearSensor(KX_TouchSensor) @@ -20,4 +18,3 @@ base class --- :class:`KX_TouchSensor` The near sensor deactivates when the object exceeds this distance. :type: float - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst index b8dcd01fe43..525289ae71f 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageActuator.rst @@ -1,8 +1,6 @@ KX_NetworkMessageActuator(SCA_IActuator) ======================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_NetworkMessageActuator(SCA_IActuator) @@ -32,4 +30,3 @@ base class --- :class:`SCA_IActuator` Send a property instead of a regular body message. :type: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst index a6b1082a4fe..a732c1e48f7 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_NetworkMessageSensor.rst @@ -1,8 +1,6 @@ KX_NetworkMessageSensor(SCA_ISensor) ==================================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: KX_NetworkMessageSensor(SCA_ISensor) @@ -34,5 +32,3 @@ base class --- :class:`SCA_ISensor` The list of message bodies received. (read-only). :type: list of strings - - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst index 347b000be3d..f3948578cd5 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_ObjectActuator.rst @@ -1,8 +1,6 @@ KX_ObjectActuator(SCA_IActuator) ================================ -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_ObjectActuator(SCA_IActuator) @@ -126,4 +124,3 @@ base class --- :class:`SCA_IActuator` The object that is used as reference to compute the velocity for the servo controller. :type: :class:`KX_GameObject` or None - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst index 77dcb907d6a..13f4bcb7615 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_ParentActuator.rst @@ -1,8 +1,6 @@ KX_ParentActuator(SCA_IActuator) ================================ -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_ParentActuator(SCA_IActuator) @@ -35,4 +33,3 @@ base class --- :class:`SCA_IActuator` Effective only if the shape is not added to the parent compound shape. :type: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst index f43cf62eec1..68baff8d45c 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_PolyProxy.rst @@ -1,8 +1,6 @@ KX_PolyProxy(SCA_IObject) ========================= -.. module:: bge.types - base class --- :class:`SCA_IObject` .. class:: KX_PolyProxy(SCA_IObject) @@ -136,4 +134,3 @@ base class --- :class:`SCA_IObject` :return: mesh proxy :rtype: :class:`MeshProxy` - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst index 4274c1142f4..82028cfc186 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_RadarSensor.rst @@ -1,8 +1,6 @@ KX_RadarSensor(KX_NearSensor) ============================= -.. module:: bge.types - base class --- :class:`KX_NearSensor` .. class:: KX_RadarSensor(KX_NearSensor) @@ -41,4 +39,3 @@ base class --- :class:`KX_NearSensor` KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z, KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst index f182a84409f..75e171dd612 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_RaySensor.rst @@ -1,8 +1,6 @@ KX_RaySensor(SCA_ISensor) ========================= -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: KX_RaySensor(SCA_ISensor) @@ -75,4 +73,3 @@ base class --- :class:`SCA_ISensor` * KX_RAY_AXIS_NEG_X * KX_RAY_AXIS_NEG_Y * KX_RAY_AXIS_NEG_Z - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst index fecc863909d..9b7d2ad874a 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SCA_AddObjectActuator.rst @@ -1,8 +1,6 @@ KX_SCA_AddObjectActuator(SCA_IActuator) ======================================= -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SCA_AddObjectActuator(SCA_IActuator) @@ -52,4 +50,3 @@ base class --- :class:`SCA_IActuator` adds the object without needing to calling SCA_PythonController.activate() .. note:: Use objectLastCreated to get the newly created object. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst index 055c4098253..822c343aacd 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SCA_DynamicActuator.rst @@ -1,8 +1,6 @@ KX_SCA_DynamicActuator(SCA_IActuator) ===================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SCA_DynamicActuator(SCA_IActuator) @@ -26,4 +24,3 @@ base class --- :class:`SCA_IActuator` the mass value for the KX_DYN_SET_MASS operation. :type: float - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst index 8d9221febb0..3a414df9493 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SCA_EndObjectActuator.rst @@ -1,8 +1,6 @@ KX_SCA_EndObjectActuator(SCA_IActuator) ======================================= -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SCA_EndObjectActuator(SCA_IActuator) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IActuator` Edit Object Actuator (in End Object mode) This actuator has no python methods. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst index 137c63ea829..8a88dff99b9 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SCA_ReplaceMeshActuator.rst @@ -1,8 +1,6 @@ KX_SCA_ReplaceMeshActuator(SCA_IActuator) ========================================= -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SCA_ReplaceMeshActuator(SCA_IActuator) @@ -86,4 +84,3 @@ base class --- :class:`SCA_IActuator` .. method:: instantReplaceMesh() Immediately replace mesh without delay. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst b/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst index 5bd8e3a77de..7e632d2c8d4 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_Scene.rst @@ -1,8 +1,6 @@ KX_Scene(PyObjectPlus) ====================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_Scene(PyObjectPlus) @@ -183,4 +181,3 @@ base class --- :class:`PyObjectPlus` .. method:: drawObstacleSimulation() Draw debug visualization of obstacle simulation. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst index 9d073ff5b19..b6aeaff282c 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SceneActuator.rst @@ -1,8 +1,6 @@ KX_SceneActuator(SCA_IActuator) =============================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SceneActuator(SCA_IActuator) @@ -46,4 +44,3 @@ base class --- :class:`SCA_IActuator` The mode of the actuator. :type: integer from 0 to 5. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst index aa85bd663b8..d6d258b40d5 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SoundActuator.rst @@ -1,8 +1,6 @@ KX_SoundActuator(SCA_IActuator) =============================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SoundActuator(SCA_IActuator) @@ -112,4 +110,3 @@ base class --- :class:`SCA_IActuator` Stops the sound. :return: None - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst index c9d08457cc6..7dbe47276fd 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_StateActuator.rst @@ -1,8 +1,6 @@ KX_StateActuator(SCA_IActuator) =============================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_StateActuator(SCA_IActuator) @@ -26,4 +24,3 @@ base class --- :class:`SCA_IActuator` The bits that are 0 are will be left unmodified expect for the Copy operation which copies the mask to the object state. :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst index f0ce248f069..9e2f2a427a1 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_SteeringActuator.rst @@ -1,8 +1,6 @@ KX_SteeringActuator(SCA_IActuator) ================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_SteeringActuator(SCA_IActuator) @@ -68,4 +66,3 @@ base class --- :class:`SCA_IActuator` Path update period :type: int - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst b/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst index 876d14bc6c8..79fd1a63151 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_TouchSensor.rst @@ -1,8 +1,6 @@ KX_TouchSensor(SCA_ISensor) =========================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: KX_TouchSensor(SCA_ISensor) @@ -44,4 +42,3 @@ base class --- :class:`SCA_ISensor` The material of the object in the face hit by the ray. (read-only). :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst index 5b5c5d0c0db..fd80c547ce3 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_TrackToActuator.rst @@ -1,8 +1,6 @@ KX_TrackToActuator(SCA_IActuator) ================================= -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_TrackToActuator(SCA_IActuator) diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst b/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst index 631075363ca..0d7b7103ba4 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_VehicleWrapper.rst @@ -1,8 +1,6 @@ KX_VehicleWrapper(PyObjectPlus) =============================== -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_VehicleWrapper(PyObjectPlus) @@ -163,4 +161,3 @@ base class --- :class:`PyObjectPlus` :arg wheelIndex: the wheel index :type wheelIndex: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst b/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst index 73d692770d6..f6b52affa27 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_VertexProxy.rst @@ -1,8 +1,6 @@ KX_VertexProxy(SCA_IObject) =========================== -.. module:: bge.types - base class --- :class:`SCA_IObject` .. class:: KX_VertexProxy(SCA_IObject) @@ -206,4 +204,3 @@ base class --- :class:`SCA_IObject` :type: sequence of floats [r, g, b] :arg normal: the new normal of this vertex. - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst b/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst index 4beb6539e0e..fc6c042e5b1 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_VisibilityActuator.rst @@ -1,8 +1,6 @@ KX_VisibilityActuator(SCA_IActuator) ==================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: KX_VisibilityActuator(SCA_IActuator) @@ -26,4 +24,3 @@ base class --- :class:`SCA_IActuator` whether the visibility/occlusion should be propagated to all children of the object. :type: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst b/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst index 1501d85b86c..d96d1c1190f 100644 --- a/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst +++ b/doc/python_api/rst/bge_types/bge.types.KX_WorldInfo.rst @@ -1,8 +1,6 @@ KX_WorldInfo(PyObjectPlus) ============================= -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: KX_WorldInfo(PyObjectPlus) diff --git a/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst b/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst index e035f457a96..4c8ddb9bcf5 100644 --- a/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst +++ b/doc/python_api/rst/bge_types/bge.types.PyObjectPlus.rst @@ -1,8 +1,6 @@ PyObjectPlus ============ -.. module:: bge.types - .. class:: PyObjectPlus PyObjectPlus base class of most other types in the Game Engine. @@ -18,4 +16,3 @@ PyObjectPlus The invalid attribute allows testing for this case without exception handling. :type: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst index 0a6c5fc9025..b4c00ff0181 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_2DFilterActuator.rst @@ -1,8 +1,6 @@ SCA_2DFilterActuator(SCA_IActuator) =================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: SCA_2DFilterActuator(SCA_IActuator) @@ -46,4 +44,3 @@ base class --- :class:`SCA_IActuator` argument for motion blur filter. :type: float (0.0-100.0) - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst index 0942f715231..abef7dd5cb3 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_ANDController.rst @@ -1,8 +1,6 @@ SCA_ANDController(SCA_IController) ================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_ANDController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An AND controller activates only when all linked sensors are activated. There are no special python methods for this controller. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst index 54916389298..cc89fd192c2 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_ActuatorSensor.rst @@ -1,8 +1,6 @@ SCA_ActuatorSensor(SCA_ISensor) =============================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_ActuatorSensor(SCA_ISensor) @@ -16,4 +14,3 @@ base class --- :class:`SCA_ISensor` the name of the actuator that the sensor is monitoring. :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst index a217b114d62..2a654a2bf38 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_AlwaysSensor.rst @@ -1,11 +1,8 @@ SCA_AlwaysSensor(SCA_ISensor) ============================= -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_AlwaysSensor(SCA_ISensor) This sensor is always activated. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst index ce2b8e52eec..34bdc4da44e 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_DelaySensor.rst @@ -1,8 +1,6 @@ SCA_DelaySensor(SCA_ISensor) ============================ -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_DelaySensor(SCA_ISensor) @@ -36,4 +34,3 @@ base class --- :class:`SCA_ISensor` 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once. :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst index 1432d5166ef..b6afe4acc2f 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_IActuator.rst @@ -1,11 +1,8 @@ SCA_IActuator(SCA_ILogicBrick) ============================== -.. module:: bge.types - base class --- :class:`SCA_ILogicBrick` .. class:: SCA_IActuator(SCA_ILogicBrick) Base class for all actuator logic bricks. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst index 5eb225ed329..4532070c814 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_IController.rst @@ -1,8 +1,6 @@ SCA_IController(SCA_ILogicBrick) ================================ -.. module:: bge.types - base class --- :class:`SCA_ILogicBrick` .. class:: SCA_IController(SCA_ILogicBrick) @@ -52,4 +50,3 @@ base class --- :class:`SCA_ILogicBrick` .. note:: Order of execution between high priority controllers is not guaranteed. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst index 5ed44c4bb38..e8d9413d7e5 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_ILogicBrick.rst @@ -1,8 +1,6 @@ SCA_ILogicBrick(CValue) ======================= -.. module:: bge.types - base class --- :class:`CValue` .. class:: SCA_ILogicBrick(CValue) @@ -26,4 +24,3 @@ base class --- :class:`CValue` The name of this logic brick (read-only). :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst b/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst index 22065944542..a3080879fd0 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_IObject.rst @@ -1,11 +1,8 @@ SCA_IObject(CValue) =================== -.. module:: bge.types - base class --- :class:`CValue` .. class:: SCA_IObject(CValue) This class has no python functions - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst index af444fb9e65..7c8d632b0a2 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_ISensor.rst @@ -1,8 +1,6 @@ SCA_ISensor(SCA_ILogicBrick) ============================ -.. module:: bge.types - base class --- :class:`SCA_ILogicBrick` .. class:: SCA_ISensor(SCA_ILogicBrick) @@ -98,4 +96,3 @@ base class --- :class:`SCA_ILogicBrick` Reset sensor internal state, effect depends on the type of sensor and settings. The sensor is put in its initial state as if it was just activated. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst index 5b6628f60be..824b9932dc1 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_JoystickSensor.rst @@ -1,8 +1,6 @@ SCA_JoystickSensor(SCA_ISensor) =============================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_JoystickSensor(SCA_ISensor) @@ -130,4 +128,3 @@ base class --- :class:`SCA_ISensor` :type buttonIndex: integer :return: The current pressed state of the specified button. :rtype: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst index 91613068ad0..7450d9c19bb 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_KeyboardSensor.rst @@ -1,8 +1,6 @@ SCA_KeyboardSensor(SCA_ISensor) =============================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_KeyboardSensor(SCA_ISensor) @@ -61,4 +59,3 @@ base class --- :class:`SCA_ISensor` :type keycode: integer :return: The state of the given key, can be one of :ref:`these constants<input-status>` :rtype: int - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst index bbc695e4cbf..8f22ec06404 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_MouseSensor.rst @@ -1,8 +1,6 @@ SCA_MouseSensor(SCA_ISensor) ============================ -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_MouseSensor(SCA_ISensor) @@ -36,4 +34,3 @@ base class --- :class:`SCA_ISensor` :type button: int :return: The state of the given key, can be one of :ref:`these constants<input-status>` :rtype: int - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst index 4bd67fb22ee..74094f476f3 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_NANDController.rst @@ -1,8 +1,6 @@ SCA_NANDController(SCA_IController) =================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_NANDController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An NAND controller activates when all linked sensors are not active. There are no special python methods for this controller. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst index 5a567c84ece..ee06cda19aa 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_NORController.rst @@ -1,8 +1,6 @@ SCA_NORController(SCA_IController) ================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_NORController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An NOR controller activates only when all linked sensors are de-activated. There are no special python methods for this controller. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst index ed57b0dbaf2..874e706b3ab 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_ORController.rst @@ -1,8 +1,6 @@ SCA_ORController(SCA_IController) ================================= -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_ORController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An OR controller activates when any connected sensor activates. There are no special python methods for this controller. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst index 36a4ea7fefe..149b2607077 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PropertyActuator.rst @@ -1,8 +1,6 @@ SCA_PropertyActuator(SCA_IActuator) =================================== -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: SCA_PropertyActuator(SCA_IActuator) @@ -26,4 +24,3 @@ base class --- :class:`SCA_IActuator` TODO - add constants to game logic dict!. :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst index 3c41e4679db..d9fd1cc313f 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PropertySensor.rst @@ -1,8 +1,6 @@ SCA_PropertySensor(SCA_ISensor) =============================== -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_PropertySensor(SCA_ISensor) @@ -38,4 +36,3 @@ base class --- :class:`SCA_ISensor` the maximum value of the range used to evaluate the property when in interval mode. :type: string - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst index 7b5619106ed..a11c1398546 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PythonController.rst @@ -1,8 +1,6 @@ SCA_PythonController(SCA_IController) ===================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_PythonController(SCA_IController) @@ -51,4 +49,3 @@ base class --- :class:`SCA_IController` :arg actuator: The actuator to operate on. :type actuator: actuator or the actuator name as a string - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst index bcec751929d..a8867ee7f96 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PythonJoystick.rst @@ -1,8 +1,6 @@ SCA_PythonJoystick(PyObjectPlus) ================================ -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: SCA_PythonJoystick(PyObjectPlus) @@ -74,4 +72,3 @@ base class --- :class:`PyObjectPlus` The number of hats for the joystick at this index. (read-only). :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst index 7511f6724d8..59a3d99efc2 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PythonKeyboard.rst @@ -1,8 +1,6 @@ SCA_PythonKeyboard(PyObjectPlus) ================================ -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: SCA_PythonKeyboard(PyObjectPlus) @@ -34,4 +32,3 @@ base class --- :class:`PyObjectPlus` :arg text: New clipboard text :type text: string - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst b/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst index 5dfa78d3942..6088d785eeb 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_PythonMouse.rst @@ -1,8 +1,6 @@ SCA_PythonMouse(PyObjectPlus) ============================= -.. module:: bge.types - base class --- :class:`PyObjectPlus` .. class:: SCA_PythonMouse(PyObjectPlus) @@ -32,4 +30,3 @@ base class --- :class:`PyObjectPlus` The visibility of the mouse cursor. :type: boolean - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst b/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst index 68357229262..ef497d81643 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_RandomActuator.rst @@ -1,8 +1,6 @@ SCA_RandomActuator(SCA_IActuator) ================================= -.. module:: bge.types - base class --- :class:`SCA_IActuator` .. class:: SCA_RandomActuator(SCA_IActuator) @@ -124,4 +122,3 @@ base class --- :class:`SCA_IActuator` The half-life 'time' is characterized by half_life. :type half_life: float - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst b/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst index 05e61ccf118..aaa8b1084fe 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_RandomSensor.rst @@ -1,8 +1,6 @@ SCA_RandomSensor(SCA_ISensor) ============================= -.. module:: bge.types - base class --- :class:`SCA_ISensor` .. class:: SCA_RandomSensor(SCA_ISensor) @@ -20,4 +18,3 @@ base class --- :class:`SCA_ISensor` The seed of the random number generator. :type: integer - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst index d0235f29a20..a46ac104307 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_XNORController.rst @@ -1,8 +1,6 @@ SCA_XNORController(SCA_IController) =================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_XNORController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An XNOR controller activates when all linked sensors are the same (activated or inative). There are no special python methods for this controller. - diff --git a/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst b/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst index 98ccf142f63..bc69df421ea 100644 --- a/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst +++ b/doc/python_api/rst/bge_types/bge.types.SCA_XORController.rst @@ -1,8 +1,6 @@ SCA_XORController(SCA_IController) ================================== -.. module:: bge.types - base class --- :class:`SCA_IController` .. class:: SCA_XORController(SCA_IController) @@ -10,4 +8,3 @@ base class --- :class:`SCA_IController` An XOR controller activates when there is the input is mixed, but not when all are on or off. There are no special python methods for this controller. - diff --git a/intern/clog/clog.c b/intern/clog/clog.c index dfbd34d341a..dc0229e0748 100644 --- a/intern/clog/clog.c +++ b/intern/clog/clog.c @@ -29,10 +29,13 @@ #include <assert.h> /* For 'isatty' to check for color. */ -#if defined(__unix__) +#if defined(__unix__) || defined(__APPLE__) # include <unistd.h> #endif +#if defined(_MSC_VER) +# include <io.h> +#endif /* Only other dependency (could use regular malloc too). */ #include "MEM_guardedalloc.h" @@ -68,7 +71,8 @@ typedef struct CLogContext { bool use_basename; /** Borrowed, not owned. */ - FILE *output; + int output; + FILE *output_file; /** For new types. */ struct { @@ -400,13 +404,12 @@ void CLG_log_str( clg_str_append(&cstr, "\n"); /* could be optional */ - fwrite(cstr.data, cstr.len, 1, lg->ctx->output); - fflush(lg->ctx->output); + write(lg->ctx->output, cstr.data, cstr.len); clg_str_free(&cstr); if (severity == CLG_SEVERITY_FATAL) { - clg_ctx_fatal_action(lg->ctx, lg->ctx->output); + clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file); } } @@ -432,13 +435,12 @@ void CLG_logf( clg_str_append(&cstr, "\n"); /* could be optional */ - fwrite(cstr.data, cstr.len, 1, lg->ctx->output); - fflush(lg->ctx->output); + write(lg->ctx->output, cstr.data, cstr.len); clg_str_free(&cstr); if (severity == CLG_SEVERITY_FATAL) { - clg_ctx_fatal_action(lg->ctx, lg->ctx->output); + clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file); } } @@ -450,9 +452,10 @@ void CLG_logf( static void CLG_ctx_output_set(CLogContext *ctx, void *file_handle) { - ctx->output = file_handle; -#if defined(__unix__) - ctx->use_color = isatty(fileno(file_handle)); + ctx->output_file = file_handle; + ctx->output = fileno(file_handle); +#if defined(__unix__) || defined(__APPLE__) + ctx->use_color = isatty(ctx->output); #endif } diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index ff05ffc8df7..c698db2e8f5 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -72,7 +72,7 @@ void BKE_object_free_caches(struct Object *object); void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData *hmd); -bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type); +bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type); void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src); void BKE_object_free_modifiers(struct Object *ob, const int flag); @@ -80,9 +80,9 @@ void BKE_object_free_modifiers(struct Object *ob, const int flag); void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); -bool BKE_object_exists_check(struct Object *obtest); -bool BKE_object_is_in_editmode(struct Object *ob); -bool BKE_object_is_in_editmode_vgroup(struct Object *ob); +bool BKE_object_exists_check(const struct Object *obtest); +bool BKE_object_is_in_editmode(const struct Object *ob); +bool BKE_object_is_in_editmode_vgroup(const struct Object *ob); bool BKE_object_is_in_wpaint_select_vert(const struct Object *ob); typedef enum eObjectVisibilityCheck { @@ -123,8 +123,8 @@ void BKE_object_copy_data(struct Main *bmain, struct Object *ob_dst, const struc struct Object *BKE_object_copy(struct Main *bmain, const struct Object *ob); void BKE_object_make_local(struct Main *bmain, struct Object *ob, const bool lib_local); void BKE_object_make_local_ex(struct Main *bmain, struct Object *ob, const bool lib_local, const bool clear_proxy); -bool BKE_object_is_libdata(struct Object *ob); -bool BKE_object_obdata_is_libdata(struct Object *ob); +bool BKE_object_is_libdata(const struct Object *ob); +bool BKE_object_obdata_is_libdata(const struct Object *ob); void BKE_object_obdata_size_init(struct Object *ob, const float scale); @@ -136,7 +136,7 @@ void BKE_object_to_mat4(struct Object *ob, float mat[4][4]); void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent); void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]); -bool BKE_object_pose_context_check(struct Object *ob); +bool BKE_object_pose_context_check(const struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); struct Object *BKE_object_pose_armature_get_visible(struct Object *ob, struct ViewLayer *view_layer); @@ -274,7 +274,7 @@ bool BKE_object_shapekey_free(struct Main *bmain, struct Object *ob); bool BKE_object_flag_test_recursive(const struct Object *ob, short flag); -bool BKE_object_is_child_recursive(struct Object *ob_parent, struct Object *ob_child); +bool BKE_object_is_child_recursive(const struct Object *ob_parent, const struct Object *ob_child); bool BKE_object_is_animated(struct Scene *scene, struct Object *ob); /* return ModifierMode flag */ diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 98db06752c8..b53af3cec53 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -44,8 +44,6 @@ struct TextUndoBuf; void BKE_text_free_lines (struct Text *text); void BKE_text_free (struct Text *text); -void txt_set_undostate (int u); -int txt_get_undostate (void); void BKE_text_init(struct Text *ta); struct Text *BKE_text_add (struct Main *bmain, const char *name); int txt_extended_ascii_as_utf8(char **str); diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 9697c7dd8e2..53ea8ddefe8 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -149,6 +149,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, struct bContext *C, cons bool BKE_undosys_step_push(UndoStack *ustack, struct bContext *C, const char *name); UndoStep *BKE_undosys_step_find_by_name_with_type(UndoStack *ustack, const char *name, const UndoType *ut); +UndoStep *BKE_undosys_step_find_by_type(UndoStack *ustack, const UndoType *ut); UndoStep *BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name); bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack, struct bContext *C, UndoStep *us, bool use_skip); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index acb2db8d7ad..e47c87c995b 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -500,7 +500,7 @@ bPoseChannel *BKE_pose_channel_active(Object *ob) } /** - * \see #ED_armature_bone_get_mirrored (edit-mode, matching function) + * \see #ED_armature_ebone_get_mirrored (edit-mode, matching function) */ bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 67769c9ae3b..875d716305f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -238,7 +238,7 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd) } } -bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type) +bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) { const ModifierTypeInfo *mti; @@ -487,7 +487,7 @@ void BKE_object_free(Object *ob) } /* actual check for internal data, not context or flags */ -bool BKE_object_is_in_editmode(Object *ob) +bool BKE_object_is_in_editmode(const Object *ob) { if (ob->data == NULL) return false; @@ -530,7 +530,7 @@ bool BKE_object_is_in_editmode(Object *ob) return false; } -bool BKE_object_is_in_editmode_vgroup(Object *ob) +bool BKE_object_is_in_editmode_vgroup(const Object *ob) { return (OB_TYPE_SUPPORT_VGROUP(ob->type) && BKE_object_is_in_editmode(ob)); @@ -578,7 +578,7 @@ bool BKE_object_is_visible(Object *ob, const eObjectVisibilityCheck mode) } } -bool BKE_object_exists_check(Object *obtest) +bool BKE_object_exists_check(const Object *obtest) { Object *ob; @@ -1150,7 +1150,7 @@ static void copy_object_lod(Object *obn, const Object *ob, const int UNUSED(flag obn->currentlod = (LodLevel *)obn->lodlevels.first; } -bool BKE_object_pose_context_check(Object *ob) +bool BKE_object_pose_context_check(const Object *ob) { if ((ob) && (ob->type == OB_ARMATURE) && @@ -1352,13 +1352,13 @@ void BKE_object_make_local(Main *bmain, Object *ob, const bool lib_local) } /* Returns true if the Object is from an external blend file (libdata) */ -bool BKE_object_is_libdata(Object *ob) +bool BKE_object_is_libdata(const Object *ob) { return (ob && ID_IS_LINKED(ob)); } /* Returns true if the Object data is from an external blend file (libdata) */ -bool BKE_object_obdata_is_libdata(Object *ob) +bool BKE_object_obdata_is_libdata(const Object *ob) { /* Linked objects with local obdata are forbidden! */ BLI_assert(!ob || !ob->data || (ID_IS_LINKED(ob) ? ID_IS_LINKED(ob->data) : true)); @@ -3138,7 +3138,7 @@ bool BKE_object_flag_test_recursive(const Object *ob, short flag) } } -bool BKE_object_is_child_recursive(Object *ob_parent, Object *ob_child) +bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child) { for (ob_child = ob_child->parent; ob_child; ob_child = ob_child->parent) { if (ob_child == ob_parent) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index cd9b8ae339d..b1ff2724375 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -174,18 +174,12 @@ static void txt_make_dirty(Text *text); /***/ -static unsigned char undoing; - -/* allow to switch off undoing externally */ -void txt_set_undostate(int u) -{ - undoing = u; -} - -int txt_get_undostate(void) -{ - return undoing; -} +/** + * Set to true when undoing (so we don't generate undo steps while undoing). + * + * Also use to disable undo entirely. + */ +static bool undoing; /** * \note caller must handle `undo_buf` and `compiled` members. @@ -525,29 +519,26 @@ void BKE_text_make_local(Main *bmain, Text *text, const bool lib_local) void BKE_text_clear(Text *text, TextUndoBuf *utxt) /* called directly from rna */ { - int oldstate; - - if (utxt) { - oldstate = txt_get_undostate(); - } - txt_set_undostate(utxt != NULL); + const bool undoing_orig = undoing; + undoing = (utxt == NULL); txt_sel_all(text); txt_delete_sel(text, utxt); - txt_set_undostate(oldstate); + undoing = undoing_orig; txt_make_dirty(text); } void BKE_text_write(Text *text, TextUndoBuf *utxt, const char *str) /* called directly from rna */ { - int oldstate; + const bool undoing_orig = undoing; + undoing = (utxt == NULL); - oldstate = txt_get_undostate(); txt_insert_buf(text, utxt, str); txt_move_eof(text, 0); - txt_set_undostate(oldstate); + + undoing = undoing_orig; txt_make_dirty(text); } @@ -1395,7 +1386,8 @@ char *txt_sel_to_buf(Text *text) void txt_insert_buf(Text *text, TextUndoBuf *utxt, const char *in_buffer) { - int l = 0, u, len; + const bool undoing_orig = undoing; + int l = 0, len; size_t i = 0, j; TextLine *add; char *buffer; @@ -1408,41 +1400,44 @@ void txt_insert_buf(Text *text, TextUndoBuf *utxt, const char *in_buffer) buffer = BLI_strdupn(in_buffer, len); len += txt_extended_ascii_as_utf8(&buffer); - if (!undoing) txt_undo_add_blockop(text, utxt, UNDO_IBLOCK, buffer); - - u = undoing; - undoing = 1; + if (!undoing) { + txt_undo_add_blockop(text, utxt, UNDO_IBLOCK, buffer); + } + undoing = true; /* Read the first line (or as close as possible */ - while (buffer[i] && buffer[i] != '\n') + while (buffer[i] && buffer[i] != '\n') { txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &i)); + } - if (buffer[i] == '\n') txt_split_curline(text, utxt); - else { undoing = u; MEM_freeN(buffer); return; } - i++; + if (buffer[i] == '\n') { + txt_split_curline(text, utxt); + i++; - while (i < len) { - l = 0; + while (i < len) { + l = 0; - while (buffer[i] && buffer[i] != '\n') { - i++; l++; - } - - if (buffer[i] == '\n') { - add = txt_new_linen(buffer + (i - l), l); - BLI_insertlinkbefore(&text->lines, text->curl, add); - i++; - } - else { - for (j = i - l; j < i && j < len; ) - txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &j)); - break; + while (buffer[i] && buffer[i] != '\n') { + i++; + l++; + } + + if (buffer[i] == '\n') { + add = txt_new_linen(buffer + (i - l), l); + BLI_insertlinkbefore(&text->lines, text->curl, add); + i++; + } + else { + for (j = i - l; j < i && j < len; ) { + txt_add_raw_char(text, utxt, BLI_str_utf8_as_unicode_step(buffer, &j)); + } + break; + } } } - - MEM_freeN(buffer); - undoing = u; + MEM_freeN(buffer); + undoing = undoing_orig; } /******************/ diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 40cdd57fc3b..fd62650e898 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -505,6 +505,16 @@ UndoStep *BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name) return BLI_rfindstring(&ustack->steps, name, offsetof(UndoStep, name)); } +UndoStep *BKE_undosys_step_find_by_type(UndoStack *ustack, const UndoType *ut) +{ + for (UndoStep *us = ustack->steps.last; us; us = us->prev) { + if (us->type == ut) { + return us; + } + } + return NULL; +} + bool BKE_undosys_step_undo_with_data_ex( UndoStack *ustack, bContext *C, UndoStep *us, bool use_skip) diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h index b713b963056..c407ea31b9b 100644 --- a/source/blender/blenloader/BLO_undofile.h +++ b/source/blender/blenloader/BLO_undofile.h @@ -56,7 +56,9 @@ typedef struct MemFileUndoData { } MemFileUndoData; /* actually only used writefile.c */ -extern void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsigned int size); +extern void memfile_chunk_add( + MemFile *memfile, const char *buf, unsigned int size, + MemFileChunk **compchunk_step); /* exports */ extern void BLO_memfile_free(MemFile *memfile); diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index f6584ecf25f..7133dee0e82 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -96,36 +96,26 @@ void BLO_memfile_merge(MemFile *first, MemFile *second) BLO_memfile_free(first); } -void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsigned int size) +void memfile_chunk_add( + MemFile *memfile, const char *buf, unsigned int size, + MemFileChunk **compchunk_step) { - static MemFileChunk *compchunk = NULL; - MemFileChunk *curchunk; - - /* this function inits when compare != NULL or when current == NULL */ - if (compare) { - compchunk = compare->chunks.first; - return; - } - if (current == NULL) { - compchunk = NULL; - return; - } - - curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk"); + MemFileChunk *curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk"); curchunk->size = size; curchunk->buf = NULL; curchunk->is_identical = false; - BLI_addtail(¤t->chunks, curchunk); - + BLI_addtail(&memfile->chunks, curchunk); + /* we compare compchunk with buf */ - if (compchunk) { + if (*compchunk_step != NULL) { + MemFileChunk *compchunk = *compchunk_step; if (compchunk->size == curchunk->size) { if (memcmp(compchunk->buf, buf, size) == 0) { curchunk->buf = compchunk->buf; curchunk->is_identical = true; } } - compchunk = compchunk->next; + *compchunk_step = compchunk->next; } /* not equal... */ @@ -133,7 +123,7 @@ void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsi char *buf_new = MEM_mallocN(size, "Chunk buffer"); memcpy(buf_new, buf, size); curchunk->buf = buf_new; - current->size += size; + memfile->size += size; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 40c54e04ec7..7f4e7fdc646 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -206,8 +206,11 @@ #define MYWRITE_BUFFER_SIZE (MEM_SIZE_OPTIMAL(1 << 17)) /* 128kb */ #define MYWRITE_MAX_CHUNK (MEM_SIZE_OPTIMAL(1 << 15)) /* ~32kb */ +/** Use if we want to store how many bytes have been written to the file. */ +// #define USE_WRITE_DATA_LEN -/** \name Small API to handle compression. +/* -------------------------------------------------------------------- */ +/** \name Internal Write Wrapper's (Abstracts Compression) * \{ */ typedef enum { @@ -311,20 +314,41 @@ static void ww_handle_init(eWriteWrapType ww_type, WriteWrap *r_ww) /** \} */ - +/* -------------------------------------------------------------------- */ +/** \name Write Data Type & Functions + * \{ */ typedef struct { const struct SDNA *sdna; - unsigned char *buf; - MemFile *compare, *current; + /** Use for file and memory writing (fixed size of #MYWRITE_BUFFER_SIZE). */ + uchar *buf; + /** Number of bytes used in #WriteData.buf (flushed when exceeded). */ + int buf_used_len; + +#ifdef USE_WRITE_DATA_LEN + /** Total number of bytes written. */ + size_t write_len; +#endif - int tot, count; + /** Set on unlikely case of an error (ignores further file writing). */ bool error; - /* Wrap writing, so we can use zlib or + /** #MemFile writing (used for undo). */ + struct { + MemFile *current; + MemFile *compare; + /** Use to de-duplicate chunks when writing. */ + MemFileChunk *compare_chunk; + } mem; + /** When true, write to #WriteData.current, could also call 'is_undo'. */ + bool use_memfile; + + /** + * Wrap writing, so we can use zlib or * other compression types later, see: G_FILE_COMPRESS - * Will be NULL for UNDO. */ + * Will be NULL for UNDO. + */ WriteWrap *ww; #ifdef USE_BMESH_SAVE_AS_COMPAT @@ -356,8 +380,8 @@ static void writedata_do_write(WriteData *wd, const void *mem, int memlen) } /* memory based save */ - if (wd->current) { - memfile_chunk_add(NULL, wd->current, mem, memlen); + if (wd->use_memfile) { + memfile_chunk_add(wd->mem.current, mem, memlen, &wd->mem.compare_chunk); } else { if (wd->ww->write(wd->ww, mem, memlen) != memlen) { @@ -372,7 +396,11 @@ static void writedata_free(WriteData *wd) MEM_freeN(wd); } -/***/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Local Writing API 'mywrite' + * \{ */ /** * Flush helps the de-duplicating memory for undo-save by logically segmenting data, @@ -380,9 +408,9 @@ static void writedata_free(WriteData *wd) */ static void mywrite_flush(WriteData *wd) { - if (wd->count) { - writedata_do_write(wd, wd->buf, wd->count); - wd->count = 0; + if (wd->buf_used_len) { + writedata_do_write(wd, wd->buf, wd->buf_used_len); + wd->buf_used_len = 0; } } @@ -390,7 +418,6 @@ static void mywrite_flush(WriteData *wd) * Low level WRITE(2) wrapper that buffers data * \param adr Pointer to new chunk of data * \param len Length of new chunk of data - * \warning Talks to other functions with global parameters */ static void mywrite(WriteData *wd, const void *adr, int len) { @@ -398,19 +425,21 @@ static void mywrite(WriteData *wd, const void *adr, int len) return; } - if (adr == NULL) { + if (UNLIKELY(adr == NULL)) { BLI_assert(0); return; } - wd->tot += len; +#ifdef USE_WRITE_DATA_LEN + wd->write_len += len; +#endif /* if we have a single big chunk, write existing data in * buffer and write out big chunk in smaller pieces */ if (len > MYWRITE_MAX_CHUNK) { - if (wd->count) { - writedata_do_write(wd, wd->buf, wd->count); - wd->count = 0; + if (wd->buf_used_len) { + writedata_do_write(wd, wd->buf, wd->buf_used_len); + wd->buf_used_len = 0; } do { @@ -424,14 +453,14 @@ static void mywrite(WriteData *wd, const void *adr, int len) } /* if data would overflow buffer, write out the buffer */ - if (len + wd->count > MYWRITE_BUFFER_SIZE - 1) { - writedata_do_write(wd, wd->buf, wd->count); - wd->count = 0; + if (len + wd->buf_used_len > MYWRITE_BUFFER_SIZE - 1) { + writedata_do_write(wd, wd->buf, wd->buf_used_len); + wd->buf_used_len = 0; } /* append data at end of buffer */ - memcpy(&wd->buf[wd->count], adr, len); - wd->count += len; + memcpy(&wd->buf[wd->buf_used_len], adr, len); + wd->buf_used_len += len; } /** @@ -441,19 +470,17 @@ static void mywrite(WriteData *wd, const void *adr, int len) * \param current The current memory file (can be NULL). * \warning Talks to other functions with global parameters */ -static WriteData *bgnwrite(WriteWrap *ww, MemFile *compare, MemFile *current) +static WriteData *mywrite_begin(WriteWrap *ww, MemFile *compare, MemFile *current) { WriteData *wd = writedata_new(ww); - if (wd == NULL) { - return NULL; + if (current != NULL) { + wd->mem.current = current; + wd->mem.compare = compare; + wd->mem.compare_chunk = compare ? compare->chunks.first : NULL; + wd->use_memfile = true; } - wd->compare = compare; - wd->current = current; - /* this inits comparing */ - memfile_chunk_add(compare, NULL, NULL, 0); - return wd; } @@ -463,11 +490,11 @@ static WriteData *bgnwrite(WriteWrap *ww, MemFile *compare, MemFile *current) * \return unknown global variable otherwise * \warning Talks to other functions with global parameters */ -static bool endwrite(WriteData *wd) +static bool mywrite_end(WriteData *wd) { - if (wd->count) { - writedata_do_write(wd, wd->buf, wd->count); - wd->count = 0; + if (wd->buf_used_len) { + writedata_do_write(wd, wd->buf, wd->buf_used_len); + wd->buf_used_len = 0; } const bool err = wd->error; @@ -476,7 +503,11 @@ static bool endwrite(WriteData *wd) return err; } -/* ********** WRITE FILE ****************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Generic DNA File Writing + * \{ */ static void writestruct_at_address_nr( WriteData *wd, int filecode, const int struct_nr, int nr, @@ -602,8 +633,14 @@ static void writelist_id(WriteData *wd, int filecode, const char *structname, co #define writelist(wd, filecode, struct_id, lb) \ writelist_nr(wd, filecode, SDNA_TYPE_FROM_STRUCT(struct_id), lb) -/* *************** writing some direct data structs used in more code parts **************** */ -/*These functions are used by blender's .blend system for file saving/loading.*/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Typed DNA File Writing + * + * These functions are used by blender's .blend system for file saving/loading. + * \{ */ + void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd); void IDP_WriteProperty(const IDProperty *prop, void *wd); @@ -830,7 +867,7 @@ static void write_fcurves(WriteData *wd, ListBase *fcurves) static void write_action(WriteData *wd, bAction *act) { - if (act->id.us > 0 || wd->current) { + if (act->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_AC, bAction, 1, act); write_iddata(wd, &act->id); @@ -938,7 +975,7 @@ static void write_node_socket(WriteData *wd, bNodeTree *UNUSED(ntree), bNode *no { #ifdef USE_NODE_COMPAT_CUSTOMNODES /* forward compatibility code, so older blenders still open (not for undo) */ - if (wd->current == NULL) { + if (wd->use_memfile == false) { sock->stack_type = 1; if (node->type == NODE_GROUP) { @@ -1058,7 +1095,7 @@ static void write_nodetree_nolib(WriteData *wd, bNodeTree *ntree) * Not ideal (there is no ideal solution here), but should do for now. */ NodeGlare *ndg = node->storage; /* Not in undo case. */ - if (!wd->current) { + if (wd->use_memfile == false) { switch (ndg->type) { case 2: /* Grrrr! magic numbers :( */ ndg->angle = ndg->streaks; @@ -1319,7 +1356,7 @@ static void write_pointcaches(WriteData *wd, ListBase *ptcaches) static void write_particlesettings(WriteData *wd, ParticleSettings *part) { - if (part->id.us > 0 || wd->current) { + if (part->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_PA, ParticleSettings, 1, part); write_iddata(wd, &part->id); @@ -1904,7 +1941,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) static void write_object(WriteData *wd, Object *ob) { - if (ob->id.us > 0 || wd->current) { + if (ob->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_OB, Object, 1, ob); write_iddata(wd, &ob->id); @@ -1968,7 +2005,7 @@ static void write_object(WriteData *wd, Object *ob) static void write_vfont(WriteData *wd, VFont *vf) { - if (vf->id.us > 0 || wd->current) { + if (vf->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_VF, VFont, 1, vf); write_iddata(wd, &vf->id); @@ -1985,7 +2022,7 @@ static void write_vfont(WriteData *wd, VFont *vf) static void write_key(WriteData *wd, Key *key) { - if (key->id.us > 0 || wd->current) { + if (key->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_KE, Key, 1, key); write_iddata(wd, &key->id); @@ -2006,7 +2043,7 @@ static void write_key(WriteData *wd, Key *key) static void write_camera(WriteData *wd, Camera *cam) { - if (cam->id.us > 0 || wd->current) { + if (cam->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_CA, Camera, 1, cam); write_iddata(wd, &cam->id); @@ -2023,7 +2060,7 @@ static void write_camera(WriteData *wd, Camera *cam) static void write_mball(WriteData *wd, MetaBall *mb) { - if (mb->id.us > 0 || wd->current) { + if (mb->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_MB, MetaBall, 1, mb); write_iddata(wd, &mb->id); @@ -2042,7 +2079,7 @@ static void write_mball(WriteData *wd, MetaBall *mb) static void write_curve(WriteData *wd, Curve *cu) { - if (cu->id.us > 0 || wd->current) { + if (cu->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_CU, Curve, 1, cu); write_iddata(wd, &cu->id); @@ -2143,7 +2180,7 @@ static void write_customdata( int i; /* write external customdata (not for undo) */ - if (data->external && !wd->current) { + if (data->external && (wd->use_memfile == false)) { CustomData_external_write(data, id, CD_MASK_MESH, count, 0); } @@ -2213,7 +2250,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh) CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE]; CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE]; - if (mesh->id.us > 0 || wd->current) { + if (mesh->id.us > 0 || wd->use_memfile) { /* write LibData */ if (!save_for_old_blender) { /* write a copy of the mesh, don't modify in place because it is @@ -2355,7 +2392,7 @@ static void write_mesh(WriteData *wd, Mesh *mesh) static void write_lattice(WriteData *wd, Lattice *lt) { - if (lt->id.us > 0 || wd->current) { + if (lt->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_LT, Lattice, 1, lt); write_iddata(wd, <->id); @@ -2374,7 +2411,7 @@ static void write_lattice(WriteData *wd, Lattice *lt) static void write_image(WriteData *wd, Image *ima) { - if (ima->id.us > 0 || wd->current) { + if (ima->id.us > 0 || wd->use_memfile) { ImagePackedFile *imapf; /* Some trickery to keep forward compatibility of packed images. */ @@ -2410,7 +2447,7 @@ static void write_image(WriteData *wd, Image *ima) static void write_texture(WriteData *wd, Tex *tex) { - if (tex->id.us > 0 || wd->current) { + if (tex->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_TE, Tex, 1, tex); write_iddata(wd, &tex->id); @@ -2454,7 +2491,7 @@ static void write_texture(WriteData *wd, Tex *tex) static void write_material(WriteData *wd, Material *ma) { - if (ma->id.us > 0 || wd->current) { + if (ma->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_MA, Material, 1, ma); write_iddata(wd, &ma->id); @@ -2488,7 +2525,7 @@ static void write_material(WriteData *wd, Material *ma) static void write_world(WriteData *wd, World *wrld) { - if (wrld->id.us > 0 || wd->current) { + if (wrld->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_WO, World, 1, wrld); write_iddata(wd, &wrld->id); @@ -2515,7 +2552,7 @@ static void write_world(WriteData *wd, World *wrld) static void write_lamp(WriteData *wd, Lamp *la) { - if (la->id.us > 0 || wd->current) { + if (la->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_LA, Lamp, 1, la); write_iddata(wd, &la->id); @@ -2832,7 +2869,7 @@ static void write_scene(WriteData *wd, Scene *sce) static void write_gpencil(WriteData *wd, bGPdata *gpd) { - if (gpd->id.us > 0 || wd->current) { + if (gpd->id.us > 0 || wd->use_memfile) { /* write gpd data block to file */ writestruct(wd, ID_GD, bGPdata, 1, gpd); write_iddata(wd, &gpd->id); @@ -3147,7 +3184,7 @@ static void write_bone(WriteData *wd, Bone *bone) static void write_armature(WriteData *wd, bArmature *arm) { - if (arm->id.us > 0 || wd->current) { + if (arm->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_AR, bArmature, 1, arm); write_iddata(wd, &arm->id); @@ -3190,7 +3227,7 @@ static void write_text(WriteData *wd, Text *text) static void write_speaker(WriteData *wd, Speaker *spk) { - if (spk->id.us > 0 || wd->current) { + if (spk->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_SPK, Speaker, 1, spk); write_iddata(wd, &spk->id); @@ -3203,7 +3240,7 @@ static void write_speaker(WriteData *wd, Speaker *spk) static void write_sound(WriteData *wd, bSound *sound) { - if (sound->id.us > 0 || wd->current) { + if (sound->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_SO, bSound, 1, sound); write_iddata(wd, &sound->id); @@ -3218,7 +3255,7 @@ static void write_sound(WriteData *wd, bSound *sound) static void write_probe(WriteData *wd, LightProbe *prb) { - if (prb->id.us > 0 || wd->current) { + if (prb->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_LP, LightProbe, 1, prb); write_iddata(wd, &prb->id); @@ -3231,7 +3268,7 @@ static void write_probe(WriteData *wd, LightProbe *prb) static void write_group(WriteData *wd, Group *group) { - if (group->id.us > 0 || wd->current) { + if (group->id.us > 0 || wd->use_memfile) { /* write LibData */ writestruct(wd, ID_GR, Group, 1, group); write_iddata(wd, &group->id); @@ -3244,7 +3281,7 @@ static void write_group(WriteData *wd, Group *group) static void write_nodetree(WriteData *wd, bNodeTree *ntree) { - if (ntree->id.us > 0 || wd->current) { + if (ntree->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_NT, bNodeTree, 1, ntree); /* Note that trees directly used by other IDs (materials etc.) are not 'real' ID, they cannot * be linked, etc., so we write actual id data here only, for 'real' ID trees. */ @@ -3326,7 +3363,7 @@ static void customnodes_free_deprecated_data(Main *mainvar) static void write_brush(WriteData *wd, Brush *brush) { - if (brush->id.us > 0 || wd->current) { + if (brush->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_BR, Brush, 1, brush); write_iddata(wd, &brush->id); @@ -3341,7 +3378,7 @@ static void write_brush(WriteData *wd, Brush *brush) static void write_palette(WriteData *wd, Palette *palette) { - if (palette->id.us > 0 || wd->current) { + if (palette->id.us > 0 || wd->use_memfile) { PaletteColor *color; writestruct(wd, ID_PAL, Palette, 1, palette); write_iddata(wd, &palette->id); @@ -3354,7 +3391,7 @@ static void write_palette(WriteData *wd, Palette *palette) static void write_paintcurve(WriteData *wd, PaintCurve *pc) { - if (pc->id.us > 0 || wd->current) { + if (pc->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_PC, PaintCurve, 1, pc); write_iddata(wd, &pc->id); @@ -3402,7 +3439,7 @@ static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction static void write_movieclip(WriteData *wd, MovieClip *clip) { - if (clip->id.us > 0 || wd->current) { + if (clip->id.us > 0 || wd->use_memfile) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *object; @@ -3432,7 +3469,7 @@ static void write_movieclip(WriteData *wd, MovieClip *clip) static void write_mask(WriteData *wd, Mask *mask) { - if (mask->id.us > 0 || wd->current) { + if (mask->id.us > 0 || wd->use_memfile) { MaskLayer *masklay; writestruct(wd, ID_MSK, Mask, 1, mask); @@ -3737,7 +3774,7 @@ static void write_linestyle_geometry_modifiers(WriteData *wd, ListBase *modifier static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle) { - if (linestyle->id.us > 0 || wd->current) { + if (linestyle->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_LS, FreestyleLineStyle, 1, linestyle); write_iddata(wd, &linestyle->id); @@ -3763,7 +3800,7 @@ static void write_linestyle(WriteData *wd, FreestyleLineStyle *linestyle) static void write_cachefile(WriteData *wd, CacheFile *cache_file) { - if (cache_file->id.us > 0 || wd->current) { + if (cache_file->id.us > 0 || wd->use_memfile) { writestruct(wd, ID_CF, CacheFile, 1, cache_file); if (cache_file->adt) { @@ -3825,7 +3862,7 @@ static void write_libraries(WriteData *wd, Main *main) PackedFile *pf = main->curlib->packedfile; writestruct(wd, DATA, PackedFile, 1, pf); writedata(wd, DATA, pf->size, pf->data); - if (wd->current == NULL) { + if (wd->use_memfile == false) { printf("write packed .blend: %s\n", main->curlib->name); } } @@ -3853,7 +3890,7 @@ static void write_libraries(WriteData *wd, Main *main) * - for undofile, curscene needs to be saved */ static void write_global(WriteData *wd, int fileflags, Main *mainvar) { - const bool is_undo = (wd->current != NULL); + const bool is_undo = wd->use_memfile; FileGlobal fg; bScreen *screen; Scene *scene; @@ -3910,6 +3947,12 @@ static void write_thumb(WriteData *wd, const BlendThumbnail *thumb) } } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name File Writing (Private) + * \{ */ + /* if MemFile * there's filesave to memory */ static bool write_file_handle( Main *mainvar, @@ -3924,7 +3967,7 @@ static bool write_file_handle( blo_split_main(&mainlist, mainvar); - wd = bgnwrite(ww, compare, current); + wd = mywrite_begin(ww, compare, current); #ifdef USE_BMESH_SAVE_AS_COMPAT wd->use_mesh_compat = (write_flags & G_FILE_MESH_COMPAT) != 0; @@ -3953,7 +3996,7 @@ static bool write_file_handle( * avoid thumbnail detecting changes because of this. */ mywrite_flush(wd); - OverrideStaticStorage *override_storage = !wd->current ? BKE_override_static_operations_store_initialize() : NULL; + OverrideStaticStorage *override_storage = wd->use_memfile ? NULL : BKE_override_static_operations_store_initialize(); /* This outer loop allows to save first datablocks from real mainvar, then the temp ones from override process, * if needed, without duplicating whole code. */ @@ -4142,7 +4185,7 @@ static bool write_file_handle( blo_join_main(&mainlist); - return endwrite(wd); + return mywrite_end(wd); } /* do reverse file history: .blend1 -> .blend2, .blend -> .blend1 */ @@ -4187,6 +4230,12 @@ static bool do_history(const char *name, ReportList *reports) return 0; } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name File Writing (Public) + * \{ */ + /** * \return Success. */ @@ -4300,3 +4349,5 @@ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int w return (err == 0); } + +/** \} */ diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index b2794b3bd23..f24688479af 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -104,7 +104,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon it = std::find(finished_joints.begin(), finished_joints.end(), node); if (it != finished_joints.end()) return chain_length; - EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node)); + EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node)); totbone++; /* @@ -636,8 +636,8 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin) } void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, const char *parentname, float parent_mat[4][4]) -{ - char *bone_name = (char *) bc_get_joint_name(root_node); +{ + const char *bone_name = bc_get_joint_name(root_node); float mat[4][4]; float obmat[4][4]; diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index bccfe025089..9c04e74a7da 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -24,20 +24,20 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" extern "C" { - #include "BLI_jitter_2d.h" +#include "BLI_jitter_2d.h" } #include "COM_VectorBlurOperation.h" /* Defined */ -#define PASS_VECTOR_MAX 10000.0f +#define PASS_VECTOR_MAX 10000.0f /* Forward declarations */ struct ZSpan; struct DrawBufPixel; void zbuf_accumulate_vecblur( - NodeBlurData *nbd, int xsize, int ysize, float *newrect, - const float *imgrect, float *vecbufrect, const float *zbufrect); + NodeBlurData *nbd, int xsize, int ysize, float *newrect, + const float *imgrect, float *vecbufrect, const float *zbufrect); void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop); void zbuf_free_span(ZSpan *zspan); void antialias_tagbuf(int xsize, int ysize, char *rectmove); @@ -70,7 +70,7 @@ void VectorBlurOperation::initExecution() void VectorBlurOperation::executePixel(float output[4], int x, int y, void *data) { - float *buffer = (float *) data; + float *buffer = (float *)data; int index = (y * this->getWidth() + x) * COM_NUM_CHANNELS_COLOR; copy_v4_v4(output, &buffer[index]); } @@ -148,7 +148,7 @@ typedef struct ZSpan { float zmulx, zmuly, zofsx, zofsy; int *rectz; - DrawBufPixel* rectdraw; + DrawBufPixel *rectdraw; float clipcrop; } ZSpan; @@ -158,13 +158,13 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop) { memset(zspan, 0, sizeof(ZSpan)); - zspan->rectx= rectx; - zspan->recty= recty; + zspan->rectx = rectx; + zspan->recty = recty; - zspan->span1= (float*)MEM_mallocN(recty*sizeof(float), "zspan"); - zspan->span2= (float*)MEM_mallocN(recty*sizeof(float), "zspan"); + zspan->span1 = (float *)MEM_mallocN(recty * sizeof(float), "zspan"); + zspan->span2 = (float *)MEM_mallocN(recty * sizeof(float), "zspan"); - zspan->clipcrop= clipcrop; + zspan->clipcrop = clipcrop; } void zbuf_free_span(ZSpan *zspan) @@ -172,16 +172,16 @@ void zbuf_free_span(ZSpan *zspan) if (zspan) { if (zspan->span1) MEM_freeN(zspan->span1); if (zspan->span2) MEM_freeN(zspan->span2); - zspan->span1= zspan->span2= NULL; + zspan->span1 = zspan->span2 = NULL; } } /* reset range for clipping */ static void zbuf_init_span(ZSpan *zspan) { - zspan->miny1= zspan->miny2= zspan->recty+1; - zspan->maxy1= zspan->maxy2= -1; - zspan->minp1= zspan->maxp1= zspan->minp2= zspan->maxp2= NULL; + zspan->miny1 = zspan->miny2 = zspan->recty + 1; + zspan->maxy1 = zspan->maxy2 = -1; + zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL; } static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) @@ -191,30 +191,30 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) float xx1, dx0, xs0; int y, my0, my2; - if (v1[1]<v2[1]) { - minv= v1; maxv= v2; + if (v1[1] < v2[1]) { + minv = v1; maxv = v2; } else { - minv= v2; maxv= v1; + minv = v2; maxv = v1; } - my0= ceil(minv[1]); - my2= floor(maxv[1]); + my0 = ceil(minv[1]); + my2 = floor(maxv[1]); - if (my2<0 || my0>= zspan->recty) return; + if (my2 < 0 || my0 >= zspan->recty) return; /* clip top */ - if (my2>=zspan->recty) my2= zspan->recty-1; + if (my2 >= zspan->recty) my2 = zspan->recty - 1; /* clip bottom */ - if (my0<0) my0= 0; + if (my0 < 0) my0 = 0; - if (my0>my2) return; + if (my0 > my2) return; /* if (my0>my2) should still fill in, that way we get spans that skip nicely */ - xx1= maxv[1]-minv[1]; - if (xx1>FLT_EPSILON) { - dx0= (minv[0]-maxv[0])/xx1; - xs0= dx0*(minv[1]-my2) + minv[0]; + xx1 = maxv[1] - minv[1]; + if (xx1 > FLT_EPSILON) { + dx0 = (minv[0] - maxv[0]) / xx1; + xs0 = dx0 * (minv[1] - my2) + minv[0]; } else { dx0 = 0.0f; @@ -223,43 +223,43 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2]) /* empty span */ if (zspan->maxp1 == NULL) { - span= zspan->span1; + span = zspan->span1; } - else { /* does it complete left span? */ - if ( maxv == zspan->minp1 || minv==zspan->maxp1) { - span= zspan->span1; + else { /* does it complete left span? */ + if (maxv == zspan->minp1 || minv == zspan->maxp1) { + span = zspan->span1; } else { - span= zspan->span2; + span = zspan->span2; } } - if (span==zspan->span1) { + if (span == zspan->span1) { // printf("left span my0 %d my2 %d\n", my0, my2); - if (zspan->minp1==NULL || zspan->minp1[1] > minv[1] ) { - zspan->minp1= minv; + if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) { + zspan->minp1 = minv; } - if (zspan->maxp1==NULL || zspan->maxp1[1] < maxv[1] ) { - zspan->maxp1= maxv; + if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) { + zspan->maxp1 = maxv; } - if (my0<zspan->miny1) zspan->miny1= my0; - if (my2>zspan->maxy1) zspan->maxy1= my2; + if (my0 < zspan->miny1) zspan->miny1 = my0; + if (my2 > zspan->maxy1) zspan->maxy1 = my2; } else { // printf("right span my0 %d my2 %d\n", my0, my2); - if (zspan->minp2==NULL || zspan->minp2[1] > minv[1] ) { - zspan->minp2= minv; + if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) { + zspan->minp2 = minv; } - if (zspan->maxp2==NULL || zspan->maxp2[1] < maxv[1] ) { - zspan->maxp2= maxv; + if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) { + zspan->maxp2 = maxv; } - if (my0<zspan->miny2) zspan->miny2= my0; - if (my2>zspan->maxy2) zspan->maxy2= my2; + if (my0 < zspan->miny2) zspan->miny2 = my0; + if (my2 > zspan->maxy2) zspan->maxy2 = my2; } - for (y=my2; y>=my0; y--, xs0+= dx0) { + for (y = my2; y >= my0; y--, xs0 += dx0) { /* xs0 is the xcoord! */ - span[y]= xs0; + span[y] = xs0; } } @@ -292,79 +292,79 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float zbuf_add_to_span(zspan, v4, v1); /* clipped */ - if (zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2 == NULL || zspan->maxp2 == NULL) return; my0 = max_ii(zspan->miny1, zspan->miny2); my2 = min_ii(zspan->maxy1, zspan->maxy2); // printf("my %d %d\n", my0, my2); - if (my2<my0) return; + if (my2 < my0) return; /* ZBUF DX DY, in floats still */ - x1= v1[0]- v2[0]; - x2= v2[0]- v3[0]; - y1= v1[1]- v2[1]; - y2= v2[1]- v3[1]; - z1= v1[2]- v2[2]; - z2= v2[2]- v3[2]; - x0= y1*z2-z1*y2; - y0= z1*x2-x1*z2; - z0= x1*y2-y1*x2; + x1 = v1[0] - v2[0]; + x2 = v2[0] - v3[0]; + y1 = v1[1] - v2[1]; + y2 = v2[1] - v3[1]; + z1 = v1[2] - v2[2]; + z2 = v2[2] - v3[2]; + x0 = y1 * z2 - z1 * y2; + y0 = z1 * x2 - x1 * z2; + z0 = x1 * y2 - y1 * x2; - if (z0==0.0f) return; + if (z0 == 0.0f) return; - xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; + xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2]; - zxd= -(double)x0/(double)z0; - zyd= -(double)y0/(double)z0; - zy0= ((double)my2)*zyd + (double)xx1; + zxd = -(double)x0 / (double)z0; + zyd = -(double)y0 / (double)z0; + zy0 = ((double)my2) * zyd + (double)xx1; /* start-offset in rect */ - rectx= zspan->rectx; - rectzofs= (float *)(zspan->rectz + rectx*my2); - rectpofs= ((DrawBufPixel *)zspan->rectdraw) + rectx*my2; + rectx = zspan->rectx; + rectzofs = (float *)(zspan->rectz + rectx * my2); + rectpofs = ((DrawBufPixel *)zspan->rectdraw) + rectx * my2; /* correct span */ - sn1= (my0 + my2)/2; + sn1 = (my0 + my2) / 2; if (zspan->span1[sn1] < zspan->span2[sn1]) { - span1= zspan->span1+my2; - span2= zspan->span2+my2; + span1 = zspan->span1 + my2; + span2 = zspan->span2 + my2; } else { - span1= zspan->span2+my2; - span2= zspan->span1+my2; + span1 = zspan->span2 + my2; + span2 = zspan->span1 + my2; } - for (y=my2; y>=my0; y--, span1--, span2--) { + for (y = my2; y >= my0; y--, span1--, span2--) { - sn1= floor(*span1); - sn2= floor(*span2); + sn1 = floor(*span1); + sn2 = floor(*span2); sn1++; - if (sn2>=rectx) sn2= rectx-1; - if (sn1<0) sn1= 0; + if (sn2 >= rectx) sn2 = rectx - 1; + if (sn1 < 0) sn1 = 0; - if (sn2>=sn1) { - zverg= (double)sn1*zxd + zy0; - rz= rectzofs+sn1; - rp= rectpofs+sn1; - x= sn2-sn1; + if (sn2 >= sn1) { + zverg = (double)sn1 * zxd + zy0; + rz = rectzofs + sn1; + rp = rectpofs + sn1; + x = sn2 - sn1; - while (x>=0) { + while (x >= 0) { if (zverg < (double)*rz) { - *rz= zverg; - *rp= *col; + *rz = zverg; + *rp = *col; } - zverg+= zxd; + zverg += zxd; rz++; rp++; x--; } } - zy0-=zyd; - rectzofs-= rectx; - rectpofs-= rectx; + zy0 -= zyd; + rectzofs -= rectx; + rectpofs -= rectx; } } @@ -377,43 +377,43 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) int a, x, y, step; /* 1: tag pixels to be candidate for AA */ - for (y=2; y<ysize; y++) { + for (y = 2; y < ysize; y++) { /* setup rows */ - row1= rectmove + (y-2)*xsize; - row2= row1 + xsize; - row3= row2 + xsize; - for (x=2; x<xsize; x++, row1++, row2++, row3++) { + row1 = rectmove + (y - 2) * xsize; + row2 = row1 + xsize; + row3 = row2 + xsize; + for (x = 2; x < xsize; x++, row1++, row2++, row3++) { if (row2[1]) { - if (row2[0]==0 || row2[2]==0 || row1[1]==0 || row3[1]==0) - row2[1]= 128; + if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0) + row2[1] = 128; } } } /* 2: evaluate horizontal scanlines and calculate alphas */ - row1= rectmove; - for (y=0; y<ysize; y++) { + row1 = rectmove; + for (y = 0; y < ysize; y++) { row1++; - for (x=1; x<xsize; x++, row1++) { - if (row1[0]==128 && row1[1]==128) { + for (x = 1; x < xsize; x++, row1++) { + if (row1[0] == 128 && row1[1] == 128) { /* find previous color and next color and amount of steps to blend */ - prev= row1[-1]; - step= 1; - while (x+step<xsize && row1[step]==128) + prev = row1[-1]; + step = 1; + while (x + step < xsize && row1[step] == 128) step++; - if (x+step!=xsize) { + if (x + step != xsize) { /* now we can blend values */ - next= row1[step]; + next = row1[step]; /* note, prev value can be next value, but we do this loop to clear 128 then */ - for (a=0; a<step; a++) { + for (a = 0; a < step; a++) { int fac, mfac; - fac= ((a+1)<<8)/(step+1); - mfac= 255-fac; + fac = ((a + 1) << 8) / (step + 1); + mfac = 255 - fac; - row1[a]= (prev*mfac + next*fac)>>8; + row1[a] = (prev * mfac + next * fac) >> 8; } } } @@ -422,28 +422,28 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) /* 3: evaluate vertical scanlines and calculate alphas */ /* use for reading a copy of the original tagged buffer */ - for (x=0; x<xsize; x++) { - row1= rectmove + x+xsize; + for (x = 0; x < xsize; x++) { + row1 = rectmove + x + xsize; - for (y=1; y<ysize; y++, row1+=xsize) { - if (row1[0]==128 && row1[xsize]==128) { + for (y = 1; y < ysize; y++, row1 += xsize) { + if (row1[0] == 128 && row1[xsize] == 128) { /* find previous color and next color and amount of steps to blend */ - prev= row1[-xsize]; - step= 1; - while (y+step<ysize && row1[step*xsize]==128) + prev = row1[-xsize]; + step = 1; + while (y + step < ysize && row1[step * xsize] == 128) step++; - if (y+step!=ysize) { + if (y + step != ysize) { /* now we can blend values */ - next= row1[step*xsize]; + next = row1[step * xsize]; /* note, prev value can be next value, but we do this loop to clear 128 then */ - for (a=0; a<step; a++) { + for (a = 0; a < step; a++) { int fac, mfac; - fac= ((a+1)<<8)/(step+1); - mfac= 255-fac; + fac = ((a + 1) << 8) / (step + 1); + mfac = 255 - fac; - row1[a*xsize]= (prev*mfac + next*fac)>>8; + row1[a * xsize] = (prev * mfac + next * fac) >> 8; } } } @@ -451,15 +451,15 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) } /* last: pixels with 0 we fill in zbuffer, with 1 we skip for mask */ - for (y=2; y<ysize; y++) { + for (y = 2; y < ysize; y++) { /* setup rows */ - row1= rectmove + (y-2)*xsize; - row2= row1 + xsize; - row3= row2 + xsize; - for (x=2; x<xsize; x++, row1++, row2++, row3++) { - if (row2[1]==0) { - if (row2[0]>1 || row2[2]>1 || row1[1]>1 || row3[1]>1) - row2[1]= 1; + row1 = rectmove + (y - 2) * xsize; + row2 = row1 + xsize; + row3 = row2 + xsize; + for (x = 2; x < xsize; x++, row1++, row2++, row3++) { + if (row2[1] == 0) { + if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1) + row2[1] = 1; } } } @@ -473,32 +473,32 @@ static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata) { float p1[2], p2[2], p3[2]; - p3[0]= -v2[0]; - p3[1]= -v2[1]; + p3[0] = -v2[0]; + p3[1] = -v2[1]; - p1[0]= v1[0]; - p1[1]= v1[1]; + p1[0] = v1[0]; + p1[1] = v1[1]; /* official formula 2*p2 - 0.5*p1 - 0.5*p3 */ - p2[0]= -0.5f*p1[0] - 0.5f*p3[0]; - p2[1]= -0.5f*p1[1] - 0.5f*p3[1]; + p2[0] = -0.5f * p1[0] - 0.5f * p3[0]; + p2[1] = -0.5f * p1[1] - 0.5f * p3[1]; - result[0]= ipodata[0]*p1[0] + ipodata[1]*p2[0] + ipodata[2]*p3[0]; - result[1]= ipodata[0]*p1[1] + ipodata[1]*p2[1] + ipodata[2]*p3[1]; + result[0] = ipodata[0] * p1[0] + ipodata[1] * p2[0] + ipodata[2] * p3[0]; + result[1] = ipodata[0] * p1[1] + ipodata[1] * p2[1] + ipodata[2] * p3[1]; } static void set_quad_bezier_ipo(float fac, float *data) { - float mfac= (1.0f-fac); + float mfac = (1.0f - fac); - data[0]= mfac*mfac; - data[1]= 2.0f*mfac*fac; - data[2]= fac*fac; + data[0] = mfac * mfac; + data[1] = 2.0f * mfac * fac; + data[2] = fac * fac; } void zbuf_accumulate_vecblur( - NodeBlurData *nbd, int xsize, int ysize, float *newrect, - const float *imgrect, float *vecbufrect, const float *zbufrect) + NodeBlurData *nbd, int xsize, int ysize, float *newrect, + const float *imgrect, float *vecbufrect, const float *zbufrect) { ZSpan zspan; DrawBufPixel *rectdraw, *dr; @@ -506,64 +506,64 @@ void zbuf_accumulate_vecblur( float v1[3], v2[3], v3[3], v4[3], fx, fy; const float *dimg, *dz, *ro; float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz; - float *minvecbufrect= NULL, *rectweight, *rw, *rectmax, *rm; - float maxspeedsq= (float)nbd->maxspeed*nbd->maxspeed; - int y, x, step, maxspeed=nbd->maxspeed, samples= nbd->samples; - int tsktsk= 0; - static int firsttime= 1; + float *minvecbufrect = NULL, *rectweight, *rw, *rectmax, *rm; + float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed; + int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples; + int tsktsk = 0; + static int firsttime = 1; char *rectmove, *dm; zbuf_alloc_span(&zspan, xsize, ysize, 1.0f); - zspan.zmulx= ((float)xsize)/2.0f; - zspan.zmuly= ((float)ysize)/2.0f; - zspan.zofsx= 0.0f; - zspan.zofsy= 0.0f; + zspan.zmulx = ((float)xsize) / 2.0f; + zspan.zmuly = ((float)ysize) / 2.0f; + zspan.zofsx = 0.0f; + zspan.zofsy = 0.0f; /* the buffers */ - rectz= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "zbuf accum"); - zspan.rectz= (int *)rectz; + rectz = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "zbuf accum"); + zspan.rectz = (int *)rectz; - rectmove= (char*)MEM_mapallocN(xsize*ysize, "rectmove"); - rectdraw= (DrawBufPixel*)MEM_mapallocN(sizeof(DrawBufPixel)*xsize*ysize, "rect draw"); - zspan.rectdraw= rectdraw; + rectmove = (char *)MEM_mapallocN(xsize * ysize, "rectmove"); + rectdraw = (DrawBufPixel *)MEM_mapallocN(sizeof(DrawBufPixel) * xsize * ysize, "rect draw"); + zspan.rectdraw = rectdraw; - rectweight= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "rect weight"); - rectmax= (float*)MEM_mapallocN(sizeof(float)*xsize*ysize, "rect max"); + rectweight = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect weight"); + rectmax = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect max"); /* debug... check if PASS_VECTOR_MAX still is in buffers */ - dvec1= vecbufrect; - for (x= 4*xsize*ysize; x>0; x--, dvec1++) { - if (dvec1[0]==PASS_VECTOR_MAX) { - dvec1[0]= 0.0f; - tsktsk= 1; + dvec1 = vecbufrect; + for (x = 4 * xsize * ysize; x > 0; x--, dvec1++) { + if (dvec1[0] == PASS_VECTOR_MAX) { + dvec1[0] = 0.0f; + tsktsk = 1; } } if (tsktsk) printf("Found uninitialized speed in vector buffer... fixed.\n"); /* min speed? then copy speedbuffer to recalculate speed vectors */ if (nbd->minspeed) { - float minspeed= (float)nbd->minspeed; - float minspeedsq= minspeed*minspeed; + float minspeed = (float)nbd->minspeed; + float minspeedsq = minspeed * minspeed; - minvecbufrect= (float*)MEM_mapallocN(4*sizeof(float)*xsize*ysize, "minspeed buf"); + minvecbufrect = (float *)MEM_mapallocN(4 * sizeof(float) * xsize * ysize, "minspeed buf"); - dvec1= vecbufrect; - dvec2= minvecbufrect; - for (x= 2*xsize*ysize; x>0; x--, dvec1+=2, dvec2+=2) { - if (dvec1[0]==0.0f && dvec1[1]==0.0f) { - dvec2[0]= dvec1[0]; - dvec2[1]= dvec1[1]; + dvec1 = vecbufrect; + dvec2 = minvecbufrect; + for (x = 2 * xsize * ysize; x > 0; x--, dvec1 += 2, dvec2 += 2) { + if (dvec1[0] == 0.0f && dvec1[1] == 0.0f) { + dvec2[0] = dvec1[0]; + dvec2[1] = dvec1[1]; } else { - float speedsq= dvec1[0]*dvec1[0] + dvec1[1]*dvec1[1]; + float speedsq = dvec1[0] * dvec1[0] + dvec1[1] * dvec1[1]; if (speedsq <= minspeedsq) { - dvec2[0]= 0.0f; - dvec2[1]= 0.0f; + dvec2[0] = 0.0f; + dvec2[1] = 0.0f; } else { speedsq = 1.0f - minspeed / sqrtf(speedsq); - dvec2[0]= speedsq*dvec1[0]; - dvec2[1]= speedsq*dvec1[1]; + dvec2[0] = speedsq * dvec1[0]; + dvec2[1] = speedsq * dvec1[1]; } } } @@ -571,75 +571,75 @@ void zbuf_accumulate_vecblur( } /* make vertex buffer with averaged speed and zvalues */ - rectvz= (float*)MEM_mapallocN(4*sizeof(float)*(xsize+1)*(ysize+1), "vertices"); - dvz= rectvz; - for (y=0; y<=ysize; y++) { + rectvz = (float *)MEM_mapallocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices"); + dvz = rectvz; + for (y = 0; y <= ysize; y++) { - if (y==0) - dvec1= vecbufrect + 4*y*xsize; + if (y == 0) + dvec1 = vecbufrect + 4 * y * xsize; else - dvec1= vecbufrect + 4*(y-1)*xsize; + dvec1 = vecbufrect + 4 * (y - 1) * xsize; - if (y==ysize) - dvec2= vecbufrect + 4*(y-1)*xsize; + if (y == ysize) + dvec2 = vecbufrect + 4 * (y - 1) * xsize; else - dvec2= vecbufrect + 4*y*xsize; + dvec2 = vecbufrect + 4 * y * xsize; - for (x=0; x<=xsize; x++) { + for (x = 0; x <= xsize; x++) { /* two vectors, so a step loop */ - for (step=0; step<2; step++, dvec1+=2, dvec2+=2, dvz+=2) { + for (step = 0; step < 2; step++, dvec1 += 2, dvec2 += 2, dvz += 2) { /* average on minimal speed */ - int div= 0; + int div = 0; - if (x!=0) { - if (dvec1[-4]!=0.0f || dvec1[-3]!=0.0f) { - dvz[0]= dvec1[-4]; - dvz[1]= dvec1[-3]; + if (x != 0) { + if (dvec1[-4] != 0.0f || dvec1[-3] != 0.0f) { + dvz[0] = dvec1[-4]; + dvz[1] = dvec1[-3]; div++; } - if (dvec2[-4]!=0.0f || dvec2[-3]!=0.0f) { - if (div==0) { - dvz[0]= dvec2[-4]; - dvz[1]= dvec2[-3]; + if (dvec2[-4] != 0.0f || dvec2[-3] != 0.0f) { + if (div == 0) { + dvz[0] = dvec2[-4]; + dvz[1] = dvec2[-3]; div++; } - else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { - dvz[0]= dvec2[-4]; - dvz[1]= dvec2[-3]; + else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3])) < (ABS(dvz[0]) + ABS(dvz[1])) ) { + dvz[0] = dvec2[-4]; + dvz[1] = dvec2[-3]; } } } - if (x!=xsize) { - if (dvec1[0]!=0.0f || dvec1[1]!=0.0f) { - if (div==0) { - dvz[0]= dvec1[0]; - dvz[1]= dvec1[1]; + if (x != xsize) { + if (dvec1[0] != 0.0f || dvec1[1] != 0.0f) { + if (div == 0) { + dvz[0] = dvec1[0]; + dvz[1] = dvec1[1]; div++; } - else if ( (ABS(dvec1[0]) + ABS(dvec1[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { - dvz[0]= dvec1[0]; - dvz[1]= dvec1[1]; + else if ( (ABS(dvec1[0]) + ABS(dvec1[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) { + dvz[0] = dvec1[0]; + dvz[1] = dvec1[1]; } } - if (dvec2[0]!=0.0f || dvec2[1]!=0.0f) { - if (div==0) { - dvz[0]= dvec2[0]; - dvz[1]= dvec2[1]; + if (dvec2[0] != 0.0f || dvec2[1] != 0.0f) { + if (div == 0) { + dvz[0] = dvec2[0]; + dvz[1] = dvec2[1]; } - else if ( (ABS(dvec2[0]) + ABS(dvec2[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { - dvz[0]= dvec2[0]; - dvz[1]= dvec2[1]; + else if ( (ABS(dvec2[0]) + ABS(dvec2[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) { + dvz[0] = dvec2[0]; + dvz[1] = dvec2[1]; } } } if (maxspeed) { - float speedsq= dvz[0]*dvz[0] + dvz[1]*dvz[1]; + float speedsq = dvz[0] * dvz[0] + dvz[1] * dvz[1]; if (speedsq > maxspeedsq) { speedsq = (float)maxspeed / sqrtf(speedsq); - dvz[0]*= speedsq; - dvz[1]*= speedsq; + dvz[0] *= speedsq; + dvz[1] *= speedsq; } } } @@ -647,117 +647,117 @@ void zbuf_accumulate_vecblur( } /* set border speeds to keep border speeds on border */ - dz1= rectvz; - dz2= rectvz+4*(ysize)*(xsize+1); - for (x=0; x<=xsize; x++, dz1+=4, dz2+=4) { - dz1[1]= 0.0f; - dz2[1]= 0.0f; - dz1[3]= 0.0f; - dz2[3]= 0.0f; + dz1 = rectvz; + dz2 = rectvz + 4 * (ysize) * (xsize + 1); + for (x = 0; x <= xsize; x++, dz1 += 4, dz2 += 4) { + dz1[1] = 0.0f; + dz2[1] = 0.0f; + dz1[3] = 0.0f; + dz2[3] = 0.0f; } - dz1= rectvz; - dz2= rectvz+4*(xsize); - for (y=0; y<=ysize; y++, dz1+=4*(xsize+1), dz2+=4*(xsize+1)) { - dz1[0]= 0.0f; - dz2[0]= 0.0f; - dz1[2]= 0.0f; - dz2[2]= 0.0f; + dz1 = rectvz; + dz2 = rectvz + 4 * (xsize); + for (y = 0; y <= ysize; y++, dz1 += 4 * (xsize + 1), dz2 += 4 * (xsize + 1)) { + dz1[0] = 0.0f; + dz2[0] = 0.0f; + dz1[2] = 0.0f; + dz2[2] = 0.0f; } /* tag moving pixels, only these faces we draw */ - dm= rectmove; - dvec1= vecbufrect; - for (x=xsize*ysize; x>0; x--, dm++, dvec1+=4) { - if ((dvec1[0]!=0.0f || dvec1[1]!=0.0f || dvec1[2]!=0.0f || dvec1[3]!=0.0f)) - *dm= 255; + dm = rectmove; + dvec1 = vecbufrect; + for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) { + if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f)) + *dm = 255; } antialias_tagbuf(xsize, ysize, rectmove); /* has to become static, the init-jit calls a random-seed, screwing up texture noise node */ if (firsttime) { - firsttime= 0; + firsttime = 0; BLI_jitter_init(jit, 256); } - memset(newrect, 0, sizeof(float)*xsize*ysize*4); + memset(newrect, 0, sizeof(float) * xsize * ysize * 4); /* accumulate */ - samples/= 2; - for (step= 1; step<=samples; step++) { - float speedfac= 0.5f*nbd->fac*(float)step/(float)(samples+1); + samples /= 2; + for (step = 1; step <= samples; step++) { + float speedfac = 0.5f * nbd->fac * (float)step / (float)(samples + 1); int side; - for (side=0; side<2; side++) { + for (side = 0; side < 2; side++) { float blendfac, ipodata[4]; /* clear zbuf, if we draw future we fill in not moving pixels */ if (0) - for (x= xsize*ysize-1; x>=0; x--) rectz[x]= 10e16; + for (x = xsize * ysize - 1; x >= 0; x--) rectz[x] = 10e16; else - for (x= xsize*ysize-1; x>=0; x--) { - if (rectmove[x]==0) - rectz[x]= zbufrect[x]; + for (x = xsize * ysize - 1; x >= 0; x--) { + if (rectmove[x] == 0) + rectz[x] = zbufrect[x]; else - rectz[x]= 10e16; + rectz[x] = 10e16; } /* clear drawing buffer */ - for (x= xsize*ysize-1; x>=0; x--) rectdraw[x].colpoin= NULL; + for (x = xsize * ysize - 1; x >= 0; x--) rectdraw[x].colpoin = NULL; - dimg= imgrect; - dm= rectmove; - dz= zbufrect; - dz1= rectvz; - dz2= rectvz + 4*(xsize + 1); + dimg = imgrect; + dm = rectmove; + dz = zbufrect; + dz1 = rectvz; + dz2 = rectvz + 4 * (xsize + 1); if (side) { - if (nbd->curved==0) { - dz1+= 2; - dz2+= 2; + if (nbd->curved == 0) { + dz1 += 2; + dz2 += 2; } - speedfac= -speedfac; + speedfac = -speedfac; } - set_quad_bezier_ipo(0.5f + 0.5f*speedfac, ipodata); + set_quad_bezier_ipo(0.5f + 0.5f * speedfac, ipodata); - for (fy= -0.5f+jit[step & 255][0], y=0; y<ysize; y++, fy+=1.0f) { - for (fx= -0.5f+jit[step & 255][1], x=0; x<xsize; x++, fx+=1.0f, dimg+=4, dz1+=4, dz2+=4, dm++, dz++) { - if (*dm>1) { + for (fy = -0.5f + jit[step & 255][0], y = 0; y < ysize; y++, fy += 1.0f) { + for (fx = -0.5f + jit[step & 255][1], x = 0; x < xsize; x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) { + if (*dm > 1) { float jfx = fx + 0.5f; float jfy = fy + 0.5f; DrawBufPixel col; /* make vertices */ - if (nbd->curved) { /* curved */ - quad_bezier_2d(v1, dz1, dz1+2, ipodata); - v1[0]+= jfx; v1[1]+= jfy; v1[2]= *dz; + if (nbd->curved) { /* curved */ + quad_bezier_2d(v1, dz1, dz1 + 2, ipodata); + v1[0] += jfx; v1[1] += jfy; v1[2] = *dz; - quad_bezier_2d(v2, dz1+4, dz1+4+2, ipodata); - v2[0]+= jfx+1.0f; v2[1]+= jfy; v2[2]= *dz; + quad_bezier_2d(v2, dz1 + 4, dz1 + 4 + 2, ipodata); + v2[0] += jfx + 1.0f; v2[1] += jfy; v2[2] = *dz; - quad_bezier_2d(v3, dz2+4, dz2+4+2, ipodata); - v3[0]+= jfx+1.0f; v3[1]+= jfy+1.0f; v3[2]= *dz; + quad_bezier_2d(v3, dz2 + 4, dz2 + 4 + 2, ipodata); + v3[0] += jfx + 1.0f; v3[1] += jfy + 1.0f; v3[2] = *dz; - quad_bezier_2d(v4, dz2, dz2+2, ipodata); - v4[0]+= jfx; v4[1]+= jfy+1.0f; v4[2]= *dz; + quad_bezier_2d(v4, dz2, dz2 + 2, ipodata); + v4[0] += jfx; v4[1] += jfy + 1.0f; v4[2] = *dz; } else { - v1[0]= speedfac*dz1[0]+jfx; v1[1]= speedfac*dz1[1]+jfy; v1[2]= *dz; - v2[0]= speedfac*dz1[4]+jfx+1.0f; v2[1]= speedfac*dz1[5]+jfy; v2[2]= *dz; - v3[0]= speedfac*dz2[4]+jfx+1.0f; v3[1]= speedfac*dz2[5]+jfy+1.0f; v3[2]= *dz; - v4[0]= speedfac*dz2[0]+jfx; v4[1]= speedfac*dz2[1]+jfy+1.0f; v4[2]= *dz; + ARRAY_SET_ITEMS(v1, speedfac * dz1[0] + jfx, speedfac * dz1[1] + jfy, *dz); + ARRAY_SET_ITEMS(v2, speedfac * dz1[4] + jfx + 1.0f, speedfac * dz1[5] + jfy, *dz); + ARRAY_SET_ITEMS(v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz); + ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz); } - if (*dm==255) col.alpha= 1.0f; - else if (*dm<2) col.alpha= 0.0f; - else col.alpha= ((float)*dm)/255.0f; - col.colpoin= dimg; + if (*dm == 255) col.alpha = 1.0f; + else if (*dm < 2) col.alpha = 0.0f; + else col.alpha = ((float)*dm) / 255.0f; + col.colpoin = dimg; zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4); } } - dz1+=4; - dz2+=4; + dz1 += 4; + dz2 += 4; } /* blend with a falloff. this fixes the ugly effect you get with @@ -767,43 +767,43 @@ void zbuf_accumulate_vecblur( * we don't know what is behind it so we don't do that. this hack * overestimates the contribution of foreground pixels but looks a * bit better without a sudden cutoff. */ - blendfac= ((samples - step)/(float)samples); + blendfac = ((samples - step) / (float)samples); /* smoothstep to make it look a bit nicer as well */ - blendfac= 3.0f*pow(blendfac, 2.0f) - 2.0f*pow(blendfac, 3.0f); + blendfac = 3.0f * pow(blendfac, 2.0f) - 2.0f * pow(blendfac, 3.0f); /* accum */ - rw= rectweight; - rm= rectmax; - for (dr= rectdraw, dz2=newrect, x= xsize*ysize-1; x>=0; x--, dr++, dz2+=4, rw++, rm++) { + rw = rectweight; + rm = rectmax; + for (dr = rectdraw, dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dr++, dz2 += 4, rw++, rm++) { if (dr->colpoin) { - float bfac= dr->alpha*blendfac; + float bfac = dr->alpha * blendfac; - dz2[0] += bfac*dr->colpoin[0]; - dz2[1] += bfac*dr->colpoin[1]; - dz2[2] += bfac*dr->colpoin[2]; - dz2[3] += bfac*dr->colpoin[3]; + dz2[0] += bfac * dr->colpoin[0]; + dz2[1] += bfac * dr->colpoin[1]; + dz2[2] += bfac * dr->colpoin[2]; + dz2[3] += bfac * dr->colpoin[3]; *rw += bfac; - *rm= MAX2(*rm, bfac); + *rm = MAX2(*rm, bfac); } } } } /* blend between original images and accumulated image */ - rw= rectweight; - rm= rectmax; - ro= imgrect; - dm= rectmove; - for (dz2=newrect, x= xsize*ysize-1; x>=0; x--, dz2+=4, ro+=4, rw++, rm++, dm++) { + rw = rectweight; + rm = rectmax; + ro = imgrect; + dm = rectmove; + for (dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dz2 += 4, ro += 4, rw++, rm++, dm++) { float mfac = *rm; - float fac = (*rw == 0.0f)? 0.0f: mfac/(*rw); + float fac = (*rw == 0.0f) ? 0.0f : mfac / (*rw); float nfac = 1.0f - mfac; - dz2[0]= fac*dz2[0] + nfac*ro[0]; - dz2[1]= fac*dz2[1] + nfac*ro[1]; - dz2[2]= fac*dz2[2] + nfac*ro[2]; - dz2[3]= fac*dz2[3] + nfac*ro[3]; + dz2[0] = fac * dz2[0] + nfac * ro[0]; + dz2[1] = fac * dz2[1] + nfac * ro[1]; + dz2[2] = fac * dz2[2] + nfac * ro[2]; + dz2[3] = fac * dz2[3] + nfac * ro[3]; } MEM_freeN(rectz); diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 3e09cdd9768..f96f496a0f9 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -183,7 +183,6 @@ data_to_c_simple(engines/eevee/shaders/lightprobe_planar_downsample_vert.glsl SR data_to_c_simple(engines/eevee/shaders/prepass_frag.glsl SRC) data_to_c_simple(engines/eevee/shaders/prepass_vert.glsl SRC) data_to_c_simple(engines/eevee/shaders/shadow_frag.glsl SRC) -data_to_c_simple(engines/eevee/shaders/shadow_geom.glsl SRC) data_to_c_simple(engines/eevee/shaders/shadow_vert.glsl SRC) data_to_c_simple(engines/eevee/shaders/shadow_store_frag.glsl SRC) data_to_c_simple(engines/eevee/shaders/shadow_copy_frag.glsl SRC) diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index 7496142a26e..86c9b9c850b 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -44,7 +44,6 @@ static struct { } e_data = {NULL}; /* Engine data */ extern char datatoc_shadow_vert_glsl[]; -extern char datatoc_shadow_geom_glsl[]; extern char datatoc_shadow_frag_glsl[]; extern char datatoc_shadow_store_frag_glsl[]; extern char datatoc_shadow_copy_frag_glsl[]; @@ -106,7 +105,7 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata) if (!e_data.shadow_sh) { e_data.shadow_sh = DRW_shader_create( - datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, datatoc_shadow_frag_glsl, NULL); + datatoc_shadow_vert_glsl, NULL, datatoc_shadow_frag_glsl, NULL); } if (!sldata->lamps) { @@ -287,8 +286,7 @@ void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; psl->shadow_pass = DRW_pass_create("Shadow Pass", state); - DRWShadingGroup *grp = stl->g_data->shadow_shgrp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass); - DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo); + stl->g_data->shadow_shgrp = DRW_shgroup_create(e_data.shadow_sh, psl->shadow_pass); } } @@ -387,30 +385,26 @@ void EEVEE_lights_cache_add(EEVEE_ViewLayerData *sldata, Object *ob) /* Add a shadow caster to the shadowpasses */ void EEVEE_lights_cache_shcaster_add( - EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob) + EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl, struct Gwn_Batch *geom, Object *ob) { - DRW_shgroup_call_object_instances_add( + DRW_shgroup_call_object_add( stl->g_data->shadow_shgrp, - geom, ob, - &sldata->lamps->shadow_instance_count); + geom, ob); } void EEVEE_lights_cache_shcaster_material_add( - EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, struct GPUMaterial *gpumat, - struct Gwn_Batch *geom, struct Object *ob, float (*obmat)[4], float *alpha_threshold) + EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_PassList *psl, struct GPUMaterial *gpumat, + struct Gwn_Batch *geom, struct Object *ob, float *alpha_threshold) { /* TODO / PERF : reuse the same shading group for objects with the same material */ DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, psl->shadow_pass); if (grp == NULL) return; - DRW_shgroup_uniform_block(grp, "shadow_render_block", sldata->shadow_render_ubo); - DRW_shgroup_uniform_mat4(grp, "ShadowModelMatrix", (float *)obmat); - if (alpha_threshold != NULL) DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1); - DRW_shgroup_call_object_instances_add(grp, geom, ob, &sldata->lamps->shadow_instance_count); + DRW_shgroup_call_object_add(grp, geom, ob); } /* Make that object update shadow casting lamps inside its influence bounding box. */ @@ -719,7 +713,6 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE } /* Lamps Matrices */ - float (*viewmat)[4], projmat[4][4]; int sh_nbr = 1; /* TODO : MSM */ int cascade_nbr = la->cascade_count; @@ -730,10 +723,10 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE /* obmat = Object Space > World Space */ /* viewmat = World Space > View Space */ - invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_VIEW], ob->obmat); - viewmat = sh_data->clipmat.mat[DRW_MAT_VIEW]; + float (*viewmat)[4] = sh_data->viewmat; + invert_m4_m4(viewmat, ob->obmat); normalize_m4(viewmat); - invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_VIEWINV], viewmat); + invert_m4_m4(sh_data->viewinv, viewmat); /* The technique consists into splitting * the view frustum into several sub-frustum @@ -833,8 +826,8 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE cascade_data->split_start[0] = LERP(la->cascade_fade, cascade_data->split_end[cascade_nbr - 1], prev_split); /* For each cascade */ - rctf rect_clip, rect_cascade; for (int c = 0; c < cascade_nbr; ++c) { + float (*projmat)[4] = sh_data->projmat[c]; /* Given 8 frustum corners */ float corners[8][3] = { /* Near Cap */ @@ -877,32 +870,17 @@ static void eevee_shadow_cascade_setup(Object *ob, EEVEE_LampsInfo *linfo, EEVEE add_v2_v2(center, shadow_texco); /* Expand the projection to cover frustum range */ + rctf rect_cascade; BLI_rctf_init_pt_radius(&rect_cascade, center, sh_data->radius[c]); orthographic_m4(projmat, rect_cascade.xmin, rect_cascade.xmax, rect_cascade.ymin, rect_cascade.ymax, la->clipsta, la->clipend); - if (c == 0) { - memcpy(&rect_clip, &rect_cascade, sizeof(rect_clip)); - } - else { - BLI_rctf_union(&rect_clip, &rect_cascade); - } - mul_m4_m4m4(sh_data->viewprojmat[c], projmat, viewmat); mul_m4_m4m4(cascade_data->shadowmat[c], texcomat, sh_data->viewprojmat[c]); } - /* Clipping mats */ - orthographic_m4(sh_data->clipmat.mat[DRW_MAT_WIN], - rect_clip.xmin, rect_clip.xmax, - rect_clip.ymin, rect_clip.ymax, - la->clipsta, la->clipend); - mul_m4_m4m4(sh_data->clipmat.mat[DRW_MAT_PERS], sh_data->clipmat.mat[DRW_MAT_WIN], viewmat); - invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_WININV], sh_data->clipmat.mat[DRW_MAT_WIN]); - invert_m4_m4(sh_data->clipmat.mat[DRW_MAT_PERSINV], sh_data->clipmat.mat[DRW_MAT_PERS]); - ubo_data->bias = 0.05f * la->bias; ubo_data->near = la->clipsta; ubo_data->far = la->clipend; @@ -1004,37 +982,6 @@ void EEVEE_lights_update(EEVEE_ViewLayerData *sldata) } } -static void eevee_shadows_cube_culling_frustum(EEVEE_ShadowRender *srd) -{ - float persmat[4][4], persinv[4][4]; - float viewmat[4][4], viewinv[4][4]; - float winmat[4][4], wininv[4][4]; - orthographic_m4(winmat, -srd->clip_far, srd->clip_far, -srd->clip_far, srd->clip_far, -srd->clip_far, srd->clip_far); - DRW_viewport_matrix_override_set(winmat, DRW_MAT_WIN); - - invert_m4_m4(wininv, winmat); - DRW_viewport_matrix_override_set(wininv, DRW_MAT_WININV); - - unit_m4(viewmat); - negate_v3_v3(viewmat[3], srd->position); - DRW_viewport_matrix_override_set(viewmat, DRW_MAT_VIEW); - - unit_m4(viewinv); - copy_v3_v3(viewinv[3], srd->position); - DRW_viewport_matrix_override_set(viewinv, DRW_MAT_VIEWINV); - - mul_m4_m4m4(persmat, winmat, viewmat); - DRW_viewport_matrix_override_set(persmat, DRW_MAT_PERS); - - invert_m4_m4(persinv, persmat); - DRW_viewport_matrix_override_set(persinv, DRW_MAT_PERSINV); -} - -static void eevee_shadows_cascade_culling_frustum(EEVEE_ShadowCascadeData *evscd) -{ - DRW_viewport_matrix_override_set_all(&evscd->clipmat); -} - /* this refresh lamps shadow buffers */ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) { @@ -1058,32 +1005,45 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) continue; } + DRWMatrixState render_mats; + float (*winmat)[4] = render_mats.mat[DRW_MAT_WIN]; + float (*viewmat)[4] = render_mats.mat[DRW_MAT_VIEW]; + float (*persmat)[4] = render_mats.mat[DRW_MAT_PERS]; + EEVEE_ShadowRender *srd = &linfo->shadow_render_data; EEVEE_ShadowCubeData *evscd = &led->data.scd; - float cube_projmat[4][4]; - float cube_viewmat[4][4]; - perspective_m4(cube_projmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend); - unit_m4(cube_viewmat); + perspective_m4(winmat, -la->clipsta, la->clipsta, -la->clipsta, la->clipsta, la->clipsta, la->clipend); srd->clip_near = la->clipsta; srd->clip_far = la->clipend; copy_v3_v3(srd->position, ob->obmat[3]); - negate_v3_v3(cube_viewmat[3], srd->position); - for (int j = 0; j < 6; j++) { - mul_m4_m4m4(srd->viewmat[j], cubefacemat[j], cube_viewmat); - mul_m4_m4m4(srd->shadowmat[j], cube_projmat, srd->viewmat[j]); - } DRW_uniformbuffer_update(sldata->shadow_render_ubo, srd); - eevee_shadows_cube_culling_frustum(srd); - /* Render shadow cube */ - linfo->shadow_instance_count = 6; - GPU_framebuffer_bind(sldata->shadow_cube_target_fb); - GPU_framebuffer_clear_depth(sldata->shadow_cube_target_fb, 1.0f); - DRW_draw_pass(psl->shadow_pass); + /* Render 6 faces separatly: seems to be faster for the general case. + * The only time it's more beneficial is when the CPU culling overhead + * outweight the instancing overhead. which is rarelly the case. */ + for (int j = 0; j < 6; j++) { + /* TODO optimize */ + float tmp[4][4]; + unit_m4(tmp); + negate_v3_v3(tmp[3], srd->position); + mul_m4_m4m4(viewmat, cubefacemat[j], tmp); + mul_m4_m4m4(persmat, winmat, viewmat); + invert_m4_m4(render_mats.mat[DRW_MAT_WININV], winmat); + invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat); + invert_m4_m4(render_mats.mat[DRW_MAT_PERSINV], persmat); + + DRW_viewport_matrix_override_set_all(&render_mats); + + GPU_framebuffer_texture_cubeface_attach(sldata->shadow_cube_target_fb, + sldata->shadow_cube_target, 0, j, 0); + GPU_framebuffer_bind(sldata->shadow_cube_target_fb); + GPU_framebuffer_clear_depth(sldata->shadow_cube_target_fb, 1.0f); + DRW_draw_pass(psl->shadow_pass); + } /* 0.001f is arbitrary, but it should be relatively small so that filter size is not too big. */ float filter_texture_size = la->soft * 0.001f; @@ -1143,22 +1103,39 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl) EEVEE_ShadowCascadeData *evscd = &led->data.scad; EEVEE_ShadowRender *srd = &linfo->shadow_render_data; + DRWMatrixState render_mats; + float (*winmat)[4] = render_mats.mat[DRW_MAT_WIN]; + float (*viewmat)[4] = render_mats.mat[DRW_MAT_VIEW]; + float (*persmat)[4] = render_mats.mat[DRW_MAT_PERS]; + eevee_shadow_cascade_setup(ob, linfo, led); srd->clip_near = la->clipsta; srd->clip_far = la->clipend; - for (int j = 0; j < la->cascade_count; ++j) { - copy_m4_m4(srd->shadowmat[j], evscd->viewprojmat[j]); - } + DRW_uniformbuffer_update(sldata->shadow_render_ubo, &linfo->shadow_render_data); - eevee_shadows_cascade_culling_frustum(evscd); + copy_m4_m4(viewmat, evscd->viewmat); + invert_m4_m4(render_mats.mat[DRW_MAT_VIEWINV], viewmat); /* Render shadow cascades */ - linfo->shadow_instance_count = la->cascade_count; - GPU_framebuffer_bind(sldata->shadow_cascade_target_fb); - GPU_framebuffer_clear_depth(sldata->shadow_cascade_target_fb, 1.0); - DRW_draw_pass(psl->shadow_pass); + /* Render cascade separatly: seems to be faster for the general case. + * The only time it's more beneficial is when the CPU culling overhead + * outweight the instancing overhead. which is rarelly the case. */ + for (int j = 0; j < la->cascade_count; j++) { + copy_m4_m4(winmat, evscd->projmat[j]); + copy_m4_m4(persmat, evscd->viewprojmat[j]); + invert_m4_m4(render_mats.mat[DRW_MAT_WININV], winmat); + invert_m4_m4(render_mats.mat[DRW_MAT_PERSINV], persmat); + + DRW_viewport_matrix_override_set_all(&render_mats); + + GPU_framebuffer_texture_layer_attach(sldata->shadow_cascade_target_fb, + sldata->shadow_cascade_target, 0, j, 0); + GPU_framebuffer_bind(sldata->shadow_cascade_target_fb); + GPU_framebuffer_clear_depth(sldata->shadow_cascade_target_fb, 1.0f); + DRW_draw_pass(psl->shadow_pass); + } /* TODO: OPTI: Filter all cascade in one/two draw call */ for (linfo->current_shadow_cascade = 0; diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index fc4439a253c..e64b8c4282f 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -47,7 +47,6 @@ /* *********** STATIC *********** */ static struct { - char *shadow_shader_lib; char *frag_shader_lib; char *volume_shader_lib; @@ -90,7 +89,6 @@ extern char datatoc_lit_surface_vert_glsl[]; extern char datatoc_raytrace_lib_glsl[]; extern char datatoc_ssr_lib_glsl[]; extern char datatoc_shadow_vert_glsl[]; -extern char datatoc_shadow_geom_glsl[]; extern char datatoc_lightprobe_geom_glsl[]; extern char datatoc_lightprobe_vert_glsl[]; extern char datatoc_background_vert_glsl[]; @@ -532,7 +530,8 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E char *frag_str = NULL; /* Shaders */ - e_data.shadow_shader_lib = BLI_string_joinN( + e_data.frag_shader_lib = BLI_string_joinN( + datatoc_common_view_lib_glsl, datatoc_common_uniforms_lib_glsl, datatoc_bsdf_common_lib_glsl, datatoc_bsdf_sampling_lib_glsl, @@ -556,10 +555,6 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, E datatoc_lit_surface_frag_glsl, datatoc_volumetric_lib_glsl); - e_data.frag_shader_lib = BLI_string_joinN( - datatoc_common_view_lib_glsl, - e_data.shadow_shader_lib); - e_data.volume_shader_lib = BLI_string_joinN( datatoc_common_view_lib_glsl, datatoc_common_uniforms_lib_glsl, @@ -762,13 +757,13 @@ struct GPUMaterial *EEVEE_material_mesh_depth_get( char *defines = eevee_get_defines(options); char *frag_str = BLI_string_joinN( - (is_shadow) ? e_data.shadow_shader_lib : e_data.frag_shader_lib, + e_data.frag_shader_lib, datatoc_prepass_frag_glsl); mat = DRW_shader_create_from_material( scene, ma, engine, options, (is_shadow) ? datatoc_shadow_vert_glsl : datatoc_lit_surface_vert_glsl, - (is_shadow) ? datatoc_shadow_geom_glsl : NULL, + NULL, frag_str, defines); @@ -1412,11 +1407,11 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld break; case MA_BS_CLIP: gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true); - EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, &ma->alpha_threshold); + EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold); break; case MA_BS_HASHED: gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true); - EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, ob->obmat, NULL); + EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, NULL); break; case MA_BS_NONE: default: @@ -1530,7 +1525,7 @@ void EEVEE_materials_free(void) for (int i = 0; i < VAR_MAT_MAX; ++i) { DRW_SHADER_FREE_SAFE(e_data.default_lit[i]); } - MEM_SAFE_FREE(e_data.shadow_shader_lib); + MEM_SAFE_FREE(e_data.frag_shader_lib); MEM_SAFE_FREE(e_data.frag_shader_lib); MEM_SAFE_FREE(e_data.volume_shader_lib); DRW_SHADER_FREE_SAFE(e_data.default_prepass_sh); diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index bf77914832e..f0ba458dcc8 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -312,8 +312,6 @@ typedef struct EEVEE_ShadowCascade { } EEVEE_ShadowCascade; typedef struct EEVEE_ShadowRender { - float shadowmat[6][4][4]; /* World->Lamp->NDC : used to render the shadow map. 6 frustum for cubemap shadow */ - float viewmat[6][4][4]; /* World->Lamp : used to render the shadow map. 6 viewmat for cubemap shadow */ float position[3], pad; float cube_texel_size; float stored_texel_size; @@ -675,7 +673,8 @@ typedef struct EEVEE_ShadowCubeData { typedef struct EEVEE_ShadowCascadeData { short light_id, shadow_id, cascade_id, layer_id; float viewprojmat[MAX_CASCADE_NUM][4][4]; /* World->Lamp->NDC : used for rendering the shadow map. */ - DRWMatrixState clipmat; /* Override matrices used for clipping. */ + float projmat[MAX_CASCADE_NUM][4][4]; + float viewmat[4][4], viewinv[4][4]; float radius[MAX_CASCADE_NUM]; } EEVEE_ShadowCascadeData; @@ -806,7 +805,7 @@ void EEVEE_lights_cache_shcaster_add( void EEVEE_lights_cache_shcaster_material_add( EEVEE_ViewLayerData *sldata, EEVEE_PassList *psl, struct GPUMaterial *gpumat, struct Gwn_Batch *geom, struct Object *ob, - float (*obmat)[4], float *alpha_threshold); + float *alpha_threshold); void EEVEE_lights_cache_shcaster_object_add(EEVEE_ViewLayerData *sldata, struct Object *ob); void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata); void EEVEE_lights_update(EEVEE_ViewLayerData *sldata); diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index 77c873c1503..b5e54c8747a 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -8,37 +8,6 @@ #define LUT_SIZE 64 -#ifdef SHADOW_SHADER -layout(std140) uniform shadow_render_block { - mat4 ShadowMatrix[6]; - mat4 FaceViewMatrix[6]; - vec4 lampPosition; - float cubeTexelSize; - float storedTexelSize; - float nearClip; - float farClip; - int shadowSampleCount; - float shadowInvSampleCount; -}; - -flat in int shFace; /* Shadow layer we are rendering to. */ - -/* Replacing viewBlock */ -#define ViewMatrix FaceViewMatrix[shFace] -#define ViewProjectionMatrix ShadowMatrix[shFace] -/* TODO optimize */ -#define ProjectionMatrix \ -mat4(vec4(1.0, 0.0, 0.0, 0.0), \ - vec4(0.0, 1.0, 0.0, 0.0), \ - vec4(0.0, 0.0, -(farClip + nearClip) / (farClip - nearClip), -1.0), \ - vec4(0.0, 0.0, (-2.0 * farClip * nearClip) / (farClip - nearClip), 0.0)) - -#define ViewMatrixInverse inverse(ViewMatrix) -#define ViewProjectionMatrixInverse inverse(ViewProjectionMatrix) -#define ProjectionMatrixInverse inverse(ProjectionMatrix) -#define CameraTexCoFactors vec4(1.0f, 1.0f, 0.0f, 0.0f) -#endif - /* Buffers */ uniform sampler2D colorBuffer; uniform sampler2D depthBuffer; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl index 67b0fc2bdfc..4ae22b480f1 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_copy_frag.glsl @@ -2,8 +2,6 @@ * to linear depth (or other storage method) and doing a 3x3 box filter. */ layout(std140) uniform shadow_render_block { - mat4 ShadowMatrix[6]; - mat4 FaceViewMatrix[6]; vec4 lampPosition; float cubeTexelSize; float storedTexelSize; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl b/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl deleted file mode 100644 index ea51fa73a65..00000000000 --- a/source/blender/draw/engines/eevee/shaders/shadow_geom.glsl +++ /dev/null @@ -1,53 +0,0 @@ - -layout(std140) uniform shadow_render_block { - mat4 ShadowMatrix[6]; - mat4 FaceViewMatrix[6]; - vec4 lampPosition; - float cubeTexelSize; - float storedTexelSize; - float nearClip; - float farClip; - int shadowSampleCount; - float shadowInvSampleCount; -}; - -layout(triangles) in; -layout(triangle_strip, max_vertices=3) out; - -in vec4 vPos[]; -flat in int face[]; - -#ifdef MESH_SHADER -in vec3 vNor[]; -#endif - -out vec3 worldPosition; -#ifdef MESH_SHADER -out vec3 viewPosition; /* Required. otherwise generate linking error. */ -out vec3 worldNormal; /* Required. otherwise generate linking error. */ -out vec3 viewNormal; /* Required. otherwise generate linking error. */ -flat out int shFace; -#else -int shFace; -#endif - -void main() { - shFace = face[0]; - gl_Layer = shFace; - - for (int v = 0; v < 3; ++v) { - gl_Position = ShadowMatrix[shFace] * vPos[v]; - worldPosition = vPos[v].xyz; -#ifdef MESH_SHADER - worldNormal = vNor[v]; - viewPosition = (FaceViewMatrix[shFace] * vec4(worldPosition, 1.0)).xyz; - viewNormal = (FaceViewMatrix[shFace] * vec4(worldNormal, 0.0)).xyz; -#ifdef ATTRIB - pass_attrib(v); -#endif -#endif - EmitVertex(); - } - - EndPrimitive(); -}
\ No newline at end of file diff --git a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl index 0fc7e4c9396..b40155be454 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_store_frag.glsl @@ -1,7 +1,5 @@ layout(std140) uniform shadow_render_block { - mat4 ShadowMatrix[6]; - mat4 FaceViewMatrix[6]; vec4 lampPosition; float cubeTexelSize; float storedTexelSize; diff --git a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl index 29cbcfdd6e4..9fa57b8e136 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_vert.glsl @@ -1,29 +1,33 @@ -uniform mat4 ModelMatrix; +uniform mat4 ModelViewProjectionMatrix; #ifdef MESH_SHADER +uniform mat4 ModelMatrix; +uniform mat4 ModelViewMatrix; uniform mat3 WorldNormalMatrix; +# ifndef ATTRIB +uniform mat3 NormalMatrix; +# endif #endif in vec3 pos; -#ifdef MESH_SHADER in vec3 nor; -#endif -out vec4 vPos; #ifdef MESH_SHADER -out vec3 vNor; +out vec3 worldPosition; +out vec3 viewPosition; +out vec3 worldNormal; +out vec3 viewNormal; #endif -flat out int face; - void main() { - vPos = ModelMatrix * vec4(pos, 1.0); - face = gl_InstanceID; - + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); #ifdef MESH_SHADER - vNor = WorldNormalMatrix * nor; + viewPosition = (ModelViewMatrix * vec4(pos, 1.0)).xyz; + worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz; + viewNormal = normalize(NormalMatrix * nor); + worldNormal = normalize(WorldNormalMatrix * nor); #ifdef ATTRIB pass_attrib(pos); #endif #endif -} +}
\ No newline at end of file diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 60e855108f9..66ca8971a46 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -404,7 +404,7 @@ typedef struct DRWMatrixState { void DRW_viewport_init(const bContext *C); void DRW_viewport_matrix_get(float mat[4][4], DRWViewportMatrixType type); void DRW_viewport_matrix_get_all(DRWMatrixState *state); -void DRW_viewport_matrix_override_set(float mat[4][4], DRWViewportMatrixType type); +void DRW_viewport_matrix_override_set(const float mat[4][4], DRWViewportMatrixType type); void DRW_viewport_matrix_override_set_all(DRWMatrixState *state); void DRW_viewport_matrix_override_unset(DRWViewportMatrixType type); void DRW_viewport_matrix_override_unset_all(void); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index f9968fdc16c..b8ed341e2c5 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -518,7 +518,7 @@ void DRW_viewport_matrix_get_all(DRWMatrixState *state) memcpy(state, DST.view_data.matstate.mat, sizeof(DRWMatrixState)); } -void DRW_viewport_matrix_override_set(float mat[4][4], DRWViewportMatrixType type) +void DRW_viewport_matrix_override_set(const float mat[4][4], DRWViewportMatrixType type) { BLI_assert(type < DRW_MAT_COUNT); copy_m4_m4(DST.view_data.matstate.mat[type], mat); diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index e69a1026815..6021863c690 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -390,7 +390,8 @@ void DRW_state_clip_planes_reset(void) * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f}); * for (int i = 0; i < 8; i++) {mul_project_m4_v3(viewprojinv, bbox.vec[i]);} */ -static void draw_frustum_boundbox_calc(const float (*projmat)[4], const float (*viewinv)[4], BoundBox *r_bbox) +static void UNUSED_FUNCTION(draw_frustum_boundbox_calc)( + const float (*projmat)[4], const float (*viewinv)[4], BoundBox *r_bbox) { float screenvecs[3][3], loc[3], near, far, w_half, h_half; bool is_persp = projmat[3][3] == 0.0f; @@ -492,7 +493,14 @@ static void draw_clipping_setup_from_view(void) /* Extract Clipping Planes */ BoundBox bbox; +#if 0 /* does not currently work for all casses. */ draw_frustum_boundbox_calc(projmat, viewinv, &bbox); +#else + BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f}); + for (int i = 0; i < 8; i++) { + mul_project_m4_v3(DST.view_data.matstate.mat[DRW_MAT_PERSINV], bbox.vec[i]); + } +#endif /* Compute clip planes using the world space frustum corners. */ for (int p = 0; p < 6; p++) { diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 4af8089ffea..36402b82cbf 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2817,7 +2817,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* deselect all other channels */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); - if (pchan) ED_pose_de_selectall(ob, SEL_DESELECT, false); + if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); /* only select channels in group and group itself */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) @@ -2827,7 +2827,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, else { /* select group by itself */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); - if (pchan) ED_pose_de_selectall(ob, SEL_DESELECT, false); + if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); agrp->flag |= AGRP_SELECTED; } diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index bd3ddfe93c6..cb072bee345 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -63,12 +63,12 @@ /* default bone add, returns it selected, but without tail set */ /* XXX should be used everywhere, now it mallocs bones still locally in functions */ -EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) +EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) { EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); - unique_editbone_name(arm->edbo, bone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL); BLI_addtail(arm->edbo, bone); @@ -97,15 +97,15 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) return bone; } -EditBone *ED_armature_edit_bone_add_primitive(Object *obedit_arm, float length, bool view_aligned) +EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool view_aligned) { bArmature *arm = obedit_arm->data; EditBone *bone; - ED_armature_deselect_all(obedit_arm); + ED_armature_edit_deselect_all(obedit_arm); /* Create a bone */ - bone = ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_ebone_add(arm, "Bone"); arm->act_edbone = bone; @@ -157,12 +157,12 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) to_root = 1; } - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); /* we re-use code for mirror editing... */ flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) - flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); for (a = 0; a < 2; a++) { if (a == 1) { @@ -173,7 +173,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) } } - newbone = ED_armature_edit_bone_add(arm, ebone->name); + newbone = ED_armature_ebone_add(arm, ebone->name); arm->act_edbone = newbone; if (to_root) { @@ -205,7 +205,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -268,7 +268,7 @@ EditBone *add_points_bone(Object *obedit, float head[3], float tail[3]) { EditBone *ebo; - ebo = ED_armature_edit_bone_add(obedit->data, "Bone"); + ebo = ED_armature_ebone_add(obedit->data, "Bone"); copy_v3_v3(ebo->head, head); copy_v3_v3(ebo->tail, tail); @@ -333,7 +333,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob) for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) { EditBone *ebone_dst = ebone_src->temp.ebone; if (!ebone_dst) { - ebone_dst = ED_armature_bone_get_mirrored(editbones, ebone_src); + ebone_dst = ED_armature_ebone_get_mirrored(editbones, ebone_src); } if (ebone_dst) { BLI_ghash_insert(name_map, ebone_src->name, ebone_dst->name); @@ -438,7 +438,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase BLI_strncpy(eBone->name, name, sizeof(eBone->name)); } - unique_editbone_name(editbones, eBone->name, NULL); + ED_armature_ebone_unique_name(editbones, eBone->name, NULL); BLI_addtail(editbones, eBone); /* copy the ID property */ @@ -487,7 +487,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) const bool do_flip_names = RNA_boolean_get(op->ptr, "do_flip_names"); - ED_armature_sync_selection(arm->edbo); // XXX why is this needed? + ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed? preEditBoneDuplicate(arm->edbo); @@ -499,7 +499,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) { EditBone *ebone; - ebone = ED_armature_bone_get_mirrored(arm->edbo, ebone_iter); + ebone = ED_armature_ebone_get_mirrored(arm->edbo, ebone_iter); if (ebone) { ebone->flag |= BONE_SELECTED; } @@ -522,7 +522,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Only use flipped name if not yet in use. Otherwise we'd get again inconsistent namings * (different numbers), better keep default behavior in this case. */ - if (ED_armature_bone_find_name(arm->edbo, new_bone_name_buff) == NULL) { + if (ED_armature_ebone_find_name(arm->edbo, new_bone_name_buff) == NULL) { new_bone_name = new_bone_name_buff; } } @@ -583,7 +583,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) postEditBoneDuplicate(arm->edbo, obedit); - ED_armature_validate_active(arm); + ED_armature_edit_validate_active(arm); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -630,7 +630,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) if (CTX_DATA_COUNT(C, selected_bones) == 0) return OPERATOR_CANCELLED; - ED_armature_sync_selection(arm->edbo); // XXX why is this needed? + ED_armature_edit_sync_selection(arm->edbo); // XXX why is this needed? preEditBoneDuplicate(arm->edbo); @@ -648,7 +648,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) ebone_iter->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } else { - EditBone *ebone = ED_armature_bone_find_name(arm->edbo, name_flip); + EditBone *ebone = ED_armature_ebone_find_name(arm->edbo, name_flip); if (ebone) { if ((ebone->flag & BONE_SELECTED) == 0) { @@ -738,7 +738,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* the parent may have been duplicated, if not lookup the mirror parent */ EditBone *ebone_parent = (ebone_iter->parent->temp.ebone ? - ebone_iter->parent->temp.ebone : ED_armature_bone_get_mirrored(arm->edbo, ebone_iter->parent)); + ebone_iter->parent->temp.ebone : ED_armature_ebone_get_mirrored(arm->edbo, ebone_iter->parent)); if (ebone_parent == NULL) { /* If the mirror lookup failed, (but the current bone has a parent) @@ -759,7 +759,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) } } - transform_armature_mirror_update(obedit); + ED_armature_edit_transform_mirror_update(obedit); /* Selected bones now have their 'temp' pointer set, * so we don't need this anymore */ @@ -786,7 +786,7 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) postEditBoneDuplicate(arm->edbo, obedit); - ED_armature_validate_active(arm); + ED_armature_edit_validate_active(arm); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -870,7 +870,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) /* we re-use code for mirror editing... */ flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) { - flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (flipbone) { forked = 0; // we extrude 2 different bones if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) @@ -944,7 +944,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) else strcat(newbone->name, "_R"); } } - unique_editbone_name(arm->edbo, newbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); /* Add the new bone to the list */ BLI_addtail(arm->edbo, newbone); @@ -974,7 +974,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } /* Transform the endpoints */ - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1027,10 +1027,10 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); /* Create a bone */ - bone = ED_armature_edit_bone_add(obedit->data, name); + bone = ED_armature_ebone_add(obedit->data, name); copy_v3_v3(bone->head, curs); @@ -1118,7 +1118,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) newbone->prop = NULL; - unique_editbone_name(arm->edbo, newbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); /* correct parent bones */ for (tbone = arm->edbo->first; tbone; tbone = tbone->next) { diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index bb3c4164fc1..75b80627dff 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -67,7 +67,7 @@ /* ************************** Object Tools Exports ******************************* */ /* NOTE: these functions are exported to the Object module to be called from the tools there */ -void ED_armature_apply_transform(Object *ob, float mat[4][4], const bool do_props) +void ED_armature_transform_apply(Object *ob, float mat[4][4], const bool do_props) { bArmature *arm = ob->data; @@ -205,7 +205,7 @@ void ED_armature_origin_set(Object *ob, float cursor[3], int centermode, int aro /* adjust bone roll to align Z axis with vector * vec is in local space and is normalized */ -float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const bool axis_only) +float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only) { float mat[3][3], nor[3]; float vec[3], align_axis_proj[3], roll = 0.0f; @@ -331,7 +331,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); if (axis_flip) negate_v3(cursor_rel); if (normalize_v3(cursor_rel) != 0.0f) { - ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only); } } } @@ -370,13 +370,13 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) if (axis_flip) negate_v3(vec); if (is_edit) { - ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only); } /* parentless bones use cross product with child */ if (is_edit_parent) { if (ebone->parent->parent == NULL) { - ebone->parent->roll = ED_rollBoneToVector(ebone->parent, vec, axis_only); + ebone->parent->roll = ED_armature_ebone_roll_to_vector(ebone->parent, vec, axis_only); } } } @@ -420,7 +420,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ - ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only); } } } @@ -428,7 +428,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) if (arm->flag & ARM_MIRROR_EDIT) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { ebone->roll = -ebone_mirr->roll; } @@ -482,7 +482,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op) if (arm->flag & ARM_MIRROR_EDIT) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { ebone->roll = -ebone_mirr->roll; } @@ -771,7 +771,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) } if (newbone) { - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); arm->act_edbone = newbone; newbone->flag |= BONE_TIPSEL; } @@ -883,7 +883,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone } newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); } @@ -959,7 +959,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) } /* updates */ - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); return OPERATOR_FINISHED; @@ -1181,7 +1181,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) actmirb = actbone; } @@ -1293,7 +1293,7 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p) bArmature *arm = arm_p; EditBone *ebone; - ebone = ED_armature_bone_find_name(arm->edbo, bone_name); + ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); return (ebone && (ebone->flag & BONE_SELECTED) && (arm->layer & ebone->layer)); } @@ -1303,7 +1303,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; EditBone *curBone, *ebone_next; - Object *obedit = CTX_data_edit_object(C); // XXX get from context + Object *obedit = CTX_data_edit_object(C); bool changed = false; arm = obedit->data; @@ -1320,7 +1320,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { if (curBone == arm->act_edbone) arm->act_edbone = NULL; - ED_armature_edit_bone_remove(arm, curBone); + ED_armature_ebone_remove(arm, curBone); changed = true; } } @@ -1329,7 +1329,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) if (!changed) return OPERATOR_CANCELLED; - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1358,7 +1358,7 @@ static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p) bArmature *arm = arm_p; EditBone *ebone; - ebone = ED_armature_bone_find_name(arm->edbo, bone_name); + ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); return (ebone && (ebone->flag & BONE_DONE)); } @@ -1460,7 +1460,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) ebone->parent->rad_tail = ebone->rad_tail; SET_FLAG_FROM_TEST(ebone->parent->flag, ebone->flag & BONE_TIPSEL, BONE_TIPSEL); - ED_armature_edit_bone_remove_ex(arm, ebone, false); + ED_armature_ebone_remove_ex(arm, ebone, false); changed = true; } } @@ -1493,7 +1493,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1538,8 +1538,8 @@ static int armature_hide_exec(bContext *C, wmOperator *op) } } } - ED_armature_validate_active(arm); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1581,8 +1581,8 @@ static int armature_reveal_exec(bContext *C, wmOperator *op) } } } - ED_armature_validate_active(arm); - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 52e9e424a85..e8d45f72f89 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -74,11 +74,11 @@ static bool editbone_unique_check(void *arg, const char *name) { struct {ListBase *lb; void *bone; } *data = arg; - EditBone *dupli = ED_armature_bone_find_name(data->lb, name); + EditBone *dupli = ED_armature_ebone_find_name(data->lb, name); return dupli && dupli != data->bone; } -void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone) +void ED_armature_ebone_unique_name(ListBase *edbo, char *name, EditBone *bone) { struct {ListBase *lb; void *bone; } data; data.lb = edbo; @@ -153,10 +153,10 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { - EditBone *eBone = ED_armature_bone_find_name(arm->edbo, oldname); + EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname); if (eBone) { - unique_editbone_name(arm->edbo, newname, NULL); + ED_armature_ebone_unique_name(arm->edbo, newname, NULL); BLI_strncpy(eBone->name, newname, MAXBONENAME); } else { diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index de2611f7092..0dafbf51d74 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -312,10 +312,10 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Copy bones and posechannels from the object to the edit armature */ for (pchan = opose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = ED_armature_bone_find_name(curarm->edbo, pchan->name); + curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name); /* Get new name */ - unique_editbone_name(arm->edbo, curbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL); BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name); /* Transform the bone */ @@ -528,7 +528,7 @@ static void separate_armature_bones(Object *ob, short sel) /* go through pose-channels, checking if a bone should be removed */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; - curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); + curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || @@ -640,7 +640,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) ED_armature_to_edit(obedit->data); /* parents tips remain selected when connected children are removed. */ - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); BKE_report(op->reports, RPT_INFO, "Separated bones"); @@ -760,7 +760,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) actmirb = actbone; } @@ -883,7 +883,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 397691a409b..587cafa6d48 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -64,7 +64,7 @@ /* **************** PoseMode & EditMode Selection Buffer Queries *************************** */ /* only for opengl selection indices */ -Bone *get_indexed_bone(Object *ob, int index) +Bone *ED_armature_bone_find_index(Object *ob, int index) { bPoseChannel *pchan; if (ob->pose == NULL) return NULL; @@ -100,7 +100,7 @@ void *get_bone_from_selectbuffer( if (obedit == NULL || base->object != obedit) { /* no singular posemode, so check for correct object */ if (base->object->select_color == (hitresult & 0xFFFF)) { - bone = get_indexed_bone(base->object, hitresult); + bone = ED_armature_bone_find_index(base->object, hitresult); if (findunsel) sel = (bone->flag & BONE_SELECTED); @@ -247,7 +247,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv bone = NULL; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -294,8 +294,8 @@ static int selectbuffer_ret_hits_5(unsigned int *buffer, const int hits12, const /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ static EditBone *get_nearest_editbonepoint( - const EvaluationContext *eval_ctx, ViewContext *vc, const int mval[2], - ListBase *edbo, bool findunsel, bool use_cycle, int *r_selmask) + const EvaluationContext *eval_ctx, ViewContext *vc, + bool findunsel, bool use_cycle, int *r_selmask) { bArmature *arm = (bArmature *)vc->obedit->data; EditBone *ebone_next_act = arm->act_edbone; @@ -327,11 +327,11 @@ static EditBone *get_nearest_editbonepoint( if (use_cycle) { if (vc->v3d->drawtype > OB_WIRE) { do_nearest = true; - if (len_manhattan_v2v2_int(mval, last_mval) < 3) { + if (len_manhattan_v2v2_int(vc->mval, last_mval) < 3) { do_nearest = false; } } - copy_v2_v2_int(last_mval, mval); + copy_v2_v2_int(last_mval, vc->mval); } else { if (vc->v3d->drawtype > OB_WIRE) { @@ -346,7 +346,7 @@ static EditBone *get_nearest_editbonepoint( /* we _must_ end cache before return, use 'goto cache_end' */ view3d_opengl_select_cache_begin(); - BLI_rcti_init_pt_radius(&rect, mval, 12); + BLI_rcti_init_pt_radius(&rect, vc->mval, 12); hits12 = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, &rect, select_mode); if (hits12 == 1) { hits = selectbuffer_ret_hits_12(buffer, hits12); @@ -356,7 +356,7 @@ static EditBone *get_nearest_editbonepoint( int offs; offs = 4 * hits12; - BLI_rcti_init_pt_radius(&rect, mval, 5); + BLI_rcti_init_pt_radius(&rect, vc->mval, 5); hits5 = view3d_opengl_select(eval_ctx, vc, buffer + offs, MAXPICKBUF - offs, &rect, select_mode); if (hits5 == 1) { @@ -384,7 +384,7 @@ cache_end: if (!(hitresult & BONESEL_NOSEL)) { int dep; - ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY); + ebone = BLI_findlink(arm->edbo, hitresult & ~BONESEL_ANY); /* clicks on bone points get advantage */ if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) { @@ -428,7 +428,7 @@ cache_end: if (!(besthitresult & BONESEL_NOSEL)) { - ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY); + ebone = BLI_findlink(arm->edbo, besthitresult & ~BONESEL_ANY); *r_selmask = 0; if (besthitresult & BONESEL_ROOT) @@ -444,7 +444,7 @@ cache_end: return NULL; } -void ED_armature_deselect_all(Object *obedit) +void ED_armature_edit_deselect_all(Object *obedit) { bArmature *arm = obedit->data; EditBone *ebone; @@ -454,7 +454,7 @@ void ED_armature_deselect_all(Object *obedit) } } -void ED_armature_deselect_all_visible(Object *obedit) +void ED_armature_edit_deselect_all_visible(Object *obedit) { bArmature *arm = obedit->data; EditBone *ebone; @@ -466,7 +466,7 @@ void ED_armature_deselect_all_visible(Object *obedit) } } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); } /* accounts for connected parents */ @@ -481,10 +481,9 @@ static int ebone_select_flag(EditBone *ebone) } /* context: editmode armature in view3d */ -bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) +bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; EvaluationContext eval_ctx; ViewContext vc; EditBone *nearBone = NULL; @@ -492,16 +491,19 @@ bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool d CTX_data_eval_ctx(C, &eval_ctx); ED_view3d_viewcontext_init(C, &vc); + vc.mval[0] = mval[0]; + vc.mval[1] = mval[1]; if (BIF_sk_selectStroke(C, mval, extend)) { return true; } - nearBone = get_nearest_editbonepoint(&eval_ctx, &vc, mval, arm->edbo, true, true, &selmask); + nearBone = get_nearest_editbonepoint(&eval_ctx, &vc, true, true, &selmask); if (nearBone) { + bArmature *arm = obedit->data; if (!extend && !deselect && !toggle) { - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); } /* by definition the non-root connected bones have no root point drawn, @@ -572,7 +574,7 @@ bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool d nearBone->flag |= selmask; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); if (nearBone) { /* then now check for active status */ @@ -716,7 +718,7 @@ static void armature_select_more_less(Object *ob, bool more) EditBone *ebone; /* XXX, eventually we shouldn't need this - campbell */ - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); /* count bones & store selection state */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { @@ -746,7 +748,7 @@ static void armature_select_more_less(Object *ob, bool more) ebone->temp.p = NULL; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); } static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1151,7 +1153,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); @@ -1207,7 +1209,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) EditBone *ebone_mirror; int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0; - if ((ebone_mirror = ED_armature_bone_get_mirrored(arm->edbo, ebone)) && + if ((ebone_mirror = ED_armature_ebone_get_mirrored(arm->edbo, ebone)) && (EBONE_VISIBLE(arm, ebone_mirror))) { const int flag_mirror = EBONE_PREV_FLAG_GET(ebone_mirror); @@ -1231,7 +1233,7 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) arm->act_edbone = ebone_mirror_act; } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1316,7 +1318,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const else if (ED_armature_ebone_is_child_recursive(ebone_dst, ebone_src)) { SWAP(EditBone *, ebone_src, ebone_dst); } - else if ((ebone_isect_parent = ED_armature_bone_find_shared_parent(ebone_isect_child, 2))) { + else if ((ebone_isect_parent = ED_armature_ebone_find_shared_parent(ebone_isect_child, 2))) { /* pass */ } else { @@ -1351,7 +1353,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const if (changed) { arm->act_edbone = ebone_dst; - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 5c8e08a0d89..e25056a7a4a 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -431,7 +431,7 @@ static void add_verts_to_dgroups( MEM_freeN(verts); } -void create_vgroups_from_armature( +void ED_object_vgroup_calc_from_armature( ReportList *reports, const EvaluationContext *eval_ctx, Scene *scene, Object *ob, Object *par, const int mode, const bool mirror) { diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index aa0aa0e03ff..c4580a370c9 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -54,7 +54,7 @@ /* Validation */ /* Sync selection to parent for connected children */ -void ED_armature_sync_selection(ListBase *edbo) +void ED_armature_edit_sync_selection(ListBase *edbo) { EditBone *ebo; @@ -76,7 +76,7 @@ void ED_armature_sync_selection(ListBase *edbo) } } -void ED_armature_validate_active(struct bArmature *arm) +void ED_armature_edit_validate_active(struct bArmature *arm) { EditBone *ebone = arm->act_edbone; @@ -137,7 +137,7 @@ void bone_free(bArmature *arm, EditBone *bone) /** * \param clear_connected: When false caller is responsible for keeping the flag in a valid state. */ -void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected) +void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_connected) { EditBone *curBone; @@ -154,9 +154,9 @@ void ED_armature_edit_bone_remove_ex(bArmature *arm, EditBone *exBone, bool clea bone_free(arm, exBone); } -void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) +void ED_armature_ebone_remove(bArmature *arm, EditBone *exBone) { - ED_armature_edit_bone_remove_ex(arm, exBone, true); + ED_armature_ebone_remove_ex(arm, exBone, true); } bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child) @@ -175,7 +175,7 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon * \param ebone_child_tot Size of the ebone_child array * \return The shared parent or NULL. */ -EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot) +EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot) { unsigned int i; EditBone *ebone_iter; @@ -255,7 +255,7 @@ void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) /** * Return a pointer to the bone of the given name */ -EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name) +EditBone *ED_armature_ebone_find_name(const ListBase *edbo, const char *name) { return BLI_findstring(edbo, name, offsetof(EditBone, name)); } @@ -267,7 +267,7 @@ EditBone *ED_armature_bone_find_name(const ListBase *edbo, const char *name) /** * \see #BKE_pose_channel_get_mirrored (pose-mode, matching function) */ -EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo) +EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo) { char name_flip[MAXBONENAME]; @@ -277,7 +277,7 @@ EditBone *ED_armature_bone_get_mirrored(const ListBase *edbo, EditBone *ebo) BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip)); if (!STREQ(name_flip, ebo->name)) { - return ED_armature_bone_find_name(edbo, name_flip); + return ED_armature_ebone_find_name(edbo, name_flip); } return NULL; @@ -297,7 +297,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag) for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & flag) { - ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); + ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); if (ebone_mirr) ebone_mirr->flag |= (curBone->flag & flag); } @@ -326,7 +326,7 @@ void armature_tag_select_mirrored(bArmature *arm) for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) { ebone_mirr->flag |= BONE_DONE; } @@ -336,7 +336,7 @@ void armature_tag_select_mirrored(bArmature *arm) for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { - EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); + EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); } } @@ -359,7 +359,7 @@ void armature_tag_unselect(bArmature *arm) /* if editbone (partial) selected, copy data */ /* context; editmode armature, with mirror editing enabled */ -void transform_armature_mirror_update(Object *obedit) +void ED_armature_edit_transform_mirror_update(Object *obedit) { bArmature *arm = obedit->data; EditBone *ebo, *eboflip; @@ -367,7 +367,7 @@ void transform_armature_mirror_update(Object *obedit) for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { /* no layer check, correct mirror is more important */ if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { - eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo); + eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); if (eboflip) { /* we assume X-axis flipping for now */ @@ -437,7 +437,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone = MEM_callocN(sizeof(EditBone), "make_editbone"); /* Copy relevant data from bone to eBone - * Keep selection logic in sync with ED_armature_sync_selection. + * Keep selection logic in sync with ED_armature_edit_sync_selection. */ eBone->parent = parent; BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name)); diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 4eb9e3ecc79..57843265496 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -39,7 +39,7 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma copy_v3_v3(normal, no); mul_m3_v3(tmat, normal); - bone->roll = ED_rollBoneToVector(bone, normal, false); + bone->roll = ED_armature_ebone_roll_to_vector(bone, normal, false); } } @@ -252,7 +252,7 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U IT_head(iter); - parent = ED_armature_edit_bone_add(arm, "Bone"); + parent = ED_armature_ebone_add(arm, "Bone"); copy_v3_v3(parent->head, iter->p); if (iter->size > FLT_EPSILON) { @@ -265,7 +265,7 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U while (index != -1) { IT_peek(iter, index); - child = ED_armature_edit_bone_add(arm, "Bone"); + child = ED_armature_ebone_add(arm, "Bone"); copy_v3_v3(child->head, parent->tail); child->parent = parent; child->flag |= BONE_CONNECTED; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 3dd41f25e09..bf6126658af 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -158,11 +158,11 @@ static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float q if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) { rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ - return ED_rollBoneToVector(bone, x_axis, false); + return ED_armature_ebone_roll_to_vector(bone, x_axis, false); } else { rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */ - return ED_rollBoneToVector(bone, z_axis, false); + return ED_armature_ebone_roll_to_vector(bone, z_axis, false); } } @@ -207,7 +207,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4] /* real qroll between normal and up_axis */ rotation_between_vecs_to_quat(qroll, new_up_axis, normal); - return ED_rollBoneToVector(edge->bone, normal, false); + return ED_armature_ebone_roll_to_vector(edge->bone, normal, false); } } @@ -218,7 +218,7 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) copy_v3_v3(new_up_axis, old_up_axis); mul_qt_v3(qrot, new_up_axis); - return ED_rollBoneToVector(bone, new_up_axis, false); + return ED_armature_ebone_roll_to_vector(bone, new_up_axis, false); } /************************************ DESTRUCTORS ******************************************************/ @@ -424,7 +424,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo name[j] = '\0'; - unique_editbone_name(editbones, name, NULL); + ED_armature_ebone_unique_name(editbones, name, NULL); } static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string) @@ -1435,7 +1435,7 @@ static EditBone *add_editbonetolist(char *name, ListBase *list) EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); - unique_editbone_name(list, bone->name, NULL); + ED_armature_ebone_unique_name(list, bone->name, NULL); BLI_addtail(list, bone); @@ -2626,7 +2626,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) } RIG_freeRigGraph((BGraph *)rigg); - ED_armature_validate_active(armedit); + ED_armature_edit_validate_active(armedit); // XXX // allqueue(REDRAWVIEW3D, 0); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 1f1468a8e41..26f11f8fd60 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -1358,7 +1358,7 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) } if (bone == NULL) { - bone = ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_ebone_add(arm, "Bone"); copy_v3_v3(bone->head, head->p); copy_v3_v3(bone->tail, pt->p); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 489940007e4..ea7a35a4b0e 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1636,7 +1636,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa free_bvhtree_from_mesh(&mdb->bvhdata); } -void mesh_deform_bind( +void ED_mesh_deform_bind_callback( Scene *scene, MeshDeformModifierData *mmd, DerivedMesh *cagedm, float *vertexcos, int totvert, float cagemat[4][4]) { diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 05ade4fc43e..9c4ceacbee6 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -68,7 +68,7 @@ void rigid_deform_end(int cancel); /* Harmonic Coordinates */ -/* mesh_deform_bind(...) defined in ED_armature.h */ +/* ED_mesh_deform_bind_callback(...) defined in ED_armature.h */ #endif diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index a66cedd8d4f..1c23f71233d 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -133,7 +133,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) /* called from editview.c, for mode-less pose selection */ /* assumes scene obact and basact is still on old situation */ -bool ED_do_pose_selectbuffer( +bool ED_armature_pose_select_pick_with_buffer( ViewLayer *view_layer, Base *base, const unsigned int *buffer, short hits, bool extend, bool deselect, bool toggle, bool do_nearest) { @@ -166,7 +166,7 @@ bool ED_do_pose_selectbuffer( } if (!extend && !deselect && !toggle) { - ED_pose_de_selectall(ob, SEL_DESELECT, true); + ED_pose_deselect_all(ob, SEL_DESELECT, true); nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); arm->act_bone = nearBone; } @@ -220,7 +220,7 @@ bool ED_do_pose_selectbuffer( /* 'select_mode' is usual SEL_SELECT/SEL_DESELECT/SEL_TOGGLE/SEL_INVERT. * When true, 'ignore_visibility' makes this func also affect invisible bones (hidden or on hidden layers). */ -void ED_pose_de_selectall(Object *ob, int select_mode, const bool ignore_visibility) +void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility) { bArmature *arm = ob->data; bPoseChannel *pchan; diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index c49591be5d1..7fc40d00042 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -128,7 +128,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) pose = ob->pose; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - curbone = ED_armature_bone_find_name(arm->edbo, pchan->name); + curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 0dcc4f32e43..186ca5313e5 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -139,29 +139,30 @@ void ED_armature_from_edit(struct bArmature *arm); void ED_armature_to_edit(struct bArmature *arm); void ED_armature_edit_free(struct bArmature *arm); -void ED_armature_deselect_all(struct Object *obedit); -void ED_armature_deselect_all_visible(struct Object *obedit); +void ED_armature_edit_deselect_all(struct Object *obedit); +void ED_armature_edit_deselect_all_visible(struct Object *obedit); -bool ED_do_pose_selectbuffer( +bool ED_armature_pose_select_pick_with_buffer( struct ViewLayer *view_layer, struct Base *base, const unsigned int *buffer, short hits, bool extend, bool deselect, bool toggle, bool do_nearest); -bool ED_armature_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +bool ED_armature_edit_select_pick( + struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); int join_armature_exec(struct bContext *C, struct wmOperator *op); -struct Bone *get_indexed_bone(struct Object *ob, int index); -float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const bool axis_only); -EditBone *ED_armature_bone_find_name(const struct ListBase *edbo, const char *name); -EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo); -void ED_armature_sync_selection(struct ListBase *edbo); -void ED_armature_validate_active(struct bArmature *arm); +struct Bone *ED_armature_bone_find_index(struct Object *ob, int index); +float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float new_up_axis[3], const bool axis_only); +EditBone *ED_armature_ebone_find_name(const struct ListBase *edbo, const char *name); +EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo); +void ED_armature_edit_sync_selection(struct ListBase *edbo); +void ED_armature_edit_validate_active(struct bArmature *arm); -EditBone *ED_armature_edit_bone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned); -EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name); +EditBone *ED_armature_ebone_add_primitive(struct Object *obedit_arm, float length, bool view_aligned); +EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name); -void ED_armature_edit_bone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected); -void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone); +void ED_armature_ebone_remove_ex(struct bArmature *arm, EditBone *exBone, bool clear_connected); +void ED_armature_ebone_remove(struct bArmature *arm, EditBone *exBone); bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child); -EditBone *ED_armature_bone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot); +EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const unsigned int ebone_child_tot); void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]); void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]); @@ -169,23 +170,23 @@ void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]); void ED_armature_ebone_from_mat3(EditBone *ebone, float mat[3][3]); void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]); -void transform_armature_mirror_update(struct Object *obedit); +void ED_armature_edit_transform_mirror_update(struct Object *obedit); void ED_armature_origin_set(struct Object *ob, float cursor[3], int centermode, int around); void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const bool do_props); -void ED_armature_apply_transform(struct Object *ob, float mat[4][4], const bool do_props); +void ED_armature_transform_apply(struct Object *ob, float mat[4][4], const bool do_props); void ED_armature_transform(struct bArmature *arm, float mat[4][4], const bool do_props); #define ARM_GROUPS_NAME 1 #define ARM_GROUPS_ENVELOPE 2 #define ARM_GROUPS_AUTO 3 -void create_vgroups_from_armature( +void ED_object_vgroup_calc_from_armature( struct ReportList *reports, const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, struct Object *par, const int mode, const bool mirror); /* if bone is already in list, pass it as param to ignore it */ -void unique_editbone_name(struct ListBase *ebones, char *name, EditBone *bone); +void ED_armature_ebone_unique_name(struct ListBase *ebones, char *name, EditBone *bone); void ED_armature_bone_rename(struct bArmature *arm, const char *oldnamep, const char *newnamep); void ED_armature_bones_flip_names(struct bArmature *arm, struct ListBase *bones_names, const bool do_strip_numbers); @@ -209,7 +210,7 @@ bool ED_object_posemode_exit_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_exit(struct bContext *C, struct Object *ob); bool ED_object_posemode_enter_ex(struct Main *bmain, struct Object *ob); bool ED_object_posemode_enter(struct bContext *C, struct Object *ob); -void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool ignore_visibility); +void ED_pose_deselect_all(struct Object *ob, int select_mode, const bool ignore_visibility); void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select); void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob); struct Object *ED_pose_object_from_context(struct bContext *C); @@ -235,11 +236,12 @@ void BDR_drawSketch(const struct bContext *vc); int BDR_drawSketchNames(struct ViewContext *vc); /* meshlaplacian.c */ -void mesh_deform_bind(struct Scene *scene, - struct MeshDeformModifierData *mmd, - struct DerivedMesh *cagedm, - float *vertexcos, int totvert, float cagemat[4][4]); - +void ED_mesh_deform_bind_callback( + struct Scene *scene, + struct MeshDeformModifierData *mmd, + struct DerivedMesh *cagedm, + float *vertexcos, int totvert, float cagemat[4][4]); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 043dfc9fd99..bb9bfdd4429 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -721,6 +721,7 @@ enum { ROUNDBOX_TRIA_SCROLL, ROUNDBOX_TRIA_MENU, ROUNDBOX_TRIA_CHECK, + ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MAX, /* don't use */ }; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 5a210d01f27..d72e59beb91 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -221,8 +221,22 @@ static const uint g_shape_preset_hold_action_face[2][3] = {{2, 0, 1}, {3, 5, 4}} **/ /* offset in triavec[] in shader per type */ -static const int tria_ofs[ROUNDBOX_TRIA_MAX] = {0, 0, 6, 22, 28}; -static const int tria_vcount[ROUNDBOX_TRIA_MAX] = {0, 3, 16, 3, 6}; +static const int tria_ofs[ROUNDBOX_TRIA_MAX] = { + [ROUNDBOX_TRIA_NONE] = 0, + [ROUNDBOX_TRIA_ARROWS] = 0, + [ROUNDBOX_TRIA_SCROLL] = 6, + [ROUNDBOX_TRIA_MENU] = 22, + [ROUNDBOX_TRIA_CHECK] = 28, + [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 34, +}; +static const int tria_vcount[ROUNDBOX_TRIA_MAX] = { + [ROUNDBOX_TRIA_NONE] = 0, + [ROUNDBOX_TRIA_ARROWS] = 3, + [ROUNDBOX_TRIA_SCROLL] = 16, + [ROUNDBOX_TRIA_MENU] = 3, + [ROUNDBOX_TRIA_CHECK] = 6, + [ROUNDBOX_TRIA_HOLD_ACTION_ARROW] = 3, +}; static struct { Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX]; @@ -288,7 +302,7 @@ static uint32_t set_tria_vertex( static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data) { - const int tria_num = (tria == ROUNDBOX_TRIA_CHECK) ? 1 : 2; + const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW) ? 1 : 2; /* for each tria */ for (int t = 0; t < tria_num; ++t) { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -315,7 +329,7 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) vcount += ((WIDGET_CURVE_RESOLU * 2) * 2) * WIDGET_AA_JITTER; /* emboss */ if (tria) { vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria1 */ - if (tria != ROUNDBOX_TRIA_CHECK) { + if (!ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW)) { vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */ } } @@ -832,6 +846,12 @@ static void shape_preset_init_number_arrows(uiWidgetTrias *tria, const rcti *rec static void shape_preset_init_hold_action(uiWidgetTrias *tria, const rcti *rect, float triasize, char where) { + tria->type = ROUNDBOX_TRIA_HOLD_ACTION_ARROW; + /* With the current changes to use batches for widget drawing, the code + * below is doing almost nothing effectively. 'where' doesn't work either, + * shader is currently hardcoded to work for the button triangle pointing + * at the lower right. The same limitation applies to other trias as well. + * XXX Should be addressed. */ shape_preset_init_trias_ex( tria, rect, triasize, where, g_shape_preset_hold_action_vert, ARRAY_SIZE(g_shape_preset_hold_action_vert), diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d3f6a42c3c1..d2c859565a3 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -850,7 +850,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) } dia = RNA_float_get(op->ptr, "radius"); - ED_armature_edit_bone_add_primitive(obedit, dia, view_aligned); + ED_armature_ebone_add_primitive(obedit, dia, view_aligned); /* userdef */ if (newob && !enter_editmode) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 04243660440..c79bd3bcb1d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1673,7 +1673,7 @@ static void skin_armature_bone_create(Object *skin_ob, v = (e->v1 == parent_v ? e->v2 : e->v1); - bone = ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_ebone_add(arm, "Bone"); bone->parent = parent_bone; bone->flag |= BONE_CONNECTED; @@ -1746,7 +1746,7 @@ static Object *modifier_skin_armature_create(const EvaluationContext *eval_ctx, * a fake root bone (have it going off in the Y direction * (arbitrary) */ if (emap[v].count > 1) { - bone = ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_ebone_add(arm, "Bone"); copy_v3_v3(bone->head, me->mvert[v].co); copy_v3_v3(bone->tail, me->mvert[v].co); @@ -1953,7 +1953,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) int mode = mmd->modifier.mode; /* force modifier to run, it will call binding routine */ - mmd->bindfunc = mesh_deform_bind; + mmd->bindfunc = ED_mesh_deform_bind_callback; mmd->modifier.mode |= eModifierMode_Realtime; if (ob->type == OB_MESH) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 3443a268ef2..ba58c0d3d2a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -785,14 +785,14 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, } else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) { if (partype == PAR_ARMATURE_NAME) { - create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_NAME, false); + ED_object_vgroup_calc_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_NAME, false); } else if (partype == PAR_ARMATURE_ENVELOPE) { - create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); + ED_object_vgroup_calc_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); } else if (partype == PAR_ARMATURE_AUTO) { WM_cursor_wait(1); - create_vgroups_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_AUTO, xmirror); + ED_object_vgroup_calc_from_armature(reports, &eval_ctx, scene, ob, par, ARM_GROUPS_AUTO, xmirror); WM_cursor_wait(0); } /* get corrected inverse */ diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bb23f871a25..d0ebb0cd6fe 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -545,7 +545,7 @@ static int apply_objects_internal( BKE_mesh_calc_normals(me); } else if (ob->type == OB_ARMATURE) { - ED_armature_apply_transform(ob, mat, do_props); + ED_armature_transform_apply(ob, mat, do_props); } else if (ob->type == OB_LATTICE) { Lattice *lt = ob->data; diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 98a6670d10f..343e615f76b 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -220,7 +220,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) - flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (editable_bones) { @@ -262,7 +262,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) - flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (selected_editable_bones) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 3892b776440..a5b9a840c33 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -135,7 +135,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) CTX_data_eval_ctx(C, &eval_ctx); - create_vgroups_from_armature(op->reports, &eval_ctx, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); + ED_object_vgroup_calc_from_armature(op->reports, &eval_ctx, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 2f44420f3b7..9ddaf6d7642 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -575,7 +575,7 @@ static eOLDrawState tree_element_active_ebone( if (set != OL_SETSEL_NONE) { if (set == OL_SETSEL_NORMAL) { if (!(ebone->flag & BONE_HIDDEN_A)) { - ED_armature_deselect_all(obedit); + ED_armature_edit_deselect_all(obedit); tree_element_active_ebone__sel(C, obedit, arm, ebone, true); status = OL_DRAWSEL_NORMAL; } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index be8e63dffe6..c38bcbcd645 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -657,14 +657,14 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); if (extend == false && select) - ED_armature_deselect_all_visible(vc->obedit); + ED_armature_edit_deselect_all_visible(vc->obedit); armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.is_changed) { bArmature *arm = vc->obedit->data; - ED_armature_sync_selection(arm->edbo); - ED_armature_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); } } @@ -1500,7 +1500,7 @@ static bool ed_object_select_pick( } } } - else if (ED_do_pose_selectbuffer(view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { + else if (ED_armature_pose_select_pick_with_buffer(view_layer, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { /* then bone is found */ /* we make the armature selected: @@ -1904,7 +1904,6 @@ static int do_armature_box_select( const rcti *rect, bool select, bool extend) { bArmature *arm = vc->obedit->data; - EditBone *ebone; int a; unsigned int buffer[MAXPICKBUF]; @@ -1913,27 +1912,27 @@ static int do_armature_box_select( hits = view3d_opengl_select(eval_ctx, vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL); /* clear flag we use to detect point was affected */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) ebone->flag &= ~BONE_DONE; if (extend == false && select) - ED_armature_deselect_all_visible(vc->obedit); + ED_armature_edit_deselect_all_visible(vc->obedit); /* first we only check points inside the border */ for (a = 0; a < hits; a++) { int index = buffer[(4 * a) + 3]; if (index != -1) { - ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); if ((index & 0xFFFF0000) == 0) { continue; } + EditBone *ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) { if (index & BONESEL_TIP) { ebone->flag |= BONE_DONE; if (select) ebone->flag |= BONE_TIPSEL; else ebone->flag &= ~BONE_TIPSEL; } - + if (index & BONESEL_ROOT) { ebone->flag |= BONE_DONE; if (select) ebone->flag |= BONE_ROOTSEL; @@ -1942,34 +1941,37 @@ static int do_armature_box_select( } } } - + /* now we have to flush tag from parents... */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { - if (ebone->parent->flag & BONE_DONE) + if (ebone->parent->flag & BONE_DONE) { ebone->flag |= BONE_DONE; + } } } - + /* only select/deselect entire bones when no points where in the rect */ for (a = 0; a < hits; a++) { int index = buffer[(4 * a) + 3]; if (index != -1) { - ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); if (index & BONESEL_BONE) { + EditBone *ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY)); if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) { if (!(ebone->flag & BONE_DONE)) { - if (select) + if (select) { ebone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); - else + } + else { ebone->flag &= ~(BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); + } } } } } } - ED_armature_sync_selection(arm->edbo); + ED_armature_edit_sync_selection(arm->edbo); return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -2056,7 +2058,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b if (BASE_SELECTABLE(base)) { while (base->object->select_color == (*col & 0xFFFF)) { /* we got an object */ if (*col & 0xFFFF0000) { /* we got a bone */ - bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY)); + bone = ED_armature_bone_find_index(base->object, *col & ~(BONESEL_ANY)); if (bone) { if (select) { if ((bone->flag & BONE_UNSELECTABLE) == 0) { @@ -2295,7 +2297,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) if (obedit->type == OB_MESH) retval = EDBM_select_pick(C, location, extend, deselect, toggle); else if (obedit->type == OB_ARMATURE) - retval = ED_armature_select_pick(C, location, extend, deselect, toggle); + retval = ED_armature_edit_select_pick(C, location, extend, deselect, toggle); else if (obedit->type == OB_LATTICE) retval = ED_lattice_select_pick(C, location, extend, deselect, toggle); else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) @@ -2736,8 +2738,8 @@ static void armature_circle_select(ViewContext *vc, const bool select, const int armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.is_changed) { - ED_armature_sync_selection(arm->edbo); - ED_armature_validate_active(arm); + ED_armature_edit_sync_selection(arm->edbo); + ED_armature_edit_validate_active(arm); WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2d7ff1eb523..fff124c8995 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1186,7 +1186,7 @@ static void createTransArmatureVerts(TransInfo *t) } if (mirror && (oldtot < t->total)) { - eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo); + eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); if (eboflip) total_mirrored++; } @@ -1356,7 +1356,7 @@ static void createTransArmatureVerts(TransInfo *t) } if (mirror && (td_old != td)) { - eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo); + eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); if (eboflip) { bid[i].bone = eboflip; bid[i].dist = eboflip->dist; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 6a813eb2a55..08e8e8fe175 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -853,7 +853,7 @@ static void recalcData_objects(TransInfo *t) mul_qt_v3(qrot, up_axis); /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */ - roll = ED_rollBoneToVector(ebo, up_axis, false); + roll = ED_armature_ebone_roll_to_vector(ebo, up_axis, false); ebo->roll = angle_compat_rad(roll, td->ival); } } @@ -862,7 +862,7 @@ static void recalcData_objects(TransInfo *t) if (arm->flag & ARM_MIRROR_EDIT) { if (t->state != TRANS_CANCEL) - transform_armature_mirror_update(t->obedit); + ED_armature_edit_transform_mirror_update(t->obedit); else restoreBones(t); } diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c index f4ed96f98f3..511f4bc72f1 100644 --- a/source/blender/editors/undo/memfile_undo.c +++ b/source/blender/editors/undo/memfile_undo.c @@ -70,9 +70,10 @@ static bool memfile_undosys_step_encode(struct bContext *C, UndoStep *us_p) /* Important we only use 'main' from the context (see: BKE_undosys_stack_init_from_main). */ struct Main *bmain = CTX_data_main(C); + UndoStack *ustack = ED_undo_stack_get(); /* can be NULL, use when set. */ - MemFileUndoStep *us_prev = (MemFileUndoStep *)BKE_undosys_step_same_type_prev(us_p); + MemFileUndoStep *us_prev = (MemFileUndoStep *)BKE_undosys_step_find_by_type(ustack, BKE_UNDOSYS_TYPE_MEMFILE); us->data = BKE_memfile_undo_encode(bmain, us_prev ? us_prev->data : NULL); us->step.data_size = us->data->undo_size; diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c index 872810c5cf2..494ae769cf3 100644 --- a/source/blender/editors/util/ed_transverts.c +++ b/source/blender/editors/util/ed_transverts.c @@ -154,7 +154,7 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit) } } if (arm->flag & ARM_MIRROR_EDIT) - transform_armature_mirror_update(obedit); + ED_armature_edit_transform_mirror_update(obedit); } else if (obedit->type == OB_LATTICE) { Lattice *lt = obedit->data; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl index 0c351a3bce4..107480580f9 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl @@ -47,11 +47,11 @@ const vec2 jit[9] = vec2[9]( /* We can reuse the CORNER_* bits for tria */ #define TRIA_VEC_RANGE BIT_RANGE(6) -const vec2 triavec[34] = vec2[34]( - /* horizontal tria */ +const vec2 triavec[37] = vec2[37]( + /* ROUNDBOX_TRIA_ARROWS */ vec2(-0.352077, 0.532607), vec2(-0.352077, -0.549313), vec2( 0.330000, -0.008353), vec2( 0.352077, 0.532607), vec2( 0.352077, -0.549313), vec2(-0.330000, -0.008353), - /* circle tria (triangle strip) */ + /* ROUNDBOX_TRIA_SCROLL - circle tria (triangle strip) */ vec2(0.000000, 1.000000), vec2(0.382684, 0.923879), vec2(-0.382683, 0.923880), vec2(0.707107, 0.707107), vec2(-0.707107, 0.707107), @@ -61,12 +61,19 @@ const vec2 triavec[34] = vec2[34]( vec2(0.707107, -0.707107), vec2(-0.707107, -0.707107), vec2(0.382684, -0.923879), vec2(-0.382683, -0.923880), vec2(0.000000, -1.000000), - /* menu arrow */ + /* ROUNDBOX_TRIA_MENU - menu arrows */ vec2(-0.33, 0.16), vec2(0.33, 0.16), vec2(0.0, 0.82), vec2(0.0, -0.82), vec2(-0.33, -0.16), vec2(0.33, -0.16), - /* check mark */ + /* ROUNDBOX_TRIA_CHECK - check mark */ vec2(-0.578579, 0.253369), vec2(-0.392773, 0.412794), vec2(-0.004241, -0.328551), - vec2(-0.003001, 0.034320), vec2(1.055313, 0.864744), vec2(0.866408, 1.026895) + vec2(-0.003001, 0.034320), vec2(1.055313, 0.864744), vec2(0.866408, 1.026895), + /* ROUNDBOX_TRIA_HOLD_ACTION_ARROW - hold action arrows */ +#define OY -0.2 +#define SC 0.35 +// vec2(-0.5 + SC, 1.0 + OY), vec2( 0.5, 1.0 + OY), vec2( 0.5, 0.0 + OY + SC), + vec2( 0.5 - SC, 1.0 + OY), vec2(-0.5, 1.0 + OY), vec2(-0.5, 0.0 + OY + SC) +#undef OY +#undef SC ); uniform mat4 ModelViewProjectionMatrix; @@ -183,4 +190,4 @@ void main() v += jit[(vflag >> JIT_OFS) & JIT_RANGE]; gl_Position = ModelViewProjectionMatrix * vec4(v, 0.0, 1.0); -}
\ No newline at end of file +} diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index bbcb583ab39..05074bc9f16 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -108,7 +108,7 @@ static EditBone *rna_Armature_edit_bone_new(bArmature *arm, ReportList *reports, BKE_reportf(reports, RPT_ERROR, "Armature '%s' not in edit mode, cannot add an editbone", arm->id.name + 2); return NULL; } - return ED_armature_edit_bone_add(arm, name); + return ED_armature_ebone_add(arm, name); } static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, PointerRNA *ebone_ptr) @@ -124,7 +124,7 @@ static void rna_Armature_edit_bone_remove(bArmature *arm, ReportList *reports, P return; } - ED_armature_edit_bone_remove(arm, ebone); + ED_armature_ebone_remove(arm, ebone); RNA_POINTER_INVALIDATE(ebone_ptr); } @@ -427,7 +427,7 @@ static void rna_Armature_editbone_transform_update(Main *bmain, Scene *scene, Po copy_v3_v3(child->head, ebone->tail); if (arm->flag & ARM_MIRROR_EDIT) { - eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebone); + eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (eboflip) { eboflip->roll = -ebone->roll; diff --git a/source/blender/makesrna/intern/rna_armature_api.c b/source/blender/makesrna/intern/rna_armature_api.c index 0616331bc05..222baf99afd 100644 --- a/source/blender/makesrna/intern/rna_armature_api.c +++ b/source/blender/makesrna/intern/rna_armature_api.c @@ -46,7 +46,7 @@ static void rna_EditBone_align_roll(EditBone *ebo, float no[3]) { - ebo->roll = ED_rollBoneToVector(ebo, no, false); + ebo->roll = ED_armature_ebone_roll_to_vector(ebo, no, false); } static float rna_Bone_do_envelope(Bone *bone, float *vec) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3c600f6e367..1032acbae67 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -112,7 +112,7 @@ const EnumPropertyItem rna_enum_uv_sculpt_tool_items[] = { const EnumPropertyItem rna_enum_snap_target_items[] = { {SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", "Snap closest point onto target"}, - {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap center onto target"}, + {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap transormation center onto target"}, {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", "Snap median onto target"}, {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 827b69f5403..1e2837799e3 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -1295,11 +1295,20 @@ BGL_Wrap(UniformMatrix4x3fv, void, (GLint, GLsizei, GLboolean, GLflo /* GL_VERSION_3_0 */ +BGL_Wrap(BindFramebuffer, void, (GLenum, GLuint)) +BGL_Wrap(BindRenderbuffer, void, (GLenum, GLuint)) BGL_Wrap(BindVertexArray, void, (GLuint)) +BGL_Wrap(CheckFramebufferStatus, GLenum, (GLenum)) +BGL_Wrap(DeleteFramebuffers, void, (GLsizei, GLuintP)) +BGL_Wrap(DeleteRenderbuffers, void, (GLsizei, GLuintP)) BGL_Wrap(DeleteVertexArrays, void, (GLsizei, GLuintP)) +BGL_Wrap(FramebufferRenderbuffer, void, (GLenum, GLenum, GLenum, GLuint)) +BGL_Wrap(GenFramebuffers, void, (GLsizei, GLuintP)) +BGL_Wrap(GenRenderbuffers, void, (GLsizei, GLuintP)) BGL_Wrap(GenVertexArrays, void, (GLsizei, GLuintP)) BGL_Wrap(GetStringi, GLstring, (GLenum, GLuint)) BGL_Wrap(IsVertexArray, GLboolean, (GLuint)) +BGL_Wrap(RenderbufferStorage, void, (GLenum, GLenum, GLsizei, GLsizei)) /* GL_VERSION_3_1 */ @@ -1626,11 +1635,20 @@ PyObject *BPyInit_bgl(void) /* GL_VERSION_3_0 */ { + PY_MOD_ADD_METHOD(BindFramebuffer); + PY_MOD_ADD_METHOD(BindRenderbuffer); PY_MOD_ADD_METHOD(BindVertexArray); + PY_MOD_ADD_METHOD(CheckFramebufferStatus); + PY_MOD_ADD_METHOD(DeleteFramebuffers); + PY_MOD_ADD_METHOD(DeleteRenderbuffers); PY_MOD_ADD_METHOD(DeleteVertexArrays); + PY_MOD_ADD_METHOD(FramebufferRenderbuffer); + PY_MOD_ADD_METHOD(GenFramebuffers); + PY_MOD_ADD_METHOD(GenRenderbuffers); PY_MOD_ADD_METHOD(GenVertexArrays); PY_MOD_ADD_METHOD(GetStringi); PY_MOD_ADD_METHOD(IsVertexArray); + PY_MOD_ADD_METHOD(RenderbufferStorage); } /* GL_VERSION_3_1 */ diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 96242c229d1..f953f1b89d8 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -428,7 +428,7 @@ struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow * void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer) RET_NONE float WM_event_tablet_data(const struct wmEvent *event, int *pen_flip, float tilt[2]) RET_ZERO bool WM_event_is_tablet(const struct wmEvent *event) RET_ZERO -void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE +void ED_armature_ebone_remove(struct bArmature *arm, struct EditBone *exBone) RET_NONE void object_test_constraints(struct Object *owner) RET_NONE void ED_armature_ebone_to_mat4(struct EditBone *ebone, float mat[4][4]) RET_NONE void ED_armature_ebone_from_mat4(EditBone *ebone, float mat[4][4]) RET_NONE @@ -447,8 +447,8 @@ bool UI_view2d_view_to_region_clip(struct View2D *v2d, float x, float y, int *re void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *region_y) RET_NONE void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag) RET_NONE -struct EditBone *ED_armature_bone_get_mirrored(const struct ListBase *edbo, EditBone *ebo) RET_NULL -struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name) RET_NULL +struct EditBone *ED_armature_ebone_get_mirrored(const struct ListBase *edbo, EditBone *ebo) RET_NULL +struct EditBone *ED_armature_ebone_add(struct bArmature *arm, const char *name) RET_NULL struct ListBase *get_active_constraints (struct Object *ob) RET_NULL struct ListBase *get_constraint_lb(struct Object *ob, struct bConstraint *con, struct bPoseChannel **r_pchan) RET_NULL @@ -604,7 +604,7 @@ float ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vert int ED_mesh_mirror_topo_table(struct Object *ob, struct DerivedMesh *dm, char mode) RET_ZERO int ED_mesh_mirror_spatial_table(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, const float co[3], char mode) RET_ZERO -float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const bool axis_only) RET_ZERO +float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float new_up_axis[3], const bool axis_only) RET_ZERO void ED_space_image_get_size(struct SpaceImage *sima, int *width, int *height) RET_NONE bool ED_space_image_check_show_maskedit(struct SpaceImage *sima, struct ViewLayer *view_layer) RET_ZERO |