Per-Axis Speed Limits in POPs

   658   5   2
User Avatar
Member
4 posts
Joined: 9月 2024
Offline
Hi everyone,

I need to clamp particle velocities with different limits for horizontal, upward, and downward directions. The POP Speed Limit node works perfectly for overall speed clamping, and when I export the simulation data to external software, it accurately shows the limits being enforced. However, when I try to implement per-axis limits using a POP Wrangle, the exported data shows particles exceeding these limits, even though Houdini shows the clamped speeds correctly in the simulation.

My approach so far:
- I'm calculating horizontal speed
length(v@v.x, v@v.y, 0)
upward speed
v@v.z > 0 ? v@v.z : 0
and downward speed
v@v.z < 0 ? abs(v@v.z) : 0
then clamping them separately in a POP Wrangle.
- The issue: Despite Houdini showing the correct clamped speeds, my exported data shows particles exceeding these limits when checked in external software. However, using the POP Speed Limit node works perfectly for export.

My question:
- How can I implement per-axis speed limits that behave like the POP Speed Limit node, ensuring that the limits are correctly enforced even when exporting to external software?
- Is there a more reliable way to handle per-axis speed limits, possibly using VEX in the POP Speed Limit node or another approach?

Any help would be appreciated! Thanks.
Edited by luanrogalewski - 2024年10月16日 13:19:59
User Avatar
Member
155 posts
Joined: 8月 2017
Offline
If I understand correctly Speed limit.
// User parameters for per-axis speed limits
float max_speed_x = chf("max_speed_x");
float max_speed_y = chf("max_speed_y");
float max_speed_z = chf("max_speed_z");

// Get the current velocity of the particle
vector velocity = v@v;

// Clamp velocity along each axis independently
if (abs(velocity.x) > max_speed_x) {
    velocity.x = sign(velocity.x) * max_speed_x;
}
if (abs(velocity.y) > max_speed_y) {
    velocity.y = sign(velocity.y) * max_speed_y;
}
if (abs(velocity.z) > max_speed_z) {
    velocity.z = sign(velocity.z) * max_speed_z;
}

// Assign the clamped velocity back to the particle
v@v = velocity;
Conservation of Momentum
User Avatar
Member
4 posts
Joined: 9月 2024
Offline
Thanks for the suggestion!

However, it behaves just like my previous solution attempt. After exporting the particle positions and testing in another software, the speed still isn’t clamped correctly. Increasing substeps helps bring the speeds closer to the threshold, but what’s puzzling is that the POP Speed Limit node works perfectly with a substep count of 1.

I’m looking for a way to replicate exactly what the POP Speed Limit node does, but with separate max speed limits for horizontal, upward, and downward movements.

Any ideas on how to approach this?
User Avatar
Member
463 posts
Joined: 11月 2016
Offline
If Pop Speed Limit is our only choice, you could try creating three attributes out of horizontal speed, upward speed and downward speed, then one by one, piping them into v, applying Pop Speed Limit, then writing them back in their individual attributes. Then add the three attributes together to get your limited v.
Edited by Tanto - 2024年10月17日 14:40:56
User Avatar
Member
4 posts
Joined: 9月 2024
Offline
Thanks, the idea sounds promising! But, I couldn’t find a way to implement it, maybe I'm not doing it right.

What I tried:
- Stored horizontal, upward, and downward forces into three separate attributes.
- Zeroed the Z forces to isolate horizontal movement.
- Applied POP Speed Limit.
- Added back the upward and downward forces.

The result was that speeds in all directions were clamped equally, just like using POP Speed Limit without isolating directions. Tried the same for the velocity attribute and the result was similar.

It seems the POP Speed Limit might be handling velocity in a way that isn’t as straightforward for isolating components.
I’m really curious about how the POP Speed Limit node works internally because I’d like to replicate its behavior but for different directions, and I just can’t seem to figure it out.
User Avatar
Member
463 posts
Joined: 11月 2016
Offline
Thinking about it further, I think what you should be really limiting are the forces, so that each individual Velocity component + (Force that affects it * Time increment) doesn't surpass your limits. Pop speed limit must do that internally but it can't affect each component of your velocity separately.
  • Quick Links