A node is a collection of algorithms with relatively independent functions that encapsulate specific function modules. It is mainly composed of input node, input data, output node, output data, state variable and function module.
Creating a complete node consists of the following steps:
define input nodes (optional)
DEF_NODE_PORT(T, name, desc)
This macro defines a single node input, where T represents the node type, name represents the name, desc represents the input node description information, and the access method is import+data name.
DEF_NODE_PORTS(T, name, desc)
This macro definition can define an array of input nodes, which can access 0 to any number of nodes of type T as input. The access method is import+data name+s.
define input data (optional)
DEF_VAR_IN(T, name, desc)
Define a single data type with input type T and name name as input.
DEF_ARRAY_IN(T, name, device, desc)
Define a one-dimensional array of type T and name name as input on the device (CPU/GPU) device.
DEF_ARRAY2D_IN(T, name, device, desc)
Define a two-dimensional array of type T and name as input on the device (CPU/GPU) device.
DEF_ARRAY3D_IN(T, name, device, desc)
Define a three-dimensional array of type T and name name as input on the device (CPU/GPU) device.
DEF_INSTANCE_IN(T, name, desc)
Define an instance of input type T and name name as input.
DEF_ARRAYLIST_IN(T, name, device, desc)
Define a one-dimensional dynamic list array of type T and name name as input on the device (CPU/GPU) device.
define output data (optional)
DEF_VAR_OUT(T, name, desc)
Define a single data type with input type T and name name as output.
DEF_ARRAY_OUT(T, name, device, desc)
Define a one-dimensional array of type T and name name as output on the device (CPU/GPU) device.
DEF_ARRAY2D_OUT(T, name, device, desc)
Define a two-dimensional array of type T and name name as output on the device (CPU/GPU) device.
DEF_ARRAY3D_OUT(T, name, device, desc)
Define a three-dimensional array of type T and name name as output on the device (CPU/GPU) device.
DEF_INSTANCE_OUT(T, name, desc)
Define an instance of input type T and name name as output.
DEF_ARRAYLIST_OUT(T, name, device, desc)
Define a one-dimensional dynamic list array with type T and name name as output on the device (CPU/GPU) device.
define state variables
DEF_VAR(T, name, value, desc)
Define a single data type with type T, name as name, and initial value type as value as a state variable.
DEF_ARRAY_STATE(T, name, device, desc)
Define a one-dimensional array of type T and name name as a state variable on the device (CPU/GPU) device.
DEF_ARRAY2D_STATE(T, name, device, desc)
Define a two-dimensional array of type T and name as a state variable on the device (CPU/GPU) device.
DEF_ARRAY3D_STATE(T, name, device, desc)
Define a three-dimensional array of type T and name as a state variable on the device (CPU/GPU) device.
DEF_INSTANCE_STATE(T, name, desc)
Define an instance of input type T and name name as a state variable.
DEF_ARRAYLIST_STATE(T, name, device, desc)
Define a one-dimensional dynamic list array of type T and name name as a state variable on the device (CPU/GPU) device.
Create function modules
Taking RigidBodySystem as an example, the function modules created in the constructor are as follows:
//Create a self-collision detection module
auto elementQuery = std::make_shared<NeighborElementQuery<TDataType>>();
this->currentTopology()->connect(elementQuery->inDiscreteElements());
this->stateCollisionMask()->connect(elementQuery->inCollisionMask());
this->animationPipeline()->pushModule(elementQuery);
//Create a Bounding Box Collision Detection Function Module
auto cdBV = std::make_shared<CollistionDetectionBoundingBox<TDataType>>();
this->currentTopology()->connect(cdBV->inDiscreteElements());
this->animationPipeline()->pushModule(cdBV);
//Create a combined contact function block
auto merge = std::make_shared<ContactsUnion<TDataType>>();
elementQuery->outContacts()->connect(merge->inContactsA());
cdBV->outContacts()->connect(merge->inContactsB());
this->animationPipeline()->pushModule(merge);
//Create a Rigid Body Dynamics Solver Module
auto iterSolver = std::make_shared<IterativeConstraintSolver<TDataType>>();
this->varTimeStep()->connect(iterSolver->inTimeStep());
this->varFrictionEnabled()->connect(iterSolver->varFrictionEnabled());
this->stateMass()->connect(iterSolver->inMass());
this->stateCenter()->connect(iterSolver->inCenter());
this->stateVelocity()->connect(iterSolver->inVelocity());
this->stateAngularVelocity()->connect(iterSolver->inAngularVelocity());
this->stateRotationMatrix()->connect(iterSolver->inRotationMatrix());
this->stateInertia()->connect(iterSolver->inInertia());
this->stateQuaternion()->connect(iterSolver->inQuaternion());
this->stateInitialInertia()->connect(iterSolver->inInitialInertia());
merge->outContacts()->connect(iterSolver->inContacts());
this->animationPipeline()->pushModule(iterSolver);
Overload virtual function
virtual void preUpdateStates();
Status update pre-processing function
virtual void updateStates();
The state update function, the default is to call the pipeline to execute the default algorithm process
virtual void postUpdateStates();
Status update post-processing function