Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Try to modify the velocity
#4
Hi,

Just realized you're executing this code at the end of the simulation step (OnSimulationEnd). At the start of the next simulation step, positions and velocities will be replaced with the ones in CPU memory as part of the normal simulation cycle. See:

http://obi.virtualmethodstudio.com/manua...icles.html
Quote:Obi will automatically upload particle data to the GPU at the start of every simulation step (only those data lists that have been modified by the CPU since the last time they were uploaded). However, it will only automatically read positions and velocities back from the GPU at the end of each step for performance reasons. If you want to read any other data from the CPU (eg. colors or user data) you need to manually ask Obi to read this data back from the GPU. Note this is also necessary if you're going to modify this data on the CPU, otherwise you would be working with stale data.

If you want to modify the velocity after taking a simulation step instead of before, I've attached a slightly modified version of ObiSolver.cs that allows you to use solver.OnRequestReadback for this purpose instead. OnRequestReadback also takes place at the end of the simulation step just like OnSimulationEnd, but before requesting an async readback of positions/velocities. This will ensure any modifications made to the GPU copy of the data at the end of each step will be read back to the CPU.

kind regards,


Attached Files
.cs   ObiSolver.cs (Size: 90.17 KB / Downloads: 1)
Reply


Messages In This Thread
Try to modify the velocity - by a172862967 - 11-08-2024, 10:39 AM
RE: Try to modify the velocity - by josemendez - 12-08-2024, 07:44 AM
RE: Try to modify the velocity - by a172862967 - 12-08-2024, 09:55 AM
RE: Try to modify the velocity - by josemendez - 12-08-2024, 10:52 AM