Subversion Repository Public Repository

Divide-Framework

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
Copyright (c) 2018 DIVIDE-Studio
Copyright (c) 2009 Ionut Cava

This file is part of DIVIDE Framework.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software
and associated documentation files (the "Software"), to deal in the Software
without restriction,
including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

#ifndef _TRANSFORM_INL_
#define _TRANSFORM_INL_

namespace Divide {

inline void TransformValues::operator=(const TransformValues& other) {
    _translation.set(other._translation);
    _scale.set(other._scale);
    _orientation.set(other._orientation);
}

inline bool TransformValues::operator==(const TransformValues& other) const {
    return _scale.compare(other._scale) &&
        _orientation.compare(other._orientation) &&
        _translation.compare(other._translation);
}

inline bool TransformValues::operator!=(const TransformValues& other) const {
    return !_scale.compare(other._scale) ||
        !_orientation.compare(other._orientation) ||
        !_translation.compare(other._translation);
}

/// Set the local X,Y and Z position
inline void Transform::setPosition(const vec3<F32>& position) {
    _dirty = true;
    _transformValues._translation.set(position);
}
/// Set the object's position on the X axis
inline void Transform::setPositionX(const F32 positionX) {
    setPosition(vec3<F32>(positionX,
        _transformValues._translation.y,
        _transformValues._translation.z));
}
/// Set the object's position on the Y axis
inline void Transform::setPositionY(const F32 positionY) {
    setPosition(vec3<F32>(_transformValues._translation.x,
        positionY,
        _transformValues._translation.z));
}

/// Set the object's position on the Z axis
inline void Transform::setPositionZ(const F32 positionZ) {
    setPosition(vec3<F32>(_transformValues._translation.x,
        _transformValues._translation.y,
        positionZ));
}

/// Set the local X,Y and Z scale factors
inline void Transform::setScale(const vec3<F32>& scale) {
    _dirty = true;
    _rebuildMatrix = true;
    _transformValues._scale.set(scale);
}

/// Set the local orientation using the Axis-Angle system.
/// The angle can be in either degrees(default) or radians
inline void Transform::setRotation(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) {
    setRotation(Quaternion<F32>(axis, degrees));
}

/// Set the local orientation using the Euler system.
/// The angles can be in either degrees(default) or radians
inline void Transform::setRotation(Angle::DEGREES<F32> pitch, Angle::DEGREES<F32> yaw, Angle::DEGREES<F32> roll) {
    setRotation(Quaternion<F32>(pitch, yaw, roll));
}

/// Set the local orientation so that it matches the specified quaternion.
inline void Transform::setRotation(const Quaternion<F32>& quat) {
    _dirty = true;
    _rebuildMatrix = true;
    _transformValues._orientation.set(quat);
    _transformValues._orientation.normalize();
}

/// Add the specified translation factors to the current local position
inline void Transform::translate(const vec3<F32>& axisFactors) {
    _dirty = true;
    _transformValues._translation += axisFactors;
}

/// Add the specified scale factors to the current local position
inline void Transform::scale(const vec3<F32>& axisFactors) {
    _dirty = true;
    _rebuildMatrix = true;
    _transformValues._scale *= axisFactors;
}

/// Apply the specified Axis-Angle rotation starting from the current
/// orientation.
/// The angles can be in either degrees(default) or radians
inline void Transform::rotate(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) {
    rotate(Quaternion<F32>(axis, degrees));
}

/// Apply the specified Euler rotation starting from the current
/// orientation.
/// The angles can be in either degrees(default) or radians
inline void Transform::rotate(Angle::DEGREES<F32> pitch, Angle::DEGREES<F32> yaw, Angle::DEGREES<F32> roll) {
    rotate(Quaternion<F32>(pitch, yaw, roll));
}

/// Apply the specified Quaternion rotation starting from the current orientation.
inline void Transform::rotate(const Quaternion<F32>& quat) {
    setRotation(quat * _transformValues._orientation);
}

/// Perform a SLERP rotation towards the specified quaternion
inline void Transform::rotateSlerp(const Quaternion<F32>& quat, const D64 deltaTime) {
    _dirty = true;
    _rebuildMatrix = true;
    _transformValues._orientation.slerp(quat, to_F32(deltaTime));
    _transformValues._orientation.normalize();
}

/// Set the scaling factor on the X axis
inline void Transform::setScaleX(const F32 ammount) {
    setScale(vec3<F32>(ammount, _transformValues._scale.y,
                                _transformValues._scale.z));
}
/// Set the scaling factor on the Y axis
inline void Transform::setScaleY(const F32 ammount) {
    setScale(vec3<F32>(_transformValues._scale.x, ammount,
                                _transformValues._scale.z));
}
/// Set the scaling factor on the Z axis
inline void Transform::setScaleZ(const F32 ammount) {
    setScale(vec3<F32>(_transformValues._scale.x,
                                _transformValues._scale.y, ammount));
}

/// Increase the scaling factor on the X axis by the specified factor
inline void Transform::scaleX(const F32 ammount) {
    scale(vec3<F32>(ammount,
                    _transformValues._scale.y,
                    _transformValues._scale.z));
}
/// Increase the scaling factor on the Y axis by the specified factor
inline void Transform::scaleY(const F32 ammount) {
    scale(vec3<F32>(_transformValues._scale.x,
                    ammount,
                    _transformValues._scale.z));
}
/// Increase the scaling factor on the Z axis by the specified factor
inline void Transform::scaleZ(const F32 ammount) {
    scale(vec3<F32>(_transformValues._scale.x,
                    _transformValues._scale.y,
                    ammount));
}
/// Rotate on the X axis (Axis-Angle used) by the specified angle (either
/// degrees or radians)
inline void Transform::rotateX(const Angle::DEGREES<F32> angle) {
    rotate(vec3<F32>(1, 0, 0), angle);
}
/// Rotate on the Y axis (Axis-Angle used) by the specified angle (either
/// degrees or radians)
inline void Transform::rotateY(const Angle::DEGREES<F32> angle) {
    rotate(vec3<F32>(0, 1, 0), angle);
}
/// Rotate on the Z axis (Axis-Angle used) by the specified angle (either
/// degrees or radians)
inline void Transform::rotateZ(const Angle::DEGREES<F32> angle) {
    rotate(vec3<F32>(0, 0, 1), angle);
}
/// Set the rotation on the X axis (Axis-Angle used) by the specified angle
/// (either degrees or radians)
inline void Transform::setRotationX(const Angle::DEGREES<F32> angle) {
    setRotation(vec3<F32>(1, 0, 0), angle);
}
/// Set the rotation on the Y axis (Axis-Angle used) by the specified angle
/// (either degrees or radians)
inline void Transform::setRotationY(const Angle::DEGREES<F32> angle) {
    setRotation(vec3<F32>(0, 1, 0), angle);
}
/// Set the rotation on the Z axis (Axis-Angle used) by the specified angle
/// (either degrees or radians)
inline void Transform::setRotationZ(const Angle::DEGREES<F32> angle) {
    setRotation(vec3<F32>(0, 0, 1), angle);
}

/// Return the scale factor
inline void Transform::getScale(vec3<F32>& scaleOut) const {
    scaleOut.set(_transformValues._scale);
}

/// Return the position
inline void Transform::getPosition(vec3<F32>& posOut) const {
    posOut.set(_transformValues._translation);
}

/// Return the orientation quaternion
inline void Transform::getOrientation(Quaternion<F32>& quatOut) const {
    quatOut.set(_transformValues._orientation);
}

inline void Transform::clone(Transform* const transform) {
    _dirty = true;
    _rebuildMatrix = true;

    transform->getValues(_transformValues);
}

inline void Transform::getValues(TransformValues& valuesOut) const {
    valuesOut = _transformValues;
}

/// Set position, scale and rotation based on the specified transform values
inline void Transform::setValues(const TransformValues& values) {
    _dirty = true;
    _rebuildMatrix = true;

    _transformValues._scale.set(values._scale);
    _transformValues._translation.set(values._translation);
    _transformValues._orientation.set(values._orientation);
}

/// Compares 2 transforms
inline bool Transform::operator==(const Transform& other) const {
    return _transformValues == other._transformValues;
}

inline bool Transform::operator!=(const Transform& other) const {
    return _transformValues != other._transformValues;
}
};

#endif //_TRANSFORM_INL_

Commits for Divide-Framework/trunk/Source Code/Core/Math/Headers/Transform.inl

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

898 Diff Diff IonutCava picture IonutCava Thu 22 Jun, 2017 22:05:34 +0000

[IonutCava]
- Use vectorImpl instead of vector in the few remaining places it wasn’t used
- Force GLIM to use the submitRenderCommand / GenericDrawCommand system
- Add basic framework for a “pushConstants” type buffer that will replace Uniform() calls
- Add some code to allow hardware query rewrite in the future

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

821 Diff Diff IonutCava picture IonutCava Tue 17 Jan, 2017 17:15:45 +0000

[IonutCava]
- Profile guided optimizations

695 IonutCava picture IonutCava Sun 08 May, 2016 22:45:32 +0000

[IonutCava]
- Better separation of rigid body based physics and standard transform system