fixed a bug that prevented kitchens/1.sdf to render properly (local scaling was double applied)

disable some left-over clipping that was moved to another part of the code
This commit is contained in:
Erwin Coumans 2017-04-06 21:13:23 -07:00
parent d6125ecb8c
commit 82b576a390
3 changed files with 16 additions and 17 deletions

View File

@ -746,16 +746,13 @@ upAxisMat.setIdentity();
btTriangleMesh* meshInterface = new btTriangleMesh(); btTriangleMesh* meshInterface = new btTriangleMesh();
for (int i=0; i<glmesh->m_numIndices/3; i++) for (int i=0; i<glmesh->m_numIndices/3; i++)
{ {
float* v0 = glmesh->m_vertices->at(glmesh->m_indices->at(i*3)).xyzw; const btVector3& v0 = convertedVerts[glmesh->m_indices->at(i*3)];
float* v1 = glmesh->m_vertices->at(glmesh->m_indices->at(i*3+1)).xyzw; const btVector3& v1 = convertedVerts[glmesh->m_indices->at(i*3+1)];
float* v2 = glmesh->m_vertices->at(glmesh->m_indices->at(i*3+2)).xyzw; const btVector3& v2 = convertedVerts[glmesh->m_indices->at(i*3+2)];
meshInterface->addTriangle( meshInterface->addTriangle(v0,v1,v2);
btVector3(v0[0],v0[1],v0[2]),
btVector3(v1[0],v1[1],v1[2]),
btVector3(v2[0],v2[1],v2[2]));
} }
btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true,true); btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true,true);
trimesh->setLocalScaling(collision->m_geometry.m_meshScale); //trimesh->setLocalScaling(collision->m_geometry.m_meshScale);
shape = trimesh; shape = trimesh;
} else } else
@ -765,7 +762,7 @@ upAxisMat.setIdentity();
convexHull->optimizeConvexHull(); convexHull->optimizeConvexHull();
//convexHull->initializePolyhedralFeatures(); //convexHull->initializePolyhedralFeatures();
convexHull->setMargin(gUrdfDefaultCollisionMargin); convexHull->setMargin(gUrdfDefaultCollisionMargin);
convexHull->setLocalScaling(collision->m_geometry.m_meshScale); //convexHull->setLocalScaling(collision->m_geometry.m_meshScale);
shape = convexHull; shape = convexHull;
} }

View File

@ -89,10 +89,10 @@ protected:
virtual void resetCamera() virtual void resetCamera()
{ {
float dist = 4; float dist = 3.45;
float pitch = 193; float pitch = 287;
float yaw = 25; float yaw = 16.2;
float targetPos[3]={0,0,0.5};//-3,2.8,-2.5}; float targetPos[3]={2.05,0.02,0.53};//-3,2.8,-2.5};
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]); m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
} }
@ -256,7 +256,11 @@ void PhysicsClientExample::prepareAndSubmitCommand(int commandId)
case CMD_LOAD_SDF: case CMD_LOAD_SDF:
{ {
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "two_cubes.sdf");//kuka_iiwa/model.sdf"); #ifdef BT_DEBUG
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "two_cubes.sdf");
#else
b3SharedMemoryCommandHandle commandHandle = b3LoadSdfCommandInit(m_physicsClientHandle, "kitchens/1.sdf");//two_cubes.sdf");//kitchens/1.sdf");//kuka_iiwa/model.sdf");
#endif
b3SubmitClientCommand(m_physicsClientHandle, commandHandle); b3SubmitClientCommand(m_physicsClientHandle, commandHandle);
break; break;
} }

View File

@ -152,9 +152,7 @@ void triangle(mat<4,3,float> &clipc, IShader &shader, TGAImage &image, float *zb
void triangle(mat<4,3,float> &clipc, IShader &shader, TGAImage &image, float *zbuffer, int* segmentationMaskBuffer, const Matrix& viewPortMatrix, int objectIndex) { void triangle(mat<4,3,float> &clipc, IShader &shader, TGAImage &image, float *zbuffer, int* segmentationMaskBuffer, const Matrix& viewPortMatrix, int objectIndex) {
mat<3,4,float> pts = (viewPortMatrix*clipc).transpose(); // transposed to ease access to each of the points mat<3,4,float> pts = (viewPortMatrix*clipc).transpose(); // transposed to ease access to each of the points
//we don't clip triangles that cross the near plane, just discard them instead of showing artifacts
if (pts[0][3]<0 || pts[1][3] <0 || pts[2][3] <0)
return;
mat<3,2,float> pts2; mat<3,2,float> pts2;
for (int i=0; i<3; i++) pts2[i] = proj<2>(pts[i]/pts[i][3]); for (int i=0; i<3; i++) pts2[i] = proj<2>(pts[i]/pts[i][3]);