~ubuntu-branches/ubuntu/lucid/blender/lucid

« back to all changes in this revision

Viewing changes to extern/bullet2/src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2009-08-06 22:32:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090806223219-8z4eej1u8levu4pz
Tags: 2.49a+dfsg-0ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control: Build-depend on python-2.6 rather than python-2.5.
  - debian/misc/*.desktop: Add Spanish translation to .desktop 
    files.
  - debian/pyversions: 2.6.
  - debian/rules: Clean *.o of source/blender/python/api2_2x/
* New upstream release (LP: #382153).
* Refreshed patches:
  - 01_sanitize_sys.patch
  - 02_tmp_in_HOME
  - 10_use_systemwide_ftgl
  - 70_portability_platform_detection
* Removed patches merged upstream:
  - 30_fix_python_syntax_warning
  - 90_ubuntu_ffmpeg_52_changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Bullet Continuous Collision Detection and Physics Library
3
 
Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
4
 
 
5
 
This software is provided 'as-is', without any express or implied warranty.
6
 
In no event will the authors be held liable for any damages arising from the use of this software.
7
 
Permission is granted to anyone to use this software for any purpose, 
8
 
including commercial applications, and to alter it and redistribute it freely, 
9
 
subject to the following restrictions:
10
 
 
11
 
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12
 
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
 
3. This notice may not be removed or altered from any source distribution.
14
 
*/
15
 
 
16
 
/// This file was created by Alex Silverman
17
 
 
18
 
#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
19
 
#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
20
 
 
21
 
#include "btBvhTriangleMeshShape.h"
22
 
#include "btMaterial.h"
23
 
 
24
 
///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution.
25
 
ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
26
 
{
27
 
    btAlignedObjectArray <btMaterial*> m_materialList;
28
 
    int ** m_triangleMaterials;
29
 
 
30
 
public:
31
 
 
32
 
        BT_DECLARE_ALIGNED_ALLOCATOR();
33
 
 
34
 
    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
35
 
    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
36
 
        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
37
 
        {
38
 
            btVector3 m_triangle[3];
39
 
            const unsigned char *vertexbase;
40
 
            int numverts;
41
 
            PHY_ScalarType type;
42
 
            int stride;
43
 
            const unsigned char *indexbase;
44
 
            int indexstride;
45
 
            int numfaces;
46
 
            PHY_ScalarType indicestype;
47
 
 
48
 
            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
49
 
 
50
 
            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
51
 
            {
52
 
                m_meshInterface->getLockedReadOnlyVertexIndexBase(
53
 
                    &vertexbase,
54
 
                    numverts,
55
 
                    type,
56
 
                    stride,
57
 
                    &indexbase,
58
 
                    indexstride,
59
 
                    numfaces,
60
 
                    indicestype,
61
 
                    i);
62
 
                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
63
 
            }
64
 
        }
65
 
 
66
 
        ///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
67
 
        btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
68
 
        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
69
 
        {
70
 
            btVector3 m_triangle[3];
71
 
            const unsigned char *vertexbase;
72
 
            int numverts;
73
 
            PHY_ScalarType type;
74
 
            int stride;
75
 
            const unsigned char *indexbase;
76
 
            int indexstride;
77
 
            int numfaces;
78
 
            PHY_ScalarType indicestype;
79
 
 
80
 
            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
81
 
 
82
 
            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
83
 
            {
84
 
                m_meshInterface->getLockedReadOnlyVertexIndexBase(
85
 
                    &vertexbase,
86
 
                    numverts,
87
 
                    type,
88
 
                    stride,
89
 
                    &indexbase,
90
 
                    indexstride,
91
 
                    numfaces,
92
 
                    indicestype,
93
 
                    i);
94
 
                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
95
 
            }
96
 
        }
97
 
        
98
 
    virtual ~btMultimaterialTriangleMeshShape()
99
 
    {
100
 
/*
101
 
        for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
102
 
        {
103
 
            btAlignedFree(m_materialValues[i]);
104
 
            m_materialLookup[i] = NULL;
105
 
        }
106
 
        btAlignedFree(m_materialValues);
107
 
        m_materialLookup = NULL;
108
 
*/
109
 
    }
110
 
        virtual int     getShapeType() const
111
 
        {
112
 
                return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
113
 
        }
114
 
        
115
 
        //debugging
116
 
        virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
117
 
 
118
 
    ///Obtains the material for a specific triangle
119
 
    const btMaterial * getMaterialProperties(int partID, int triIndex);
120
 
 
121
 
}
122
 
;
123
 
 
124
 
#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
 
1
/*
 
2
Bullet Continuous Collision Detection and Physics Library
 
3
Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
 
4
 
 
5
This software is provided 'as-is', without any express or implied warranty.
 
6
In no event will the authors be held liable for any damages arising from the use of this software.
 
7
Permission is granted to anyone to use this software for any purpose, 
 
8
including commercial applications, and to alter it and redistribute it freely, 
 
9
subject to the following restrictions:
 
10
 
 
11
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
 
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 
13
3. This notice may not be removed or altered from any source distribution.
 
14
*/
 
15
 
 
16
/// This file was created by Alex Silverman
 
17
 
 
18
#ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
 
19
#define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
 
20
 
 
21
#include "btBvhTriangleMeshShape.h"
 
22
#include "btMaterial.h"
 
23
 
 
24
///The BvhTriangleMaterialMeshShape extends the btBvhTriangleMeshShape. Its main contribution is the interface into a material array, which allows per-triangle friction and restitution.
 
25
ATTRIBUTE_ALIGNED16(class) btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
 
26
{
 
27
    btAlignedObjectArray <btMaterial*> m_materialList;
 
28
    int ** m_triangleMaterials;
 
29
 
 
30
public:
 
31
 
 
32
        BT_DECLARE_ALIGNED_ALLOCATOR();
 
33
 
 
34
    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
 
35
    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
 
36
        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
 
37
        {
 
38
            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
 
39
 
 
40
            btVector3 m_triangle[3];
 
41
            const unsigned char *vertexbase;
 
42
            int numverts;
 
43
            PHY_ScalarType type;
 
44
            int stride;
 
45
            const unsigned char *indexbase;
 
46
            int indexstride;
 
47
            int numfaces;
 
48
            PHY_ScalarType indicestype;
 
49
 
 
50
            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
 
51
 
 
52
            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
 
53
            {
 
54
                m_meshInterface->getLockedReadOnlyVertexIndexBase(
 
55
                    &vertexbase,
 
56
                    numverts,
 
57
                    type,
 
58
                    stride,
 
59
                    &indexbase,
 
60
                    indexstride,
 
61
                    numfaces,
 
62
                    indicestype,
 
63
                    i);
 
64
                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
 
65
            }
 
66
        }
 
67
 
 
68
        ///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
 
69
        btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
 
70
        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
 
71
        {
 
72
            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
 
73
 
 
74
            btVector3 m_triangle[3];
 
75
            const unsigned char *vertexbase;
 
76
            int numverts;
 
77
            PHY_ScalarType type;
 
78
            int stride;
 
79
            const unsigned char *indexbase;
 
80
            int indexstride;
 
81
            int numfaces;
 
82
            PHY_ScalarType indicestype;
 
83
 
 
84
            //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
 
85
 
 
86
            for(int i = 0; i < meshInterface->getNumSubParts(); i++)
 
87
            {
 
88
                m_meshInterface->getLockedReadOnlyVertexIndexBase(
 
89
                    &vertexbase,
 
90
                    numverts,
 
91
                    type,
 
92
                    stride,
 
93
                    &indexbase,
 
94
                    indexstride,
 
95
                    numfaces,
 
96
                    indicestype,
 
97
                    i);
 
98
                //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
 
99
            }
 
100
        }
 
101
        
 
102
    virtual ~btMultimaterialTriangleMeshShape()
 
103
    {
 
104
/*
 
105
        for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
 
106
        {
 
107
            btAlignedFree(m_materialValues[i]);
 
108
            m_materialLookup[i] = NULL;
 
109
        }
 
110
        btAlignedFree(m_materialValues);
 
111
        m_materialLookup = NULL;
 
112
*/
 
113
    }
 
114
        //debugging
 
115
        virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
 
116
 
 
117
    ///Obtains the material for a specific triangle
 
118
    const btMaterial * getMaterialProperties(int partID, int triIndex);
 
119
 
 
120
}
 
121
;
 
122
 
 
123
#endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H