Autoformat selection for soft body, btDbvt related classes (no code change, just layout using Visual Studio)
This commit is contained in:
@@ -22,57 +22,57 @@ subject to the following restrictions:
|
||||
|
||||
//
|
||||
static void drawVertex( btIDebugDraw* idraw,
|
||||
const btVector3& x,btScalar s,const btVector3& c)
|
||||
{
|
||||
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
||||
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
||||
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
||||
}
|
||||
const btVector3& x,btScalar s,const btVector3& c)
|
||||
{
|
||||
idraw->drawLine(x-btVector3(s,0,0),x+btVector3(s,0,0),c);
|
||||
idraw->drawLine(x-btVector3(0,s,0),x+btVector3(0,s,0),c);
|
||||
idraw->drawLine(x-btVector3(0,0,s),x+btVector3(0,0,s),c);
|
||||
}
|
||||
|
||||
//
|
||||
static void drawBox( btIDebugDraw* idraw,
|
||||
const btVector3& mins,
|
||||
const btVector3& maxs,
|
||||
const btVector3& color)
|
||||
const btVector3& mins,
|
||||
const btVector3& maxs,
|
||||
const btVector3& color)
|
||||
{
|
||||
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
||||
btVector3(mins.x(),maxs.y(),maxs.z())};
|
||||
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
||||
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
||||
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
||||
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
||||
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
||||
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
||||
const btVector3 c[]={ btVector3(mins.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),mins.y(),mins.z()),
|
||||
btVector3(maxs.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),maxs.y(),mins.z()),
|
||||
btVector3(mins.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),mins.y(),maxs.z()),
|
||||
btVector3(maxs.x(),maxs.y(),maxs.z()),
|
||||
btVector3(mins.x(),maxs.y(),maxs.z())};
|
||||
idraw->drawLine(c[0],c[1],color);idraw->drawLine(c[1],c[2],color);
|
||||
idraw->drawLine(c[2],c[3],color);idraw->drawLine(c[3],c[0],color);
|
||||
idraw->drawLine(c[4],c[5],color);idraw->drawLine(c[5],c[6],color);
|
||||
idraw->drawLine(c[6],c[7],color);idraw->drawLine(c[7],c[4],color);
|
||||
idraw->drawLine(c[0],c[4],color);idraw->drawLine(c[1],c[5],color);
|
||||
idraw->drawLine(c[2],c[6],color);idraw->drawLine(c[3],c[7],color);
|
||||
}
|
||||
|
||||
//
|
||||
static void drawTree( btIDebugDraw* idraw,
|
||||
const btDbvtNode* node,
|
||||
int depth,
|
||||
const btVector3& ncolor,
|
||||
const btVector3& lcolor,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
const btDbvtNode* node,
|
||||
int depth,
|
||||
const btVector3& ncolor,
|
||||
const btVector3& lcolor,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
if(node)
|
||||
if(node)
|
||||
{
|
||||
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
||||
if(node->isinternal()&&((depth<maxdepth)||(maxdepth<0)))
|
||||
{
|
||||
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[0],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
drawTree(idraw,node->childs[1],depth+1,ncolor,lcolor,mindepth,maxdepth);
|
||||
}
|
||||
if(depth>=mindepth)
|
||||
if(depth>=mindepth)
|
||||
{
|
||||
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
||||
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
||||
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
||||
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
||||
const btScalar scl=(btScalar)(node->isinternal()?1:1);
|
||||
const btVector3 mi=node->volume.Center()-node->volume.Extents()*scl;
|
||||
const btVector3 mx=node->volume.Center()+node->volume.Extents()*scl;
|
||||
drawBox(idraw,mi,mx,node->isleaf()?lcolor:ncolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,25 +81,25 @@ if(node)
|
||||
template <typename T>
|
||||
static inline T sum(const btAlignedObjectArray<T>& items)
|
||||
{
|
||||
T v;
|
||||
if(items.size())
|
||||
T v;
|
||||
if(items.size())
|
||||
{
|
||||
v=items[0];
|
||||
for(int i=1,ni=items.size();i<ni;++i)
|
||||
v=items[0];
|
||||
for(int i=1,ni=items.size();i<ni;++i)
|
||||
{
|
||||
v+=items[i];
|
||||
v+=items[i];
|
||||
}
|
||||
}
|
||||
return(v);
|
||||
return(v);
|
||||
}
|
||||
|
||||
//
|
||||
template <typename T,typename Q>
|
||||
static inline void add(btAlignedObjectArray<T>& items,const Q& value)
|
||||
{
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
{
|
||||
items[i]+=value;
|
||||
items[i]+=value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ for(int i=0,ni=items.size();i<ni;++i)
|
||||
template <typename T,typename Q>
|
||||
static inline void mul(btAlignedObjectArray<T>& items,const Q& value)
|
||||
{
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
for(int i=0,ni=items.size();i<ni;++i)
|
||||
{
|
||||
items[i]*=value;
|
||||
items[i]*=value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ for(int i=0,ni=items.size();i<ni;++i)
|
||||
template <typename T>
|
||||
static inline T average(const btAlignedObjectArray<T>& items)
|
||||
{
|
||||
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
||||
return(sum(items)/n);
|
||||
const btScalar n=(btScalar)(items.size()>0?items.size():1);
|
||||
return(sum(items)/n);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -136,27 +136,27 @@ static inline btScalar tetravolume(const btVector3& x0,
|
||||
//
|
||||
#if 0
|
||||
static btVector3 stresscolor(btScalar stress)
|
||||
{
|
||||
{
|
||||
static const btVector3 spectrum[]= { btVector3(1,0,1),
|
||||
btVector3(0,0,1),
|
||||
btVector3(0,1,1),
|
||||
btVector3(0,1,0),
|
||||
btVector3(1,1,0),
|
||||
btVector3(1,0,0),
|
||||
btVector3(1,0,0)};
|
||||
btVector3(0,0,1),
|
||||
btVector3(0,1,1),
|
||||
btVector3(0,1,0),
|
||||
btVector3(1,1,0),
|
||||
btVector3(1,0,0),
|
||||
btVector3(1,0,0)};
|
||||
static const int ncolors=sizeof(spectrum)/sizeof(spectrum[0])-1;
|
||||
static const btScalar one=1;
|
||||
stress=btMax<btScalar>(0,btMin<btScalar>(1,stress))*ncolors;
|
||||
const int sel=(int)stress;
|
||||
const btScalar frc=stress-sel;
|
||||
return(spectrum[sel]+(spectrum[sel+1]-spectrum[sel])*frc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags)
|
||||
btIDebugDraw* idraw,
|
||||
int drawflags)
|
||||
{
|
||||
const btScalar scl=(btScalar)0.1;
|
||||
const btScalar nscl=scl*5;
|
||||
@@ -251,29 +251,29 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
const btVector3 x[]={f.m_n[0]->m_x,f.m_n[1]->m_x,f.m_n[2]->m_x};
|
||||
const btVector3 c=(x[0]+x[1]+x[2])/3;
|
||||
idraw->drawTriangle((x[0]-c)*scl+c,
|
||||
(x[1]-c)*scl+c,
|
||||
(x[2]-c)*scl+c,
|
||||
col,alp);
|
||||
(x[1]-c)*scl+c,
|
||||
(x[2]-c)*scl+c,
|
||||
col,alp);
|
||||
}
|
||||
}
|
||||
/* Clusters */
|
||||
if(0!=(drawflags&fDrawFlags::Clusters))
|
||||
{
|
||||
{
|
||||
srand(1806);
|
||||
for(i=0;i<psb->m_clusters.size();++i)
|
||||
{
|
||||
{
|
||||
if(psb->m_clusters[i]->m_collide)
|
||||
{
|
||||
{
|
||||
btVector3 color( rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX);
|
||||
rand()/(btScalar)RAND_MAX,
|
||||
rand()/(btScalar)RAND_MAX);
|
||||
color=color.normalized()*0.75;
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
vertices.resize(psb->m_clusters[i]->m_nodes.size());
|
||||
for(j=0,nj=vertices.size();j<nj;++j)
|
||||
{
|
||||
{
|
||||
vertices[j]=psb->m_clusters[i]->m_nodes[j]->m_x;
|
||||
}
|
||||
}
|
||||
HullDesc hdsc(QF_TRIANGLES,vertices.size(),&vertices[0]);
|
||||
HullResult hres;
|
||||
HullLibrary hlib;
|
||||
@@ -284,32 +284,32 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
mul(hres.m_OutputVertices,(btScalar)1);
|
||||
add(hres.m_OutputVertices,center);
|
||||
for(j=0;j<(int)hres.mNumFaces;++j)
|
||||
{
|
||||
{
|
||||
const int idx[]={hres.m_Indices[j*3+0],hres.m_Indices[j*3+1],hres.m_Indices[j*3+2]};
|
||||
idraw->drawTriangle(hres.m_OutputVertices[idx[0]],
|
||||
hres.m_OutputVertices[idx[1]],
|
||||
hres.m_OutputVertices[idx[2]],
|
||||
color,1);
|
||||
}
|
||||
hlib.ReleaseResult(hres);
|
||||
hres.m_OutputVertices[idx[1]],
|
||||
hres.m_OutputVertices[idx[2]],
|
||||
color,1);
|
||||
}
|
||||
hlib.ReleaseResult(hres);
|
||||
}
|
||||
/* Velocities */
|
||||
#if 0
|
||||
#if 0
|
||||
for(int j=0;j<psb->m_clusters[i].m_nodes.size();++j)
|
||||
{
|
||||
{
|
||||
const btSoftBody::Cluster& c=psb->m_clusters[i];
|
||||
const btVector3 r=c.m_nodes[j]->m_x-c.m_com;
|
||||
const btVector3 v=c.m_lv+cross(c.m_av,r);
|
||||
idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/* Frame */
|
||||
btSoftBody::Cluster& c=*psb->m_clusters[i];
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(10,0,0),btVector3(1,0,0));
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,10,0),btVector3(0,1,0));
|
||||
idraw->drawLine(c.m_com,c.m_framexform*btVector3(0,0,10),btVector3(0,0,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Notes */
|
||||
if(0!=(drawflags&fDrawFlags::Notes))
|
||||
{
|
||||
@@ -318,9 +318,9 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
const btSoftBody::Note& n=psb->m_notes[i];
|
||||
btVector3 p=n.m_offset;
|
||||
for(int j=0;j<n.m_rank;++j)
|
||||
{
|
||||
{
|
||||
p+=n.m_nodes[j]->m_x*n.m_coords[j];
|
||||
}
|
||||
}
|
||||
idraw->draw3dText(p,n.m_text);
|
||||
}
|
||||
}
|
||||
@@ -333,33 +333,33 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
/* Joints */
|
||||
if(0!=(drawflags&fDrawFlags::Joints))
|
||||
{
|
||||
for(i=0;i<psb->m_joints.size();++i)
|
||||
for(i=0;i<psb->m_joints.size();++i)
|
||||
{
|
||||
const btSoftBody::Joint* pj=psb->m_joints[i];
|
||||
switch(pj->Type())
|
||||
const btSoftBody::Joint* pj=psb->m_joints[i];
|
||||
switch(pj->Type())
|
||||
{
|
||||
case btSoftBody::Joint::eType::Linear:
|
||||
{
|
||||
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
||||
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
||||
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
||||
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
||||
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
||||
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
||||
const btSoftBody::LJoint* pjl=(const btSoftBody::LJoint*)pj;
|
||||
const btVector3 a0=pj->m_bodies[0].xform()*pjl->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform()*pjl->m_refs[1];
|
||||
idraw->drawLine(pj->m_bodies[0].xform().getOrigin(),a0,btVector3(1,1,0));
|
||||
idraw->drawLine(pj->m_bodies[1].xform().getOrigin(),a1,btVector3(0,1,1));
|
||||
drawVertex(idraw,a0,0.25,btVector3(1,1,0));
|
||||
drawVertex(idraw,a1,0.25,btVector3(0,1,1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case btSoftBody::Joint::eType::Angular:
|
||||
{
|
||||
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
||||
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
||||
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
||||
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
||||
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
||||
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
||||
const btSoftBody::AJoint* pja=(const btSoftBody::AJoint*)pj;
|
||||
const btVector3 o0=pj->m_bodies[0].xform().getOrigin();
|
||||
const btVector3 o1=pj->m_bodies[1].xform().getOrigin();
|
||||
const btVector3 a0=pj->m_bodies[0].xform().getBasis()*pj->m_refs[0];
|
||||
const btVector3 a1=pj->m_bodies[1].xform().getBasis()*pj->m_refs[1];
|
||||
idraw->drawLine(o0,o0+a0*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o0,o0+a1*10,btVector3(1,1,0));
|
||||
idraw->drawLine(o1,o1+a0*10,btVector3(0,1,1));
|
||||
idraw->drawLine(o1,o1+a1*10,btVector3(0,1,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,10 +368,10 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool /*stress*/)
|
||||
btIDebugDraw* idraw,
|
||||
bool masses,
|
||||
bool areas,
|
||||
bool /*stress*/)
|
||||
{
|
||||
for(int i=0;i<psb->m_nodes.size();++i)
|
||||
{
|
||||
@@ -394,34 +394,34 @@ void btSoftBodyHelpers::DrawInfos( btSoftBody* psb,
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawNodeTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_ndbvt.m_root,0,btVector3(1,0,1),btVector3(1,1,1),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawFaceTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_fdbvt.m_root,0,btVector3(0,1,0),btVector3(1,0,0),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawClusterTree( btSoftBody* psb,
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
btIDebugDraw* idraw,
|
||||
int mindepth,
|
||||
int maxdepth)
|
||||
{
|
||||
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
||||
drawTree(idraw,psb->m_cdbvt.m_root,0,btVector3(0,1,1),btVector3(1,0,0),mindepth,maxdepth);
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
||||
btIDebugDraw* idraw)
|
||||
btIDebugDraw* idraw)
|
||||
{
|
||||
if(psb->m_pose.m_bframe)
|
||||
{
|
||||
@@ -445,9 +445,9 @@ void btSoftBodyHelpers::DrawFrame( btSoftBody* psb,
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, const btVector3& from,
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds)
|
||||
const btVector3& to,
|
||||
int res,
|
||||
int fixeds)
|
||||
{
|
||||
/* Create nodes */
|
||||
const int r=res+2;
|
||||
@@ -477,13 +477,13 @@ btSoftBody* btSoftBodyHelpers::CreateRope( btSoftBodyWorldInfo& worldInfo, cons
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags)
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags)
|
||||
{
|
||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||
/* Create nodes */
|
||||
@@ -554,83 +554,83 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo,const
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords)
|
||||
const btVector3& corner00,
|
||||
const btVector3& corner10,
|
||||
const btVector3& corner01,
|
||||
const btVector3& corner11,
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags,
|
||||
float* tex_coords)
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
* corners:
|
||||
*
|
||||
* [0][0] corner00 ------- corner01 [resx][0]
|
||||
* | |
|
||||
* | |
|
||||
* [0][resy] corner10 -------- corner11 [resx][resy]
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* "fixedgs" map:
|
||||
*
|
||||
* corner00 --> +1
|
||||
* corner01 --> +2
|
||||
* corner10 --> +4
|
||||
* corner11 --> +8
|
||||
* upper middle --> +16
|
||||
* left middle --> +32
|
||||
* right middle --> +64
|
||||
* lower middle --> +128
|
||||
* center --> +256
|
||||
*
|
||||
*
|
||||
* tex_coords size (resx-1)*(resy-1)*12
|
||||
*
|
||||
*
|
||||
*
|
||||
* SINGLE QUAD INTERNALS
|
||||
*
|
||||
* 1) btSoftBody's nodes and links,
|
||||
* diagonal link is optional ("gendiags")
|
||||
*
|
||||
*
|
||||
* node00 ------ node01
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* node10 node11
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2) Faces:
|
||||
* two triangles,
|
||||
* UV Coordinates (hier example for single quad)
|
||||
*
|
||||
* (0,1) (0,1) (1,1)
|
||||
* 1 |\ 3 \-----| 2
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* 2 |-----\ 3 \| 1
|
||||
* (0,0) (1,0) (1,0)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* corners:
|
||||
*
|
||||
* [0][0] corner00 ------- corner01 [resx][0]
|
||||
* | |
|
||||
* | |
|
||||
* [0][resy] corner10 -------- corner11 [resx][resy]
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* "fixedgs" map:
|
||||
*
|
||||
* corner00 --> +1
|
||||
* corner01 --> +2
|
||||
* corner10 --> +4
|
||||
* corner11 --> +8
|
||||
* upper middle --> +16
|
||||
* left middle --> +32
|
||||
* right middle --> +64
|
||||
* lower middle --> +128
|
||||
* center --> +256
|
||||
*
|
||||
*
|
||||
* tex_coords size (resx-1)*(resy-1)*12
|
||||
*
|
||||
*
|
||||
*
|
||||
* SINGLE QUAD INTERNALS
|
||||
*
|
||||
* 1) btSoftBody's nodes and links,
|
||||
* diagonal link is optional ("gendiags")
|
||||
*
|
||||
*
|
||||
* node00 ------ node01
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* | .
|
||||
* node10 node11
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2) Faces:
|
||||
* two triangles,
|
||||
* UV Coordinates (hier example for single quad)
|
||||
*
|
||||
* (0,1) (0,1) (1,1)
|
||||
* 1 |\ 3 \-----| 2
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* | \ \ |
|
||||
* 2 |-----\ 3 \| 1
|
||||
* (0,0) (1,0) (1,0)
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define IDX(_x_,_y_) ((_y_)*rx+(_x_))
|
||||
/* Create nodes */
|
||||
@@ -675,12 +675,12 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
{
|
||||
const bool mdx=(ix+1)<rx;
|
||||
const bool mdy=(iy+1)<ry;
|
||||
|
||||
|
||||
int node00=IDX(ix,iy);
|
||||
int node01=IDX(ix+1,iy);
|
||||
int node10=IDX(ix,iy+1);
|
||||
int node11=IDX(ix+1,iy+1);
|
||||
|
||||
|
||||
if(mdx) psb->appendLink(node00,node01);
|
||||
if(mdy) psb->appendLink(node00,node10);
|
||||
if(mdx&&mdy)
|
||||
@@ -716,32 +716,32 @@ btSoftBody* btSoftBodyHelpers::CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
float btSoftBodyHelpers::CalculateUV(int resx,int resy,int ix,int iy,int id)
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* node00 --- node01
|
||||
* | |
|
||||
* node10 --- node11
|
||||
*
|
||||
*
|
||||
* ID map:
|
||||
*
|
||||
* node00 s --> 0
|
||||
* node00 t --> 1
|
||||
*
|
||||
* node01 s --> 3
|
||||
* node01 t --> 1
|
||||
*
|
||||
* node10 s --> 0
|
||||
* node10 t --> 2
|
||||
*
|
||||
* node11 s --> 3
|
||||
* node11 t --> 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*
|
||||
*
|
||||
* node00 --- node01
|
||||
* | |
|
||||
* node10 --- node11
|
||||
*
|
||||
*
|
||||
* ID map:
|
||||
*
|
||||
* node00 s --> 0
|
||||
* node00 t --> 1
|
||||
*
|
||||
* node01 s --> 3
|
||||
* node01 t --> 1
|
||||
*
|
||||
* node10 s --> 0
|
||||
* node10 t --> 2
|
||||
*
|
||||
* node11 s --> 3
|
||||
* node11 t --> 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
float tc=0.0f;
|
||||
float tc=0.0f;
|
||||
if (id == 0) {
|
||||
tc = (1.0f/((resx-1))*ix);
|
||||
}
|
||||
@@ -754,12 +754,12 @@ float tc=0.0f;
|
||||
else if (id==3) {
|
||||
tc = (1.0f/((resx-1))*(ix+1));
|
||||
}
|
||||
return tc;
|
||||
return tc;
|
||||
}
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,const btVector3& center,
|
||||
const btVector3& radius,
|
||||
int res)
|
||||
const btVector3& radius,
|
||||
int res)
|
||||
{
|
||||
struct Hammersley
|
||||
{
|
||||
@@ -790,8 +790,8 @@ btSoftBody* btSoftBodyHelpers::CreateEllipsoid(btSoftBodyWorldInfo& worldInfo,c
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo,const btScalar* vertices,
|
||||
const int* triangles,
|
||||
int ntriangles)
|
||||
const int* triangles,
|
||||
int ntriangles)
|
||||
{
|
||||
int maxidx=0;
|
||||
int i,j,ni;
|
||||
@@ -832,7 +832,7 @@ btSoftBody* btSoftBodyHelpers::CreateFromTriMesh(btSoftBodyWorldInfo& worldInfo
|
||||
|
||||
//
|
||||
btSoftBody* btSoftBodyHelpers::CreateFromConvexHull(btSoftBodyWorldInfo& worldInfo, const btVector3* vertices,
|
||||
int nvertices)
|
||||
int nvertices)
|
||||
{
|
||||
HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
|
||||
HullResult hres;
|
||||
|
||||
Reference in New Issue
Block a user