void setTransform(const HACD::SimpleBone &b,int32_t bone_index) { mBoneName = b.mBoneName; mBoneIndex = bone_index; mParentIndex = b.mParentIndex; memcpy(mTransform,b.mTransform,sizeof(float)*16); if ( mVertexCount ) { for (uint32_t i=0; i<mVertexCount; i++) { float *vtx = &mVertices[i*3]; fm_transform(b.mInverseTransform,vtx,vtx); // inverse transform the point into bone relative object space } } }
bool computeSplitPlane(unsigned int vcount, const double *vertices, unsigned int tcount, const unsigned int *indices, ConvexDecompInterface *callback, double *plane) { bool cret = false; double sides[3]; double matrix[16]; computeBestFitOBB( vcount, vertices, sizeof(double)*3, sides, matrix ); double bmax[3]; double bmin[3]; bmax[0] = sides[0]*0.5f; bmax[1] = sides[1]*0.5f; bmax[2] = sides[2]*0.5f; bmin[0] = -bmax[0]; bmin[1] = -bmax[1]; bmin[2] = -bmax[2]; double dx = sides[0]; double dy = sides[1]; double dz = sides[2]; double laxis = dx; unsigned int axis = 0; if ( dy > dx ) { axis = 1; laxis = dy; } if ( dz > dx && dz > dy ) { axis = 2; laxis = dz; } double p1[3]; double p2[3]; double p3[3]; p3[0] = p2[0] = p1[0] = bmin[0] + dx*0.5f; p3[1] = p2[1] = p1[1] = bmin[1] + dy*0.5f; p3[2] = p2[2] = p1[2] = bmin[2] + dz*0.5f; Rect3d b(bmin,bmax); Rect3d b1,b2; splitRect(axis,b,b1,b2,p1); // callback->ConvexDebugBound(b1.mMin,b1.mMax,0x00FF00); // callback->ConvexDebugBound(b2.mMin,b2.mMax,0xFFFF00); switch ( axis ) { case 0: p2[1] = bmin[1]; p2[2] = bmin[2]; if ( dz > dy ) { p3[1] = bmax[1]; p3[2] = bmin[2]; } else { p3[1] = bmin[1]; p3[2] = bmax[2]; } break; case 1: p2[0] = bmin[0]; p2[2] = bmin[2]; if ( dx > dz ) { p3[0] = bmax[0]; p3[2] = bmin[2]; } else { p3[0] = bmin[0]; p3[2] = bmax[2]; } break; case 2: p2[0] = bmin[0]; p2[1] = bmin[1]; if ( dx > dy ) { p3[0] = bmax[0]; p3[1] = bmin[1]; } else { p3[0] = bmin[0]; p3[1] = bmax[1]; } break; } double tp1[3]; double tp2[3]; double tp3[3]; fm_transform(matrix,p1,tp1); fm_transform(matrix,p2,tp2); fm_transform(matrix,p3,tp3); // callback->ConvexDebugTri(p1,p2,p3,0xFF0000); computePlane(tp1,tp2,tp3,plane); return true; }