sead
Loading...
Searching...
No Matches
seadVectorCalcCommon.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
#
ifdef
cafe
4
5
#
include
<
cafe
.
h
>
6
7
#
ifndef
DISABLE_PS
8
#
include
<
ppc_ps
.
h
>
9
10
inline
f32x2& tof32x2(f32& x)
11
{
12
return
*
reinterpret_cast
<f32x2*>(&x);
13
}
14
15
inline
const
f32x2& tof32x2(
const
f32& x)
16
{
17
return
*
reinterpret_cast
<
const
f32x2*>(&x);
18
}
19
#
endif
// DISABLE_PS
20
#
endif
// cafe
21
22
#
include
<
math
/
seadMathCalcCommon
.
h
>
23
24
namespace
sead
{
25
26
template
<
typename
T
>
27
inline
void
28
Vector2CalcCommon
<
T
>::
add
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
29
{
30
o
.
x
=
a
.
x
+
b
.
x
;
31
o
.
y
=
a
.
y
+
b
.
y
;
32
}
33
34
template
<
typename
T
>
35
inline
void
36
Vector2CalcCommon
<
T
>::
sub
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
37
{
38
o
.
x
=
a
.
x
-
b
.
x
;
39
o
.
y
=
a
.
y
-
b
.
y
;
40
}
41
42
template
<
typename
T
>
43
inline
void
44
Vector2CalcCommon
<
T
>::
div
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
45
{
46
o
.
x
=
a
.
x
/
b
.
x
;
47
o
.
y
=
a
.
y
/
b
.
y
;
48
}
49
50
template
<
typename
T
>
51
inline
bool
52
Vector2CalcCommon
<
T
>::
isEqual
(
const
Base
&
a
,
const
Base
&
b
)
53
{
54
return
a
.
x
==
b
.
x
&&
55
a
.
y
==
b
.
y
;
56
}
57
58
template
<
typename
T
>
59
inline
T
60
Vector2CalcCommon
<
T
>::
dot
(
const
Base
&
a
,
const
Base
&
b
)
61
{
62
return
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
;
63
}
64
65
template
<
typename
T
>
66
inline
T
67
Vector2CalcCommon
<
T
>::
squaredLength
(
const
Base
&
v
)
68
{
69
return
v
.
x
*
v
.
x
+
v
.
y
*
v
.
y
;
70
}
71
72
template
<
typename
T
>
73
inline
T
74
Vector2CalcCommon
<
T
>::
length
(
const
Base
&
v
)
75
{
76
return
MathCalcCommon
<
T
>::
sqrt
(
squaredLength
(
v
));
77
}
78
79
template
<
typename
T
>
80
inline
T
81
Vector2CalcCommon
<
T
>::
squaredDistance
(
const
Base
&
v
,
const
Base
&
t
)
82
{
83
T
dx
=
v
.
x
-
t
.
x
;
84
T
dy
=
v
.
y
-
t
.
y
;
85
return
dx
*
dx
+
dy
*
dy
;
86
}
87
88
template
<
typename
T
>
89
inline
T
90
Vector2CalcCommon
<
T
>::
distance
(
const
Base
&
v
,
const
Base
&
t
)
91
{
92
return
MathCalcCommon
<
T
>::
sqrt
(
squaredDistance
(
v
,
t
));
93
}
94
95
template
<
typename
T
>
96
inline
void
97
Vector2CalcCommon
<
T
>::
lerp
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
,
f32
ratio
)
98
{
99
o
.
x
=
MathCalcCommon
<
T
>::
lerp
(
a
.
x
,
b
.
x
,
ratio
);
100
o
.
y
=
MathCalcCommon
<
T
>::
lerp
(
a
.
y
,
b
.
y
,
ratio
);
101
}
102
103
template
<
typename
T
>
104
inline
void
105
Vector2CalcCommon
<
T
>::
multScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
106
{
107
o
.
x
=
v
.
x
*
t
;
108
o
.
y
=
v
.
y
*
t
;
109
}
110
111
template
<
typename
T
>
112
inline
void
113
Vector2CalcCommon
<
T
>::
divScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
114
{
115
T
inv_t
=
MathCalcCommon
<
T
>::
inv
(
t
);
116
multScalar
(
o
,
v
,
inv_t
);
117
}
118
119
template
<
typename
T
>
120
inline
void
121
Vector2CalcCommon
<
T
>::
neg
(
Base
&
o
,
const
Base
&
v
)
122
{
123
o
.
x
=
MathCalcCommon
<
T
>::
neg
(
v
.
x
);
124
o
.
y
=
MathCalcCommon
<
T
>::
neg
(
v
.
y
);
125
}
126
127
template
<
typename
T
>
128
T
Vector2CalcCommon
<
T
>::
normalize
(
Base
&
v
)
129
{
130
const
T
len
=
length
(
v
);
131
if
(
len
> 0)
132
{
133
const
T
inv_len
= 1 /
len
;
134
v
.
x
*=
inv_len
;
135
v
.
y
*=
inv_len
;
136
}
137
138
return
len
;
139
}
140
141
template
<
typename
T
>
142
T
Vector2CalcCommon
<
T
>::
setNormalize
(
Base
&
o
,
const
Base
&
v
)
143
{
144
const
T
len
=
length
(
v
);
145
if
(
len
> 0)
146
{
147
const
T
inv_len
= 1 /
len
;
148
o
.
x
=
v
.
x
*
inv_len
;
149
o
.
y
=
v
.
y
*
inv_len
;
150
}
151
152
return
len
;
153
}
154
155
template
<
typename
T
>
156
inline
constexpr
void
157
Vector2CalcCommon
<
T
>::
set
(
Base
&
o
,
const
Base
&
v
)
158
{
159
o
.
x
=
v
.
x
;
160
o
.
y
=
v
.
y
;
161
}
162
163
template
<
typename
T
>
164
inline
constexpr
void
165
Vector2CalcCommon
<
T
>::
set
(
Base
&
v
,
T
x
,
T
y
)
166
{
167
v
.
x
=
x
;
168
v
.
y
=
y
;
169
}
170
171
template
<
typename
T
>
172
inline
void
173
Vector3CalcCommon
<
T
>::
add
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
174
{
175
o
.
x
=
a
.
x
+
b
.
x
;
176
o
.
y
=
a
.
y
+
b
.
y
;
177
o
.
z
=
a
.
z
+
b
.
z
;
178
}
179
180
#
ifdef
cafe
181
#
ifndef
DISABLE_PS
182
template
<>
183
inline
void
184
Vector3CalcCommon
<
f32
>::
add
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
185
{
186
tof32x2
(
o
.
x
) =
__PS_ADD
(
tof32x2
(
a
.
x
),
tof32x2
(
b
.
x
));
187
o
.
z
=
a
.
z
+
b
.
z
;
188
}
189
#
endif
// DISABLE_PS
190
#
endif
// cafe
191
192
template
<
typename
T
>
193
inline
void
194
Vector3CalcCommon
<
T
>::
sub
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
195
{
196
o
.
x
=
a
.
x
-
b
.
x
;
197
o
.
y
=
a
.
y
-
b
.
y
;
198
o
.
z
=
a
.
z
-
b
.
z
;
199
}
200
201
#
ifdef
cafe
202
#
ifndef
DISABLE_PS
203
template
<>
204
inline
void
205
Vector3CalcCommon
<
f32
>::
sub
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
206
{
207
tof32x2
(
o
.
x
) =
__PS_SUB
(
tof32x2
(
a
.
x
),
tof32x2
(
b
.
x
));
208
o
.
z
=
a
.
z
-
b
.
z
;
209
}
210
#
endif
// DISABLE_PS
211
#
endif
// cafe
212
213
template
<
typename
T
>
214
inline
bool
215
Vector3CalcCommon
<
T
>::
isEqual
(
const
Base
&
a
,
const
Base
&
b
)
216
{
217
return
a
.
x
==
b
.
x
&&
218
a
.
y
==
b
.
y
&&
219
a
.
z
==
b
.
z
;
220
}
221
222
template
<
typename
T
>
223
inline
void
224
Vector3CalcCommon
<
T
>::
cross
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
225
{
226
Base
v
;
227
228
v
.
x
=
a
.
y
*
b
.
z
-
a
.
z
*
b
.
y
;
229
v
.
y
=
a
.
z
*
b
.
x
-
a
.
x
*
b
.
z
;
230
v
.
z
=
a
.
x
*
b
.
y
-
a
.
y
*
b
.
x
;
231
232
o
.
x
=
v
.
x
;
233
o
.
y
=
v
.
y
;
234
o
.
z
=
v
.
z
;
235
}
236
237
#
ifdef
cafe
238
239
template
<>
240
inline
void
241
Vector3CalcCommon
<
f32
>::
cross
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
242
{
243
ASM_VECCrossProduct
((
const
Vec
*)&
a
, (
const
Vec
*)&
b
, (
Vec
*)&
o
);
244
}
245
246
#
endif
// cafe
247
248
template
<
typename
T
>
249
inline
T
250
Vector3CalcCommon
<
T
>::
dot
(
const
Base
&
a
,
const
Base
&
b
)
251
{
252
return
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
;
253
}
254
255
#
ifdef
cafe
256
#
ifndef
DISABLE_PS
257
template
<>
258
inline
f32
259
Vector3CalcCommon
<
f32
>::
dot
(
const
Base
&
a
,
const
Base
&
b
)
260
{
261
f32x2
f0
;
262
f0
=
__PS_MUL
(
tof32x2
(
a
.
x
),
tof32x2
(
b
.
x
));
263
f0
=
__PS_SUM0
(
f0
,
f0
,
f0
);
264
265
return
f0
[0] +
a
.
z
*
b
.
z
;
266
}
267
#
endif
// DISABLE_PS
268
#
endif
// cafe
269
270
template
<
typename
T
>
271
inline
T
272
Vector3CalcCommon
<
T
>::
squaredLength
(
const
Base
&
v
)
273
{
274
return
v
.
x
*
v
.
x
+
v
.
y
*
v
.
y
+
v
.
z
*
v
.
z
;
275
}
276
277
#
ifdef
cafe
278
279
template
<>
280
inline
f32
281
Vector3CalcCommon
<
f32
>::
squaredLength
(
const
Base
&
v
)
282
{
283
return
ASM_VECSquareMag
((
const
Vec
*)&
v
);
284
}
285
286
#
endif
// cafe
287
288
template
<
typename
T
>
289
inline
T
290
Vector3CalcCommon
<
T
>::
length
(
const
Base
&
v
)
291
{
292
return
MathCalcCommon
<
T
>::
sqrt
(
squaredLength
(
v
));
293
}
294
295
#
ifdef
cafe
296
297
template
<>
298
inline
f32
299
Vector3CalcCommon
<
f32
>::
length
(
const
Base
&
v
)
300
{
301
return
ASM_VECMag
((
const
Vec
*)&
v
);
302
}
303
304
#
endif
// cafe
305
306
template
<
typename
T
>
307
inline
T
308
Vector3CalcCommon
<
T
>::
squaredDistance
(
const
Base
&
v
,
const
Base
&
t
)
309
{
310
T
dx
=
v
.
x
-
t
.
x
;
311
T
dy
=
v
.
y
-
t
.
y
;
312
T
dz
=
v
.
z
-
t
.
z
;
313
return
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
314
}
315
316
#
ifdef
cafe
317
318
template
<>
319
inline
f32
320
Vector3CalcCommon
<
f32
>::
squaredDistance
(
const
Base
&
v
,
const
Base
&
t
)
321
{
322
return
ASM_VECSquareDistance
((
const
Vec
*)&
v
, (
const
Vec
*)&
t
);
323
}
324
325
#
endif
// cafe
326
327
template
<
typename
T
>
328
inline
T
329
Vector3CalcCommon
<
T
>::
distance
(
const
Base
&
v
,
const
Base
&
t
)
330
{
331
return
MathCalcCommon
<
T
>::
sqrt
(
squaredDistance
(
v
,
t
));
332
}
333
334
#
ifdef
cafe
335
336
template
<>
337
inline
f32
338
Vector3CalcCommon
<
f32
>::
distance
(
const
Base
&
v
,
const
Base
&
t
)
339
{
340
return
ASM_VECDistance
((
const
Vec
*)&
v
, (
const
Vec
*)&
t
);
341
}
342
343
#
endif
// cafe
344
345
template
<
typename
T
>
346
inline
void
347
Vector3CalcCommon
<
T
>::
lerp
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
,
f32
ratio
)
348
{
349
o
.
x
=
MathCalcCommon
<
T
>::
lerp
(
a
.
x
,
b
.
x
,
ratio
);
350
o
.
y
=
MathCalcCommon
<
T
>::
lerp
(
a
.
y
,
b
.
y
,
ratio
);
351
o
.
z
=
MathCalcCommon
<
T
>::
lerp
(
a
.
z
,
b
.
z
,
ratio
);
352
}
353
354
#
ifdef
cafe
355
356
template
<>
357
inline
void
358
Vector3CalcCommon
<
f32
>::
mul
(
Base
&
o
,
const
Mtx34
&
m
,
const
Base
&
v
)
359
{
360
ASM_MTXMultVec
(
const_cast
<
f32
(*)[4]>(
m
.
m
), (
const
Vec
*)&
v
, (
Vec
*)&
o
);
361
}
362
363
template
<>
364
inline
void
365
Vector3CalcCommon
<
f32
>::
rotate
(
Base
&
o
,
const
Mtx34
&
m
,
const
Base
&
v
)
366
{
367
ASM_MTXMultVecSR
(
const_cast
<
f32
(*)[4]>(
m
.
m
), (
const
Vec
*)&
v
, (
Vec
*)&
o
);
368
}
369
370
#
endif
// cafe
371
372
template
<
typename
T
>
373
inline
void
374
Vector3CalcCommon
<
T
>::
multScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
375
{
376
o
.
x
=
v
.
x
*
t
;
377
o
.
y
=
v
.
y
*
t
;
378
o
.
z
=
v
.
z
*
t
;
379
}
380
381
#
ifdef
cafe
382
#
ifndef
DISABLE_PS
383
template
<>
384
inline
void
385
Vector3CalcCommon
<
f32
>::
multScalar
(
Base
&
o
,
const
Base
&
v
,
f32
t
)
386
{
387
tof32x2
(
o
.
x
) =
__PS_MULS0F
(
tof32x2
(
v
.
x
),
t
);
388
o
.
z
=
v
.
z
*
t
;
389
}
390
#
endif
// DISABLE_PS
391
#
endif
// cafe
392
393
template
<
typename
T
>
394
inline
void
395
Vector3CalcCommon
<
T
>::
multScalarAdd
(
Base
&
o
,
T
t
,
const
Base
&
a
,
const
Base
&
b
)
396
{
397
o
.
x
=
a
.
x
*
t
+
b
.
x
;
398
o
.
y
=
a
.
y
*
t
+
b
.
y
;
399
o
.
z
=
a
.
z
*
t
+
b
.
z
;
400
}
401
402
#
ifdef
cafe
403
#
ifndef
DISABLE_PS
404
template
<>
405
inline
void
406
Vector3CalcCommon
<
f32
>::
multScalarAdd
(
Base
&
o
,
f32
t
,
const
Base
&
a
,
const
Base
&
b
)
407
{
408
tof32x2
(
o
.
x
) =
__PS_MADDS0F
(
tof32x2
(
a
.
x
),
t
,
tof32x2
(
b
.
x
));
409
o
.
z
=
a
.
z
*
t
+
b
.
z
;
410
}
411
#
endif
// DISABLE_PS
412
#
endif
// cafe
413
414
template
<
typename
T
>
415
inline
void
416
Vector3CalcCommon
<
T
>::
divScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
417
{
418
T
inv_t
=
MathCalcCommon
<
T
>::
inv
(
t
);
419
multScalar
(
o
,
v
,
inv_t
);
420
}
421
422
template
<
typename
T
>
423
inline
void
424
Vector3CalcCommon
<
T
>::
neg
(
Base
&
o
,
const
Base
&
v
)
425
{
426
o
.
x
=
MathCalcCommon
<
T
>::
neg
(
v
.
x
);
427
o
.
y
=
MathCalcCommon
<
T
>::
neg
(
v
.
y
);
428
o
.
z
=
MathCalcCommon
<
T
>::
neg
(
v
.
z
);
429
}
430
431
template
<
typename
T
>
432
T
Vector3CalcCommon
<
T
>::
normalize
(
Base
&
v
)
433
{
434
const
T
len
=
length
(
v
);
435
if
(
len
> 0)
436
{
437
const
T
inv_len
= 1 /
len
;
438
v
.
x
*=
inv_len
;
439
v
.
y
*=
inv_len
;
440
v
.
z
*=
inv_len
;
441
}
442
443
return
len
;
444
}
445
446
template
<
typename
T
>
447
T
Vector3CalcCommon
<
T
>::
setNormalize
(
Base
&
o
,
const
Base
&
v
)
448
{
449
const
T
len
=
length
(
v
);
450
if
(
len
> 0)
451
{
452
const
T
inv_len
= 1 /
len
;
453
o
.
x
=
v
.
x
*
inv_len
;
454
o
.
y
=
v
.
y
*
inv_len
;
455
o
.
z
=
v
.
z
*
inv_len
;
456
}
457
458
return
len
;
459
}
460
461
template
<
typename
T
>
462
inline
constexpr
void
463
Vector3CalcCommon
<
T
>::
set
(
Base
&
o
,
const
Base
&
v
)
464
{
465
o
.
x
=
v
.
x
;
466
o
.
y
=
v
.
y
;
467
o
.
z
=
v
.
z
;
468
}
469
470
template
<
typename
T
>
471
inline
constexpr
void
472
Vector3CalcCommon
<
T
>::
set
(
Base
&
v
,
T
x
,
T
y
,
T
z
)
473
{
474
v
.
x
=
x
;
475
v
.
y
=
y
;
476
v
.
z
=
z
;
477
}
478
479
template
<
typename
T
>
480
inline
void
481
Vector4CalcCommon
<
T
>::
add
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
482
{
483
o
.
x
=
a
.
x
+
b
.
x
;
484
o
.
y
=
a
.
y
+
b
.
y
;
485
o
.
z
=
a
.
z
+
b
.
z
;
486
o
.
w
=
a
.
w
+
b
.
w
;
487
}
488
489
template
<
typename
T
>
490
inline
void
491
Vector4CalcCommon
<
T
>::
sub
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
)
492
{
493
o
.
x
=
a
.
x
-
b
.
x
;
494
o
.
y
=
a
.
y
-
b
.
y
;
495
o
.
z
=
a
.
z
-
b
.
z
;
496
o
.
w
=
a
.
w
-
b
.
w
;
497
}
498
499
template
<
typename
T
>
500
inline
bool
501
Vector4CalcCommon
<
T
>::
isEqual
(
const
Base
&
a
,
const
Base
&
b
)
502
{
503
return
a
.
x
==
b
.
x
&&
504
a
.
y
==
b
.
y
&&
505
a
.
z
==
b
.
z
&&
506
a
.
w
==
b
.
w
;
507
}
508
509
template
<
typename
T
>
510
inline
T
511
Vector4CalcCommon
<
T
>::
dot
(
const
Base
&
a
,
const
Base
&
b
)
512
{
513
return
a
.
x
*
b
.
x
+
a
.
y
*
b
.
y
+
a
.
z
*
b
.
z
+
a
.
w
*
b
.
w
;
514
}
515
516
template
<
typename
T
>
517
inline
T
518
Vector4CalcCommon
<
T
>::
squaredLength
(
const
Base
&
v
)
519
{
520
return
v
.
x
*
v
.
x
+
v
.
y
*
v
.
y
+
v
.
z
*
v
.
z
+
v
.
w
*
v
.
w
;
521
}
522
523
template
<
typename
T
>
524
inline
T
525
Vector4CalcCommon
<
T
>::
length
(
const
Base
&
v
)
526
{
527
return
MathCalcCommon
<
T
>::
sqrt
(
squaredLength
(
v
));
528
}
529
530
template
<
typename
T
>
531
inline
T
532
Vector4CalcCommon
<
T
>::
squaredDistance
(
const
Base
&
v
,
const
Base
&
t
)
533
{
534
T
dx
=
v
.
x
-
t
.
x
;
535
T
dy
=
v
.
y
-
t
.
y
;
536
T
dz
=
v
.
z
-
t
.
z
;
537
T
dw
=
v
.
w
-
t
.
w
;
538
return
dx
*
dx
+
dy
*
dy
+
dz
*
dz
+
dw
*
dw
;
539
}
540
541
template
<
typename
T
>
542
inline
T
543
Vector4CalcCommon
<
T
>::
distance
(
const
Base
&
v
,
const
Base
&
t
)
544
{
545
return
MathCalcCommon
<
T
>::
sqrt
(
squaredDistance
(
v
,
t
));
546
}
547
548
template
<
typename
T
>
549
inline
void
550
Vector4CalcCommon
<
T
>::
lerp
(
Base
&
o
,
const
Base
&
a
,
const
Base
&
b
,
f32
ratio
)
551
{
552
o
.
x
=
MathCalcCommon
<
T
>::
lerp
(
a
.
x
,
b
.
x
,
ratio
);
553
o
.
y
=
MathCalcCommon
<
T
>::
lerp
(
a
.
y
,
b
.
y
,
ratio
);
554
o
.
z
=
MathCalcCommon
<
T
>::
lerp
(
a
.
z
,
b
.
z
,
ratio
);
555
o
.
w
=
MathCalcCommon
<
T
>::
lerp
(
a
.
w
,
b
.
w
,
ratio
);
556
}
557
558
template
<
typename
T
>
559
inline
void
560
Vector4CalcCommon
<
T
>::
multScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
561
{
562
o
.
x
=
v
.
x
*
t
;
563
o
.
y
=
v
.
y
*
t
;
564
o
.
z
=
v
.
z
*
t
;
565
o
.
w
=
v
.
w
*
t
;
566
}
567
568
template
<
typename
T
>
569
inline
void
570
Vector4CalcCommon
<
T
>::
divScalar
(
Base
&
o
,
const
Base
&
v
,
T
t
)
571
{
572
T
inv_t
=
MathCalcCommon
<
T
>::
inv
(
t
);
573
multScalar
(
o
,
v
,
inv_t
);
574
}
575
576
template
<
typename
T
>
577
inline
void
578
Vector4CalcCommon
<
T
>::
neg
(
Base
&
o
,
const
Base
&
v
)
579
{
580
o
.
x
=
MathCalcCommon
<
T
>::
neg
(
v
.
x
);
581
o
.
y
=
MathCalcCommon
<
T
>::
neg
(
v
.
y
);
582
o
.
z
=
MathCalcCommon
<
T
>::
neg
(
v
.
z
);
583
o
.
w
=
MathCalcCommon
<
T
>::
neg
(
v
.
w
);
584
}
585
586
template
<
typename
T
>
587
T
Vector4CalcCommon
<
T
>::
normalize
(
Base
&
v
)
588
{
589
const
T
len
=
length
(
v
);
590
if
(
len
> 0)
591
{
592
const
T
inv_len
= 1 /
len
;
593
v
.
x
*=
inv_len
;
594
v
.
y
*=
inv_len
;
595
v
.
z
*=
inv_len
;
596
v
.
w
*=
inv_len
;
597
}
598
599
return
len
;
600
}
601
602
template
<
typename
T
>
603
T
Vector4CalcCommon
<
T
>::
setNormalize
(
Base
&
o
,
const
Base
&
v
)
604
{
605
const
T
len
=
length
(
v
);
606
if
(
len
> 0)
607
{
608
const
T
inv_len
= 1 /
len
;
609
o
.
x
=
v
.
x
*
inv_len
;
610
o
.
y
=
v
.
y
*
inv_len
;
611
o
.
z
=
v
.
z
*
inv_len
;
612
o
.
w
=
v
.
w
*
inv_len
;
613
}
614
615
return
len
;
616
}
617
618
template
<
typename
T
>
619
inline
constexpr
void
620
Vector4CalcCommon
<
T
>::
set
(
Base
&
o
,
const
Base
&
v
)
621
{
622
o
.
x
=
v
.
x
;
623
o
.
y
=
v
.
y
;
624
o
.
z
=
v
.
z
;
625
o
.
w
=
v
.
w
;
626
}
627
628
template
<
typename
T
>
629
inline
constexpr
void
630
Vector4CalcCommon
<
T
>::
set
(
Base
&
v
,
T
x
,
T
y
,
T
z
,
T
w
)
631
{
632
v
.
x
=
x
;
633
v
.
y
=
y
;
634
v
.
z
=
z
;
635
v
.
w
=
w
;
636
}
637
638
}
// namespace sead
sead
Definition
seadAssert.h:44
engine
library
include
math
seadVectorCalcCommon.hpp
Generated by
1.14.0