Merge branch 'blender2.8' into blender2.8-workbench

This commit is contained in:
Jeroen Bakker 2018-04-16 08:20:12 +02:00
commit 7ffc8bc25d
140 changed files with 918 additions and 1124 deletions

View File

@ -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

View File

@ -35,4 +35,3 @@ Types
:glob:
bge.types.*

View File

@ -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

View File

@ -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.

View File

@ -1,8 +1,6 @@
BL_ArmatureBone(PyObjectPlus)
=============================
.. module:: bge.types
base class --- :class:`PyObjectPlus`
.. class:: BL_ArmatureBone(PyObjectPlus)

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -1,8 +1,6 @@
BL_ShapeActionActuator(SCA_IActuator)
=====================================
.. module:: bge.types
base class --- :class:`SCA_IActuator`
.. class:: BL_ShapeActionActuator(SCA_IActuator)

View File

@ -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.

View File

@ -1,11 +1,8 @@
CPropValue(CValue)
==================
.. module:: bge.types
base class --- :class:`CValue`
.. class:: CPropValue(CValue)
This class has no python functions

View File

@ -1,8 +1,6 @@
CValue(PyObjectPlus)
====================
.. module:: bge.types
base class --- :class:`PyObjectPlus`
.. class:: CValue(PyObjectPlus)

View File

@ -1,8 +1,6 @@
KX_ArmatureSensor(SCA_ISensor)
==============================
.. module:: bge.types
base class --- :class:`SCA_ISensor`
.. class:: KX_ArmatureSensor(SCA_ISensor)

View File

@ -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

View File

@ -1,8 +1,6 @@
KX_Camera(KX_GameObject)
========================
.. module:: bge.types
base class --- :class:`KX_GameObject`
.. class:: KX_Camera(KX_GameObject)

View File

@ -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

View File

@ -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.

View File

@ -1,8 +1,6 @@
KX_ConstraintActuator(SCA_IActuator)
====================================
.. module:: bge.types
base class --- :class:`SCA_IActuator`
.. class:: KX_ConstraintActuator(SCA_IActuator)

View File

@ -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`

View File

@ -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

View File

@ -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

View File

@ -1,8 +1,6 @@
KX_GameObject(SCA_IObject)
==========================
.. module:: bge.types
base class --- :class:`SCA_IObject`
.. class:: KX_GameObject(SCA_IObject)

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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)

View File

@ -1,8 +1,6 @@
KX_MouseFocusSensor(SCA_MouseSensor)
====================================
.. module:: bge.types
base class --- :class:`SCA_MouseSensor`
.. class:: KX_MouseFocusSensor(SCA_MouseSensor)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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`

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,8 +1,6 @@
KX_TrackToActuator(SCA_IActuator)
=================================
.. module:: bge.types
base class --- :class:`SCA_IActuator`
.. class:: KX_TrackToActuator(SCA_IActuator)

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -1,8 +1,6 @@
KX_WorldInfo(PyObjectPlus)
=============================
.. module:: bge.types
base class --- :class:`PyObjectPlus`
.. class:: KX_WorldInfo(PyObjectPlus)

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -1,11 +1,8 @@
SCA_IObject(CValue)
===================
.. module:: bge.types
base class --- :class:`CValue`
.. class:: SCA_IObject(CValue)
This class has no python functions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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
}

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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) {

View File

@ -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++;
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;
}
}
MEM_freeN(buffer);
if (buffer[i] == '\n') {
txt_split_curline(text, utxt);
i++;
undoing = u;
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;
}
}
}
MEM_freeN(buffer);
undoing = undoing_orig;
}
/******************/

View File

@ -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)

View File

@ -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);

View File

@ -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(&current->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;
}
}

View File

@ -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;
int tot, count;
#ifdef USE_WRITE_DATA_LEN
/** Total number of bytes written. */
size_t write_len;
#endif
/** 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, &lt->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);
}
/** \} */

View File

@ -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];

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -1,7 +1,5 @@
layout(std140) uniform shadow_render_block {
mat4 ShadowMatrix[6];
mat4 FaceViewMatrix[6];
vec4 lampPosition;
float cubeTexelSize;
float storedTexelSize;

Some files were not shown because too many files have changed in this diff Show More