my own uncrustify run
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GtkRadiant is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined (INCLUDED_TRANSFORMLIB_H)
|
||||
#if !defined ( INCLUDED_TRANSFORMLIB_H )
|
||||
#define INCLUDED_TRANSFORMLIB_H
|
||||
|
||||
#include "generic/constant.h"
|
||||
@@ -31,40 +31,36 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
class TransformNode
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT(Name, "TransformNode");
|
||||
/// \brief Returns the transform which maps the node's local-space into the local-space of its parent node.
|
||||
virtual const Matrix4& localToParent() const = 0;
|
||||
STRING_CONSTANT( Name, "TransformNode" );
|
||||
/// \brief Returns the transform which maps the node's local-space into the local-space of its parent node.
|
||||
virtual const Matrix4& localToParent() const = 0;
|
||||
};
|
||||
|
||||
/// \brief A transform node which has no effect.
|
||||
class IdentityTransform : public TransformNode
|
||||
{
|
||||
public:
|
||||
/// \brief Returns the identity matrix.
|
||||
const Matrix4& localToParent() const
|
||||
{
|
||||
return g_matrix4_identity;
|
||||
}
|
||||
/// \brief Returns the identity matrix.
|
||||
const Matrix4& localToParent() const {
|
||||
return g_matrix4_identity;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief A transform node which stores a generic transformation matrix.
|
||||
class MatrixTransform : public TransformNode
|
||||
{
|
||||
Matrix4 m_localToParent;
|
||||
Matrix4 m_localToParent;
|
||||
public:
|
||||
MatrixTransform() : m_localToParent(g_matrix4_identity)
|
||||
{
|
||||
}
|
||||
MatrixTransform() : m_localToParent( g_matrix4_identity ){
|
||||
}
|
||||
|
||||
Matrix4& localToParent()
|
||||
{
|
||||
return m_localToParent;
|
||||
}
|
||||
/// \brief Returns the stored local->parent transform.
|
||||
const Matrix4& localToParent() const
|
||||
{
|
||||
return m_localToParent;
|
||||
}
|
||||
Matrix4& localToParent(){
|
||||
return m_localToParent;
|
||||
}
|
||||
/// \brief Returns the stored local->parent transform.
|
||||
const Matrix4& localToParent() const {
|
||||
return m_localToParent;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -74,16 +70,15 @@ typedef Vector3 Translation;
|
||||
typedef Quaternion Rotation;
|
||||
typedef Vector3 Scale;
|
||||
|
||||
inline Matrix4 matrix4_transform_for_components(const Translation& translation, const Rotation& rotation, const Scale& scale)
|
||||
{
|
||||
Matrix4 result(matrix4_rotation_for_quaternion_quantised(rotation));
|
||||
vector4_to_vector3(result.x()) *= scale.x();
|
||||
vector4_to_vector3(result.y()) *= scale.y();
|
||||
vector4_to_vector3(result.z()) *= scale.z();
|
||||
result.tx() = translation.x();
|
||||
result.ty() = translation.y();
|
||||
result.tz() = translation.z();
|
||||
return result;
|
||||
inline Matrix4 matrix4_transform_for_components( const Translation& translation, const Rotation& rotation, const Scale& scale ){
|
||||
Matrix4 result( matrix4_rotation_for_quaternion_quantised( rotation ) );
|
||||
vector4_to_vector3( result.x() ) *= scale.x();
|
||||
vector4_to_vector3( result.y() ) *= scale.y();
|
||||
vector4_to_vector3( result.z() ) *= scale.z();
|
||||
result.tx() = translation.x();
|
||||
result.ty() = translation.y();
|
||||
result.tz() = translation.z();
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef bool TransformModifierType;
|
||||
@@ -102,91 +97,79 @@ const TransformModifierType TRANSFORM_COMPONENT = true;
|
||||
class Transformable
|
||||
{
|
||||
public:
|
||||
STRING_CONSTANT(Name, "Transformable");
|
||||
STRING_CONSTANT( Name, "Transformable" );
|
||||
|
||||
virtual void setType(TransformModifierType type) = 0;
|
||||
virtual void setTranslation(const Translation& value) = 0;
|
||||
virtual void setRotation(const Rotation& value) = 0;
|
||||
virtual void setScale(const Scale& value) = 0;
|
||||
virtual void freezeTransform() = 0;
|
||||
virtual void setType( TransformModifierType type ) = 0;
|
||||
virtual void setTranslation( const Translation& value ) = 0;
|
||||
virtual void setRotation( const Rotation& value ) = 0;
|
||||
virtual void setScale( const Scale& value ) = 0;
|
||||
virtual void freezeTransform() = 0;
|
||||
};
|
||||
|
||||
const Translation c_translation_identity = Translation(0, 0, 0);
|
||||
const Translation c_translation_identity = Translation( 0, 0, 0 );
|
||||
const Rotation c_rotation_identity = c_quaternion_identity;
|
||||
const Scale c_scale_identity = Scale(1, 1, 1);
|
||||
const Scale c_scale_identity = Scale( 1, 1, 1 );
|
||||
|
||||
|
||||
class TransformModifier : public Transformable
|
||||
{
|
||||
Translation m_translation;
|
||||
Rotation m_rotation;
|
||||
Scale m_scale;
|
||||
Callback m_changed;
|
||||
Callback m_apply;
|
||||
TransformModifierType m_type;
|
||||
Translation m_translation;
|
||||
Rotation m_rotation;
|
||||
Scale m_scale;
|
||||
Callback m_changed;
|
||||
Callback m_apply;
|
||||
TransformModifierType m_type;
|
||||
public:
|
||||
|
||||
TransformModifier(const Callback& changed, const Callback& apply) :
|
||||
m_translation(c_translation_identity),
|
||||
m_rotation(c_quaternion_identity),
|
||||
m_scale(c_scale_identity),
|
||||
m_changed(changed),
|
||||
m_apply(apply),
|
||||
m_type(TRANSFORM_PRIMITIVE)
|
||||
{
|
||||
}
|
||||
void setType(TransformModifierType type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
TransformModifierType getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
void setTranslation(const Translation& value)
|
||||
{
|
||||
m_translation = value;
|
||||
m_changed();
|
||||
}
|
||||
void setRotation(const Rotation& value)
|
||||
{
|
||||
m_rotation = value;
|
||||
m_changed();
|
||||
}
|
||||
void setScale(const Scale& value)
|
||||
{
|
||||
m_scale = value;
|
||||
m_changed();
|
||||
}
|
||||
void freezeTransform()
|
||||
{
|
||||
if(m_translation != c_translation_identity
|
||||
|| m_rotation != c_rotation_identity
|
||||
|| m_scale != c_scale_identity)
|
||||
{
|
||||
m_apply();
|
||||
m_translation = c_translation_identity;
|
||||
m_rotation = c_rotation_identity;
|
||||
m_scale = c_scale_identity;
|
||||
m_changed();
|
||||
}
|
||||
}
|
||||
const Translation& getTranslation() const
|
||||
{
|
||||
return m_translation;
|
||||
}
|
||||
const Rotation& getRotation() const
|
||||
{
|
||||
return m_rotation;
|
||||
}
|
||||
const Scale& getScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
Matrix4 calculateTransform() const
|
||||
{
|
||||
return matrix4_transform_for_components(getTranslation(), getRotation(), getScale());
|
||||
}
|
||||
TransformModifier( const Callback& changed, const Callback& apply ) :
|
||||
m_translation( c_translation_identity ),
|
||||
m_rotation( c_quaternion_identity ),
|
||||
m_scale( c_scale_identity ),
|
||||
m_changed( changed ),
|
||||
m_apply( apply ),
|
||||
m_type( TRANSFORM_PRIMITIVE ){
|
||||
}
|
||||
void setType( TransformModifierType type ){
|
||||
m_type = type;
|
||||
}
|
||||
TransformModifierType getType() const {
|
||||
return m_type;
|
||||
}
|
||||
void setTranslation( const Translation& value ){
|
||||
m_translation = value;
|
||||
m_changed();
|
||||
}
|
||||
void setRotation( const Rotation& value ){
|
||||
m_rotation = value;
|
||||
m_changed();
|
||||
}
|
||||
void setScale( const Scale& value ){
|
||||
m_scale = value;
|
||||
m_changed();
|
||||
}
|
||||
void freezeTransform(){
|
||||
if ( m_translation != c_translation_identity
|
||||
|| m_rotation != c_rotation_identity
|
||||
|| m_scale != c_scale_identity ) {
|
||||
m_apply();
|
||||
m_translation = c_translation_identity;
|
||||
m_rotation = c_rotation_identity;
|
||||
m_scale = c_scale_identity;
|
||||
m_changed();
|
||||
}
|
||||
}
|
||||
const Translation& getTranslation() const {
|
||||
return m_translation;
|
||||
}
|
||||
const Rotation& getRotation() const {
|
||||
return m_rotation;
|
||||
}
|
||||
const Scale& getScale() const {
|
||||
return m_scale;
|
||||
}
|
||||
Matrix4 calculateTransform() const {
|
||||
return matrix4_transform_for_components( getTranslation(), getRotation(), getScale() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user