~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
This software is provided 'as-is', without any express or implied warranty.
6
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, 
 
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
9
subject to the following restrictions:
10
10
 
11
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.
16
16
#include "btTriangleIndexVertexArray.h"
17
17
 
18
18
btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
 
19
: m_hasAabb(0)
19
20
{
20
21
        btIndexedMesh mesh;
21
 
        
 
22
 
22
23
        mesh.m_numTriangles = numTriangles;
23
24
        mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
24
25
        mesh.m_triangleIndexStride = triangleIndexStride;
25
26
        mesh.m_numVertices = numVertices;
26
27
        mesh.m_vertexBase = (const unsigned char *)vertexBase;
27
28
        mesh.m_vertexStride = vertexStride;
28
 
        
 
29
 
29
30
        addIndexedMesh(mesh);
30
31
 
31
32
}
32
33
 
 
34
btTriangleIndexVertexArray::~btTriangleIndexVertexArray()
 
35
{
 
36
 
 
37
}
 
38
 
33
39
void    btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
34
40
{
35
41
        btAssert(subpart< getNumSubParts() );
36
 
        
 
42
 
37
43
        btIndexedMesh& mesh = m_indexedMeshes[subpart];
38
44
 
39
45
        numverts = mesh.m_numVertices;
40
46
        (*vertexbase) = (unsigned char *) mesh.m_vertexBase;
 
47
        #ifdef BT_USE_DOUBLE_PRECISION
 
48
        type = PHY_DOUBLE;
 
49
        #else
41
50
        type = PHY_FLOAT;
 
51
        #endif
42
52
        vertexStride = mesh.m_vertexStride;
43
53
 
44
54
        numfaces = mesh.m_numTriangles;
45
55
 
46
56
        (*indexbase) = (unsigned char *)mesh.m_triangleIndexBase;
47
57
        indexstride = mesh.m_triangleIndexStride;
48
 
        indicestype = PHY_INTEGER;
 
58
        indicestype = mesh.m_indexType;
49
59
}
50
60
 
51
61
void    btTriangleIndexVertexArray::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const
54
64
 
55
65
        numverts = mesh.m_numVertices;
56
66
        (*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
 
67
        #ifdef BT_USE_DOUBLE_PRECISION
 
68
        type = PHY_DOUBLE;
 
69
        #else
57
70
        type = PHY_FLOAT;
 
71
        #endif
58
72
        vertexStride = mesh.m_vertexStride;
59
73
 
60
74
        numfaces = mesh.m_numTriangles;
61
75
        (*indexbase) = (const unsigned char *)mesh.m_triangleIndexBase;
62
76
        indexstride = mesh.m_triangleIndexStride;
63
 
        indicestype = PHY_INTEGER;
 
77
        indicestype = mesh.m_indexType;
 
78
}
 
79
 
 
80
bool    btTriangleIndexVertexArray::hasPremadeAabb() const
 
81
{
 
82
        return (m_hasAabb == 1);
 
83
}
 
84
 
 
85
void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
 
86
{
 
87
        m_aabbMin = aabbMin;
 
88
        m_aabbMax = aabbMax;
 
89
        m_hasAabb = 1; // this is intentionally an int see notes in header
 
90
}
 
91
 
 
92
void    btTriangleIndexVertexArray::getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const
 
93
{
 
94
        *aabbMin = m_aabbMin;
 
95
        *aabbMax = m_aabbMax;
64
96
}
65
97