c++ - How to deep copy a btTriangleMesh in Bullet Physics? -
i use bullet physics , need copy instance of bttrianglemesh
type.
// variable class member bttrianglemesh triangles;
my aim change collision shape of body new triangle mesh shape. shape should hold data stored in triangles
variable, if variable changes in future. therefore need deep copy.
// in method change collision shape bttrianglemesh *copy = new bttrianglemesh(triangles); btbvhtrianglemeshshape *shape = new btbvhtrianglemeshshape(copy), true, true); body->setcollisionshape(shape); // after that, reset variable triangles = bttrianglemesh(); // change content of variable next body // ...
i though instancing new variable on heap new bttrianglemesh(triangles)
deep copy object. can see in images below, collision shape of first body affected next one.
in image, white lines represent collision shape whereas can see actual desired shape rendered underneath. how first body looks like, fine here.
and how looks after inserting body on right side. shape of first body changed equal 1 of second body. shouldn't happen. might not clear on image in 3d see shape of first body changed match 1 of second.
how deep copy bttrianglemesh
? or doing else wrong?
by way reason fact use same variable source triangle shapes variable filled asynchronously thread.
Comments
Post a Comment