MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / getVertexNormal

Method getVertexNormal

src/collision/TriangleVertexArray.cpp:170–191  ·  view source on GitHub ↗

Return a vertex normal of the array * @param vertexIndex Index of a given vertex of the array * @return The normal vector of the vertex */

Source from the content-addressed store, hash-verified

168 * @return The normal vector of the vertex
169 */
170Vector3 TriangleVertexArray::getVertexNormal(uint32 vertexIndex) const {
171
172 assert(vertexIndex < mNbVertices);
173
174 const uchar* vertexNormalPointerChar = mVerticesNormalsStart + vertexIndex * mVerticesNormalsStride;
175 const void* vertexNormalPointer = static_cast<const void*>(vertexNormalPointerChar);
176
177 // Get the normals from the array
178 if (mVertexNormaldDataType == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE) {
179 const float* normal = static_cast<const float*>(vertexNormalPointer);
180 return Vector3(decimal(normal[0]), decimal(normal[1]), decimal(normal[2]));
181 }
182 else if (mVertexNormaldDataType == TriangleVertexArray::NormalDataType::NORMAL_DOUBLE_TYPE) {
183 const double* normal = static_cast<const double*>(vertexNormalPointer);
184 return Vector3(decimal(normal[0]), decimal(normal[1]), decimal(normal[2]));
185 }
186 else {
187 assert(false);
188 }
189
190 return Vector3::zero();
191}

Callers 5

runMethod · 0.80
testMethod · 0.80
drawConcaveMeshShapeMethod · 0.80
copyDataMethod · 0.80

Calls 1

Vector3Class · 0.50

Tested by 2

runMethod · 0.64
testMethod · 0.64