Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Core/Math/MathHelper.cpp

Diff revisions: vs.
  @@ -4,83 +4,77 @@
4 4 namespace Divide {
5 5 namespace Util {
6 6 vec4<U8> toByteColor(const vec4<F32>& floatColor) {
7 - return vec4<U8>(static_cast<U8>(floatColor.r * 255), static_cast<U8>(floatColor.g * 255), static_cast<U8>(floatColor.b * 255), static_cast<U8>(floatColor.a * 255));
7 + return vec4<U8>(static_cast<U8>(floatColor.r * 255),
8 + static_cast<U8>(floatColor.g * 255),
9 + static_cast<U8>(floatColor.b * 255),
10 + static_cast<U8>(floatColor.a * 255));
8 11 }
9 12
10 13 vec3<U8> toByteColor(const vec3<F32>& floatColor) {
11 - return vec3<U8>(static_cast<U8>(floatColor.r * 255), static_cast<U8>(floatColor.g * 255), static_cast<U8>(floatColor.b * 255));
14 + return vec3<U8>(static_cast<U8>(floatColor.r * 255),
15 + static_cast<U8>(floatColor.g * 255),
16 + static_cast<U8>(floatColor.b * 255));
12 17 }
13 18
14 19 vec4<F32> toFloatColor(const vec4<U8>& byteColor) {
15 - return vec4<F32>(static_cast<F32>(byteColor.r / 255), static_cast<F32>(byteColor.g / 255), static_cast<F32>(byteColor.b / 255), static_cast<F32>(byteColor.a / 255));
20 + return vec4<F32>(static_cast<F32>(byteColor.r / 255),
21 + static_cast<F32>(byteColor.g / 255),
22 + static_cast<F32>(byteColor.b / 255),
23 + static_cast<F32>(byteColor.a / 255));
16 24 }
17 25
18 26 vec3<F32> toFloatColor(const vec3<U8>& byteColor) {
19 - return vec3<F32>(static_cast<F32>(byteColor.r / 255), static_cast<F32>(byteColor.g / 255), static_cast<F32>(byteColor.b / 255));
27 + return vec3<F32>(static_cast<F32>(byteColor.r / 255),
28 + static_cast<F32>(byteColor.g / 255),
29 + static_cast<F32>(byteColor.b / 255));
20 30 }
21 31
22 32 void normalize(vec3<F32>& inputRotation, bool degrees, bool normYaw, bool normPitch, bool normRoll) {
23 - if(normYaw)
24 - {
33 + if (normYaw) {
25 34 F32 yaw = degrees ? RADIANS(inputRotation.yaw) : inputRotation.yaw;
26 - if(yaw < -M_PI)
27 - {
35 + if (yaw < -M_PI) {
28 36 yaw = fmod(yaw, M_PI * 2.0f);
29 - if(yaw < -M_PI)
30 - {
37 + if (yaw < -M_PI) {
31 38 yaw += M_PI * 2.0f;
32 39 }
33 40 inputRotation.yaw = DEGREES(yaw);
34 - }
35 - else if(yaw >M_PI)
36 - {
41 + } else if(yaw >M_PI) {
37 42 yaw = fmod(yaw, M_PI * 2.0f);
38 - if(yaw > M_PI)
39 - {
43 + if (yaw > M_PI) {
40 44 yaw -= M_PI * 2.0f;
41 45 }
42 46 inputRotation.yaw = degrees ? DEGREES(yaw) : yaw;
43 47 }
44 48 }
45 - if(normPitch)
46 - {
49 + if (normPitch) {
47 50 F32 pitch = degrees ? RADIANS(inputRotation.pitch) : inputRotation.pitch;
48 - if(pitch < -M_PI)
49 - {
51 + if (pitch < -M_PI) {
50 52 pitch = fmod(pitch, M_PI * 2.0f);
51 53 if(pitch < -M_PI)
52 54 {
53 55 pitch += M_PI * 2.0f;
54 56 }
55 57 inputRotation.pitch = DEGREES(pitch);
56 - }
57 - else if(pitch > M_PI)
58 - {
58 + } else if(pitch > M_PI) {
59 59 pitch = fmod(pitch,M_PI * 2.0f);
60 - if(pitch > M_PI)
61 - {
60 + if (pitch > M_PI) {
62 61 pitch -= M_PI * 2.0f;
63 62 }
64 63 inputRotation.pitch = degrees ? DEGREES(pitch) : pitch;
65 64 }
66 65 }
67 - if(normRoll)
68 - {
66 + if(normRoll) {
69 67 F32 roll= degrees ? RADIANS(inputRotation.roll) : inputRotation.roll;
70 - if(roll < -M_PI)
71 - {
68 + if (roll < -M_PI) {
72 69 roll = fmod(roll, M_PI * 2.0f);
73 70 if(roll < -M_PI)
74 71 {
75 72 roll += M_PI * 2.0f;
76 73 }
77 74 inputRotation.roll = DEGREES(roll);
78 - }
79 - else if(roll > M_PI)
80 - {
75 + } else if(roll > M_PI) {
81 76 roll = fmod(roll, M_PI * 2.0f);
82 - if(roll > M_PI)
83 - {
77 + if (roll > M_PI) {
84 78 roll -= M_PI * 2.0f;
85 79 }
86 80 inputRotation.roll = degrees ? DEGREES(roll) : roll;