Skip to content

Commit ef48491

Browse files
committed
Reformat: xrCore
1 parent eea17cc commit ef48491

File tree

206 files changed

+18439
-17346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+18439
-17346
lines changed

src/xrCore/Animation/Bone.cpp

Lines changed: 121 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33

44
#include "Bone.hpp"
55

6-
#define BONE_VERSION 0x0002
6+
#define BONE_VERSION 0x0002
77
//------------------------------------------------------------------------------
8-
#define BONE_CHUNK_VERSION 0x0001
9-
#define BONE_CHUNK_DEF 0x0002
10-
#define BONE_CHUNK_BIND_POSE 0x0003
11-
#define BONE_CHUNK_MATERIAL 0x0004
12-
#define BONE_CHUNK_SHAPE 0x0005
13-
#define BONE_CHUNK_IK_JOINT 0x0006
14-
#define BONE_CHUNK_MASS 0x0007
15-
#define BONE_CHUNK_FLAGS 0x0008
16-
#define BONE_CHUNK_IK_JOINT_BREAK 0x0009
17-
#define BONE_CHUNK_IK_JOINT_FRICTION 0x0010
18-
8+
#define BONE_CHUNK_VERSION 0x0001
9+
#define BONE_CHUNK_DEF 0x0002
10+
#define BONE_CHUNK_BIND_POSE 0x0003
11+
#define BONE_CHUNK_MATERIAL 0x0004
12+
#define BONE_CHUNK_SHAPE 0x0005
13+
#define BONE_CHUNK_IK_JOINT 0x0006
14+
#define BONE_CHUNK_MASS 0x0007
15+
#define BONE_CHUNK_FLAGS 0x0008
16+
#define BONE_CHUNK_IK_JOINT_BREAK 0x0009
17+
#define BONE_CHUNK_IK_JOINT_FRICTION 0x0010
1918

2019
static const Fobb dummy = Fobb().identity();
2120

@@ -27,12 +26,12 @@ const Fobb& CBone::get_obb() const
2726
CBone::CBone()
2827
{
2928
construct();
30-
flags.zero ();
31-
rest_length = 0;
32-
SelfID = -1;
33-
parent = 0;
29+
flags.zero();
30+
rest_length = 0;
31+
SelfID = -1;
32+
parent = 0;
3433

35-
ResetData ();
34+
ResetData();
3635
}
3736

3837
CBone::~CBone()
@@ -41,153 +40,156 @@ CBone::~CBone()
4140

4241
void CBone::ResetData()
4342
{
44-
IK_data.Reset ();
45-
game_mtl = "default_object";
46-
shape.Reset ();
43+
IK_data.Reset();
44+
game_mtl = "default_object";
45+
shape.Reset();
4746

48-
mass = 10.f;;
49-
center_of_mass.set(0.f,0.f,0.f);
47+
mass = 10.f;
48+
;
49+
center_of_mass.set(0.f, 0.f, 0.f);
5050
}
5151

5252
void CBone::Save(IWriter& F)
5353
{
54-
F.open_chunk (BONE_CHUNK_VERSION);
55-
F.w_u16 (BONE_VERSION);
56-
F.close_chunk ();
57-
58-
F.open_chunk (BONE_CHUNK_DEF);
59-
F.w_stringZ (name);
60-
F.w_stringZ (parent_name);
61-
F.w_stringZ (wmap);
62-
F.close_chunk ();
63-
64-
F.open_chunk (BONE_CHUNK_BIND_POSE);
65-
F.w_fvector3 (rest_offset);
66-
F.w_fvector3 (rest_rotate);
67-
F.w_float (rest_length);
68-
F.close_chunk ();
69-
70-
SaveData (F);
54+
F.open_chunk(BONE_CHUNK_VERSION);
55+
F.w_u16(BONE_VERSION);
56+
F.close_chunk();
57+
58+
F.open_chunk(BONE_CHUNK_DEF);
59+
F.w_stringZ(name);
60+
F.w_stringZ(parent_name);
61+
F.w_stringZ(wmap);
62+
F.close_chunk();
63+
64+
F.open_chunk(BONE_CHUNK_BIND_POSE);
65+
F.w_fvector3(rest_offset);
66+
F.w_fvector3(rest_rotate);
67+
F.w_float(rest_length);
68+
F.close_chunk();
69+
70+
SaveData(F);
7171
}
7272

7373
void CBone::Load_0(IReader& F)
7474
{
75-
F.r_stringZ (name); xr_strlwr(name);
76-
F.r_stringZ (parent_name); xr_strlwr(parent_name);
77-
F.r_stringZ (wmap);
78-
F.r_fvector3 (rest_offset);
79-
F.r_fvector3 (rest_rotate);
80-
rest_length = F.r_float();
81-
std::swap (rest_rotate.x,rest_rotate.y);
82-
Reset ();
75+
F.r_stringZ(name);
76+
xr_strlwr(name);
77+
F.r_stringZ(parent_name);
78+
xr_strlwr(parent_name);
79+
F.r_stringZ(wmap);
80+
F.r_fvector3(rest_offset);
81+
F.r_fvector3(rest_rotate);
82+
rest_length = F.r_float();
83+
std::swap(rest_rotate.x, rest_rotate.y);
84+
Reset();
8385
}
8486

8587
void CBone::Load_1(IReader& F)
8688
{
8789
R_ASSERT(F.find_chunk(BONE_CHUNK_VERSION));
88-
u16 ver = F.r_u16();
90+
u16 ver = F.r_u16();
91+
92+
if ((ver != 0x0001) && (ver != BONE_VERSION)) return;
8993

90-
if ((ver!=0x0001)&&(ver!=BONE_VERSION))
91-
return;
92-
9394
R_ASSERT(F.find_chunk(BONE_CHUNK_DEF));
94-
F.r_stringZ (name); xr_strlwr(name);
95-
F.r_stringZ (parent_name); xr_strlwr(parent_name);
96-
F.r_stringZ (wmap);
95+
F.r_stringZ(name);
96+
xr_strlwr(name);
97+
F.r_stringZ(parent_name);
98+
xr_strlwr(parent_name);
99+
F.r_stringZ(wmap);
97100

98101
R_ASSERT(F.find_chunk(BONE_CHUNK_BIND_POSE));
99-
F.r_fvector3 (rest_offset);
100-
F.r_fvector3 (rest_rotate);
101-
rest_length = F.r_float();
102-
103-
if (ver==0x0001)
104-
std::swap (rest_rotate.x,rest_rotate.y);
105-
106-
LoadData (F);
102+
F.r_fvector3(rest_offset);
103+
F.r_fvector3(rest_rotate);
104+
rest_length = F.r_float();
105+
106+
if (ver == 0x0001) std::swap(rest_rotate.x, rest_rotate.y);
107+
108+
LoadData(F);
107109
}
108110

109111
void CBone::SaveData(IWriter& F)
110112
{
111-
F.open_chunk (BONE_CHUNK_DEF);
112-
F.w_stringZ (name);
113-
F.close_chunk ();
114-
115-
F.open_chunk (BONE_CHUNK_MATERIAL);
116-
F.w_stringZ (game_mtl);
117-
F.close_chunk ();
118-
119-
F.open_chunk (BONE_CHUNK_SHAPE);
120-
F.w (&shape,sizeof(SBoneShape));
121-
F.close_chunk ();
122-
123-
F.open_chunk (BONE_CHUNK_FLAGS);
124-
F.w_u32 (IK_data.ik_flags.get());
125-
F.close_chunk ();
126-
127-
F.open_chunk (BONE_CHUNK_IK_JOINT);
128-
F.w_u32 (IK_data.type);
129-
F.w (IK_data.limits,sizeof(SJointLimit)*3);
130-
F.w_float (IK_data.spring_factor);
131-
F.w_float (IK_data.damping_factor);
132-
F.close_chunk ();
133-
134-
F.open_chunk (BONE_CHUNK_IK_JOINT_BREAK);
135-
F.w_float (IK_data.break_force);
136-
F.w_float (IK_data.break_torque);
137-
F.close_chunk ();
138-
139-
F.open_chunk (BONE_CHUNK_IK_JOINT_FRICTION);
140-
F.w_float (IK_data.friction);
141-
F.close_chunk ();
142-
143-
F.open_chunk (BONE_CHUNK_MASS);
144-
F.w_float (mass);
145-
F.w_fvector3 (center_of_mass);
146-
F.close_chunk ();
113+
F.open_chunk(BONE_CHUNK_DEF);
114+
F.w_stringZ(name);
115+
F.close_chunk();
116+
117+
F.open_chunk(BONE_CHUNK_MATERIAL);
118+
F.w_stringZ(game_mtl);
119+
F.close_chunk();
120+
121+
F.open_chunk(BONE_CHUNK_SHAPE);
122+
F.w(&shape, sizeof(SBoneShape));
123+
F.close_chunk();
124+
125+
F.open_chunk(BONE_CHUNK_FLAGS);
126+
F.w_u32(IK_data.ik_flags.get());
127+
F.close_chunk();
128+
129+
F.open_chunk(BONE_CHUNK_IK_JOINT);
130+
F.w_u32(IK_data.type);
131+
F.w(IK_data.limits, sizeof(SJointLimit) * 3);
132+
F.w_float(IK_data.spring_factor);
133+
F.w_float(IK_data.damping_factor);
134+
F.close_chunk();
135+
136+
F.open_chunk(BONE_CHUNK_IK_JOINT_BREAK);
137+
F.w_float(IK_data.break_force);
138+
F.w_float(IK_data.break_torque);
139+
F.close_chunk();
140+
141+
F.open_chunk(BONE_CHUNK_IK_JOINT_FRICTION);
142+
F.w_float(IK_data.friction);
143+
F.close_chunk();
144+
145+
F.open_chunk(BONE_CHUNK_MASS);
146+
F.w_float(mass);
147+
F.w_fvector3(center_of_mass);
148+
F.close_chunk();
147149
}
148150

149151
void CBone::LoadData(IReader& F)
150152
{
151153
R_ASSERT(F.find_chunk(BONE_CHUNK_DEF));
152-
F.r_stringZ (name); xr_strlwr(name);
154+
F.r_stringZ(name);
155+
xr_strlwr(name);
153156

154157
R_ASSERT(F.find_chunk(BONE_CHUNK_MATERIAL));
155-
F.r_stringZ (game_mtl);
158+
F.r_stringZ(game_mtl);
156159

157160
R_ASSERT(F.find_chunk(BONE_CHUNK_SHAPE));
158-
F.r (&shape,sizeof(SBoneShape));
159-
160-
if (F.find_chunk(BONE_CHUNK_FLAGS))
161-
IK_data.ik_flags.assign(F.r_u32());
161+
F.r(&shape, sizeof(SBoneShape));
162+
163+
if (F.find_chunk(BONE_CHUNK_FLAGS)) IK_data.ik_flags.assign(F.r_u32());
162164

163165
R_ASSERT(F.find_chunk(BONE_CHUNK_IK_JOINT));
164-
IK_data.type = (EJointType)F.r_u32();
165-
F.r (IK_data.limits,sizeof(SJointLimit)*3);
166-
IK_data.spring_factor = F.r_float();
167-
IK_data.damping_factor = F.r_float();
166+
IK_data.type = (EJointType)F.r_u32();
167+
F.r(IK_data.limits, sizeof(SJointLimit) * 3);
168+
IK_data.spring_factor = F.r_float();
169+
IK_data.damping_factor = F.r_float();
168170

169-
if (F.find_chunk(BONE_CHUNK_IK_JOINT_BREAK)){
171+
if (F.find_chunk(BONE_CHUNK_IK_JOINT_BREAK)) {
170172
IK_data.break_force = F.r_float();
171-
IK_data.break_torque= F.r_float();
173+
IK_data.break_torque = F.r_float();
172174
}
173175

174-
if (F.find_chunk(BONE_CHUNK_IK_JOINT_FRICTION)){
175-
IK_data.friction = F.r_float();
176+
if (F.find_chunk(BONE_CHUNK_IK_JOINT_FRICTION)) {
177+
IK_data.friction = F.r_float();
176178
}
177179

178-
if (F.find_chunk(BONE_CHUNK_MASS)){
179-
mass = F.r_float();
180+
if (F.find_chunk(BONE_CHUNK_MASS)) {
181+
mass = F.r_float();
180182
F.r_fvector3(center_of_mass);
181183
}
182184
}
183185

184186
void CBone::CopyData(CBone* bone)
185187
{
186-
game_mtl = bone->game_mtl;
187-
shape = bone->shape;
188-
IK_data = bone->IK_data;
189-
mass = bone->mass;
190-
center_of_mass = bone->center_of_mass;
188+
game_mtl = bone->game_mtl;
189+
shape = bone->shape;
190+
IK_data = bone->IK_data;
191+
mass = bone->mass;
192+
center_of_mass = bone->center_of_mass;
191193
}
192194

193195
void CBoneInstance::set_param(u32 idx, float data)

0 commit comments

Comments
 (0)