Skip to content

Commit f1bbc91

Browse files
committed
Bring back C++ SkinXW functions
They was deleted with commit cdd6c53
1 parent db50007 commit f1bbc91

File tree

7 files changed

+291
-8
lines changed

7 files changed

+291
-8
lines changed

src/xrCore/Math/MathUtil.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
#include "xrEngine/Render.h"
1313
#include "Layers/xrRender/light.h"
1414
#endif
15-
15+
#ifdef XR_X86
1616
#include "SkinXW_SSE.hpp"
17+
#else
18+
#include "SkinXW_CPP.hpp"
19+
#endif
1720
#include "Skin4W_MT.hpp"
1821
#include "PLC_SSE.hpp"
1922
#include "_math.h"
@@ -22,12 +25,11 @@ namespace XRay
2225
{
2326
namespace Math
2427
{
25-
#ifdef XR_X86
2628
Skin1WFunc Skin1W;
2729
Skin2WFunc Skin2W;
2830
Skin3WFunc Skin3W;
2931
Skin4WFunc Skin4W;
30-
#endif
32+
3133
PLCCalcFunc PLCCalc;
3234

3335
void Initialize()
@@ -41,12 +43,18 @@ void Initialize()
4143
Skin3W = Skin3W_SSE;
4244
Skin4W = Skin4W_SSE;
4345
Skin4W_MTs = Skin4W_SSE;
46+
#else
47+
Skin1W = Skin1W_CPP;
48+
Skin2W = Skin2W_CPP;
49+
Skin3W = Skin3W_CPP;
50+
Skin4W = Skin4W_CPP;
51+
Skin4W_MTs = Skin4W_CPP;
4452
#endif
4553
PLCCalc = PLCCalc_SSE;
46-
#ifdef XR_X86
54+
4755
if (ttapi_GetWorkerCount() > 1)
4856
Skin4W = Skin4W_MT;
49-
#endif
57+
5058
initialized = true;
5159
}
5260

src/xrCore/Math/MathUtil.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ namespace XRay
2323
{
2424
namespace Math
2525
{
26-
#ifdef XR_X86
2726
extern XRCORE_API Skin1WFunc Skin1W;
2827
extern XRCORE_API Skin2WFunc Skin2W;
2928
extern XRCORE_API Skin3WFunc Skin3W;
3029
extern XRCORE_API Skin4WFunc Skin4W;
3130
extern XRCORE_API PLCCalcFunc PLCCalc;
32-
#endif
3331

3432
void XRCORE_API Initialize();
3533
} // namespace Math

src/xrCore/Math/SkinXW_CPP.cpp

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
#include "stdafx.h"
2+
#include "Common/Platform.hpp"
3+
#include "SkinXW_CPP.hpp"
4+
#ifdef _EDITOR
5+
#include "SkeletonX.h"
6+
#include "SkeletonCustom.h"
7+
#else
8+
#include "Animation/Bone.hpp"
9+
#include "Layers/xrRender/SkeletonXVertRender.h"
10+
#endif
11+
12+
namespace XRay
13+
{
14+
namespace Math
15+
{
16+
void Skin1W_CPP(vertRender* D, vertBoned1W* S, u32 vCount, CBoneInstance* Bones)
17+
{
18+
// return;
19+
// Prepare
20+
int U_Count = vCount / 8;
21+
vertBoned1W* V = S;
22+
vertBoned1W* E = V + U_Count * 8;
23+
24+
// Unrolled loop
25+
for (; S != E;)
26+
{
27+
Fmatrix& M0 = Bones[S->matrix].mRenderTransform;
28+
M0.transform_tiny(D->P, S->P);
29+
M0.transform_dir(D->N, S->N);
30+
D->u = S->u;
31+
D->v = S->v;
32+
S++;
33+
D++;
34+
35+
Fmatrix& M1 = Bones[S->matrix].mRenderTransform;
36+
M1.transform_tiny(D->P, S->P);
37+
M1.transform_dir(D->N, S->N);
38+
D->u = S->u;
39+
D->v = S->v;
40+
S++;
41+
D++;
42+
43+
Fmatrix& M2 = Bones[S->matrix].mRenderTransform;
44+
M2.transform_tiny(D->P, S->P);
45+
M2.transform_dir(D->N, S->N);
46+
D->u = S->u;
47+
D->v = S->v;
48+
S++;
49+
D++;
50+
51+
Fmatrix& M3 = Bones[S->matrix].mRenderTransform;
52+
M3.transform_tiny(D->P, S->P);
53+
M3.transform_dir(D->N, S->N);
54+
D->u = S->u;
55+
D->v = S->v;
56+
S++;
57+
D++;
58+
59+
Fmatrix& M4 = Bones[S->matrix].mRenderTransform;
60+
M4.transform_tiny(D->P, S->P);
61+
M4.transform_dir(D->N, S->N);
62+
D->u = S->u;
63+
D->v = S->v;
64+
S++;
65+
D++;
66+
67+
Fmatrix& M5 = Bones[S->matrix].mRenderTransform;
68+
M5.transform_tiny(D->P, S->P);
69+
M5.transform_dir(D->N, S->N);
70+
D->u = S->u;
71+
D->v = S->v;
72+
S++;
73+
D++;
74+
75+
Fmatrix& M6 = Bones[S->matrix].mRenderTransform;
76+
M6.transform_tiny(D->P, S->P);
77+
M6.transform_dir(D->N, S->N);
78+
D->u = S->u;
79+
D->v = S->v;
80+
S++;
81+
D++;
82+
83+
Fmatrix& M7 = Bones[S->matrix].mRenderTransform;
84+
M7.transform_tiny(D->P, S->P);
85+
M7.transform_dir(D->N, S->N);
86+
D->u = S->u;
87+
D->v = S->v;
88+
S++;
89+
D++;
90+
}
91+
92+
// The end part
93+
vertBoned1W* E2 = V + vCount;
94+
for (; S != E2;)
95+
{
96+
Fmatrix& M = Bones[S->matrix].mRenderTransform;
97+
M.transform_tiny(D->P, S->P);
98+
M.transform_dir(D->N, S->N);
99+
D->u = S->u;
100+
D->v = S->v;
101+
S++;
102+
D++;
103+
}
104+
}
105+
106+
void Skin2W_CPP(vertRender* D, vertBoned2W* S, u32 vCount, CBoneInstance* Bones)
107+
{
108+
// Prepare
109+
int U_Count = vCount;
110+
vertBoned2W* V = S;
111+
vertBoned2W* E = V + U_Count;
112+
Fvector P0, N0, P1, N1;
113+
114+
// NON-Unrolled loop
115+
for (; S != E;)
116+
{
117+
if (S->matrix1 != S->matrix0)
118+
{
119+
Fmatrix& M0 = Bones[S->matrix0].mRenderTransform;
120+
Fmatrix& M1 = Bones[S->matrix1].mRenderTransform;
121+
M0.transform_tiny(P0, S->P);
122+
M0.transform_dir(N0, S->N);
123+
M1.transform_tiny(P1, S->P);
124+
M1.transform_dir(N1, S->N);
125+
D->P.lerp(P0, P1, S->w);
126+
D->N.lerp(N0, N1, S->w);
127+
D->u = S->u;
128+
D->v = S->v;
129+
}
130+
else
131+
{
132+
Fmatrix& M0 = Bones[S->matrix0].mRenderTransform;
133+
M0.transform_tiny(D->P, S->P);
134+
M0.transform_dir(D->N, S->N);
135+
D->u = S->u;
136+
D->v = S->v;
137+
}
138+
S++;
139+
D++;
140+
}
141+
}
142+
143+
144+
void Skin3W_CPP(vertRender* D, vertBoned3W* S, u32 vCount, CBoneInstance* Bones)
145+
{
146+
// Prepare
147+
int U_Count = vCount;
148+
vertBoned3W* V = S;
149+
vertBoned3W* E = V + U_Count;
150+
Fvector P0, N0, P1, N1, P2, N2;
151+
152+
// NON-Unrolled loop
153+
for (; S != E;)
154+
{
155+
Fmatrix& M0 = Bones[S->m[0]].mRenderTransform;
156+
Fmatrix& M1 = Bones[S->m[1]].mRenderTransform;
157+
Fmatrix& M2 = Bones[S->m[2]].mRenderTransform;
158+
159+
M0.transform_tiny(P0, S->P);
160+
P0.mul(S->w[0]);
161+
M0.transform_dir(N0, S->N);
162+
N0.mul(S->w[0]);
163+
164+
M1.transform_tiny(P1, S->P);
165+
P1.mul(S->w[1]);
166+
M1.transform_dir(N1, S->N);
167+
N1.mul(S->w[1]);
168+
169+
M2.transform_tiny(P2, S->P);
170+
P2.mul(1.0f - S->w[0] - S->w[1]);
171+
M2.transform_dir(N2, S->N);
172+
N2.mul(1.0f - S->w[0] - S->w[1]);
173+
174+
P0.add(P1);
175+
P0.add(P2);
176+
177+
D->P = P0;
178+
179+
N0.add(N1);
180+
N0.add(N2);
181+
182+
D->N = N0;
183+
184+
D->u = S->u;
185+
D->v = S->v;
186+
187+
S++;
188+
D++;
189+
}
190+
}
191+
192+
193+
void Skin4W_CPP(vertRender* D, vertBoned4W* S, u32 vCount, CBoneInstance* Bones)
194+
{
195+
// Prepare
196+
int U_Count = vCount;
197+
vertBoned4W* V = S;
198+
vertBoned4W* E = V + U_Count;
199+
Fvector P0, N0, P1, N1, P2, N2, P3, N3;
200+
201+
// NON-Unrolled loop
202+
for (; S != E;)
203+
{
204+
Fmatrix& M0 = Bones[S->m[0]].mRenderTransform;
205+
Fmatrix& M1 = Bones[S->m[1]].mRenderTransform;
206+
Fmatrix& M2 = Bones[S->m[2]].mRenderTransform;
207+
Fmatrix& M3 = Bones[S->m[3]].mRenderTransform;
208+
209+
M0.transform_tiny(P0, S->P);
210+
P0.mul(S->w[0]);
211+
M0.transform_dir(N0, S->N);
212+
N0.mul(S->w[0]);
213+
214+
M1.transform_tiny(P1, S->P);
215+
P1.mul(S->w[1]);
216+
M1.transform_dir(N1, S->N);
217+
N1.mul(S->w[1]);
218+
219+
M2.transform_tiny(P2, S->P);
220+
P2.mul(S->w[2]);
221+
M2.transform_dir(N2, S->N);
222+
N2.mul(S->w[2]);
223+
224+
M3.transform_tiny(P3, S->P);
225+
P3.mul(1.0f - S->w[0] - S->w[1] - S->w[2]);
226+
M3.transform_dir(N3, S->N);
227+
N3.mul(1.0f - S->w[0] - S->w[1] - S->w[2]);
228+
229+
P0.add(P1);
230+
P0.add(P2);
231+
P0.add(P3);
232+
233+
D->P = P0;
234+
235+
N0.add(N1);
236+
N0.add(N2);
237+
N0.add(N3);
238+
239+
D->N = N0;
240+
241+
D->u = S->u;
242+
D->v = S->v;
243+
244+
S++;
245+
D++;
246+
}
247+
}
248+
} // namespace Math
249+
} // namespace XRay

src/xrCore/Math/SkinXW_CPP.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
#include "xrCore.h"
3+
4+
struct vertRender;
5+
struct vertBoned1W;
6+
struct vertBoned2W;
7+
struct vertBoned3W;
8+
struct vertBoned4W;
9+
class CBoneInstance;
10+
11+
namespace XRay
12+
{
13+
namespace Math
14+
{
15+
void Skin1W_CPP(vertRender* D, vertBoned1W* S, u32 vCount, CBoneInstance* Bones);
16+
void Skin2W_CPP(vertRender* D, vertBoned2W* S, u32 vCount, CBoneInstance* Bones);
17+
void Skin3W_CPP(vertRender* D, vertBoned3W* S, u32 vCount, CBoneInstance* Bones);
18+
void Skin4W_CPP(vertRender* D, vertBoned4W* S, u32 vCount, CBoneInstance* Bones);
19+
} // namespace Math
20+
} // namespace XRay

src/xrCore/Math/SkinXW_SSE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,5 @@ void Skin1W_SSE(vertRender* D, vertBoned1W* S, u32 vCount, CBoneInstance* Bones)
411411
}
412412
}
413413
#endif
414-
} // namespace Util3D
414+
} // namespace Math
415415
} // namespace XRay

src/xrCore/xrCore.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@
334334
<ClCompile Include="log.cpp" />
335335
<ClCompile Include="LzHuf.cpp" />
336336
<ClCompile Include="Math\PLC_SSE.cpp" />
337+
<ClCompile Include="Math\SkinXW_CPP.cpp" />
337338
<ClCompile Include="Math\Skin4W_MT.cpp" />
338339
<ClCompile Include="Math\SkinXW_SSE.cpp" />
339340
<ClCompile Include="Math\MathUtil.cpp" />
@@ -503,6 +504,7 @@
503504
<ClInclude Include="Math\PLC_SSE.hpp" />
504505
<ClInclude Include="Math\Random32.hpp" />
505506
<ClInclude Include="Math\Skin4W_MT.hpp" />
507+
<ClInclude Include="Math\SkinXW_CPP.hpp" />
506508
<ClInclude Include="Math\SkinXW_SSE.hpp" />
507509
<ClInclude Include="Math\MathUtil.hpp" />
508510
<ClInclude Include="math_constants.h" />

src/xrCore/xrCore.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@
357357
<ClCompile Include="stdafx.cpp">
358358
<Filter>PCH</Filter>
359359
</ClCompile>
360+
<ClCompile Include="Math\SkinXW_CPP.cpp">
361+
<Filter>Math</Filter>
362+
</ClCompile>
360363
</ItemGroup>
361364
<ItemGroup>
362365
<ClInclude Include="FTimer.h">
@@ -752,6 +755,9 @@
752755
<ClInclude Include="xr_vector_defs.h">
753756
<Filter>Math\Extensions</Filter>
754757
</ClInclude>
758+
<ClInclude Include="Math\SkinXW_CPP.hpp">
759+
<Filter>Math</Filter>
760+
</ClInclude>
755761
</ItemGroup>
756762
<ItemGroup>
757763
<ResourceCompile Include="xrCore.rc">

0 commit comments

Comments
 (0)