[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22906] trunk/blender/source/gameengine: bugfix [#19254] KX_PolyProxy returns improper VertexIndex with triangles, using .getVertexIndex() and .v1, .v2, etc.
Campbell Barton
ideasman42 at gmail.com
Mon Aug 31 05:36:03 CEST 2009
Revision: 22906
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22906
Author: campbellbarton
Date: 2009-08-31 05:36:02 +0200 (Mon, 31 Aug 2009)
Log Message:
-----------
bugfix [#19254] KX_PolyProxy returns improper VertexIndex with triangles, using .getVertexIndex() and .v1, .v2, etc.
Surprising this wasn't noticed before. Any mix of quads/tris caused the face verts of either quads/tries (whichever comes last).
Tested by exporting the KX_MeshProxy and re-importing as an OBJ.
This fix assumes there are only 2 m_darray's per face array which is currently true, but wont be if edge support is added back.
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp
trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.h
trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.cpp
trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.h
Modified: trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp 2009-08-31 01:58:11 UTC (rev 22905)
+++ trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp 2009-08-31 03:36:02 UTC (rev 22906)
@@ -140,19 +140,19 @@
}
if (!strcmp(attr_str, "v1"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(0));
+ return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
}
if (!strcmp(attr_str, "v2"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(1));
+ return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
}
if (!strcmp(attr_str, "v3"))
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(2));
+ return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
}
if (!strcmp(attr_str, "v4"))
{
- return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
+ return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
}
if (!strcmp(attr_str, "visible"))
{
@@ -255,7 +255,7 @@
}
if (index < m_polygon->VertexCount())
{
- return PyInt_FromLong(m_polygon->GetVertexOffset(index));
+ return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, index));
}
return PyInt_FromLong(0);
}
Modified: trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.h
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.h 2009-08-31 01:58:11 UTC (rev 22905)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.h 2009-08-31 03:36:02 UTC (rev 22906)
@@ -79,8 +79,11 @@
public:
vector<RAS_TexVert> m_vertex;
vector<unsigned short> m_index;
+ /* LINE currently isnt used */
enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type;
//RAS_MeshSlot *m_origSlot;
+
+ /* Number of RAS_MeshSlot using this array */
int m_users;
enum { BUCKET_MAX_INDEX = 65535 };
Modified: trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.cpp
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.cpp 2009-08-31 01:58:11 UTC (rev 22905)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.cpp 2009-08-31 03:36:02 UTC (rev 22906)
@@ -31,6 +31,7 @@
#endif
#include "RAS_Polygon.h"
+#include "RAS_MeshObject.h" /* only for GetVertexOffsetAbs */
RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
{
@@ -63,6 +64,20 @@
return m_offset[i];
}
+int RAS_Polygon::GetVertexOffsetAbs(RAS_MeshObject *mesh, int i)
+{
+ /* hack that only works because there can only ever be 2 different
+ * GetDisplayArray's per mesh. if this uses a different display array to the first
+ * then its incices are offset.
+ * if support for edges is added back this would need to be changed. */
+ RAS_DisplayArray* darray= mesh->GetPolygon(0)->GetDisplayArray();
+
+ if(m_darray != darray)
+ return m_offset[i] + darray->m_vertex.size();
+
+ return m_offset[i];
+}
+
/*
int RAS_Polygon::GetEdgeCode()
{
Modified: trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.h
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.h 2009-08-31 01:58:11 UTC (rev 22905)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_Polygon.h 2009-08-31 03:36:02 UTC (rev 22906)
@@ -68,6 +68,7 @@
void SetVertexOffset(int i, unsigned short offset);
int GetVertexOffset(int i);
+ int GetVertexOffsetAbs(RAS_MeshObject *mesh, int i); /* accounts for quad and tri arrays, slower, for python */
// each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
// - Not used yet!
More information about the Bf-blender-cvs
mailing list