Hongzhu Posted April 28, 2019 Share Posted April 28, 2019 I'm learning HDK and fluid sim by swapping out microsolver nodes in Houdini's built in FLIP solver. I've successfully changed the GasExternalForce node to my simple gravity node. It works okay but there's a small problem that bugs me a lot. So here's the implementation in the built in solver: There's a gravity node in the Auto DOP network (looks like the order doesn't really matter. I tried putting the gravity node before the flipsover and nothing changed.) And then in the flipsolver there's a GasExternalForces microsolver that apply forces on the particles. I deleted the gravity node and changed the GasExternalForces node to my implementation: bool SIM_HZExternalForce::solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep) { SIM_Geometry* geo = (SIM_Geometry*)obj->getGeometry(); if (!geo) { return false; } GU_DetailHandle gdh = geo->getOwnGeometry(); const GU_Detail* gdp_in = gdh.readLock(); // Must unlock later GU_Detail* gdp_out = gdh.writeLock(); GA_RWAttributeRef p_ref_vel = gdp_out->findPointAttribute("v"); GA_RWHandleT<UT_Vector3F> p_vel(p_ref_vel.getAttribute()); if (p_vel.isInvalid()) { return false; } for (GA_Iterator it(gdp_out->getPointRange()); !it.atEnd(); it.advance()){ int pid = it.getOffset(); UT_Vector3F vel = p_vel.get(pid); vel[1] -= timestep * 9.80665f; p_vel.set(pid, vel); } gdh.unlock(gdp_out); gdh.unlock(gdp_in); // Successful cook return true; } The problem is, the velocities in the first frame are all zero in the official implementation: But in my implementation, the velocities got changed in the first frame: I really want to know where this discrepancy comes from. Any suggestions? I've uploaded the source code and scene file if anyone is interested. GravityTest.zip 1 Quote Link to comment Share on other sites More sharing options...
Sumit Posted August 19, 2019 Share Posted August 19, 2019 from what I see, your vel is coming from vel[1] -= timestep * 9.80665f; on first frame its -(1/24) * 9.80665 = -0.40861 timestep will evaluate in first frame too, official might have something else. Quote Link to comment Share on other sites More sharing options...
anim Posted August 19, 2019 Share Posted August 19, 2019 not knowing anything about HDK, but there is a checkbox on Empty Object and therefore Flip Object too called Solve On Creation Frame, which is off by default that's why default external forces are not applied on the first frame, so possibly your implementation needs to consider that flag Quote Link to comment Share on other sites More sharing options...
DonRomano Posted August 19, 2019 Share Posted August 19, 2019 From what I see, you multiply the gravity by the timestep, so at frame 0 you'll have 0 because 0 * 9.80665 = 0, that's what Sumit said. So I guess that even if you cook the first frame it will stay at zero. Try to set it initial and don't multiply it by the timestep Quote Link to comment Share on other sites More sharing options...
Nicholas Ralabate Posted December 19, 2020 Share Posted December 19, 2020 I am having a similar issue, (using Gas Turbulence DOP) but even when I dive in and disable multiplication by timestep it does not work when the amplitude is set to if($SF==1, 10, 0). Are there any other workarounds? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.