ExpressionME-L allows you to connect multiple nodes and work with the data supplied by these nodes. Handling particle collisions can be easily achieved by using either the UDeflector Node or the FlowData Node. Special functions have been implemented in ME-L to allow for easy handling of collision events. Find below a list of these functions along with their parameters and variables.
Global Variable:
collision_in_id | returns the index of the input you created (starting with 0 excluding Time and On). |
Detects a collision for a given particle. Works with UDeflector and FlowData
Parameters:
Parameter | Description |
---|---|
pid_in | The particle ID to check for a collision. |
affect_in | (Optional) A boolean value that specifies whether to affect the particle position and velocity if a collision is detected. Default is false . |
Output:
Return | Description |
---|---|
scalar | 0: failed, 1: success |
Gets the collision point information. Only valid if the collision_in_detect()
function returns 1
.
Parameters:
Parameter | Description |
---|---|
point_data | The data to retrieve from the collision point. Check out the full listy for PointData |
scalar_out | A scalar value to store the output. |
vector_out | A vector[3] to store the output. |
Output:
Return | Description |
---|---|
scalar | 0: failed, 1: success |
Important To know
UDefector is able to use/generate the following information:
point_pos
point_opos
point_center
point_vel
point_norm
point_onorm
point_gnorm
point_ognorm
point_fid
point_bc
point_mtlid
point_col
point_uvw
FlowData only offers collision event and the following point data:
point_norm
Sample 1: Get the collision detect info from the FlowData operator and on collide, get the surface normal of the collision point
var normal[3];
if (collision_in_detect(pid))
{
collision_in_point(point_norm, normal); // Do anything here with the normal value
}
Sample 2: UDeflector - get the collision and update the particle position and velocity to the collision values (if you use a group as the first input of the expression, all particles in this group will be evaluated in parallel for the collision detection)
var ppos[3];
var pvel[3];
if (collision_in_detect(pid))
{ // Get and set the values, with affect_in set to true
collision_in_point(point_pos, ppos, true);
collision_in_point(point_vel, pvel, true);
set_pdata(pid, data_pos, ppos);
set_pdata(pid, data_vel, pvel);
}
// The same as the above code collision_in_detect(pid, true);