MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetVertexColor

Method GetVertexColor

Source/Engine/Level/Actors/StaticModel.cpp:135–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135Color32 StaticModel::GetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex) const
136{
137 if (Model && !Model->WaitForLoaded() && _vertexColorsCount == Model->GetLODsCount())
138 {
139 if (lodIndex < 0 || lodIndex >= Model->GetLODsCount())
140 {
141 LOG(Warning, "Specified model LOD index {0} was out of range.", lodIndex);
142 return Color32::Black;
143 }
144
145 int32 index = 0;
146 const ModelLOD& lod = Model->LODs[lodIndex];
147 auto& vertexColorsData = _vertexColorsData[lodIndex];
148 if (vertexColorsData.Count() != lod.GetVertexCount())
149 return Color32::Black;
150 for (int32 i = 0; i < lod.Meshes.Count(); i++)
151 {
152 const Mesh& mesh = lod.Meshes[i];
153 if (i == meshIndex)
154 {
155 if (vertexIndex < 0 || vertexIndex >= mesh.GetVertexCount())
156 {
157 LOG(Warning, "Specified vertex index {3} was out of range. LOD{0} mesh {1} has {2}.", lodIndex, meshIndex, mesh.GetVertexCount(), vertexIndex);
158 return Color32::Black;
159 }
160 index += vertexIndex;
161 return _vertexColorsData[lodIndex][index];
162 }
163 index += mesh.GetVertexCount();
164 }
165
166 LOG(Warning, "Specified model mesh index was out of range. LOD{0} mesh {1}.", lodIndex, meshIndex);
167 }
168
169 return Color32::Black;
170}
171
172void StaticModel::SetVertexColor(int32 lodIndex, int32 meshIndex, int32 vertexIndex, const Color32& color)
173{

Callers 1

PaintUpdateMethod · 0.80

Calls 3

WaitForLoadedMethod · 0.80
GetLODsCountMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected