Home › Forum › SOFA › Programming with SOFA › simulationStep(dt) does not update the visuals
Tagged: 64_bits, Linux_ubuntu, SOFA_1712, SofaPython
- This topic has 2 replies, 3 voices, and was last updated 5 years, 10 months ago by Damien Marchal.
-
AuthorPosts
-
6 November 2018 at 14:08 #12345RishabhBlocked
Hello, I am working with SofaPython plugin for a cloth simulation case,
- Issue:
The simulationStep(dt) function use does not update the visuals, all the other aspects of the simulation are taking place, attaching the link to a video showing this behavior
I am calling the simulationStep(dt) function inside a onKeyPressed(self,k) function call, upon a keyboard event the simulation steps in all possible ways except the visuals do not get updated. However when I press the step button on the GUI, the simulation behaves as usual. Any clues would be appreciated
Thanks,
Rishabh14 November 2018 at 19:01 #12444HugoKeymasterDear @jangirrishabh
You are right, the function simulationStep() of a Node (e.g. rootNode) does only bind the animate() function.
/// step the simulation static PyObject * Node_simulationStep(PyObject * self, PyObject * args) { Node* node = get_node(self); double dt; if (!PyArg_ParseTuple(args, "d",&dt)) { return NULL; } getSimulation()->animate ( node, (SReal)dt ); Py_RETURN_NONE; }
Unfortunately, the AnimationLoop does not seem to be bound in Python.
An alternative could be to send the two required Visitors just after your call as follows:rootNode.simulationStep(dt) rootNode.executeVisitor(UpdateSimulationContextVisitor) rootNode.executeVisitor(UpdateMappingVisitor)
But I never did trigger visitors in Python myself.
Let me know whether this works.
BestHugo
16 January 2019 at 14:17 #12791Damien MarchalBlockedHi,
You are right this is not working.
But I fear that this binding of simulationStep() method on Node was not designed for such use case.
The easiest solution (not the most elegant one) I can find is to add an updateVisual() method to the node binding to expose the initVisual() that we can found in Simulation.h.
Actually it is very strange that we bind Simulation::animate and not Simulation::initVisual.This will update the visual but this will not trigger the runSofa 3D viewport to update the content of the 3D views but I think this may work if you start runSofa with the -i option (in that case the 3D view is refreshed at regular interval).
But, all that requires to make change on the sofa source code so I suggest to open an issue on github to track this topic: https://github.com/sofa-framework/sofa/issues
Regards,
Damien -
AuthorPosts
- You must be logged in to reply to this topic.