Page MenuHome

KX_PolyProxy has incorrect getVertexIndex results
Closed, ResolvedPublic

Description

This is a serious flaw in the API, which has occurred somewhere between Blender 2.64 and HEAD.

The values from getVertexIndex are (I believe) per bucket, which isn't respected in the getVertex call. I'm not sure whether the issue is in RAS_MeshObject or whether it is before this point, but essentially calling offset = slot->AddVertex(texvert) returns the bucket vertex index

Event Timeline

Angus Hollands (agoose77) raised the priority of this task from to Unbreak Now!.
Angus Hollands (agoose77) updated the task description. (Show Details)
Angus Hollands (agoose77) edited a custom field.

Revision: dee33e80970ff0b83a06b2dd5d23b8e25f7317df
Author: Campbell Barton <ideasman42@gmail.com>
Date: 01/05/2013 23:41:55
Message:
fix [#34609] mesh.getVertex doesn't work as spected with poly.getMaterialIndex() and poly vertex indexes

revert r22906 (own old commit, was incorrectly trying to make vertex indices absolute)

Modified: source/gameengine/Ketsji/KX_PolyProxy.cpp
Modified: source/gameengine/Rasterizer/RAS_Polygon.cpp
Modified: source/gameengine/Rasterizer/RAS_Polygon.h

This seems to be the culprit

Thomas Dinges (dingto) lowered the priority of this task from Unbreak Now! to 90.Jan 2 2014, 5:18 PM

"Unbreak now" is only meant for Release show stoppers.

My apologies, I had intended to set to medium.

@Angus Hollands (agoose77) I am not sure I understand the problem.

The documentation says this:
"Returns the mesh vertex index of a polygon vertex This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from MeshProxy."

The commit rBdee33e80970ff0b83a06b2dd5d23b8e25f7317df is already correcting something, are you saying it has a bug or that it is supposed to do something different?
I really don't know what this does or is supposed to do.

Originally, the commit by Campbell appeared to break things. Since then the issue has disappeared, so I think this can be closed!

Inês Almeida (brita_) changed the task status from Unknown Status to Resolved.Jul 30 2014, 6:33 PM
John Topple (Pickledtezcat) changed the task status from Resolved to Unknown Status.Nov 5 2014, 12:18 PM

I'm having trouble with this still, with Blender 2.72b (and before). Rather than open a new bug I'm going to reopen this one as it seems to be the same problem that never went away.

Some more details:
When using

poly = mesh.getPolygon(polyID)
        
        vert_length = poly.getNumVertex()
                    
        for v in range(vert_length):
            index = poly.getVertexIndex(v)
                            
            vertex = mesh.getVertex(0, index)   ### (the material index is 0 since there's only one material on the object).

The getVertexIndex() call is getting the wrong index in the following situations:

  1. when you have a mix of quads and triangles in a mesh.
  2. when you have more than one material in a mesh.

For illustration I've used a property to store xyz co-ordinates in poly groups captured from the mesh and then render.drawline to illustrate the results. You can see that all quad meshes and all triangle meshes are fine, but everything else just returns the wrong indexes. The objects are the same, just with some quads triangulated.

You can recreate the bug using this Blend:

Just run the game engine.

In a nutshell the problem is that the poly.getVertexIndex as well as the poly.v1 poly.v2 poly.v3 poly.v4 functions (I tested them too with the same result) to return constituent vertices of a polygon are broken. They only work when all polys are of one type, either quads or triangles and only one material is present.

Jorge Bernal (lordloki) lowered the priority of this task from 90 to Normal.May 16 2015, 1:47 AM