Fix T38030.
In c++ source we use one list for triangles and an other for quads, but KX_PolyProxy doesn't care about that and return the vertex offset in its list. So we just have to compute the offset of each RAS_DisplayArray to its previous to have an absolute vertex index.
Details
- Reviewers
Campbell Barton (campbellbarton) Thomas Szepe (hg1) Daniel Stokes (kupoman) Mitchell Stokes (moguri) Angus Hollands (agoose77) Inês Almeida (brita_) - Maniphest Tasks
- T35692: Vertex colors fail when mesh contains quads and tris
T38030: KX_PolyProxy has incorrect getVertexIndex results - Commits
- rBS2a305580b2c7: BGE: Fix T38030: wrong vertex index returned by KX_PolyProxy
rB2a305580b2c7: BGE: Fix T38030: wrong vertex index returned by KX_PolyProxy
Diff Detail
- Repository
- rB Blender
- Branch
- ge_poly_vertex_index
Event Timeline
I don't know if that would mess up the mesh, but wouldn't it better to calculate the correct vertex offset before it will be set with SetVertexOffset().
| source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | ||
|---|---|---|
| 292 | unsigned int | |
| source/gameengine/Rasterizer/RAS_MaterialBucket.h | ||
| 89 | Unsigned short is maybe the value range is to small for big meshes. Should be changed to Unsigned int. | |
| source/gameengine/Rasterizer/RAS_MeshObject.h | ||
| 134–135 | I think this cloud be deleted. If you want to keep it, move it into RAS_MeshObject.cpp in RAS_MeshObject::EndConversion(). | |
| source/gameengine/Rasterizer/RAS_Polygon.h | ||
| 74–75 | Look like that GetVertexOffset() is now unused, because GetVertexOffsetAbsolute() is now used instead. One of the methods should be deleted. | |
We can't set the array offset with SetVertexOffset because this function is called for each polygon during the array construction and we will get incorrect index.
[EDIT : i didn't see your last comment]
| source/gameengine/Rasterizer/RAS_Polygon.h | ||
|---|---|---|
| 74–75 | I think that it's useful to keep the function GetVertexOffset(), It can be used later for mesh generation ect … | |
Use unsigned int instead of unsigned short for offset, move comment block of EndConversion in the .cpp.
| source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | ||
|---|---|---|
| 293 | You need to change the iterator to unsigned int too. Note: | |
| source/gameengine/Rasterizer/RAS_Polygon.cpp | ||
| 65–68 | GetVertexOffset() is now not unused anywhere. One of the methods should be deleted. | |
| 70 | unsigned int for the return type. | |
| source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | ||
|---|---|---|
| 293 | I am sorry, I don't checked what the maximum value of m_displayArrays is. In that case you can leave unsigned short. | |
| source/gameengine/Rasterizer/RAS_Polygon.cpp | ||
| 65–68 | I think we don't need to do this. There is actually no usage for getting a non absolute vertex offset. int RAS_Polygon::GetVertexOffset(int i)
{
return m_offset[i] + m_darray->m_offset;
}You can also keep your new GetVertexOffsetAbsolute(), and delete the old one, if you like the new method name more. | |
Remove function GetVertexOffset and use unsigned int instead of int for returned value and unsigned short for the function argument.
Looking at the original T38030 problem:
- why make a new function? People will still use the old function and think it doesn't work properly sometimes. Why would one use the old vs this new function?
- does this fix the problem with mixed materials as well?
pointed a few typos.
I see now that it was supposed to be a function rename, not a new function.
Are we sure about the name change? How about SetVertexOffset ? does it need to consider the different lists too?
(This is not at all my area, I'm just trying to help. I really can't give feedback on the overall solution as I don't know the design)
| source/gameengine/Rasterizer/RAS_MaterialBucket.h | ||
|---|---|---|
| 85 | lists not listes | |
| 175 | display | |
| 179 | avoid doing cleanup mixed with functional changes. (not ultra important, though. for next time) | |
Provided it solves the test case, and all pending comments are addressed, I'm happy with this revision.
| source/gameengine/Rasterizer/RAS_Polygon.cpp | ||
|---|---|---|
| 65–68 | To be clear : i prefer keep the name "GetVertexOffsetAbsolute" and not "GetVertexOffset" because we have a setter named "SetVertexoffset" and a getter with the same name must be return the same value, but here is not the case. | |