enable premake4 option --ios and Test_LinearMath
usage: ./premake4_osx --ios xcode4 open xcode4ios/0_Bullet3Solution.xcworkspace
This commit is contained in:
@@ -18,6 +18,11 @@
|
||||
act = _ACTION
|
||||
end
|
||||
|
||||
newoption {
|
||||
trigger = "ios",
|
||||
description = "Enable iOS target (requires xcode4)"
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "force_dlopen_opengl",
|
||||
@@ -95,6 +100,18 @@
|
||||
postfix=""
|
||||
|
||||
if _ACTION == "xcode4" then
|
||||
if _OPTIONS["ios"] then
|
||||
postfix = "ios";
|
||||
xcodebuildsettings
|
||||
{
|
||||
'INFOPLIST_FILE = "../../test/Bullet2/Info.plist"',
|
||||
'CODE_SIGN_IDENTITY = "iPhone Developer"',
|
||||
"SDKROOT = iphoneos",
|
||||
'ARCHS = "armv7"',
|
||||
'TARGETED_DEVICE_FAMILY = "1,2"',
|
||||
'VALID_ARCHS = "armv7"',
|
||||
}
|
||||
else
|
||||
xcodebuildsettings
|
||||
{
|
||||
'ARCHS = "$(ARCHS_STANDARD_32_BIT) $(ARCHS_STANDARD_64_BIT)"',
|
||||
@@ -102,6 +119,7 @@
|
||||
'SDKROOT = "macosx10.9"',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- comment-out for now, URDF reader needs exceptions
|
||||
-- flags { "NoRTTI", "NoExceptions"}
|
||||
@@ -123,6 +141,8 @@
|
||||
|
||||
language "C++"
|
||||
|
||||
if not _OPTIONS["ios"] then
|
||||
|
||||
include "../examples/ExampleBrowser"
|
||||
include "../examples/OpenGLWindow"
|
||||
|
||||
@@ -137,20 +157,6 @@
|
||||
include "../test/enet/server"
|
||||
end
|
||||
|
||||
if not _OPTIONS["without-gtest"] then
|
||||
include "../test/gtest-1.7.0"
|
||||
-- include "../test/hello_gtest"
|
||||
include "../test/collision"
|
||||
include "../test/TestBullet3OpenCL"
|
||||
include "../test/GwenOpenGLTest"
|
||||
end
|
||||
|
||||
|
||||
include "../src/BulletSoftBody"
|
||||
include "../src/BulletDynamics"
|
||||
include "../src/BulletCollision"
|
||||
include "../src/LinearMath"
|
||||
|
||||
include "../src/Bullet3Common"
|
||||
include "../src/Bullet3Geometry"
|
||||
include "../src/Bullet3Collision"
|
||||
@@ -158,5 +164,18 @@
|
||||
include "../src/Bullet3OpenCL"
|
||||
include "../src/Bullet3Serialize/Bullet2FileLoader"
|
||||
|
||||
if not _OPTIONS["without-gtest"] then
|
||||
include "../test/gtest-1.7.0"
|
||||
-- include "../test/hello_gtest"
|
||||
include "../test/collision"
|
||||
include "../test/TestBullet3OpenCL"
|
||||
include "../test/GwenOpenGLTest"
|
||||
end
|
||||
end
|
||||
|
||||
include "../test/Bullet2"
|
||||
include "../src/BulletSoftBody"
|
||||
include "../src/BulletDynamics"
|
||||
include "../src/BulletCollision"
|
||||
include "../src/LinearMath"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "Utils.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <vectormath/vmInclude.h>
|
||||
#include "../vectormath/vmInclude.h"
|
||||
|
||||
|
||||
//typedef Vectormath::Aos::Vector3 vmVector3;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
|
||||
project "AppUnitTest"
|
||||
project "Test_LinearMath"
|
||||
|
||||
if _OPTIONS["ios"] then
|
||||
kind "WindowedApp"
|
||||
else
|
||||
kind "ConsoleApp"
|
||||
end
|
||||
targetdir "bin"
|
||||
|
||||
includedirs {"../src","Source", "Source/Tests"}
|
||||
targetdir "../../bin"
|
||||
|
||||
includedirs {"../../src","Source", "Source/Tests"}
|
||||
|
||||
links {
|
||||
"BulletDynamics","BulletCollision", "LinearMath"
|
||||
|
||||
226
test/Bullet2/vectormath/neon/boolInVec.h
Normal file
226
test/Bullet2/vectormath/neon/boolInVec.h
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
unsigned int mData;
|
||||
|
||||
public:
|
||||
// Default constructor; does no initialization
|
||||
//
|
||||
inline boolInVec( ) { };
|
||||
|
||||
// Construct from a value converted from float
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// Explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
// Explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
// Implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// Boolean negation operator
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
|
||||
// Assignment operator
|
||||
//
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
|
||||
// Boolean and assignment operator
|
||||
//
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
|
||||
// Boolean exclusive or assignment operator
|
||||
//
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
|
||||
// Boolean or assignment operator
|
||||
//
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
};
|
||||
|
||||
// Equal operator
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Not equal operator
|
||||
//
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// And operator
|
||||
//
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Exclusive or operator
|
||||
//
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Or operator
|
||||
//
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Conditionally select between two values
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
mData = -(int)scalar;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
{
|
||||
return (mData > 0);
|
||||
}
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
{
|
||||
return getAsBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(!mData);
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() == vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() & vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() | vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() ^ vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return (select_vec1.getAsBool() == 0) ? vec0 : vec1;
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
|
||||
344
test/Bullet2/vectormath/neon/floatInVec.h
Normal file
344
test/Bullet2/vectormath/neon/floatInVec.h
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
#ifndef _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
// A class representing a scalar float value contained in a vector register
|
||||
// This class does not support fastmath
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
float mData;
|
||||
|
||||
public:
|
||||
// Default constructor; does no initialization
|
||||
//
|
||||
inline floatInVec( ) { };
|
||||
|
||||
// Construct from a value converted from bool
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// Explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
// Explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
// Implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// Post increment (add 1.0f)
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
|
||||
// Post decrement (subtract 1.0f)
|
||||
//
|
||||
inline const floatInVec operator -- (int);
|
||||
|
||||
// Pre increment (add 1.0f)
|
||||
//
|
||||
inline floatInVec& operator ++ ();
|
||||
|
||||
// Pre decrement (subtract 1.0f)
|
||||
//
|
||||
inline floatInVec& operator -- ();
|
||||
|
||||
// Negation operator
|
||||
//
|
||||
inline const floatInVec operator - () const;
|
||||
|
||||
// Assignment operator
|
||||
//
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
|
||||
// Multiplication assignment operator
|
||||
//
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
|
||||
// Division assignment operator
|
||||
//
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
|
||||
// Addition assignment operator
|
||||
//
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
|
||||
// Subtraction assignment operator
|
||||
//
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
};
|
||||
|
||||
// Multiplication operator
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Division operator
|
||||
//
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Addition operator
|
||||
//
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Subtraction operator
|
||||
//
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Less than operator
|
||||
//
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Less than or equal operator
|
||||
//
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Greater than operator
|
||||
//
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Greater than or equal operator
|
||||
//
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Equal operator
|
||||
//
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Not equal operator
|
||||
//
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Conditionally select between two values
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = float(vec.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
mData = scalar;
|
||||
}
|
||||
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
{
|
||||
return getAsFloat();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
float olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
float olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec(-mData);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() * vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(num.getAsFloat() / den.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() + vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() - vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() < vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() > vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() == vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return (select_vec1.getAsBool() == 0) ? vec0 : vec1;
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
|
||||
1631
test/Bullet2/vectormath/neon/mat_aos.h
Normal file
1631
test/Bullet2/vectormath/neon/mat_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
413
test/Bullet2/vectormath/neon/quat_aos.h
Normal file
413
test/Bullet2/vectormath/neon/quat_aos.h
Normal file
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
vXYZW = quat.vXYZW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mXYZW[0] = _x;
|
||||
mXYZW[1] = _y;
|
||||
mXYZW[2] = _z;
|
||||
mXYZW[3] = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( float32x4_t fXYZW )
|
||||
{
|
||||
vXYZW = fXYZW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, float _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mXYZW[0] = vec.getX();
|
||||
mXYZW[1] = vec.getY();
|
||||
mXYZW[2] = vec.getZ();
|
||||
mXYZW[3] = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
vXYZW = vdupq_n_f32(scalar);
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
start = ( -unitQuat0 );
|
||||
} else {
|
||||
start = unitQuat0;
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void loadXYZW( Quat & quat, const float * fptr )
|
||||
{
|
||||
quat = Quat( fptr[0], fptr[1], fptr[2], fptr[3] );
|
||||
}
|
||||
|
||||
inline void storeXYZW( const Quat & quat, float * fptr )
|
||||
{
|
||||
vst1q_f32(fptr, quat.getvXYZW());
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
vXYZW = quat.getvXYZW();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mXYZW[0] = vec.getX();
|
||||
mXYZW[1] = vec.getY();
|
||||
mXYZW[2] = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mXYZW[0], mXYZW[1], mXYZW[2] );
|
||||
}
|
||||
|
||||
inline float32x4_t Quat::getvXYZW( ) const
|
||||
{
|
||||
return vXYZW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mXYZW[0] = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return mXYZW[0];
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mXYZW[1] = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return mXYZW[1];
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mXYZW[2] = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return mXYZW[2];
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mXYZW[3] = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return mXYZW[3];
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
*(&mXYZW[0] + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mXYZW[0] + idx);
|
||||
}
|
||||
|
||||
inline float & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mXYZW[0] + idx);
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mXYZW[0] + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat( vaddq_f32(vXYZW, quat.vXYZW) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat( vsubq_f32(vXYZW, quat.vXYZW) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
float32x4_t v_scalar = vdupq_n_f32(scalar);
|
||||
return Quat( vmulq_f32(vXYZW, v_scalar) );
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mXYZW[0] / scalar ),
|
||||
( mXYZW[1] / scalar ),
|
||||
( mXYZW[2] / scalar ),
|
||||
( mXYZW[3] / scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat( vnegq_f32(vXYZW) );
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0.getX() * quat1.getX() );
|
||||
result = ( result + ( quat0.getY() * quat1.getY() ) );
|
||||
result = ( result + ( quat0.getZ() * quat1.getZ() ) );
|
||||
result = ( result + ( quat0.getW() * quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float norm( const Quat & quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat.getX() * quat.getX() );
|
||||
result = ( result + ( quat.getY() * quat.getY() ) );
|
||||
result = ( result + ( quat.getZ() * quat.getZ() ) );
|
||||
result = ( result + ( quat.getW() * quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float length( const Quat & quat )
|
||||
{
|
||||
return ::sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
return Quat(
|
||||
( quat.getX() * lenInv ),
|
||||
( quat.getY() * lenInv ),
|
||||
( quat.getZ() * lenInv ),
|
||||
( quat.getW() * lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, const Vector3 & unitVec )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( ( ( ( mXYZW[3] * quat.mXYZW[0] ) + ( mXYZW[0] * quat.mXYZW[3] ) ) + ( mXYZW[1] * quat.mXYZW[2] ) ) - ( mXYZW[2] * quat.mXYZW[1] ) ),
|
||||
( ( ( ( mXYZW[3] * quat.mXYZW[1] ) + ( mXYZW[1] * quat.mXYZW[3] ) ) + ( mXYZW[2] * quat.mXYZW[0] ) ) - ( mXYZW[0] * quat.mXYZW[2] ) ),
|
||||
( ( ( ( mXYZW[3] * quat.mXYZW[2] ) + ( mXYZW[2] * quat.mXYZW[3] ) ) + ( mXYZW[0] * quat.mXYZW[1] ) ) - ( mXYZW[1] * quat.mXYZW[0] ) ),
|
||||
( ( ( ( mXYZW[3] * quat.mXYZW[3] ) - ( mXYZW[0] * quat.mXYZW[0] ) ) - ( mXYZW[1] * quat.mXYZW[1] ) ) - ( mXYZW[2] * quat.mXYZW[2] ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) );
|
||||
tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) );
|
||||
tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) );
|
||||
tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) );
|
||||
return Vector3(
|
||||
( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ),
|
||||
( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ),
|
||||
( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 )
|
||||
{
|
||||
return Quat(
|
||||
( select1 )? quat1.getX() : quat0.getX(),
|
||||
( select1 )? quat1.getY() : quat0.getY(),
|
||||
( select1 )? quat1.getZ() : quat0.getZ(),
|
||||
( select1 )? quat1.getW() : quat0.getW()
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
|
||||
1427
test/Bullet2/vectormath/neon/vec_aos.h
Normal file
1427
test/Bullet2/vectormath/neon/vec_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
1890
test/Bullet2/vectormath/neon/vectormath_aos.h
Normal file
1890
test/Bullet2/vectormath/neon/vectormath_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
225
test/Bullet2/vectormath/scalar/boolInVec.h
Normal file
225
test/Bullet2/vectormath/scalar/boolInVec.h
Normal file
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
unsigned int mData;
|
||||
|
||||
public:
|
||||
// Default constructor; does no initialization
|
||||
//
|
||||
inline boolInVec( ) { };
|
||||
|
||||
// Construct from a value converted from float
|
||||
//
|
||||
inline boolInVec(floatInVec vec);
|
||||
|
||||
// Explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
// Explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
// Implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// Boolean negation operator
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
|
||||
// Assignment operator
|
||||
//
|
||||
inline boolInVec& operator = (boolInVec vec);
|
||||
|
||||
// Boolean and assignment operator
|
||||
//
|
||||
inline boolInVec& operator &= (boolInVec vec);
|
||||
|
||||
// Boolean exclusive or assignment operator
|
||||
//
|
||||
inline boolInVec& operator ^= (boolInVec vec);
|
||||
|
||||
// Boolean or assignment operator
|
||||
//
|
||||
inline boolInVec& operator |= (boolInVec vec);
|
||||
|
||||
};
|
||||
|
||||
// Equal operator
|
||||
//
|
||||
inline const boolInVec operator == (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Not equal operator
|
||||
//
|
||||
inline const boolInVec operator != (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// And operator
|
||||
//
|
||||
inline const boolInVec operator & (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Exclusive or operator
|
||||
//
|
||||
inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Or operator
|
||||
//
|
||||
inline const boolInVec operator | (boolInVec vec0, boolInVec vec1);
|
||||
|
||||
// Conditionally select between two values
|
||||
//
|
||||
inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1);
|
||||
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(floatInVec vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
mData = -(int)scalar;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
{
|
||||
return (mData > 0);
|
||||
}
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
{
|
||||
return getAsBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(!mData);
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (boolInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (boolInVec vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (boolInVec vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (boolInVec vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() == vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() & vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() | vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (boolInVec vec0, boolInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsBool() ^ vec1.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return (select_vec1.getAsBool() == 0) ? vec0 : vec1;
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
343
test/Bullet2/vectormath/scalar/floatInVec.h
Normal file
343
test/Bullet2/vectormath/scalar/floatInVec.h
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
#ifndef _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
// A class representing a scalar float value contained in a vector register
|
||||
// This class does not support fastmath
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
float mData;
|
||||
|
||||
public:
|
||||
// Default constructor; does no initialization
|
||||
//
|
||||
inline floatInVec( ) { };
|
||||
|
||||
// Construct from a value converted from bool
|
||||
//
|
||||
inline floatInVec(boolInVec vec);
|
||||
|
||||
// Explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
// Explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
// Implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// Post increment (add 1.0f)
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
|
||||
// Post decrement (subtract 1.0f)
|
||||
//
|
||||
inline const floatInVec operator -- (int);
|
||||
|
||||
// Pre increment (add 1.0f)
|
||||
//
|
||||
inline floatInVec& operator ++ ();
|
||||
|
||||
// Pre decrement (subtract 1.0f)
|
||||
//
|
||||
inline floatInVec& operator -- ();
|
||||
|
||||
// Negation operator
|
||||
//
|
||||
inline const floatInVec operator - () const;
|
||||
|
||||
// Assignment operator
|
||||
//
|
||||
inline floatInVec& operator = (floatInVec vec);
|
||||
|
||||
// Multiplication assignment operator
|
||||
//
|
||||
inline floatInVec& operator *= (floatInVec vec);
|
||||
|
||||
// Division assignment operator
|
||||
//
|
||||
inline floatInVec& operator /= (floatInVec vec);
|
||||
|
||||
// Addition assignment operator
|
||||
//
|
||||
inline floatInVec& operator += (floatInVec vec);
|
||||
|
||||
// Subtraction assignment operator
|
||||
//
|
||||
inline floatInVec& operator -= (floatInVec vec);
|
||||
|
||||
};
|
||||
|
||||
// Multiplication operator
|
||||
//
|
||||
inline const floatInVec operator * (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Division operator
|
||||
//
|
||||
inline const floatInVec operator / (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Addition operator
|
||||
//
|
||||
inline const floatInVec operator + (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Subtraction operator
|
||||
//
|
||||
inline const floatInVec operator - (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Less than operator
|
||||
//
|
||||
inline const boolInVec operator < (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Less than or equal operator
|
||||
//
|
||||
inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Greater than operator
|
||||
//
|
||||
inline const boolInVec operator > (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Greater than or equal operator
|
||||
//
|
||||
inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Equal operator
|
||||
//
|
||||
inline const boolInVec operator == (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Not equal operator
|
||||
//
|
||||
inline const boolInVec operator != (floatInVec vec0, floatInVec vec1);
|
||||
|
||||
// Conditionally select between two values
|
||||
//
|
||||
inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1);
|
||||
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(boolInVec vec)
|
||||
{
|
||||
mData = float(vec.getAsBool());
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
mData = scalar;
|
||||
}
|
||||
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
#ifndef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
{
|
||||
return getAsFloat();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
float olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
float olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec(1.0f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec(-mData);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (floatInVec vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (floatInVec vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (floatInVec vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (floatInVec vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (floatInVec vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() * vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (floatInVec num, floatInVec den)
|
||||
{
|
||||
return floatInVec(num.getAsFloat() / den.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() + vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return floatInVec(vec0.getAsFloat() - vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() < vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 > vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() > vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 < vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return boolInVec(vec0.getAsFloat() == vec1.getAsFloat());
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (floatInVec vec0, floatInVec vec1)
|
||||
{
|
||||
return !(vec0 == vec1);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1)
|
||||
{
|
||||
return (select_vec1.getAsBool() == 0) ? vec0 : vec1;
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
1630
test/Bullet2/vectormath/scalar/mat_aos.h
Normal file
1630
test/Bullet2/vectormath/scalar/mat_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
433
test/Bullet2/vectormath/scalar/quat_aos.h
Normal file
433
test/Bullet2/vectormath/scalar/quat_aos.h
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
Copyright (C) 2009 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
inline Quat::Quat( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
}
|
||||
|
||||
inline Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mX = _x;
|
||||
mY = _y;
|
||||
mZ = _z;
|
||||
mW = _w;
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector3 & xyz, float _w )
|
||||
{
|
||||
this->setXYZ( xyz );
|
||||
this->setW( _w );
|
||||
}
|
||||
|
||||
inline Quat::Quat( const Vector4 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
mW = vec.getW();
|
||||
}
|
||||
|
||||
inline Quat::Quat( float scalar )
|
||||
{
|
||||
mX = scalar;
|
||||
mY = scalar;
|
||||
mZ = scalar;
|
||||
mW = scalar;
|
||||
}
|
||||
|
||||
inline const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
float recipSinAngle, scale0, scale1, cosAngle, angle;
|
||||
cosAngle = dot( unitQuat0, unitQuat1 );
|
||||
if ( cosAngle < 0.0f ) {
|
||||
cosAngle = -cosAngle;
|
||||
start = ( -unitQuat0 );
|
||||
} else {
|
||||
start = unitQuat0;
|
||||
}
|
||||
if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
|
||||
angle = acosf( cosAngle );
|
||||
recipSinAngle = ( 1.0f / sinf( angle ) );
|
||||
scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
|
||||
scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
|
||||
} else {
|
||||
scale0 = ( 1.0f - t );
|
||||
scale1 = t;
|
||||
}
|
||||
return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) );
|
||||
}
|
||||
|
||||
inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 )
|
||||
{
|
||||
Quat tmp0, tmp1;
|
||||
tmp0 = slerp( t, unitQuat0, unitQuat3 );
|
||||
tmp1 = slerp( t, unitQuat1, unitQuat2 );
|
||||
return slerp( ( ( 2.0f * t ) * ( 1.0f - t ) ), tmp0, tmp1 );
|
||||
}
|
||||
|
||||
inline void loadXYZW( Quat & quat, const float * fptr )
|
||||
{
|
||||
quat = Quat( fptr[0], fptr[1], fptr[2], fptr[3] );
|
||||
}
|
||||
|
||||
inline void storeXYZW( const Quat & quat, float * fptr )
|
||||
{
|
||||
fptr[0] = quat.getX();
|
||||
fptr[1] = quat.getY();
|
||||
fptr[2] = quat.getZ();
|
||||
fptr[3] = quat.getW();
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator =( const Quat & quat )
|
||||
{
|
||||
mX = quat.mX;
|
||||
mY = quat.mY;
|
||||
mZ = quat.mZ;
|
||||
mW = quat.mW;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setXYZ( const Vector3 & vec )
|
||||
{
|
||||
mX = vec.getX();
|
||||
mY = vec.getY();
|
||||
mZ = vec.getZ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mX, mY, mZ );
|
||||
}
|
||||
|
||||
inline Quat & Quat::setX( float _x )
|
||||
{
|
||||
mX = _x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getX( ) const
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setY( float _y )
|
||||
{
|
||||
mY = _y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getY( ) const
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setZ( float _z )
|
||||
{
|
||||
mZ = _z;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getZ( ) const
|
||||
{
|
||||
return mZ;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setW( float _w )
|
||||
{
|
||||
mW = _w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getW( ) const
|
||||
{
|
||||
return mW;
|
||||
}
|
||||
|
||||
inline Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
*(&mX + idx) = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline float Quat::getElem( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float & Quat::operator []( int idx )
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline float Quat::operator []( int idx ) const
|
||||
{
|
||||
return *(&mX + idx);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator +( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX + quat.mX ),
|
||||
( mY + quat.mY ),
|
||||
( mZ + quat.mZ ),
|
||||
( mW + quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX - quat.mX ),
|
||||
( mY - quat.mY ),
|
||||
( mZ - quat.mZ ),
|
||||
( mW - quat.mW )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX * scalar ),
|
||||
( mY * scalar ),
|
||||
( mZ * scalar ),
|
||||
( mW * scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator +=( const Quat & quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator -=( const Quat & quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return Quat(
|
||||
( mX / scalar ),
|
||||
( mY / scalar ),
|
||||
( mZ / scalar ),
|
||||
( mW / scalar )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(
|
||||
-mX,
|
||||
-mY,
|
||||
-mZ,
|
||||
-mW
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat operator *( float scalar, const Quat & quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
inline float dot( const Quat & quat0, const Quat & quat1 )
|
||||
{
|
||||
float result;
|
||||
result = ( quat0.getX() * quat1.getX() );
|
||||
result = ( result + ( quat0.getY() * quat1.getY() ) );
|
||||
result = ( result + ( quat0.getZ() * quat1.getZ() ) );
|
||||
result = ( result + ( quat0.getW() * quat1.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float norm( const Quat & quat )
|
||||
{
|
||||
float result;
|
||||
result = ( quat.getX() * quat.getX() );
|
||||
result = ( result + ( quat.getY() * quat.getY() ) );
|
||||
result = ( result + ( quat.getZ() * quat.getZ() ) );
|
||||
result = ( result + ( quat.getW() * quat.getW() ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
inline float length( const Quat & quat )
|
||||
{
|
||||
return ::sqrtf( norm( quat ) );
|
||||
}
|
||||
|
||||
inline const Quat normalize( const Quat & quat )
|
||||
{
|
||||
float lenSqr, lenInv;
|
||||
lenSqr = norm( quat );
|
||||
lenInv = ( 1.0f / sqrtf( lenSqr ) );
|
||||
return Quat(
|
||||
( quat.getX() * lenInv ),
|
||||
( quat.getY() * lenInv ),
|
||||
( quat.getZ() * lenInv ),
|
||||
( quat.getW() * lenInv )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 )
|
||||
{
|
||||
float cosHalfAngleX2, recipCosHalfAngleX2;
|
||||
cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + dot( unitVec0, unitVec1 ) ) ) );
|
||||
recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 );
|
||||
return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), ( cosHalfAngleX2 * 0.5f ) );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotation( float radians, const Vector3 & unitVec )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( ( unitVec * s ), c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( s, 0.0f, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, s, 0.0f, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
float s, c, angle;
|
||||
angle = ( radians * 0.5f );
|
||||
s = sinf( angle );
|
||||
c = cosf( angle );
|
||||
return Quat( 0.0f, 0.0f, s, c );
|
||||
}
|
||||
|
||||
inline const Quat Quat::operator *( const Quat & quat ) const
|
||||
{
|
||||
return Quat(
|
||||
( ( ( ( mW * quat.mX ) + ( mX * quat.mW ) ) + ( mY * quat.mZ ) ) - ( mZ * quat.mY ) ),
|
||||
( ( ( ( mW * quat.mY ) + ( mY * quat.mW ) ) + ( mZ * quat.mX ) ) - ( mX * quat.mZ ) ),
|
||||
( ( ( ( mW * quat.mZ ) + ( mZ * quat.mW ) ) + ( mX * quat.mY ) ) - ( mY * quat.mX ) ),
|
||||
( ( ( ( mW * quat.mW ) - ( mX * quat.mX ) ) - ( mY * quat.mY ) ) - ( mZ * quat.mZ ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline Quat & Quat::operator *=( const Quat & quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Vector3 rotate( const Quat & quat, const Vector3 & vec )
|
||||
{
|
||||
float tmpX, tmpY, tmpZ, tmpW;
|
||||
tmpX = ( ( ( quat.getW() * vec.getX() ) + ( quat.getY() * vec.getZ() ) ) - ( quat.getZ() * vec.getY() ) );
|
||||
tmpY = ( ( ( quat.getW() * vec.getY() ) + ( quat.getZ() * vec.getX() ) ) - ( quat.getX() * vec.getZ() ) );
|
||||
tmpZ = ( ( ( quat.getW() * vec.getZ() ) + ( quat.getX() * vec.getY() ) ) - ( quat.getY() * vec.getX() ) );
|
||||
tmpW = ( ( ( quat.getX() * vec.getX() ) + ( quat.getY() * vec.getY() ) ) + ( quat.getZ() * vec.getZ() ) );
|
||||
return Vector3(
|
||||
( ( ( ( tmpW * quat.getX() ) + ( tmpX * quat.getW() ) ) - ( tmpY * quat.getZ() ) ) + ( tmpZ * quat.getY() ) ),
|
||||
( ( ( ( tmpW * quat.getY() ) + ( tmpY * quat.getW() ) ) - ( tmpZ * quat.getX() ) ) + ( tmpX * quat.getZ() ) ),
|
||||
( ( ( ( tmpW * quat.getZ() ) + ( tmpZ * quat.getW() ) ) - ( tmpX * quat.getY() ) ) + ( tmpY * quat.getX() ) )
|
||||
);
|
||||
}
|
||||
|
||||
inline const Quat conj( const Quat & quat )
|
||||
{
|
||||
return Quat( -quat.getX(), -quat.getY(), -quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 )
|
||||
{
|
||||
return Quat(
|
||||
( select1 )? quat1.getX() : quat0.getX(),
|
||||
( select1 )? quat1.getY() : quat0.getY(),
|
||||
( select1 )? quat1.getZ() : quat0.getZ(),
|
||||
( select1 )? quat1.getW() : quat0.getW()
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
inline void print( const Quat & quat )
|
||||
{
|
||||
printf( "( %f %f %f %f )\n", quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
inline void print( const Quat & quat, const char * name )
|
||||
{
|
||||
printf( "%s: ( %f %f %f %f )\n", name, quat.getX(), quat.getY(), quat.getZ(), quat.getW() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
1426
test/Bullet2/vectormath/scalar/vec_aos.h
Normal file
1426
test/Bullet2/vectormath/scalar/vec_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
1872
test/Bullet2/vectormath/scalar/vectormath_aos.h
Normal file
1872
test/Bullet2/vectormath/scalar/vectormath_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
247
test/Bullet2/vectormath/sse/boolInVec.h
Normal file
247
test/Bullet2/vectormath/sse/boolInVec.h
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _BOOLINVEC_H
|
||||
#define _BOOLINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class floatInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec class
|
||||
//
|
||||
|
||||
class boolInVec
|
||||
{
|
||||
private:
|
||||
__m128 mData;
|
||||
|
||||
inline boolInVec(__m128 vec);
|
||||
public:
|
||||
inline boolInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline boolInVec(const floatInVec &vec);
|
||||
|
||||
// explicit cast from bool
|
||||
//
|
||||
explicit inline boolInVec(bool scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to bool
|
||||
//
|
||||
inline bool getAsBool() const;
|
||||
#else
|
||||
// implicit cast to bool
|
||||
//
|
||||
inline operator bool() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// bool value is splatted across all word slots of vector as 0 (false) or -1 (true)
|
||||
//
|
||||
inline __m128 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator ! () const;
|
||||
inline boolInVec& operator = (const boolInVec &vec);
|
||||
inline boolInVec& operator &= (const boolInVec &vec);
|
||||
inline boolInVec& operator ^= (const boolInVec &vec);
|
||||
inline boolInVec& operator |= (const boolInVec &vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1);
|
||||
friend inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1);
|
||||
friend inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1);
|
||||
friend inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1);
|
||||
friend inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1);
|
||||
friend inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const boolInVec operator == (const boolInVec &vec0, const boolInVec &vec1);
|
||||
inline const boolInVec operator != (const boolInVec &vec0, const boolInVec &vec1);
|
||||
inline const boolInVec operator & (const boolInVec &vec0, const boolInVec &vec1);
|
||||
inline const boolInVec operator ^ (const boolInVec &vec0, const boolInVec &vec1);
|
||||
inline const boolInVec operator | (const boolInVec &vec0, const boolInVec &vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const boolInVec select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// boolInVec implementation
|
||||
//
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(__m128 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(const floatInVec &vec)
|
||||
{
|
||||
*this = (vec != floatInVec(0.0f));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec::boolInVec(bool scalar)
|
||||
{
|
||||
unsigned int mask = -(int)scalar;
|
||||
mData = _mm_set1_ps(*(float *)&mask); // TODO: Union
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
bool
|
||||
boolInVec::getAsBool() const
|
||||
#else
|
||||
inline
|
||||
boolInVec::operator bool() const
|
||||
#endif
|
||||
{
|
||||
return *(bool *)&mData;
|
||||
}
|
||||
|
||||
inline
|
||||
__m128
|
||||
boolInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
boolInVec::operator ! () const
|
||||
{
|
||||
return boolInVec(_mm_andnot_ps(mData, _mm_cmpneq_ps(_mm_setzero_ps(),_mm_setzero_ps())));
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator = (const boolInVec &vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator &= (const boolInVec &vec)
|
||||
{
|
||||
*this = *this & vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator ^= (const boolInVec &vec)
|
||||
{
|
||||
*this = *this ^ vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
boolInVec&
|
||||
boolInVec::operator |= (const boolInVec &vec)
|
||||
{
|
||||
*this = *this | vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (const boolInVec &vec0, const boolInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (const boolInVec &vec0, const boolInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator & (const boolInVec &vec0, const boolInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_and_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator | (const boolInVec &vec0, const boolInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_or_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator ^ (const boolInVec &vec0, const boolInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_xor_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
select(const boolInVec &vec0, const boolInVec &vec1, const boolInVec &select_vec1)
|
||||
{
|
||||
return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // boolInVec_h
|
||||
340
test/Bullet2/vectormath/sse/floatInVec.h
Normal file
340
test/Bullet2/vectormath/sse/floatInVec.h
Normal file
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _FLOATINVEC_H
|
||||
#define _FLOATINVEC_H
|
||||
|
||||
#include <math.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
class boolInVec;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec class
|
||||
//
|
||||
|
||||
class floatInVec
|
||||
{
|
||||
private:
|
||||
__m128 mData;
|
||||
|
||||
public:
|
||||
inline floatInVec(__m128 vec);
|
||||
|
||||
inline floatInVec() {}
|
||||
|
||||
// matches standard type conversions
|
||||
//
|
||||
inline floatInVec(const boolInVec &vec);
|
||||
|
||||
// construct from a slot of __m128
|
||||
//
|
||||
inline floatInVec(__m128 vec, int slot);
|
||||
|
||||
// explicit cast from float
|
||||
//
|
||||
explicit inline floatInVec(float scalar);
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
// explicit cast to float
|
||||
//
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
// implicit cast to float
|
||||
//
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
// get vector data
|
||||
// float value is splatted across all word slots of vector
|
||||
//
|
||||
inline __m128 get128() const;
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator ++ (int);
|
||||
inline const floatInVec operator -- (int);
|
||||
inline floatInVec& operator ++ ();
|
||||
inline floatInVec& operator -- ();
|
||||
inline const floatInVec operator - () const;
|
||||
inline floatInVec& operator = (const floatInVec &vec);
|
||||
inline floatInVec& operator *= (const floatInVec &vec);
|
||||
inline floatInVec& operator /= (const floatInVec &vec);
|
||||
inline floatInVec& operator += (const floatInVec &vec);
|
||||
inline floatInVec& operator -= (const floatInVec &vec);
|
||||
|
||||
// friend functions
|
||||
//
|
||||
friend inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1);
|
||||
friend inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, boolInVec select_vec1);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec functions
|
||||
//
|
||||
|
||||
// operators
|
||||
//
|
||||
inline const floatInVec operator * (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const floatInVec operator / (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const floatInVec operator + (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const floatInVec operator - (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator < (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator <= (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator > (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator >= (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator == (const floatInVec &vec0, const floatInVec &vec1);
|
||||
inline const boolInVec operator != (const floatInVec &vec0, const floatInVec &vec1);
|
||||
|
||||
// select between vec0 and vec1 using boolInVec.
|
||||
// false selects vec0, true selects vec1
|
||||
//
|
||||
inline const floatInVec select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1);
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// floatInVec implementation
|
||||
//
|
||||
|
||||
#include "boolInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(__m128 vec)
|
||||
{
|
||||
mData = vec;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(const boolInVec &vec)
|
||||
{
|
||||
mData = vec_sel(_mm_setzero_ps(), _mm_set1_ps(1.0f), vec.get128());
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(__m128 vec, int slot)
|
||||
{
|
||||
SSEFloat v;
|
||||
v.m128 = vec;
|
||||
mData = _mm_set1_ps(v.f[slot]);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec::floatInVec(float scalar)
|
||||
{
|
||||
mData = _mm_set1_ps(scalar);
|
||||
}
|
||||
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline
|
||||
float
|
||||
floatInVec::getAsFloat() const
|
||||
#else
|
||||
inline
|
||||
floatInVec::operator float() const
|
||||
#endif
|
||||
{
|
||||
return *((float *)&mData);
|
||||
}
|
||||
|
||||
inline
|
||||
__m128
|
||||
floatInVec::get128() const
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator ++ (int)
|
||||
{
|
||||
__m128 olddata = mData;
|
||||
operator ++();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator -- (int)
|
||||
{
|
||||
__m128 olddata = mData;
|
||||
operator --();
|
||||
return floatInVec(olddata);
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator ++ ()
|
||||
{
|
||||
*this += floatInVec(_mm_set1_ps(1.0f));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -- ()
|
||||
{
|
||||
*this -= floatInVec(_mm_set1_ps(1.0f));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
floatInVec::operator - () const
|
||||
{
|
||||
return floatInVec(_mm_sub_ps(_mm_setzero_ps(), mData));
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator = (const floatInVec &vec)
|
||||
{
|
||||
mData = vec.mData;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator *= (const floatInVec &vec)
|
||||
{
|
||||
*this = *this * vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator /= (const floatInVec &vec)
|
||||
{
|
||||
*this = *this / vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator += (const floatInVec &vec)
|
||||
{
|
||||
*this = *this + vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
floatInVec&
|
||||
floatInVec::operator -= (const floatInVec &vec)
|
||||
{
|
||||
*this = *this - vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator * (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return floatInVec(_mm_mul_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator / (const floatInVec &num, const floatInVec &den)
|
||||
{
|
||||
return floatInVec(_mm_div_ps(num.get128(), den.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator + (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return floatInVec(_mm_add_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
operator - (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return floatInVec(_mm_sub_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator < (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpgt_ps(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator <= (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpge_ps(vec1.get128(), vec0.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator > (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpgt_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator >= (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpge_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator == (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpeq_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const boolInVec
|
||||
operator != (const floatInVec &vec0, const floatInVec &vec1)
|
||||
{
|
||||
return boolInVec(_mm_cmpneq_ps(vec0.get128(), vec1.get128()));
|
||||
}
|
||||
|
||||
inline
|
||||
const floatInVec
|
||||
select(const floatInVec &vec0, const floatInVec &vec1, const boolInVec &select_vec1)
|
||||
{
|
||||
return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128()));
|
||||
}
|
||||
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif // floatInVec_h
|
||||
2190
test/Bullet2/vectormath/sse/mat_aos.h
Normal file
2190
test/Bullet2/vectormath/sse/mat_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
579
test/Bullet2/vectormath/sse/quat_aos.h
Normal file
579
test/Bullet2/vectormath/sse/quat_aos.h
Normal file
@@ -0,0 +1,579 @@
|
||||
/*
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VECTORMATH_QUAT_AOS_CPP_H
|
||||
#define _VECTORMATH_QUAT_AOS_CPP_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
|
||||
#ifndef _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
#define _VECTORMATH_INTERNAL_FUNCTIONS
|
||||
|
||||
#endif
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
VECTORMATH_FORCE_INLINE void Quat::set128(vec_float4 vec)
|
||||
{
|
||||
mVec128 = vec;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z, const floatInVec &_w )
|
||||
{
|
||||
mVec128 = _mm_unpacklo_ps(
|
||||
_mm_unpacklo_ps( _x.get128(), _z.get128() ),
|
||||
_mm_unpacklo_ps( _y.get128(), _w.get128() ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( const Vector3 &xyz, float _w )
|
||||
{
|
||||
mVec128 = xyz.get128();
|
||||
_vmathVfSetElement(mVec128, _w, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat(const Quat& quat)
|
||||
{
|
||||
mVec128 = quat.get128();
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( float _x, float _y, float _z, float _w )
|
||||
{
|
||||
mVec128 = _mm_setr_ps(_x, _y, _z, _w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( const Vector3 &xyz, const floatInVec &_w )
|
||||
{
|
||||
mVec128 = xyz.get128();
|
||||
mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3);
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( const Vector4 &vec )
|
||||
{
|
||||
mVec128 = vec.get128();
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( float scalar )
|
||||
{
|
||||
mVec128 = floatInVec(scalar).get128();
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( const floatInVec &scalar )
|
||||
{
|
||||
mVec128 = scalar.get128();
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat::Quat( __m128 vf4 )
|
||||
{
|
||||
mVec128 = vf4;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::identity( )
|
||||
{
|
||||
return Quat( _VECTORMATH_UNIT_0001 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat lerp( float t, const Quat &quat0, const Quat &quat1 )
|
||||
{
|
||||
return lerp( floatInVec(t), quat0, quat1 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 )
|
||||
{
|
||||
return ( quat0 + ( ( quat1 - quat0 ) * t ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 )
|
||||
{
|
||||
return slerp( floatInVec(t), unitQuat0, unitQuat1 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat slerp( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1 )
|
||||
{
|
||||
Quat start;
|
||||
vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines;
|
||||
__m128 selectMask;
|
||||
cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() );
|
||||
selectMask = (__m128)vec_cmpgt( _mm_setzero_ps(), cosAngle );
|
||||
cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask );
|
||||
start = Quat( vec_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) );
|
||||
selectMask = (__m128)vec_cmpgt( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle );
|
||||
angle = acosf4( cosAngle );
|
||||
tttt = t.get128();
|
||||
oneMinusT = vec_sub( _mm_set1_ps(1.0f), tttt );
|
||||
angles = vec_mergeh( _mm_set1_ps(1.0f), tttt );
|
||||
angles = vec_mergeh( angles, oneMinusT );
|
||||
angles = vec_madd( angles, angle, _mm_setzero_ps() );
|
||||
sines = sinf4( angles );
|
||||
scales = _mm_div_ps( sines, vec_splat( sines, 0 ) );
|
||||
scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask );
|
||||
scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask );
|
||||
return Quat( vec_madd( start.get128(), scale0, vec_mul( unitQuat1.get128(), scale1 ) ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat squad( float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 )
|
||||
{
|
||||
return squad( floatInVec(t), unitQuat0, unitQuat1, unitQuat2, unitQuat3 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat squad( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 )
|
||||
{
|
||||
return slerp( ( ( floatInVec(2.0f) * t ) * ( floatInVec(1.0f) - t ) ), slerp( t, unitQuat0, unitQuat3 ), slerp( t, unitQuat1, unitQuat2 ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE __m128 Quat::get128( ) const
|
||||
{
|
||||
return mVec128;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator =( const Quat &quat )
|
||||
{
|
||||
mVec128 = quat.mVec128;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setXYZ( const Vector3 &vec )
|
||||
{
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff};
|
||||
mVec128 = vec_sel( vec.get128(), mVec128, sw );
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Vector3 Quat::getXYZ( ) const
|
||||
{
|
||||
return Vector3( mVec128 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setX( float _x )
|
||||
{
|
||||
_vmathVfSetElement(mVec128, _x, 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setX( const floatInVec &_x )
|
||||
{
|
||||
mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::getX( ) const
|
||||
{
|
||||
return floatInVec( mVec128, 0 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setY( float _y )
|
||||
{
|
||||
_vmathVfSetElement(mVec128, _y, 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setY( const floatInVec &_y )
|
||||
{
|
||||
mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::getY( ) const
|
||||
{
|
||||
return floatInVec( mVec128, 1 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setZ( float _z )
|
||||
{
|
||||
_vmathVfSetElement(mVec128, _z, 2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setZ( const floatInVec &_z )
|
||||
{
|
||||
mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::getZ( ) const
|
||||
{
|
||||
return floatInVec( mVec128, 2 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setW( float _w )
|
||||
{
|
||||
_vmathVfSetElement(mVec128, _w, 3);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setW( const floatInVec &_w )
|
||||
{
|
||||
mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::getW( ) const
|
||||
{
|
||||
return floatInVec( mVec128, 3 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setElem( int idx, float value )
|
||||
{
|
||||
_vmathVfSetElement(mVec128, value, idx);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::setElem( int idx, const floatInVec &value )
|
||||
{
|
||||
mVec128 = _vmathVfInsert(mVec128, value.get128(), idx);
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::getElem( int idx ) const
|
||||
{
|
||||
return floatInVec( mVec128, idx );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE VecIdx Quat::operator []( int idx )
|
||||
{
|
||||
return VecIdx( mVec128, idx );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec Quat::operator []( int idx ) const
|
||||
{
|
||||
return floatInVec( mVec128, idx );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator +( const Quat &quat ) const
|
||||
{
|
||||
return Quat( _mm_add_ps( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator -( const Quat &quat ) const
|
||||
{
|
||||
return Quat( _mm_sub_ps( mVec128, quat.mVec128 ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator *( float scalar ) const
|
||||
{
|
||||
return *this * floatInVec(scalar);
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator *( const floatInVec &scalar ) const
|
||||
{
|
||||
return Quat( _mm_mul_ps( mVec128, scalar.get128() ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator +=( const Quat &quat )
|
||||
{
|
||||
*this = *this + quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator -=( const Quat &quat )
|
||||
{
|
||||
*this = *this - quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator *=( float scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator *=( const floatInVec &scalar )
|
||||
{
|
||||
*this = *this * scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator /( float scalar ) const
|
||||
{
|
||||
return *this / floatInVec(scalar);
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator /( const floatInVec &scalar ) const
|
||||
{
|
||||
return Quat( _mm_div_ps( mVec128, scalar.get128() ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator /=( float scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator /=( const floatInVec &scalar )
|
||||
{
|
||||
*this = *this / scalar;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator -( ) const
|
||||
{
|
||||
return Quat(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat operator *( float scalar, const Quat &quat )
|
||||
{
|
||||
return floatInVec(scalar) * quat;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat operator *( const floatInVec &scalar, const Quat &quat )
|
||||
{
|
||||
return quat * scalar;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec dot( const Quat &quat0, const Quat &quat1 )
|
||||
{
|
||||
return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec norm( const Quat &quat )
|
||||
{
|
||||
return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const floatInVec length( const Quat &quat )
|
||||
{
|
||||
return floatInVec( _mm_sqrt_ps(_vmathVfDot4( quat.get128(), quat.get128() )), 0 );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat normalize( const Quat &quat )
|
||||
{
|
||||
vec_float4 dot =_vmathVfDot4( quat.get128(), quat.get128());
|
||||
return Quat( _mm_mul_ps( quat.get128(), newtonrapson_rsqrt4( dot ) ) );
|
||||
}
|
||||
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotation( const Vector3 &unitVec0, const Vector3 &unitVec1 )
|
||||
{
|
||||
Vector3 crossVec;
|
||||
__m128 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res;
|
||||
cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() );
|
||||
cosAngleX2Plus2 = vec_madd( cosAngle, _mm_set1_ps(2.0f), _mm_set1_ps(2.0f) );
|
||||
recipCosHalfAngleX2 = _mm_rsqrt_ps( cosAngleX2Plus2 );
|
||||
cosHalfAngleX2 = vec_mul( recipCosHalfAngleX2, cosAngleX2Plus2 );
|
||||
crossVec = cross( unitVec0, unitVec1 );
|
||||
res = vec_mul( crossVec.get128(), recipCosHalfAngleX2 );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff};
|
||||
res = vec_sel( res, vec_mul( cosHalfAngleX2, _mm_set1_ps(0.5f) ), sw );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotation( float radians, const Vector3 &unitVec )
|
||||
{
|
||||
return rotation( floatInVec(radians), unitVec );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotation( const floatInVec &radians, const Vector3 &unitVec )
|
||||
{
|
||||
__m128 s, c, angle, res;
|
||||
angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff};
|
||||
res = vec_sel( vec_mul( unitVec.get128(), s ), c, sw );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationX( float radians )
|
||||
{
|
||||
return rotationX( floatInVec(radians) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationX( const floatInVec &radians )
|
||||
{
|
||||
__m128 s, c, angle, res;
|
||||
angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int xsw[4] = {0xffffffff, 0, 0, 0};
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int wsw[4] = {0, 0, 0, 0xffffffff};
|
||||
res = vec_sel( _mm_setzero_ps(), s, xsw );
|
||||
res = vec_sel( res, c, wsw );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationY( float radians )
|
||||
{
|
||||
return rotationY( floatInVec(radians) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationY( const floatInVec &radians )
|
||||
{
|
||||
__m128 s, c, angle, res;
|
||||
angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int ysw[4] = {0, 0xffffffff, 0, 0};
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int wsw[4] = {0, 0, 0, 0xffffffff};
|
||||
res = vec_sel( _mm_setzero_ps(), s, ysw );
|
||||
res = vec_sel( res, c, wsw );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationZ( float radians )
|
||||
{
|
||||
return rotationZ( floatInVec(radians) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::rotationZ( const floatInVec &radians )
|
||||
{
|
||||
__m128 s, c, angle, res;
|
||||
angle = vec_mul( radians.get128(), _mm_set1_ps(0.5f) );
|
||||
sincosf4( angle, &s, &c );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int zsw[4] = {0, 0, 0xffffffff, 0};
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int wsw[4] = {0, 0, 0, 0xffffffff};
|
||||
res = vec_sel( _mm_setzero_ps(), s, zsw );
|
||||
res = vec_sel( res, c, wsw );
|
||||
return Quat( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat Quat::operator *( const Quat &quat ) const
|
||||
{
|
||||
__m128 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3;
|
||||
__m128 product, l_wxyz, r_wxyz, xy, qw;
|
||||
ldata = mVec128;
|
||||
rdata = quat.mVec128;
|
||||
tmp0 = _mm_shuffle_ps( ldata, ldata, _MM_SHUFFLE(3,0,2,1) );
|
||||
tmp1 = _mm_shuffle_ps( rdata, rdata, _MM_SHUFFLE(3,1,0,2) );
|
||||
tmp2 = _mm_shuffle_ps( ldata, ldata, _MM_SHUFFLE(3,1,0,2) );
|
||||
tmp3 = _mm_shuffle_ps( rdata, rdata, _MM_SHUFFLE(3,0,2,1) );
|
||||
qv = vec_mul( vec_splat( ldata, 3 ), rdata );
|
||||
qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_mul( ldata, rdata );
|
||||
l_wxyz = vec_sld( ldata, ldata, 12 );
|
||||
r_wxyz = vec_sld( rdata, rdata, 12 );
|
||||
qw = vec_nmsub( l_wxyz, r_wxyz, product );
|
||||
xy = vec_madd( l_wxyz, r_wxyz, product );
|
||||
qw = vec_sub( qw, vec_sld( xy, xy, 8 ) );
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff};
|
||||
return Quat( vec_sel( qv, qw, sw ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE Quat & Quat::operator *=( const Quat &quat )
|
||||
{
|
||||
*this = *this * quat;
|
||||
return *this;
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Vector3 rotate( const Quat &quat, const Vector3 &vec )
|
||||
{ __m128 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res;
|
||||
qdata = quat.get128();
|
||||
vdata = vec.get128();
|
||||
tmp0 = _mm_shuffle_ps( qdata, qdata, _MM_SHUFFLE(3,0,2,1) );
|
||||
tmp1 = _mm_shuffle_ps( vdata, vdata, _MM_SHUFFLE(3,1,0,2) );
|
||||
tmp2 = _mm_shuffle_ps( qdata, qdata, _MM_SHUFFLE(3,1,0,2) );
|
||||
tmp3 = _mm_shuffle_ps( vdata, vdata, _MM_SHUFFLE(3,0,2,1) );
|
||||
wwww = vec_splat( qdata, 3 );
|
||||
qv = vec_mul( wwww, vdata );
|
||||
qv = vec_madd( tmp0, tmp1, qv );
|
||||
qv = vec_nmsub( tmp2, tmp3, qv );
|
||||
product = vec_mul( qdata, vdata );
|
||||
qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product );
|
||||
qw = vec_add( vec_sld( product, product, 8 ), qw );
|
||||
tmp1 = _mm_shuffle_ps( qv, qv, _MM_SHUFFLE(3,1,0,2) );
|
||||
tmp3 = _mm_shuffle_ps( qv, qv, _MM_SHUFFLE(3,0,2,1) );
|
||||
res = vec_mul( vec_splat( qw, 0 ), qdata );
|
||||
res = vec_madd( wwww, qv, res );
|
||||
res = vec_madd( tmp0, tmp1, res );
|
||||
res = vec_nmsub( tmp2, tmp3, res );
|
||||
return Vector3( res );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat conj( const Quat &quat )
|
||||
{
|
||||
VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0x80000000,0x80000000,0x80000000,0};
|
||||
return Quat( vec_xor( quat.get128(), _mm_load_ps((float *)sw) ) );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE const Quat select( const Quat &quat0, const Quat &quat1, bool select1 )
|
||||
{
|
||||
return select( quat0, quat1, boolInVec(select1) );
|
||||
}
|
||||
|
||||
//VECTORMATH_FORCE_INLINE const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 )
|
||||
//{
|
||||
// return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) );
|
||||
//}
|
||||
|
||||
VECTORMATH_FORCE_INLINE void loadXYZW(Quat& quat, const float* fptr)
|
||||
{
|
||||
#ifdef USE_SSE3_LDDQU
|
||||
quat = Quat( SSEFloat(_mm_lddqu_si128((const __m128i*)((float*)(fptr)))).m128 );
|
||||
#else
|
||||
SSEFloat fl;
|
||||
fl.f[0] = fptr[0];
|
||||
fl.f[1] = fptr[1];
|
||||
fl.f[2] = fptr[2];
|
||||
fl.f[3] = fptr[3];
|
||||
quat = Quat( fl.m128);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE void storeXYZW(const Quat& quat, float* fptr)
|
||||
{
|
||||
fptr[0] = quat.getX();
|
||||
fptr[1] = quat.getY();
|
||||
fptr[2] = quat.getZ();
|
||||
fptr[3] = quat.getW();
|
||||
// _mm_storeu_ps((float*)quat.get128(),fptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef _VECTORMATH_DEBUG
|
||||
|
||||
VECTORMATH_FORCE_INLINE void print( const Quat &quat )
|
||||
{
|
||||
union { __m128 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
VECTORMATH_FORCE_INLINE void print( const Quat &quat, const char * name )
|
||||
{
|
||||
union { __m128 v; float s[4]; } tmp;
|
||||
tmp.v = quat.get128();
|
||||
printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
1455
test/Bullet2/vectormath/sse/vec_aos.h
Normal file
1455
test/Bullet2/vectormath/sse/vec_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
80
test/Bullet2/vectormath/sse/vecidx_aos.h
Normal file
80
test/Bullet2/vectormath/sse/vecidx_aos.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Sony Computer Entertainment Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _VECTORMATH_VECIDX_AOS_H
|
||||
#define _VECTORMATH_VECIDX_AOS_H
|
||||
|
||||
|
||||
#include "floatInVec.h"
|
||||
|
||||
namespace Vectormath {
|
||||
namespace Aos {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// VecIdx
|
||||
// Used in setting elements of Vector3, Vector4, Point3, or Quat with the
|
||||
// subscripting operator.
|
||||
//
|
||||
|
||||
VM_ATTRIBUTE_ALIGNED_CLASS16 (class) VecIdx
|
||||
{
|
||||
private:
|
||||
__m128 &ref;
|
||||
int i;
|
||||
public:
|
||||
inline VecIdx( __m128& vec, int idx ): ref(vec) { i = idx; }
|
||||
|
||||
// implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined
|
||||
// in which case, implicitly casts to floatInVec, and one must call
|
||||
// getAsFloat to convert to float.
|
||||
//
|
||||
#ifdef _VECTORMATH_NO_SCALAR_CAST
|
||||
inline operator floatInVec() const;
|
||||
inline float getAsFloat() const;
|
||||
#else
|
||||
inline operator float() const;
|
||||
#endif
|
||||
|
||||
inline float operator =( float scalar );
|
||||
inline floatInVec operator =( const floatInVec &scalar );
|
||||
inline floatInVec operator =( const VecIdx& scalar );
|
||||
inline floatInVec operator *=( float scalar );
|
||||
inline floatInVec operator *=( const floatInVec &scalar );
|
||||
inline floatInVec operator /=( float scalar );
|
||||
inline floatInVec operator /=( const floatInVec &scalar );
|
||||
inline floatInVec operator +=( float scalar );
|
||||
inline floatInVec operator +=( const floatInVec &scalar );
|
||||
inline floatInVec operator -=( float scalar );
|
||||
inline floatInVec operator -=( const floatInVec &scalar );
|
||||
};
|
||||
|
||||
} // namespace Aos
|
||||
} // namespace Vectormath
|
||||
|
||||
#endif
|
||||
2547
test/Bullet2/vectormath/sse/vectormath_aos.h
Normal file
2547
test/Bullet2/vectormath/sse/vectormath_aos.h
Normal file
File diff suppressed because it is too large
Load Diff
31
test/Bullet2/vectormath/vmInclude.h
Normal file
31
test/Bullet2/vectormath/vmInclude.h
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef __VM_INCLUDE_H
|
||||
#define __VM_INCLUDE_H
|
||||
|
||||
#include "LinearMath/btScalar.h"
|
||||
|
||||
#if defined (USE_SYSTEM_VECTORMATH) || defined (__CELLOS_LV2__)
|
||||
#include <vectormath_aos.h>
|
||||
#else //(USE_SYSTEM_VECTORMATH)
|
||||
#if defined (BT_USE_SSE)
|
||||
#include "sse/vectormath_aos.h"
|
||||
#else //all other platforms
|
||||
#if defined (BT_USE_NEON)
|
||||
#include "neon/vectormath_aos.h"
|
||||
#else
|
||||
#include "scalar/vectormath_aos.h"
|
||||
#endif
|
||||
#endif //(BT_USE_SSE) && defined (_WIN32)
|
||||
#endif //(USE_SYSTEM_VECTORMATH)
|
||||
|
||||
|
||||
|
||||
typedef Vectormath::Aos::Vector3 vmVector3;
|
||||
typedef Vectormath::Aos::Quat vmQuat;
|
||||
typedef Vectormath::Aos::Matrix3 vmMatrix3;
|
||||
typedef Vectormath::Aos::Transform3 vmTransform3;
|
||||
typedef Vectormath::Aos::Point3 vmPoint3;
|
||||
|
||||
#endif //__VM_INCLUDE_H
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
project "test_bullet_collision"
|
||||
project "Test_BulletCollision"
|
||||
|
||||
kind "ConsoleApp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user