Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp61
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h6
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp42
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.h24
4 files changed, 53 insertions, 80 deletions
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index d7ab88a6b06..4420f16c56d 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -68,8 +68,8 @@ RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer)
m_lightlayer(lightlayer),
m_zsort(false),
m_MeshMod(true),
- m_class(0),
- m_mesh(mesh)
+ m_mesh(mesh),
+ m_class(0)
{
}
@@ -259,18 +259,18 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray,
const MT_Vector3& normal,
bool flat,
RAS_IPolyMaterial* mat,
- int orgindex)
+ int origindex)
{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
+ KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray];
- RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0);
+ RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0,origindex);
#define KX_FIND_SHARED_VERTICES
#ifdef KX_FIND_SHARED_VERTICES
if(!flat) {
- for (std::vector<RAS_MatArrayIndex>::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin();
- it != m_xyz_index_to_vertex_index_mapping[orgindex].end();
+ for (std::vector<RAS_MatArrayIndex>::iterator it = m_xyz_index_to_vertex_index_mapping[origindex].begin();
+ it != m_xyz_index_to_vertex_index_mapping[origindex].end();
it++)
{
if ((*it).m_arrayindex1 == ao->m_index1 &&
@@ -293,22 +293,18 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray,
idx.m_array = vtxarray;
idx.m_index = numverts;
idx.m_matid = mat;
- m_xyz_index_to_vertex_index_mapping[orgindex].push_back(idx);
+ m_xyz_index_to_vertex_index_mapping[origindex].push_back(idx);
return numverts;
}
-
-
-const vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat)
+vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat)
{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
+ KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
return ao->m_VertexArrayCache1;
}
-
-
int RAS_MeshObject::GetVertexArrayLength(RAS_IPolyMaterial* mat)
{
int len = 0;
@@ -362,7 +358,7 @@ RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat)
{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
+ KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
return ao->m_IndexArrayCache1;
}
@@ -371,16 +367,27 @@ const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat)
KX_ArrayOptimizer* RAS_MeshObject::GetArrayOptimizer(RAS_IPolyMaterial* polymat)
{
- KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]);
+ KX_ArrayOptimizer** aop = m_matVertexArrayS[polymat];
- if (aop)
+ if(aop)
return *aop;
+ // didn't find array, but an array might already exist
+ // for a material equal to this one
+ for(int i=0;i<m_matVertexArrayS.size();i++) {
+ RAS_IPolyMaterial *mat = (RAS_IPolyMaterial*)(m_matVertexArrayS.getKey(i)->getValue());
+ if(*mat == *polymat) {
+ m_matVertexArrayS.insert(polymat, *m_matVertexArrayS.at(i));
+ return *m_matVertexArrayS.at(i);
+ }
+ }
+
+ // create new array
int numelements = m_matVertexArrayS.size();
m_sortedMaterials.push_back(polymat);
-
+
KX_ArrayOptimizer* ao = new KX_ArrayOptimizer(numelements);
- m_matVertexArrayS.insert(*polymat,ao);
+ m_matVertexArrayS.insert(polymat, ao);
return ao;
}
@@ -463,7 +470,7 @@ RAS_TexVert* RAS_MeshObject::GetVertex(short array,
unsigned int index,
RAS_IPolyMaterial* polymat)
{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);//*(m_matVertexArrays[*polymat]);
+ KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);
return &((*(ao->m_VertexArrayCache1)[array])[index]);
}
@@ -471,13 +478,19 @@ RAS_TexVert* RAS_MeshObject::GetVertex(short array,
void RAS_MeshObject::ClearArrayData()
{
- for (int i=0;i<m_matVertexArrayS.size();i++)
- {
+ for (int i=0;i<m_matVertexArrayS.size();i++) {
KX_ArrayOptimizer** ao = m_matVertexArrayS.at(i);
+
+ // we have duplicate entries, only free once
+ for(int j=i+1;j<m_matVertexArrayS.size();j++) {
+ if(ao == m_matVertexArrayS.at(j)) {
+ ao = NULL;
+ break;
+ }
+ }
+
if (ao)
- {
delete *ao;
- }
}
}
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
index d9aa133efb2..0d06748f91f 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.h
@@ -142,7 +142,7 @@ protected:
enum { BUCKET_MAX_INDICES = 65535 };//2048};//8192};
enum { BUCKET_MAX_TRIANGLES = 65535 };
- GEN_Map<class RAS_IPolyMaterial,KX_ArrayOptimizer*> m_matVertexArrayS;
+ GEN_Map<GEN_HashedPtr,KX_ArrayOptimizer*> m_matVertexArrayS;
RAS_MaterialBucket::Set m_materials;
Mesh* m_mesh;
@@ -242,10 +242,10 @@ public:
const MT_Vector3& normal,
bool flat,
RAS_IPolyMaterial* mat,
- int orgindex
+ int origindex
);
- const vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat);
+ vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat);
int GetVertexArrayLength(RAS_IPolyMaterial* mat);
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
index 61ac456b2bc..935633dc636 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp
@@ -40,7 +40,8 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
const MT_Vector4& tangent,
const unsigned int rgba,
const MT_Vector3& normal,
- const short flag)
+ const short flag,
+ const unsigned int origindex)
{
xyz.getValue(m_localxyz);
uv.getValue(m_uv1);
@@ -49,6 +50,7 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
SetNormal(normal);
tangent.getValue(m_tangent);
m_flag = flag;
+ m_origindex = origindex;
m_unit = 2;
}
@@ -107,44 +109,6 @@ void RAS_TexVert::SetNormal(const MT_Vector3& normal)
normal.getValue(m_normal);
}
-#ifndef RAS_TexVert_INLINE
-
-// leave multiline for debugging
-const float* RAS_TexVert::getUV1 () const
-{
- return m_uv1;
-}
-
-const float* RAS_TexVert::getUV2 () const
-{
- return m_uv2;
-}
-
-
-
-const float* RAS_TexVert::getNormal() const
-{
- return m_normal;
-}
-
-const float* RAS_TexVert::getTangent() const
-{
- return m_tangent;
-}
-
-
-const float* RAS_TexVert::getLocalXYZ() const
-{
- return m_localxyz;
-}
-
-const unsigned char* RAS_TexVert::getRGBA() const
-{
- return (unsigned char*) &m_rgba;
-}
-
-#endif
-
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h
index 84135db918f..bf092b4b230 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.h
+++ b/source/gameengine/Rasterizer/RAS_TexVert.h
@@ -42,8 +42,6 @@ static MT_Point2 g_pt2;
#define TV_MAX 3//match Def in BL_Material.h
-#define RAS_TexVert_INLINE 1
-
class RAS_TexVert
{
@@ -55,9 +53,10 @@ class RAS_TexVert
float m_normal[3]; // 3*2 = 6
short m_flag; // 2
unsigned int m_unit; // 4
+ unsigned int m_origindex; // 4
//---------
- // 52
- //32 bytes total size, fits nice = 52 = not fit nice.
+ // 56
+ // 32 bytes total size, fits nice = 56 = not fit nice.
// We'll go for 64 bytes total size - 24 bytes left.
public:
short getFlag() const;
@@ -71,11 +70,10 @@ public:
const MT_Vector4& tangent,
const unsigned int rgba,
const MT_Vector3& normal,
- const short flag);
+ const short flag,
+ const unsigned int origindex);
~RAS_TexVert() {};
- // leave multiline for debugging
-#ifdef RAS_TexVert_INLINE
const float* getUV1 () const {
return m_uv1;
};
@@ -99,13 +97,11 @@ public:
const unsigned char* getRGBA() const {
return (unsigned char *) &m_rgba;
}
-#else
- const float* getUV1 () const;
- const float* getUV2 () const;
- const float* getNormal() const;
- const float* getLocalXYZ() const;
- const unsigned char* getRGBA() const;
-#endif
+
+ const unsigned int getOrigIndex() const {
+ return m_origindex;
+ }
+
void SetXYZ(const MT_Point3& xyz);
void SetUV(const MT_Point2& uv);
void SetUV2(const MT_Point2& uv);