diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 72d69d022b13..c03e24bc0018 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -344,9 +344,9 @@ SCA_IInputDevice::SCA_EnumInputs BL_ConvertKeyCode(int key_code) return gReverseKeyTranslateTable[key_code]; } -static void BL_GetUvRgba(const RAS_MeshObject::LayerList& layers, std::vector& uvLayers, std::vector& colorLayers, - unsigned short uvCount, unsigned short colorCount, - unsigned int loop, MT_Vector2 uvs[RAS_Texture::MaxUnits], unsigned int rgba[RAS_Vertex::MAX_UNIT]) +static void BL_GetUvRgba(const RAS_MeshObject::LayerList& layers, std::vector& uvLayers, + std::vector& colorLayers, unsigned short uvCount, unsigned short colorCount, + unsigned int loop, float uvs[RAS_Texture::MaxUnits][2], unsigned int rgba[RAS_Vertex::MAX_UNIT]) { // No need to initialize layers to zero as all the converted layer are all the layers needed. @@ -371,7 +371,7 @@ static void BL_GetUvRgba(const RAS_MeshObject::LayerList& layers, std::vectorCreateVertex(pt, uvs, tan, rgba, no); + RAS_Vertex vertex = array->CreateVertex(mvert.co, uvs, tan, rgba, normals[j]); BL_SharedVertexList& sharedList = sharedMap[vertid]; BL_SharedVertexList::iterator it = std::find_if(sharedList.begin(), sharedList.end(), diff --git a/source/gameengine/Rasterizer/RAS_DisplayArray.h b/source/gameengine/Rasterizer/RAS_DisplayArray.h index 9e9ac75ea014..0bf7db9a563e 100644 --- a/source/gameengine/Rasterizer/RAS_DisplayArray.h +++ b/source/gameengine/Rasterizer/RAS_DisplayArray.h @@ -143,6 +143,17 @@ friend class RAS_BatchDisplayArray; return RAS_Vertex(data, m_format); } + virtual RAS_Vertex CreateVertex( + const float xyz[3], + const float (*uvs)[2], + const float tangent[4], + const unsigned int *rgba, + const float normal[3]) + { + VertexData *data = new VertexData(xyz, uvs, tangent, rgba, normal); + return RAS_Vertex(data, m_format); + } + virtual void UpdateCache() { const unsigned int size = GetVertexCount(); diff --git a/source/gameengine/Rasterizer/RAS_IDisplayArray.h b/source/gameengine/Rasterizer/RAS_IDisplayArray.h index 4ed6690a59f4..52ab3ac91f63 100644 --- a/source/gameengine/Rasterizer/RAS_IDisplayArray.h +++ b/source/gameengine/Rasterizer/RAS_IDisplayArray.h @@ -175,6 +175,13 @@ class RAS_IDisplayArray const unsigned int *rgba, const MT_Vector3& normal) = 0; + virtual RAS_Vertex CreateVertex( + const float xyz[3], + const float (*uvs)[2], + const float tangent[4], + const unsigned int *rgba, + const float normal[3]) = 0; + /** Copy vertex data from an other display array. Different vertex type is allowed. * \param other The other display array to copy from. * \param flag The flag coresponding to datas to copy. diff --git a/source/gameengine/Rasterizer/RAS_VertexData.h b/source/gameengine/Rasterizer/RAS_VertexData.h index 349da379c57a..5ccd9d6aba41 100644 --- a/source/gameengine/Rasterizer/RAS_VertexData.h +++ b/source/gameengine/Rasterizer/RAS_VertexData.h @@ -3,6 +3,8 @@ #include "MT_Vector4.h" +#include "BLI_math_vector.h" + struct RAS_VertexDataBasic { float position[3]; @@ -17,6 +19,13 @@ struct RAS_VertexDataBasic _normal.getValue(normal); _tangent.getValue(tangent); } + + inline RAS_VertexDataBasic(const float _position[3], const float _normal[3], const float _tangent[4]) + { + copy_v3_v3(position, _position); + copy_v3_v3(normal, _normal); + copy_v4_v4(tangent, _tangent); + } }; template @@ -38,6 +47,16 @@ struct RAS_VertexDataExtra } } + inline RAS_VertexDataExtra(const float _uvs[uvSize][2], const unsigned int _colors[colorSize]) + { + for (unsigned short i = 0; i < uvSize; ++i) { + copy_v2_v2(uvs[i], _uvs[i]); + } + + for (unsigned short i = 0; i < colorSize; ++i) { + colors[i] = _colors[i]; + } + } }; struct RAS_IVertexData : RAS_VertexDataBasic @@ -48,6 +67,11 @@ struct RAS_IVertexData : RAS_VertexDataBasic :RAS_VertexDataBasic(position, normal, tangent) { } + + inline RAS_IVertexData(const float position[3], const float normal[3], const float tangent[4]) + :RAS_VertexDataBasic(position, normal, tangent) + { + } }; template @@ -69,6 +93,16 @@ struct RAS_VertexData : RAS_IVertexData, RAS_VertexDataExtra RAS_VertexDataExtra(uvs, rgba) { } + + inline RAS_VertexData(const float xyz[3], + const float uvs[uvSize][2], + const float tangent[4], + const unsigned int rgba[colorSize], + const float normal[3]) + :RAS_IVertexData(xyz, normal, tangent), + RAS_VertexDataExtra(uvs, rgba) + { + } }; #endif // __RAS_VERTEX_DATA_H__