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.

a single chunk correct collision shape

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.

inserting second chunk unwantedly changes shape of first one

how deep copy bttrianglemesh? or doing else wrong?

by way reason fact use same variable source triangle shapes variable filled asynchronously thread.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -