Helper function to clean up / delete MeshSet, Skeleton and AnimationSet data
| 107 | |
| 108 | // Helper function to clean up / delete MeshSet, Skeleton and AnimationSet data |
| 109 | static void DeleteRigData(dmRigDDF::MeshSet* mesh_set, dmRigDDF::Skeleton* skeleton, dmRigDDF::AnimationSet* animation_set) |
| 110 | { |
| 111 | if (animation_set != 0x0) |
| 112 | { |
| 113 | for (uint32_t anim_idx = 0; anim_idx < animation_set->m_Animations.m_Count; ++anim_idx) |
| 114 | { |
| 115 | dmRigDDF::RigAnimation& anim = animation_set->m_Animations.m_Data[anim_idx]; |
| 116 | DeleteRigAnimation(anim); |
| 117 | } |
| 118 | delete [] animation_set->m_Animations.m_Data; |
| 119 | delete animation_set; |
| 120 | } |
| 121 | |
| 122 | if (skeleton != 0x0) |
| 123 | { |
| 124 | delete [] skeleton->m_Bones.m_Data; |
| 125 | delete [] skeleton->m_Iks.m_Data; |
| 126 | delete skeleton; |
| 127 | } |
| 128 | |
| 129 | if (mesh_set != 0x0) |
| 130 | { |
| 131 | for (uint32_t model_index = 0; model_index < mesh_set->m_Models.m_Count; ++model_index) |
| 132 | { |
| 133 | dmRigDDF::Model& model = mesh_set->m_Models.m_Data[model_index]; |
| 134 | for (uint32_t mesh_index = 0; mesh_index < model.m_Meshes.m_Count; ++mesh_index) |
| 135 | { |
| 136 | dmRigDDF::Mesh& mesh = model.m_Meshes.m_Data[mesh_index]; |
| 137 | delete[] mesh.m_Positions.m_Data; |
| 138 | delete[] mesh.m_Normals.m_Data; |
| 139 | delete[] mesh.m_Texcoord0.m_Data; |
| 140 | delete[] mesh.m_Texcoord1.m_Data; |
| 141 | delete[] mesh.m_Tangents.m_Data; |
| 142 | delete[] mesh.m_Colors.m_Data; |
| 143 | delete[] mesh.m_BoneIndices.m_Data; |
| 144 | delete[] mesh.m_Weights.m_Data; |
| 145 | |
| 146 | for (uint32_t ti = 0; ti < mesh.m_MorphTargets.m_Count; ++ti) |
| 147 | { |
| 148 | dmRigDDF::MorphTarget& mt = mesh.m_MorphTargets.m_Data[ti]; |
| 149 | delete[] mt.m_PositionsDelta.m_Data; |
| 150 | delete[] mt.m_NormalsDelta.m_Data; |
| 151 | delete[] mt.m_TangentsDelta.m_Data; |
| 152 | } |
| 153 | delete[] mesh.m_MorphTargets.m_Data; |
| 154 | delete[] mesh.m_MorphBaseWeights.m_Data; |
| 155 | } |
| 156 | |
| 157 | delete[] mesh_set->m_Models.m_Data[model_index].m_Meshes.m_Data; |
| 158 | } |
| 159 | |
| 160 | delete[] mesh_set->m_Models.m_Data; |
| 161 | delete[] mesh_set->m_BoneList.m_Data; |
| 162 | delete mesh_set; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | static void CreateTestMesh(dmRigDDF::MeshSet* mesh_set, int model_index, int mesh_index, Vector4 color) |
no test coverage detected