Reverted incorrect merge (missing files)
[blender.git] / source / gameengine / Physics / Sumo / convert.txt
1 static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
2 {
3         DT_ShapeHandle shape = DT_NewComplexShape();
4         int numpolys = meshobj->NumPolygons();
5         int numvalidpolys = 0;
6         
7         for (int p=0; p<numpolys; p++)
8         {
9                 RAS_Polygon* poly = meshobj->GetPolygon(p);
10         
11                 // only add polygons that have the collisionflag set
12                 if (poly->IsCollider())
13                 {
14                         DT_Begin();
15                         for (int v=0; v<poly->VertexCount(); v++) {
16                                 MT_Point3 pt = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
17                                                                                                   poly->GetVertexIndexBase().m_indexarray[v],
18                                                                                                   poly->GetMaterial()->GetPolyMaterial())->xyz();
19                                 DT_Vertex(pt[0],pt[1],pt[2]);
20                         }
21                         DT_End();
22         
23                         numvalidpolys++;
24                 }
25         }
26         
27         DT_EndComplexShape();
28         
29         if (numvalidpolys==0) {
30                 delete shape;
31                 return NULL;
32         } else {
33                 return shape;
34         }
35 }