MCPcopy Create free account
hub / github.com/defold/defold / GeneratePositionData

Function GeneratePositionData

engine/rig/src/rig.cpp:1163–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1161 }
1162
1163 static void GeneratePositionData(const dmRigDDF::Mesh* mesh, const Matrix4& model_matrix, const dmArray<Matrix4>& pose_matrices, float* out_buffer_world, float* out_buffer_local)
1164 {
1165 const float* positions = mesh->m_Positions.m_Data;
1166 const uint32_t vertex_count = mesh->m_Positions.m_Count / 3;
1167 Point3 in_p;
1168 Vector4 v;
1169
1170 if(!mesh->m_BoneIndices.m_Count || pose_matrices.Size() == 0)
1171 {
1172 for (uint32_t i = 0; i < vertex_count; ++i)
1173 {
1174 in_p[0] = *positions++;
1175 in_p[1] = *positions++;
1176 in_p[2] = *positions++;
1177
1178 if (out_buffer_world)
1179 {
1180 v = model_matrix * in_p;
1181 *out_buffer_world++ = v[0];
1182 *out_buffer_world++ = v[1];
1183 *out_buffer_world++ = v[2];
1184 }
1185 if (out_buffer_local)
1186 {
1187 *out_buffer_local++ = in_p[0];
1188 *out_buffer_local++ = in_p[1];
1189 *out_buffer_local++ = in_p[2];
1190 }
1191 }
1192 return;
1193 }
1194
1195 const uint32_t* indices = mesh->m_BoneIndices.m_Data;
1196 const float* weights = mesh->m_Weights.m_Data;
1197 for (uint32_t i = 0; i < vertex_count; ++i)
1198 {
1199 Vector4 in_v;
1200 in_v.setX(*positions++);
1201 in_v.setY(*positions++);
1202 in_v.setZ(*positions++);
1203 in_v.setW(1.0f);
1204
1205 Vector4 out_p(0.0f, 0.0f, 0.0f, 0.0f);
1206 const uint32_t bi_offset = i * 4;
1207 const uint32_t* bone_indices = &indices[bi_offset];
1208 const float* bone_weights = &weights[bi_offset];
1209
1210 if(bone_weights[0])
1211 {
1212 out_p += pose_matrices[bone_indices[0]] * in_v * bone_weights[0];
1213 if(bone_weights[1])
1214 {
1215 out_p += pose_matrices[bone_indices[1]] * in_v * bone_weights[1];
1216 if(bone_weights[2])
1217 {
1218 out_p += pose_matrices[bone_indices[2]] * in_v * bone_weights[2];
1219 if(bone_weights[3])
1220 {

Callers 2

GenerateVertexDataFunction · 0.85

Calls 9

setZMethod · 0.80
setWMethod · 0.80
Point3Class · 0.50
SizeMethod · 0.45
setXMethod · 0.45
setYMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
getZMethod · 0.45

Tested by

no test coverage detected