MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Load

Method Load

engine/Poseidon/World/Simulation/Animation/RtAnimation.cpp:189–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187void AnimationRTPhase::SerializeBin(SerializeBinStream& f) {}
188
189float AnimationRTPhase::Load(QIStream& in, Skeleton* skelet, int nSel, bool reversed)
190{
191 PoseidonAssert(_matrix.Size() >= nSel);
192 PoseidonAssert(_matrix.Size() <= skelet->NBones());
193 // Set identity for all; not every bone is keyed in each phase
194 for (int i = 0; i < _matrix.Size(); i++)
195 {
196 _matrix[i] = MIdentity;
197 }
198 float time = 0;
199 in.read((char*)&time, sizeof(time));
200 if (in.fail())
201 {
202 // cannol load - skip and return
203 RptF("Broken animation file");
204 return 0;
205 }
206 for (int i = 0; i < nSel; i++)
207 {
208 char name[33] = {}; // 32 wire bytes + guaranteed NUL for the strlwr / FindBone C-string use
209 Matrix4P transformP;
210 Matrix4 transform;
211 in.read(name, 32);
212 strlwr(name);
213 int index = skelet->FindBone(name);
214
215 in.read((char*)&transformP, sizeof(transformP));
216 transform = ConvertToM(transformP);
217 if (reversed)
218 {
219 // const static Matrix4P swapMatrix(MRotationY,H_PI);
220 const static Matrix4 swapMatrix(MScale, -1, 1, -1);
221 transform = swapMatrix * transform * swapMatrix;
222 }
223 if (index < 0 || index >= _matrix.Size())
224 {
225 RptF("Bad bone %s", name);
226 }
227 else
228 {
229 _matrix[index] = transform;
230 }
231 }
232 return time;
233}
234
235float AnimationRTPhase::LoadFromRTM(const Poseidon::Asset::Formats::RTMPhase& phase, const int* boneMap, int nSel,
236 bool reversed)

Callers 3

PrepareMatricesMethod · 0.45
PointMethod · 0.45
MatrixMethod · 0.45

Calls 15

readRTMHeaderFunction · 0.85
ErrorMessageFunction · 0.85
readRTMPhasesFunction · 0.85
NBonesMethod · 0.80
FindBoneMethod · 0.80
IsInListMethod · 0.80
LastMethod · 0.80
AddLoadCountMethod · 0.80
GetKeyframeCountMethod · 0.80
boneCountMethod · 0.80
phaseCountMethod · 0.80
NewBoneMethod · 0.80

Tested by

no test coverage detected