fix separate render and sim mesh
This commit is contained in:
@@ -338,20 +338,20 @@ B3_SHARED_API int b3LoadSoftBodySetStartOrientation(b3SharedMemoryCommandHandle
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
B3_SHARED_API int b3LoadSoftBodyAddRenderMesh(b3SharedMemoryCommandHandle commandHandle, const char* filename)
|
B3_SHARED_API int b3LoadSoftBodyUpdateSimMesh(b3SharedMemoryCommandHandle commandHandle, const char* filename)
|
||||||
{
|
{
|
||||||
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
struct SharedMemoryCommand* command = (struct SharedMemoryCommand*)commandHandle;
|
||||||
b3Assert(command->m_type == CMD_LOAD_SOFT_BODY);
|
b3Assert(command->m_type == CMD_LOAD_SOFT_BODY);
|
||||||
int len = strlen(filename);
|
int len = strlen(filename);
|
||||||
if (len < MAX_FILENAME_LENGTH)
|
if (len < MAX_FILENAME_LENGTH)
|
||||||
{
|
{
|
||||||
strcpy(command->m_loadSoftBodyArguments.m_renderFileName, filename);
|
strcpy(command->m_loadSoftBodyArguments.m_simFileName, filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command->m_loadSoftBodyArguments.m_renderFileName[0] = 0;
|
command->m_loadSoftBodyArguments.m_simFileName[0] = 0;
|
||||||
}
|
}
|
||||||
command->m_updateFlags |= LOAD_SOFT_BODY_RENDER_MESH;
|
command->m_updateFlags |= LOAD_SOFT_BODY_SIM_MESH;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -633,7 +633,7 @@ extern "C"
|
|||||||
B3_SHARED_API int b3LoadSoftBodySetCollisionMargin(b3SharedMemoryCommandHandle commandHandle, double collisionMargin);
|
B3_SHARED_API int b3LoadSoftBodySetCollisionMargin(b3SharedMemoryCommandHandle commandHandle, double collisionMargin);
|
||||||
B3_SHARED_API int b3LoadSoftBodySetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX, double startPosY, double startPosZ);
|
B3_SHARED_API int b3LoadSoftBodySetStartPosition(b3SharedMemoryCommandHandle commandHandle, double startPosX, double startPosY, double startPosZ);
|
||||||
B3_SHARED_API int b3LoadSoftBodySetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX, double startOrnY, double startOrnZ, double startOrnW);
|
B3_SHARED_API int b3LoadSoftBodySetStartOrientation(b3SharedMemoryCommandHandle commandHandle, double startOrnX, double startOrnY, double startOrnZ, double startOrnW);
|
||||||
B3_SHARED_API int b3LoadSoftBodyAddRenderMesh(b3SharedMemoryCommandHandle commandHandle, const char* filename);
|
B3_SHARED_API int b3LoadSoftBodyUpdateSimMesh(b3SharedMemoryCommandHandle commandHandle, const char* filename);
|
||||||
B3_SHARED_API int b3LoadSoftBodyAddCorotatedForce(b3SharedMemoryCommandHandle commandHandle, double corotatedMu, double corotatedLambda);
|
B3_SHARED_API int b3LoadSoftBodyAddCorotatedForce(b3SharedMemoryCommandHandle commandHandle, double corotatedMu, double corotatedLambda);
|
||||||
B3_SHARED_API int b3LoadSoftBodyAddCorotatedForce(b3SharedMemoryCommandHandle commandHandle, double corotatedMu, double corotatedLambda);
|
B3_SHARED_API int b3LoadSoftBodyAddCorotatedForce(b3SharedMemoryCommandHandle commandHandle, double corotatedMu, double corotatedLambda);
|
||||||
B3_SHARED_API int b3LoadSoftBodyAddNeoHookeanForce(b3SharedMemoryCommandHandle commandHandle, double NeoHookeanMu, double NeoHookeanLambda, double NeoHookeanDamping);
|
B3_SHARED_API int b3LoadSoftBodyAddNeoHookeanForce(b3SharedMemoryCommandHandle commandHandle, double NeoHookeanMu, double NeoHookeanLambda, double NeoHookeanDamping);
|
||||||
|
|||||||
@@ -1709,7 +1709,6 @@ struct PhysicsServerCommandProcessorInternalData
|
|||||||
m_dispatcher(0),
|
m_dispatcher(0),
|
||||||
m_solver(0),
|
m_solver(0),
|
||||||
m_collisionConfiguration(0),
|
m_collisionConfiguration(0),
|
||||||
|
|
||||||
#ifndef SKIP_DEFORMABLE_BODY
|
#ifndef SKIP_DEFORMABLE_BODY
|
||||||
m_deformablebodySolver(0),
|
m_deformablebodySolver(0),
|
||||||
#endif
|
#endif
|
||||||
@@ -2652,7 +2651,17 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld(int flags)
|
|||||||
m_data->m_broadphase = bv;
|
m_data->m_broadphase = bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & RESET_USE_DEFORMABLE_WORLD)
|
if (flags & RESET_USE_SOFT_MULTIBODY_WORLD)
|
||||||
|
{
|
||||||
|
m_data->m_solver = new btMultiBodyConstraintSolver;
|
||||||
|
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
||||||
|
m_data->m_dynamicsWorld = new btSoftMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, m_data->m_solver, m_data->m_collisionConfiguration);
|
||||||
|
#else
|
||||||
|
m_data->m_dynamicsWorld = new btMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, m_data->m_solver, m_data->m_collisionConfiguration);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((0==m_data->m_dynamicsWorld) && (0==(flags&RESET_USE_DISCRETE_DYNAMICS_WORLD)))
|
||||||
{
|
{
|
||||||
#ifndef SKIP_DEFORMABLE_BODY
|
#ifndef SKIP_DEFORMABLE_BODY
|
||||||
m_data->m_deformablebodySolver = new btDeformableBodySolver();
|
m_data->m_deformablebodySolver = new btDeformableBodySolver();
|
||||||
@@ -2663,14 +2672,6 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld(int flags)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0==m_data->m_dynamicsWorld) && (0==(flags&RESET_USE_DISCRETE_DYNAMICS_WORLD)))
|
|
||||||
{
|
|
||||||
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
|
|
||||||
m_data->m_solver = new btMultiBodyConstraintSolver;
|
|
||||||
m_data->m_dynamicsWorld = new btSoftMultiBodyDynamicsWorld(m_data->m_dispatcher, m_data->m_broadphase, m_data->m_solver, m_data->m_collisionConfiguration);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0==m_data->m_dynamicsWorld)
|
if (0==m_data->m_dynamicsWorld)
|
||||||
{
|
{
|
||||||
m_data->m_solver = new btMultiBodyConstraintSolver;
|
m_data->m_solver = new btMultiBodyConstraintSolver;
|
||||||
@@ -8083,17 +8084,26 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar
|
|||||||
b3FileUtils::extractPath(relativeFileName, pathPrefix, 1024);
|
b3FileUtils::extractPath(relativeFileName, pathPrefix, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::string& error_message_prefix = "";
|
const std::string& error_message_prefix = "";
|
||||||
std::string out_found_filename;
|
std::string out_found_filename, out_found_sim_filename;
|
||||||
int out_type(0);
|
int out_type(0), out_sim_type(0);
|
||||||
|
|
||||||
bool foundFile = UrdfFindMeshFile(fileIO, pathPrefix, relativeFileName, error_message_prefix, &out_found_filename, &out_type);
|
bool foundFile = UrdfFindMeshFile(fileIO, pathPrefix, relativeFileName, error_message_prefix, &out_found_filename, &out_type);
|
||||||
if (out_type == UrdfGeometry::FILE_OBJ)
|
|
||||||
|
if (clientCmd.m_updateFlags & LOAD_SOFT_BODY_SIM_MESH)
|
||||||
|
{
|
||||||
|
bool foundSimMesh = UrdfFindMeshFile(fileIO, pathPrefix, loadSoftBodyArgs.m_simFileName, error_message_prefix, &out_found_sim_filename, &out_sim_type);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out_sim_type = out_type;
|
||||||
|
out_found_sim_filename = out_found_filename;
|
||||||
|
}
|
||||||
|
if (out_sim_type == UrdfGeometry::FILE_OBJ)
|
||||||
{
|
{
|
||||||
std::vector<tinyobj::shape_t> shapes;
|
std::vector<tinyobj::shape_t> shapes;
|
||||||
tinyobj::attrib_t attribute;
|
tinyobj::attrib_t attribute;
|
||||||
std::string err = tinyobj::LoadObj(attribute, shapes, out_found_filename.c_str(), "", fileIO);
|
std::string err = tinyobj::LoadObj(attribute, shapes, out_found_sim_filename.c_str(), "", fileIO);
|
||||||
if (!shapes.empty())
|
if (!shapes.empty())
|
||||||
{
|
{
|
||||||
const tinyobj::shape_t& shape = shapes[0];
|
const tinyobj::shape_t& shape = shapes[0];
|
||||||
@@ -8142,13 +8152,13 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (out_type == UrdfGeometry::FILE_VTK)
|
else if (out_sim_type == UrdfGeometry::FILE_VTK)
|
||||||
{
|
{
|
||||||
#ifndef SKIP_DEFORMABLE_BODY
|
#ifndef SKIP_DEFORMABLE_BODY
|
||||||
btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld();
|
btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld();
|
||||||
if (deformWorld)
|
if (deformWorld)
|
||||||
{
|
{
|
||||||
psb = btSoftBodyHelpers::CreateFromVtkFile(deformWorld->getWorldInfo(), out_found_filename.c_str());
|
psb = btSoftBodyHelpers::CreateFromVtkFile(deformWorld->getWorldInfo(), out_found_sim_filename.c_str());
|
||||||
btScalar corotated_mu, corotated_lambda;
|
btScalar corotated_mu, corotated_lambda;
|
||||||
if (clientCmd.m_updateFlags & LOAD_SOFT_BODY_ADD_COROTATED_FORCE)
|
if (clientCmd.m_updateFlags & LOAD_SOFT_BODY_ADD_COROTATED_FORCE)
|
||||||
{
|
{
|
||||||
@@ -8186,14 +8196,12 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar
|
|||||||
{
|
{
|
||||||
#ifndef SKIP_DEFORMABLE_BODY
|
#ifndef SKIP_DEFORMABLE_BODY
|
||||||
btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld();
|
btDeformableMultiBodyDynamicsWorld* deformWorld = getDeformableWorld();
|
||||||
bool foundRenderMesh = false;
|
|
||||||
if (deformWorld)
|
if (deformWorld)
|
||||||
{
|
{
|
||||||
if (!render_mesh_is_sim_mesh)
|
// load render mesh
|
||||||
|
if (out_found_sim_filename != out_found_filename)
|
||||||
{
|
{
|
||||||
// load render mesh
|
// load render mesh
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
tinyobj::attrib_t attribute;
|
tinyobj::attrib_t attribute;
|
||||||
std::vector<tinyobj::shape_t> shapes;
|
std::vector<tinyobj::shape_t> shapes;
|
||||||
@@ -8230,7 +8238,6 @@ bool PhysicsServerCommandProcessor::processLoadSoftBodyCommand(const struct Shar
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btSoftBodyHelpers::interpolateBarycentricWeights(psb);
|
btSoftBodyHelpers::interpolateBarycentricWeights(psb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ enum EnumLoadSoftBodyUpdateFlags
|
|||||||
LOAD_SOFT_BODY_ADD_NEOHOOKEAN_FORCE = 1<<12,
|
LOAD_SOFT_BODY_ADD_NEOHOOKEAN_FORCE = 1<<12,
|
||||||
LOAD_SOFT_BODY_USE_SELF_COLLISION = 1<<13,
|
LOAD_SOFT_BODY_USE_SELF_COLLISION = 1<<13,
|
||||||
LOAD_SOFT_BODY_USE_FACE_CONTACT = 1<<14,
|
LOAD_SOFT_BODY_USE_FACE_CONTACT = 1<<14,
|
||||||
LOAD_SOFT_BODY_RENDER_MESH = 1<<15,
|
LOAD_SOFT_BODY_SIM_MESH = 1<<15,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EnumSimParamInternalSimFlags
|
enum EnumSimParamInternalSimFlags
|
||||||
@@ -536,7 +536,7 @@ struct LoadSoftBodyArgs
|
|||||||
double m_NeoHookeanLambda;
|
double m_NeoHookeanLambda;
|
||||||
double m_NeoHookeanDamping;
|
double m_NeoHookeanDamping;
|
||||||
int m_useFaceContact;
|
int m_useFaceContact;
|
||||||
char m_renderFileName[MAX_FILENAME_LENGTH];
|
char m_simFileName[MAX_FILENAME_LENGTH];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct b3LoadSoftBodyResultArgs
|
struct b3LoadSoftBodyResultArgs
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ enum b3NotificationType
|
|||||||
|
|
||||||
enum b3ResetSimulationFlags
|
enum b3ResetSimulationFlags
|
||||||
{
|
{
|
||||||
RESET_USE_DEFORMABLE_WORLD=1,
|
RESET_USE_SOFT_MULTIBODY_WORLD=1,
|
||||||
RESET_USE_DISCRETE_DYNAMICS_WORLD=2,
|
RESET_USE_DISCRETE_DYNAMICS_WORLD=2,
|
||||||
RESET_USE_SIMPLE_BROADPHASE=4,
|
RESET_USE_SIMPLE_BROADPHASE=4,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user