diff --git a/Extras/PhysicsEffects/CMakeLists.txt b/Extras/PhysicsEffects/CMakeLists.txt deleted file mode 100644 index 23cbe9701..000000000 --- a/Extras/PhysicsEffects/CMakeLists.txt +++ /dev/null @@ -1,344 +0,0 @@ -cmake_minimum_required(VERSION 2.4.3) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(PHYSICS_EFFECTS) -SET(PHYSICS_EFFECTS_VERSION 2.0) - -SET(BULLET_VERSION 2.80) - -SET(BULLET_PHYSICS_SOURCE_DIR "../..") - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - -INCLUDE_DIRECTORIES( ${PHYSICS_EFFECTS_SOURCE_DIR}/include ) - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") -#MESSAGE("CMAKE_CXX_FLAGS_DEBUG="+${CMAKE_CXX_FLAGS_DEBUG}) - -OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF) -OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON) -OPTION(USE_MULTITHREADED_BENCHMARK "Use Multithreaded Benchmark" OFF) - -ADD_DEFINITIONS(-DPFX_USE_FREE_VECTORMATH) - -IF (USE_MULTITHREADED_BENCHMARK) - ADD_DEFINITIONS(-DUSE_PARALLEL_SOLVER_BENCHMARK -DUSE_PARALLEL_DISPATCHER_BENCHMARK) -ENDIF() - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - -OPTION(USE_CUSTOM_VECTOR_MATH "Use custom vectormath library" OFF) - -IF (USE_CUSTOM_VECTOR_MATH) - ADD_DEFINITIONS(-DUSE_SYSTEM_VECTORMATH) - IF(WIN32) - SET (VECTOR_MATH_INCLUDE ${BULLET_PHYSICS_SOURCE_DIR}/src/vectormath/sse CACHE PATH "Vector Math library include path.") - ELSE(WIN32) - SET (VECTOR_MATH_INCLUDE ${BULLET_PHYSICS_SOURCE_DIR}/src/vectormath/scalar CACHE PATH "Vector Math library include path.") - ENDIF(WIN32) -ENDIF(USE_CUSTOM_VECTOR_MATH) - -IF (MSVC) - FIND_PATH(DIRECTX_SDK_BASE_DIR Include/D3D11.h PATH $ENV{DXSDK_DIR} ) - IF(DIRECTX_SDK_BASE_DIR) - OPTION(USE_DX11 "Use DirectX 11" ON) - ELSE() - OPTION(USE_DX11 "Use DirectX 11" OFF) - ENDIF() -ENDIF(MSVC) - - -#SET(CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:NO") -#SET(CMAKE_EXE_LINKER_FLAGS "/STACK:10000000 /INCREMENTAL:NO") - -#MESSAGE("MSVC_INCREMENTAL_YES_FLAG"+${MSVC_INCREMENTAL_YES_FLAG}) - - -IF(MSVC) - IF (NOT USE_MSVC_INCREMENTAL_LINKING) - #MESSAGE("MSVC_INCREMENTAL_DEFAULT"+${MSVC_INCREMENTAL_DEFAULT}) - SET( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:NO") - - STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG}) - SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO ${replacementFlags}" ) - MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG=${CMAKE_EXE_LINKER_FLAGS_DEBUG}") - -# STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS}) -# SET(CMAKE_EXE_LINKER_FLAGS ${replacementFlag2}) -# STRING(REPLACE "INCREMENTAL:YES" "" replacementFlags3 ${CMAKE_EXTRA_LINK_FLAGS}) -# SET(CMAKE_EXTRA_LINK_FLAGS ${replacementFlag3}) - - - STRING(REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags3 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}) - SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacementFlags3}) - SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO ${replacementFlags3}" ) - - ENDIF (NOT USE_MSVC_INCREMENTAL_LINKING) - - IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL) - #We statically link to reduce dependancies - FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - IF(${flag_var} MATCHES "/MD") - STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - ENDIF(${flag_var} MATCHES "/MD") - IF(${flag_var} MATCHES "/MDd") - STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") - ENDIF(${flag_var} MATCHES "/MDd") - ENDFOREACH(flag_var) - ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL) - - OPTION(USE_MSVC_SSE "Use MSVC /arch:sse option" ON) - IF (USE_MSVC_SSE) - ADD_DEFINITIONS(/arch:SSE) - ENDIF() - OPTION(USE_MSVC_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON) - IF (USE_MSVC_FAST_FLOATINGPOINT) - ADD_DEFINITIONS(/fp:fast) - ENDIF() -ENDIF(MSVC) - - - -IF (WIN32) -OPTION(INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES "Create MSVC projectfiles that can be distributed" OFF) - -IF (INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) - SET (LIBRARY_OUTPUT_PATH ${BULLET_PHYSICS_SOURCE_DIR}/lib CACHE PATH "Single output directory for building all libraries.") - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}) - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BULLET_PHYSICS_SOURCE_DIR}) - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BULLET_PHYSICS_SOURCE_DIR}) - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BULLET_PHYSICS_SOURCE_DIR}) - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BULLET_PHYSICS_SOURCE_DIR}) -ELSE() - SET (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE PATH "Single output directory for building all libraries.") -ENDIF() - -OPTION(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES "Create MSVC projectfiles with relative paths" OFF) -OPTION(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES "Add MSVC postfix for executable names (_Debug)" OFF) - -IF(MSVC) - FIND_PATH(AMD_OPENCL_BASE_DIR include/CL/cl.h PATH $ENV{ATISTREAMSDKROOT} ) - IF(AMD_OPENCL_BASE_DIR) - #AMD adds an extras slash at the end of the ATISTREAMSDKROOT variable - SET(AMD_OPENCL_INCLUDES ${AMD_OPENCL_BASE_DIR}/include ) - MESSAGE(${AMD_OPENCL_INCLUDES}) - IF (CMAKE_CL_64) - SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86_64 ) - ELSE(CMAKE_CL_64) - SET(CMAKE_ATISTREAMSDK_LIBPATH ${AMD_OPENCL_BASE_DIR}/lib/x86 ) - ENDIF(CMAKE_CL_64) - OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" ON) - ELSE() - OPTION(BUILD_AMD_OPENCL_DEMOS "Build OpenCL demos for AMD (GPU or CPU)" OFF) - ENDIF() - - FIND_PATH(NVIDIA_OPENCL_BASE_DIR OpenCL/common/inc/CL/cl.h PATH $ENV{NVSDKCOMPUTE_ROOT} ) - IF(NVIDIA_OPENCL_BASE_DIR) - SET(NVIDIA_OPENCL_INCLUDES ${NVIDIA_OPENCL_BASE_DIR}/OpenCL/common/inc ) - MESSAGE(${NVIDIA_OPENCL_INCLUDES}) - IF (CMAKE_CL_64) - SET(CMAKE_NVSDKCOMPUTE_LIBPATH ${NVIDIA_OPENCL_BASE_DIR}/OpenCL/common/lib/x64 ) - ELSE(CMAKE_CL_64) - SET(CMAKE_NVSDKCOMPUTE_LIBPATH ${NVIDIA_OPENCL_BASE_DIR}/OpenCL/common/lib/Win32 ) - ENDIF(CMAKE_CL_64) - SET(NVIDIA_OPENCL_LIBRARIES ${CMAKE_NVSDKCOMPUTE_LIBPATH}/OpenCL.lib) - - OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" ON) - ELSE() - OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" OFF) - ENDIF() -ENDIF() - - - -IF (INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES) -SET(CMAKE_SUPPRESS_REGENERATION 1) -SET(CMAKE_USE_RELATIVE_PATHS 1) -ENDIF(INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES) - -ENDIF (WIN32) - -IF (MSVC OR APPLE) - OPTION(BUILD_MINICL_OPENCL_DEMOS "Build OpenCL demos for MiniCL (Generic CPU)" ON) -ELSE() - OPTION(BUILD_MINICL_OPENCL_DEMOS "Build OpenCL demos for MiniCL (Generic CPU)" OFF) - - FIND_PATH(NVIDIA_OPENCL_INCLUDES CL/cl.h) - FIND_LIBRARY(NVIDIA_OPENCL_LIBRARIES OpenCL PATH /usr/lib /usr/local/lib) - IF (NVIDIA_OPENCL_INCLUDES AND NVIDIA_OPENCL_LIBRARIES) - MESSAGE("OPENCL FOUND") - MESSAGE(${NVIDIA_OPENCL_LIBRARIES}) - OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" ON) - ELSE () - MESSAGE("OPENCL NOT FOUND") - OPTION(BUILD_NVIDIA_OPENCL_DEMOS "Build OpenCL demos for NVidia (GPU)" OFF) - ENDIF () -ENDIF() - -OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU demos" ON) - - - -OPTION(INTERNAL_UPDATE_SERIALIZATION_STRUCTURES "Internal update serialization structures" OFF) -IF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES) -ADD_DEFINITIONS( -DBT_INTERNAL_UPDATE_SERIALIZATION_STRUCTURES) -ENDIF (INTERNAL_UPDATE_SERIALIZATION_STRUCTURES) - -IF (USE_DOUBLE_PRECISION) -ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION) -ENDIF (USE_DOUBLE_PRECISION) - -IF(USE_GRAPHICAL_BENCHMARK) -ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK) -ENDIF (USE_GRAPHICAL_BENCHMARK) - -IF (WIN32) -OPTION(USE_GLUT "Use Glut" ON) -ADD_DEFINITIONS( -D_IRR_STATIC_LIB_ ) -ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) -ADD_DEFINITIONS( -D_CRT_SECURE_NO_DEPRECATE ) -ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) - -IF (USE_GLUT AND MSVC) - string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - remove_definitions(-D_WINDOWS ) -ENDIF() - - - -ELSE(WIN32) -OPTION(USE_GLUT "Use Glut" ON) -ENDIF(WIN32) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system -# This should be the case. - -FIND_PACKAGE(OpenGL) -IF (OPENGL_FOUND) - MESSAGE("OPENGL FOUND") - MESSAGE(${OPENGL_LIBRARIES}) -ELSE (OPENGL_FOUND) - MESSAGE("OPENGL NOT FOUND") - SET(OPENGL_gl_LIBRARY opengl32) - SET(OPENGL_glu_LIBRARY glu32) -ENDIF (OPENGL_FOUND) - -# ADD_DEFINITIONS(-DBT_USE_FREEGLUT) - -FIND_PACKAGE(GLU) - -IF (USE_GLUT) - FIND_PACKAGE(GLUT) - IF (GLUT_FOUND) - MESSAGE("GLUT FOUND") - MESSAGE(${GLUT_glut_LIBRARY}) - ELSE (GLUT_FOUND) - IF (MINGW) - MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32") - SET(GLUT_glut_LIBRARY glut32) - #TODO add better GLUT detection for MinGW - SET(GLUT_FOUND TRUE) - ENDIF (MINGW) - IF (MSVC) - SET(GLUT_FOUND TRUE) - IF (CMAKE_CL_64) - message("Win64 using Glut/glut64.lib") - SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut64.lib) - ELSE(CMAKE_CL_64) - message("Win32 using Glut/glut32.lib") - SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib) - ENDIF (CMAKE_CL_64) - INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/Glut) - ELSE() - MESSAGE("GLUT NOT FOUND") - ENDIF (MSVC) - ENDIF (GLUT_FOUND) - - IF(NOT WIN32) - # This is added for linux. This should always work if everything is installed and working fine. - INCLUDE_DIRECTORIES(/usr/include /usr/local/include) - ENDIF() -ENDIF(USE_GLUT) - - -OPTION(BUILD_DEMOS "Set when you want to build the demos" ON) -IF(BUILD_DEMOS) - IF(EXISTS ${PHYSICS_EFFECTS_SOURCE_DIR}/sample AND IS_DIRECTORY ${PHYSICS_EFFECTS_SOURCE_DIR}/sample) - SUBDIRS(sample) - ENDIF() -ENDIF(BUILD_DEMOS) - -# "Demos_ps3") -IF (MSVC) - IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) - IF(EXISTS ${PHYSICS_EFFECTS_SOURCE_DIR}/Demos_ps3 AND IS_DIRECTORY ${PHYSICS_EFFECTS_SOURCE_DIR}/Demos_ps3) - MESSAGE("Demos_ps3 found") - SUBDIRS(Demos_ps3) - ENDIF() - ENDIF() -ENDIF(MSVC) - - -#OPTION(BUILD_EXTRAS "Set when you want to build the extras" OFF) -#IF(BUILD_EXTRAS) -# SUBDIRS(Extras) -#ENDIF(BUILD_EXTRAS) - -#Maya Dynamica plugin is moved to http://dynamica.googlecode.com - -SUBDIRS(src) - -IF("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") - OPTION(INSTALL_LIBS "Set when you want to install libraries" OFF) -ELSE() - IF(APPLE AND FRAMEWORK) - OPTION(INSTALL_LIBS "Set when you want to install libraries" ON) - ELSE() -#by default, don't enable the 'INSTALL' option for Xcode and MSVC projectfiles - OPTION(INSTALL_LIBS "Set when you want to install libraries" OFF) - ENDIF() -ENDIF() - -IF(INSTALL_LIBS) - SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) - SET (LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name") - ## the following are directories where stuff will be installed to - SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/bullet/" CACHE PATH "The subdirectory to the header prefix") - SET(PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files") - IF(NOT WIN32) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc @ONLY) - INSTALL( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc - DESTINATION - ${PKGCONFIG_INSTALL_PREFIX}) - ENDIF(NOT WIN32) -ENDIF(INSTALL_LIBS) - -#INSTALL of other files requires CMake 2.6 -IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF) -ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) - -OPTION(BUILD_UNIT_TESTS "Build Unit Tests" OFF) - -IF (BUILD_UNIT_TESTS) - SUBDIRS(UnitTests) -ENDIF() diff --git a/Extras/PhysicsEffects/README_Android.txt b/Extras/PhysicsEffects/README_Android.txt deleted file mode 100644 index 4df7dab98..000000000 --- a/Extras/PhysicsEffects/README_Android.txt +++ /dev/null @@ -1,41 +0,0 @@ -PhysicsEffects can be built and run on Android devices. The Android projects are -a mix of Java and C++ code. The code has been tested using Android NDK r5c. Build files -are provided for the NDK and ANT. Here are some instructions on how -to update the baseline PhysicsEffects branch of Bullet to support Android using the provided -files: - -1. For Windows platforms, download and install Cygwin (if it is not already installed) -2. Download and install the Android SDK. -3. Download and install the Android NDK. (The files provided have been tested with NDK r5c.) - -4. Set up these new environment variables: - - BULLET_PFX_ROOT_CYGWIN = path to your PhysicsEffects folder, for example: - BULLET_PFX_ROOT_CYGWIN=/cygdrive/d/tools/Bullet/Extras/PhysicsEffects - - CYGWIN_ROOT = path to where Cygwin is installed (Windows-style path) - ANDROID_NDK_ROOT = path to where the Android NDK is installed - -5. Open a Cygwin console. Browse to the PhysicsEffects/project/Android - folder. Then, for each package, starting with PfxLibrary, go into the - package folder and run the ndk-build command. For example: - - /PhysicsEffects/project/Android/PfxLibrary> /cygwin/d/tools/android-ndk-r5c/ndk-build - - Build every package using ndk-build. - - (It is possible to configure Eclipse to use ndk-build, but that is somewhat - tedious to do.) - -6. For each application package (PfxApp*) after running ndk-build use - ant compile - ant debug - - If your Android device is connected and setup, you can also run the app using - ant install - -7. If you run the app, you can interact with the touch interface: - - - Tap the screen to change scenes - - Pinch the screen to zoom in/out - - Drag the screen to rotate the camera diff --git a/Extras/PhysicsEffects/build/premake4.lua b/Extras/PhysicsEffects/build/premake4.lua deleted file mode 100644 index ea7fa9d54..000000000 --- a/Extras/PhysicsEffects/build/premake4.lua +++ /dev/null @@ -1,40 +0,0 @@ -solution "00_MySolution" - - configurations {"Debug", "Release"} - configuration "Release" - flags { "Optimize", "StaticRuntime", "NoRTTI", "NoExceptions"} - configuration "Debug" - flags { "Symbols", "StaticRuntime" , "NoRTTI", "NoExceptions"} - platforms {"x32", "x64"} - configuration "x32" - libdirs {"$(ATISTREAMSDKROOT)/lib/x86"} - configuration "x64" - libdirs {"$(ATISTREAMSDKROOT)/lib/x86_64"} - targetsuffix "_64" - - configuration {"x64", "debug"} - targetsuffix "_x64_debug" - configuration {"x64", "release"} - targetsuffix "_x64" - configuration {"x32", "debug"} - targetsuffix "_debug" - - - language "C++" - location "build" - targetdir "bin" - - include "../src/base_level" - include "../src/low_level" - include "../src/util" - - include "../sample/api_physics_effects/0_console" - include "../sample/api_physics_effects/1_simple" - include "../sample/api_physics_effects/2_stable" - include "../sample/api_physics_effects/3_sleep" - include "../sample/api_physics_effects/4_motion_type" - include "../sample/api_physics_effects/5_raycast" - include "../sample/api_physics_effects/6_joint" - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/build/vs2008.bat b/Extras/PhysicsEffects/build/vs2008.bat deleted file mode 100644 index c8841fe45..000000000 --- a/Extras/PhysicsEffects/build/vs2008.bat +++ /dev/null @@ -1,3 +0,0 @@ -..\..\..\msvc\premake4 clean -..\..\..\msvc\premake4 vs2008 -rename build vs2008 \ No newline at end of file diff --git a/Extras/PhysicsEffects/build/vs2010.bat b/Extras/PhysicsEffects/build/vs2010.bat deleted file mode 100644 index f93b24966..000000000 --- a/Extras/PhysicsEffects/build/vs2010.bat +++ /dev/null @@ -1,3 +0,0 @@ -..\..\..\msvc\premake4 clean -..\..\..\msvc\premake4 vs2010 -rename build vs2010 \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.cpp deleted file mode 100644 index 90752fc93..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.cpp +++ /dev/null @@ -1,479 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "btBulletPhysicsEffectsWorld.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" -#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h" -#include "BulletDynamics/ConstraintSolver/btContactConstraint.h" -#include "LinearMath/btAabbUtil2.h" -#include "BulletMultiThreaded/SequentialThreadSupport.h" -#include "BulletCollision/CollisionShapes/btCollisionShape.h" -#include "LinearMath/btIDebugDraw.h" -#include "LinearMath/btQuickprof.h" - -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" - -#include "BulletDynamics/ConstraintSolver/btConstraintSolver.h" - - -#include "BulletPhysicsEffects/btLowLevelData.h" -#include -#include -#include "btLowLevelBroadphase.h" - - -#include "BulletCollision/CollisionShapes/btCompoundShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btConvexHullShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btCylinderShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btSphereShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btCapsuleShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btBoxShape.h"//required for shape conversion -#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" -#include "BulletMultiThreaded/vectormath2bullet.h" - -#ifdef _WIN32 -#include "BulletMultiThreaded/Win32ThreadSupport.h" -#endif - - -#ifdef USE_PE_GATHER_SCATTER_SPURS_TASK -#include "SpuDispatch/BulletPEGatherScatterSpursSupport.h" -#include "SpuDispatch/SpuPEGatherScatterTaskProcess.h" -#endif - - -btBulletPhysicsEffectsWorld::btBulletPhysicsEffectsWorld(btLowLevelData* lowLevelData, btDispatcher* dispatcher,btLowLevelBroadphase* broadphase,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration, btThreadSupportInterface* threadSupport) -:btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver,collisionConfiguration), -m_lowLevelData(lowLevelData) -{ - -#ifdef USE_PE_GATHER_SCATTER_SPURS_TASK - int numGatherScatterSpus = threadSupport->getNumTasks(); - m_PEGatherScatterProcess = new SpuPEGatherScatterTaskProcess(threadSupport,numGatherScatterSpus); -#endif //USE_PE_GATHER_SCATTER_SPURS_TASK - - m_lowLevelStates.resize(broadphase->m_maxHandles);//or use expandNonInitializing? - m_lowLevelBodies.resize(broadphase->m_maxHandles); - m_lowLevelSolverBodies.resize(broadphase->m_maxHandles); - m_lowLevelCollidables.resize(broadphase->m_maxHandles); - - m_lowLevelData->m_states = &m_lowLevelStates[0]; - m_lowLevelData->m_collidables = &m_lowLevelCollidables[0]; - m_lowLevelData->m_bodies = &m_lowLevelBodies[0]; - m_lowLevelData->m_solverBodies = &m_lowLevelSolverBodies[0]; - m_lowLevelData->m_numRigidBodies = broadphase->m_maxHandles; - -} - -btBulletPhysicsEffectsWorld::~btBulletPhysicsEffectsWorld() -{ -#ifdef USE_PE_GATHER_SCATTER_SPURS_TASK - delete m_PEGatherScatterProcess; -#endif - -} - - - -void btBulletPhysicsEffectsWorld::integrateTransforms(btScalar timeStep) -{ - ///integrate transforms -#ifdef USE_PE_GATHER_SCATTER_SPURS_TASK - if (getDispatchInfo().m_enableSPU) - { - BT_PROFILE("integrateTransformsSPU"); - int numRemainingObjects = m_nonStaticRigidBodies.size(); - - int batchSize = PARALLEL_BATCH_SIZE; - int startIndex = 0; - while (numRemainingObjects>0) - { - int currentBatchSize = numRemainingObjects > batchSize? batchSize : numRemainingObjects; - - //issue and flush is likely to be called every frame, move the construction and deletion out of the inner loop (at construction/init etc) - m_PEGatherScatterProcess->issueTask( - CMD_SAMPLE_INTEGRATE_BODIES, - &m_nonStaticRigidBodies[0], - 0, - 0, - startIndex, - currentBatchSize); - numRemainingObjects -= currentBatchSize; - startIndex += currentBatchSize; - } - - m_PEGatherScatterProcess->flush(); - } else -#endif //USE_PE_GATHER_SCATTER_SPURS_TASK - { -// BT_PROFILE("integrateTransforms"); - btDiscreteDynamicsWorld::integrateTransforms(timeStep); - } -} - - -void btBulletPhysicsEffectsWorld::predictUnconstraintMotion(btScalar timeStep) -{ -#ifdef USE_PE_GATHER_SCATTER_SPURS_TASK - if (getDispatchInfo().m_enableSPU) - { - BT_PROFILE("predictUnconstraintMotionSPU"); - int numRemainingObjects = m_nonStaticRigidBodies.size(); - - int batchSize = PARALLEL_BATCH_SIZE; - int startIndex=0; - while (numRemainingObjects>0) - { - int currentBatchSize = numRemainingObjects > batchSize? batchSize : numRemainingObjects; - - //issue and flush is likely to be called every frame, move the construction and deletion out of the inner loop (at construction/init etc) - m_PEGatherScatterProcess->issueTask( - CMD_SAMPLE_PREDICT_MOTION_BODIES, - &m_nonStaticRigidBodies[0], - 0, - 0, - startIndex, - currentBatchSize); - numRemainingObjects -= currentBatchSize; - startIndex += currentBatchSize; - } - - m_PEGatherScatterProcess->flush(); - } - else -#endif //USE_PE_GATHER_SCATTER_SPURS_TASK - { - btDiscreteDynamicsWorld::predictUnconstraintMotion( timeStep); - } - - for ( int i=0;isetHitFraction(1.f); - - if (body->isActive() && (!body->isStaticOrKinematicObject())) - { - syncRigidBodyState(body); - } - } -} - - - -void btBulletPhysicsEffectsWorld::solveConstraints(btContactSolverInfo& solverInfo) -{ - BT_PROFILE("solveConstraints"); - - btCollisionDispatcher* disp = (btCollisionDispatcher*) getDispatcher(); - int numBodies = getNumCollisionObjects(); - - btPersistentManifold** manifolds = disp->getInternalManifoldPointer(); - - int numManifolds = disp->getNumManifolds(); - - - if ((getNumCollisionObjects()>0) && (numManifolds + m_constraints.size()>0)) - { - - btCollisionObject** bodies = numBodies ? &getCollisionObjectArray()[0] : 0; - btTypedConstraint** constraints = m_constraints.size() ? &m_constraints[0] : 0; - - getConstraintSolver()->solveGroup( bodies,numBodies, disp->getInternalManifoldPointer(),numManifolds, constraints, m_constraints.size() ,m_solverInfo,m_debugDrawer,m_stackAlloc,disp); - } -} - - -void btBulletPhysicsEffectsWorld::calculateSimulationIslands() -{ - -} - -static void convertShape(btCollisionShape* bulletShape, btAlignedObjectArray& shapes) -{ - switch (bulletShape->getShapeType()) - { - case BOX_SHAPE_PROXYTYPE: - { - btBoxShape* boxshape = (btBoxShape*)bulletShape; - sce::PhysicsEffects::PfxBox box(boxshape->getHalfExtentsWithMargin().getX(),boxshape->getHalfExtentsWithMargin().getY(),boxshape->getHalfExtentsWithMargin().getZ()); - sce::PhysicsEffects::PfxShape& shape = shapes.expand(); - shape.reset(); - shape.setBox(box); - break; - } - - case TRIANGLE_MESH_SHAPE_PROXYTYPE: - { - btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*) bulletShape; - - int numSubParts = trimesh->getMeshInterface()->getNumSubParts(); - btAssert(numSubParts>0); - - for (int i=0;igetMeshInterface()->getLockedVertexIndexBase(&vertexBase,numVerts,vertexType,vertexStride,&indexBase,indexStride,numFaces,indexType,i); - - sce::PhysicsEffects::PfxCreateLargeTriMeshParam param; - btAssert(param.flag&SCE_PFX_MESH_FLAG_16BIT_INDEX); - unsigned short int* copyIndices = new unsigned short int[numFaces*3]; - switch (indexType) - { - case PHY_UCHAR: - { - for (int p=0;pgetRadius()); - sce::PhysicsEffects::PfxShape& shape = shapes.expand(); - shape.reset(); - shape.setSphere(sphere); - break; - } - case CAPSULE_SHAPE_PROXYTYPE: - { - btCapsuleShape* capsuleshape= (btCapsuleShape*)bulletShape;//assume btCapsuleShapeX for now - sce::PhysicsEffects::PfxCapsule capsule(capsuleshape->getHalfHeight(),capsuleshape->getRadius()); - sce::PhysicsEffects::PfxShape& shape = shapes.expand(); - shape.reset(); - shape.setCapsule(capsule); - break; - } - case CYLINDER_SHAPE_PROXYTYPE: - { - btCylinderShape* cylindershape= (btCylinderShape*)bulletShape;//assume btCylinderShapeX for now - sce::PhysicsEffects::PfxCylinder cylinder(cylindershape->getHalfExtentsWithMargin()[0],cylindershape->getRadius()); - sce::PhysicsEffects::PfxShape& shape = shapes.expand(); - shape.reset(); - shape.setCylinder(cylinder); - break; - } - case CONVEX_HULL_SHAPE_PROXYTYPE: - { - btConvexHullShape* convexHullShape = (btConvexHullShape*)bulletShape; - - sce::PhysicsEffects::PfxConvexMesh* convex = new sce::PhysicsEffects::PfxConvexMesh(); - convex->m_numVerts = convexHullShape->getNumPoints(); - convex->m_numIndices = 0;//todo for ray intersection test support - - for (int i=0;im_numVerts;i++) - { - convex->m_verts[i].setX(convexHullShape->getPoints()[i].getX()); - convex->m_verts[i].setY(convexHullShape->getPoints()[i].getY()); - convex->m_verts[i].setZ(convexHullShape->getPoints()[i].getZ()); - } - - convex->updateAABB(); - sce::PhysicsEffects::PfxShape& shape = shapes.expand(); - shape.reset(); - shape.setConvexMesh(convex); - break; - } - case COMPOUND_SHAPE_PROXYTYPE: - { - btCompoundShape* compound = (btCompoundShape*) bulletShape; - - for (int s=0;sgetNumChildShapes();s++) - { - convertShape(compound->getChildShape(s),shapes); - - sce::PhysicsEffects::PfxMatrix3 rotMat = getVmMatrix3(compound->getChildTransform(s).getBasis()); - sce::PhysicsEffects::PfxVector3 translate = getVmVector3(compound->getChildTransform(s).getOrigin()); - sce::PhysicsEffects::PfxTransform3 childtransform(rotMat,translate); - shapes[shapes.size()-1].setOffsetTransform(childtransform); - } - - break; - } - - - default: - { - btAssert(0); - } - }; - -} - -void btBulletPhysicsEffectsWorld::createStateAndCollidable(btRigidBody* body) -{ - - int objectIndex = body->getBroadphaseProxy()->m_uniqueId; - btAssert(objectIndex>=0); - //btAssert(objectIndexreset(); - pfxbody->reset(); - pfxcollidable->reset(); - - - - pfxbody->setFriction(body->getFriction()); - pfxbody->setRestitution(body->getRestitution()); - - if (body->getInvMass()) - { - btScalar mass = 1.f/body->getInvMass(); - pfxbody->setMass(mass); - Vectormath::Aos::Matrix3 inertiaInv = inertiaInv.identity(); - inertiaInv.setElem(0,0,body->getInvInertiaDiagLocal().getX()); - inertiaInv.setElem(1,1,body->getInvInertiaDiagLocal().getY()); - inertiaInv.setElem(2,2,body->getInvInertiaDiagLocal().getZ()); - pfxbody->setInertiaInv(inertiaInv); - pfxstate->setMotionType(sce::PhysicsEffects::kPfxMotionTypeActive); - } else - { - pfxstate->setMotionType(sce::PhysicsEffects::kPfxMotionTypeFixed); - } - - btAlignedObjectArray shapes; - - convertShape(body->getCollisionShape(), shapes); - - btAssert(shapes.size()>0); - - if (shapes.size()==1) - { - pfxcollidable->addShape(shapes[0]); - pfxcollidable->finish(); - } else - { - if (shapes.size()>1) - { - sce::PhysicsEffects::PfxUInt16* ints=new sce::PhysicsEffects::PfxUInt16[shapes.size()]; - sce::PhysicsEffects::PfxShape* pfxshapes = new sce::PhysicsEffects::PfxShape[shapes.size()]; - int p; - for (p=0;preset(pfxshapes,ints,shapes.size()); - - for (p=0;paddShape(pfxshapes[p]); - } - - pfxcollidable->finish(); - } - } - pfxstate->setRigidBodyId(objectIndex); - - syncRigidBodyState(body); - - -} - - - -void btBulletPhysicsEffectsWorld::syncRigidBodyState(btRigidBody* body) -{ - int objectIndex = body->getBroadphaseProxy()->m_uniqueId; - sce::PhysicsEffects::PfxRigidState* pfxstate = &m_lowLevelStates[objectIndex]; - - pfxstate->setPosition(sce::PhysicsEffects::PfxVector3(body->getWorldTransform().getOrigin()[0],body->getWorldTransform().getOrigin()[1],body->getWorldTransform().getOrigin()[2])); - sce::PhysicsEffects::PfxQuat rot(body->getOrientation().getX(),body->getOrientation().getY(),body->getOrientation().getZ(),body->getOrientation().getW()); - pfxstate->setOrientation(rot); - -} - - - -void btBulletPhysicsEffectsWorld::addRigidBody(btRigidBody* body) -{ - - btDiscreteDynamicsWorld::addRigidBody(body); - - //create a state and collidable - - createStateAndCollidable(body); - - - - - -// m_lowLevelData->m_numRigidBodies++; -// btAssert(m_lowLevelData->m_numRigidBodiesm_maxNumRigidBodies); - -} - -void btBulletPhysicsEffectsWorld::addRigidBody(btRigidBody* body, short group, short mask) -{ - btDiscreteDynamicsWorld::addRigidBody(body,group,mask); - -} - -void btBulletPhysicsEffectsWorld::removeRigidBody(btRigidBody* body) -{ - btDiscreteDynamicsWorld::removeRigidBody(body); - -// m_lowLevelData->m_numRigidBodies--; -// btAssert(m_lowLevelData->m_numRigidBodies>=0); -} - diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h deleted file mode 100644 index d6ffe349d..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - - #ifndef _BT_PARALLEL_DYNAMICS_WORLD_H -#define _BT_PARALLEL_DYNAMICS_WORLD_H - -#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" -#include "physics_effects/base_level/rigidbody/pfx_rigid_body.h" -#include "physics_effects/base_level/rigidbody/pfx_rigid_state.h" -#include "physics_effects/base_level/collision/pfx_collidable.h" -#include "physics_effects/base_level/solver/pfx_solver_body.h" - -//#define USE_PE_GATHER_SCATTER_SPURS_TASK 1 - - -class btThreadSupportInterface; -class SpuPEGatherScatterTaskProcess; -struct CellSpurs; -class SpuBatchRaycaster; -struct btLowLevelBroadphase; - -#define PARALLEL_BATCH_SIZE 64 - - -///btBulletPhysicsEffectsWorld adds parallel processing for integration/motion prediction -class btBulletPhysicsEffectsWorld : public btDiscreteDynamicsWorld -{ - -protected: - btAlignedObjectArray m_lowLevelStates; - btAlignedObjectArray m_lowLevelBodies; - btAlignedObjectArray m_lowLevelSolverBodies; - btAlignedObjectArray m_lowLevelCollidables; - - //PfxSolverBody solverBodies[NUM_RIGIDBODIES]; - - class SpuPEGatherScatterTaskProcess* m_PEGatherScatterProcess; - - struct btLowLevelData* m_lowLevelData; - - void createStateAndCollidable(btRigidBody* body); - - void syncRigidBodyState(btRigidBody* body); -public: - - btBulletPhysicsEffectsWorld(struct btLowLevelData* lowLevelData, btDispatcher* dispatcher,btLowLevelBroadphase* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration, btThreadSupportInterface* threadSupport); - - virtual ~btBulletPhysicsEffectsWorld(); - - virtual void predictUnconstraintMotion(btScalar timeStep); - - virtual void integrateTransforms(btScalar timeStep); - - virtual void solveConstraints(btContactSolverInfo& solverInfo); - - virtual void calculateSimulationIslands(); - - virtual void addRigidBody(btRigidBody* body); - - virtual void addRigidBody(btRigidBody* body, short group, short mask); - - virtual void removeRigidBody(btRigidBody* body); - - -}; -#endif //_BT_PARALLEL_DYNAMICS_WORLD_H \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.cpp deleted file mode 100644 index ff05ed698..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "btLowLevelBroadphase.h" - - -#include "BulletMultiThreaded/PlatformDefinitions.h" -#include "BulletCollision/NarrowphaseCollision/btPersistentManifold.h" - -// Include base level headers -#include "physics_effects/base_level/pfx_base_level_include.h" - -// Include low level headers -#include "physics_effects/low_level/broadphase/pfx_broadphase.h" - -#include "physics_effects/low_level/sort/pfx_parallel_sort.h" - -#include "BulletMultiThreaded/vectormath2bullet.h" - -#include "physics_effects/base_level/base/pfx_vec_utils.h" -#include "physics_effects/base_level/collision/pfx_aabb.h" -#include "physics_effects/base_level/rigidbody/pfx_rigid_state.h" -#include "btLowLevelData.h" - -using namespace sce::PhysicsEffects; - -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - - -/////////////////////////////////////////////////////////////////////////////// -// Broadphase - - - - - -// -btLowLevelBroadphase::btLowLevelBroadphase(btLowLevelData* lowLevelData, btOverlappingPairCache* paircache, int maxProxies) -:m_lowLevelData(lowLevelData) -{ - - m_guidGenerator = 1; - m_releasepaircache = (paircache!=0)?false:true; - m_paircache = paircache? paircache : new(btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16)) btHashedOverlappingPairCache(); - m_clientData.m_bp = this; - m_clientData.m_dispatcher = 0; - - - m_broadphaseAabbMin.setValue(1e30,1e30,1e30); - m_broadphaseAabbMax.setValue(-1e30,-1e30,-1e30); - - // allocate handles buffer and put all handles on free list - m_pHandlesRawPtr = btAlignedAlloc(sizeof(btLowLevelBroadphaseProxy)*maxProxies,16); - m_pHandles = new(m_pHandlesRawPtr) btLowLevelBroadphaseProxy[maxProxies]; - m_maxHandles = maxProxies; - m_numHandles = 0; - m_firstFreeHandle = 0; - m_LastHandleIndex = -1; - - - { - for (int i = m_firstFreeHandle; i < maxProxies; i++) - { - m_pHandles[i].SetNextFree(i + 1); - m_pHandles[i].m_uniqueId = i;//start from zero, so we can re-use the uid for body ID - } - m_pHandles[maxProxies - 1].SetNextFree(0); - - } - -} - -// -btLowLevelBroadphase::~btLowLevelBroadphase() -{ - if(m_releasepaircache) - { - m_paircache->~btOverlappingPairCache(); - btAlignedFree(m_paircache); - } -} - - -btBroadphaseProxy* btLowLevelBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* /*dispatcher*/,void* multiSapProxy) -{ - if (m_numHandles >= m_maxHandles) - { - btAssert(0); - return 0; //should never happen, but don't let the game crash ;-) - } - btAssert(aabbMin[0]<= aabbMax[0] && aabbMin[1]<= aabbMax[1] && aabbMin[2]<= aabbMax[2]); - - int newHandleIndex = allocHandle(); - btLowLevelBroadphaseProxy* proxy = new (&m_pHandles[newHandleIndex])btLowLevelBroadphaseProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy); - m_uid2ptr.insert(proxy->m_uniqueId,proxy); - return proxy; -} - -void btLowLevelBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg,btDispatcher* dispatcher) -{ - m_uid2ptr.remove(proxyOrg->m_uniqueId); - - btLowLevelBroadphaseProxy* proxy0 = static_cast(proxyOrg); - freeHandle(proxy0); - - m_paircache->removeOverlappingPairsContainingProxy(proxyOrg,dispatcher); - - //validate(); - -} - -void btLowLevelBroadphase::getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const -{ - const btLowLevelBroadphaseProxy* sbp = getLowLevelProxyFromProxy(proxy); - aabbMin = sbp->m_aabbMin; - aabbMax = sbp->m_aabbMax; -} - -void btLowLevelBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* /*dispatcher*/) -{ - btLowLevelBroadphaseProxy* sbp = getLowLevelProxyFromProxy(proxy); - sbp->m_aabbMin = aabbMin; - sbp->m_aabbMax = aabbMax; -} - - -bool btLowLevelBroadphase::aabbOverlap(btLowLevelBroadphaseProxy* proxy0,btLowLevelBroadphaseProxy* proxy1) -{ - return proxy0->m_aabbMin[0] <= proxy1->m_aabbMax[0] && proxy1->m_aabbMin[0] <= proxy0->m_aabbMax[0] && - proxy0->m_aabbMin[1] <= proxy1->m_aabbMax[1] && proxy1->m_aabbMin[1] <= proxy0->m_aabbMax[1] && - proxy0->m_aabbMin[2] <= proxy1->m_aabbMax[2] && proxy1->m_aabbMin[2] <= proxy0->m_aabbMax[2]; - -} - - -PfxBroadphasePair* btLowLevelBroadphase::getCurrentPairs() -{ - return &m_lowLevelData->m_pairsBuff[m_lowLevelData->m_pairSwap][0]; -} - -const PfxBroadphasePair* btLowLevelBroadphase::getCurrentPairs() const -{ - return &m_lowLevelData->m_pairsBuff[m_lowLevelData->m_pairSwap][0]; -} - -int btLowLevelBroadphase::getNumCurrentPairs() const -{ - return m_lowLevelData->m_numPairs[m_lowLevelData->m_pairSwap]; -} - -void btLowLevelBroadphase::broadphase(PfxSortData32* proxies, int numRigidBodies, int axis, btDispatcher* dispatcher) -{ - m_lowLevelData->m_pairSwap = 1-m_lowLevelData->m_pairSwap; - - unsigned int &numPreviousPairs = m_lowLevelData->m_numPairs[1-m_lowLevelData->m_pairSwap]; - unsigned int &numCurrentPairs = m_lowLevelData->m_numPairs[m_lowLevelData->m_pairSwap]; - PfxBroadphasePair *previousPairs = &m_lowLevelData->m_pairsBuff[1-m_lowLevelData->m_pairSwap][0]; - PfxBroadphasePair *currentPairs = &m_lowLevelData->m_pairsBuff[m_lowLevelData->m_pairSwap][0]; - - - //E Create broadpahse proxies - { -// for(int i=0;im_maxPairs); - findPairsParam.pairBuff = pool.allocate(findPairsParam.pairBytes); - findPairsParam.workBytes = pfxGetWorkBytesOfFindPairs(m_lowLevelData->m_maxPairs); - findPairsParam.workBuff = pool.allocate(findPairsParam.workBytes); - findPairsParam.proxies = proxies; - findPairsParam.numProxies = numRigidBodies; - findPairsParam.maxPairs = m_lowLevelData->m_maxPairs; - findPairsParam.axis = axis; - - PfxFindPairsResult findPairsResult; - - - int ret = pfxFindPairs(findPairsParam,findPairsResult); - if(ret != SCE_PFX_OK) - SCE_PFX_PRINTF("pfxFindPairs failed %d\n",ret); - - pool.deallocate(findPairsParam.workBuff); - - //E Decompose overlapped pairs into 3 arrays - PfxDecomposePairsParam decomposePairsParam; - decomposePairsParam.pairBytes = pfxGetPairBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.pairBuff = pool.allocate(decomposePairsParam.pairBytes); - decomposePairsParam.workBytes = pfxGetWorkBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.workBuff = pool.allocate(decomposePairsParam.workBytes); - decomposePairsParam.previousPairs = previousPairs; - decomposePairsParam.numPreviousPairs = numPreviousPairs; - decomposePairsParam.currentPairs = findPairsResult.pairs; // Set pairs from pfxFindPairs() - decomposePairsParam.numCurrentPairs = findPairsResult.numPairs; // Set the number of pairs from pfxFindPairs() - - PfxDecomposePairsResult decomposePairsResult; - - ret = pfxDecomposePairs(decomposePairsParam,decomposePairsResult); - if(ret != SCE_PFX_OK) - SCE_PFX_PRINTF("pfxDecomposePairs failed %d\n",ret); - - pool.deallocate(decomposePairsParam.workBuff); - - PfxBroadphasePair *outNewPairs = decomposePairsResult.outNewPairs; - PfxBroadphasePair *outKeepPairs = decomposePairsResult.outKeepPairs; - PfxBroadphasePair *outRemovePairs = decomposePairsResult.outRemovePairs; - PfxUInt32 numOutNewPairs = decomposePairsResult.numOutNewPairs; - PfxUInt32 numOutKeepPairs = decomposePairsResult.numOutKeepPairs; - PfxUInt32 numOutRemovePairs = decomposePairsResult.numOutRemovePairs; - - for (int i=0;iremoveOverlappingPair(proxyA,proxyB,dispatcher); - - //free low level contacts - m_lowLevelData->m_contactIdPool[m_lowLevelData->m_numContactIdPool++] = pfxGetContactId(outRemovePairs[i]); - - } - - for (int i=0;iaddOverlappingPair(proxyA,proxyB); - - //initialize low level contacts - int cId = 0; - if(m_lowLevelData->m_numContactIdPool > 0) { - cId = m_lowLevelData->m_contactIdPool[--m_lowLevelData->m_numContactIdPool]; - } - else { - cId = m_lowLevelData->m_numContacts++; - } - if(cId >= m_lowLevelData->m_maxContacts) { - cId = 0; - } - SCE_PFX_ASSERT(cId < m_lowLevelData->m_maxContacts); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = m_lowLevelData->m_contacts[cId]; - int sz = sizeof(PfxContactManifold); - int sz2 = sizeof(btPersistentManifold); - int sz3 = 4*3*sizeof(btConstraintRow); - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - contact.setCompositeFriction(0.1f); - btpair->m_internalTmpValue = cId; - } - - - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;im_aabbMin); - PfxVector3 maxRig = getVmVector3(bulletProxy->m_aabbMax); - - PfxVecInt3 aabbMin,aabbMax; - pfxConvertCoordWorldToLocal(worldCenter,worldExtent,minRig,maxRig,aabbMin,aabbMax); - - pfxSetXMin(proxy,aabbMin.getX()); - pfxSetXMax(proxy,aabbMax.getX()); - pfxSetYMin(proxy,aabbMin.getY()); - pfxSetYMax(proxy,aabbMax.getY()); - pfxSetZMin(proxy,aabbMin.getZ()); - pfxSetZMax(proxy,aabbMax.getZ()); - pfxSetKey(proxy,aabbMin.get(axis)); - pfxSetObjectId(proxy,rigidbodyId); - pfxSetMotionMask(proxy, kPfxMotionTypeActive); - pfxSetSelf(proxy,bulletProxy->m_collisionFilterGroup); - pfxSetTarget(proxy,bulletProxy->m_collisionFilterMask); - - return ret; -} - -void btLowLevelBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) -{ - - //set the broadphase proxies - - btAlignedObjectArray proxies; - proxies.reserve(m_LastHandleIndex); - - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - int i; - PfxVector3 s(0.0f),s2(0.0f); - - PfxVector3 worldMin(-1000);//PFX_FLT_MAX); - PfxVector3 worldMax(1000);//-PFX_FLT_MAX); - - int numRigidBodies = 0; - for (i=0; i <= m_LastHandleIndex; i++) - { - btLowLevelBroadphaseProxy* proxy0 = &m_pHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - - PfxVector3 pe_pos = getVmVector3(0.5f*(proxy0->m_aabbMax+proxy0->m_aabbMin)); - PfxVector3 pe_min = getVmVector3(proxy0->m_aabbMin); - PfxVector3 pe_max = getVmVector3(proxy0->m_aabbMax); - numRigidBodies++; - //worldMin = minPerElem(worldMin,pe_min); - //worldMax = maxPerElem(worldMax,pe_max); - - s += pe_pos; - s2 += mulPerElem(pe_pos,pe_pos); - } - - - if (numRigidBodies) - { - PfxVector3 v = s2 - mulPerElem(s,s) / (float)numRigidBodies; - if(v[1] > v[0]) - axis = 1; - if(v[2] > v[axis]) - axis = 2; - } - - PfxVector3 worldCenter = 0.5f*(worldMax+worldMin); - PfxVector3 worldExtent = 0.5f*(worldMax-worldMin); - - for (i=0; i <= m_LastHandleIndex; i++) - { - btLowLevelBroadphaseProxy* proxy0 = &m_pHandles[i]; - if(!proxy0->m_clientObject) - { - continue; - } - - PfxBroadphaseProxy& proxy = proxies.expandNonInitializing(); - MyUpdateBroadphaseProxy(proxy,proxy0->m_uniqueId,proxy0,worldCenter,worldExtent,axis); - - } - - //find pairs, and call 'addOverlappingPair' for new pairs and 'removeOverlappingPair' for removed pairs - broadphase(&proxies[0],proxies.size(),axis, dispatcher); -} - - -// -btOverlappingPairCache* btLowLevelBroadphase::getOverlappingPairCache() -{ - return(m_paircache); -} - -// -const btOverlappingPairCache* btLowLevelBroadphase::getOverlappingPairCache() const -{ - return(m_paircache); -} - - -void btLowLevelBroadphase::getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const -{ - aabbMin = m_broadphaseAabbMin; - aabbMax = m_broadphaseAabbMax; -} - -void btLowLevelBroadphase::printStats() -{ -} - -void btLowLevelBroadphase::setNumTasks(int numTasks) -{ -} diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.h deleted file mode 100644 index eb2dccfd0..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelBroadphase.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -///btLowLevelBroadphase implementation -#ifndef BT_LOW_LEVEL_BROADPHASE_H -#define BT_LOW_LEVEL_BROADPHASE_H - -#include "BulletCollision/BroadphaseCollision/btDbvt.h" -#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h" - -#include "physics_effects/base_level/broadphase/pfx_broadphase_pair.h" -#include "LinearMath/btHashMap.h" - -struct btLowLevelBroadphase; -struct btLowLevelData; - -namespace sce -{ - namespace PhysicsEffects - { - struct PfxSortData32; - }; -}; - -struct btMyClientData -{ - btDispatcher* m_dispatcher; - btLowLevelBroadphase* m_bp; -}; - -struct btLowLevelBroadphaseProxy : public btBroadphaseProxy -{ - int m_nextFree; - -// int m_handleId; - - - btLowLevelBroadphaseProxy() {}; - - btLowLevelBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy) - :btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy) - { - (void)shapeType; - } - - - SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;} - SIMD_FORCE_INLINE int GetNextFree() const {return m_nextFree;} - - - - -}; - -///btLowLevelBroadphase is a binding between Open Physics low-level broadphase and Bullet, through the btBroadphaseInterface - -struct btLowLevelBroadphase : btBroadphaseInterface -{ - - int m_numHandles; // number of active handles - int m_maxHandles; // max number of handles - int m_LastHandleIndex; - - btLowLevelBroadphaseProxy* m_pHandles; // handles pool - - void* m_pHandlesRawPtr; - int m_firstFreeHandle; // free handles list - - btOverlappingPairCache* m_paircache; // Pair cache - bool m_releasepaircache; // Release pair cache on delete - int m_guidGenerator; - btVector3 m_broadphaseAabbMin; - btVector3 m_broadphaseAabbMax; - - btMyClientData m_clientData; - - btLowLevelData* m_lowLevelData; - btHashMap m_uid2ptr; - - - int allocHandle() - { - btAssert(m_numHandles < m_maxHandles); - int freeHandle = m_firstFreeHandle; - m_firstFreeHandle = m_pHandles[freeHandle].GetNextFree(); - m_numHandles++; - if(freeHandle > m_LastHandleIndex) - { - m_LastHandleIndex = freeHandle; - } - return freeHandle; - } - - void freeHandle(btLowLevelBroadphaseProxy* proxy) - { - int handle = int(proxy-m_pHandles); - btAssert(handle >= 0 && handle < m_maxHandles); - if(handle == m_LastHandleIndex) - { - m_LastHandleIndex--; - } - proxy->SetNextFree(m_firstFreeHandle); - m_firstFreeHandle = handle; - - proxy->m_clientObject = 0; - - m_numHandles--; - } - - inline btLowLevelBroadphaseProxy* getLowLevelProxyFromProxy(btBroadphaseProxy* proxy) - { - btLowLevelBroadphaseProxy* proxy0 = static_cast(proxy); - return proxy0; - } - - inline const btLowLevelBroadphaseProxy* getLowLevelProxyFromProxy(btBroadphaseProxy* proxy) const - { - const btLowLevelBroadphaseProxy* proxy0 = static_cast(proxy); - return proxy0; - } - - - - inline bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) - { - btLowLevelBroadphaseProxy* p0 = getLowLevelProxyFromProxy(proxy0); - btLowLevelBroadphaseProxy* p1 = getLowLevelProxyFromProxy(proxy1); - return aabbOverlap(p0,p1); - } - - static bool aabbOverlap(btLowLevelBroadphaseProxy* proxy0,btLowLevelBroadphaseProxy* proxy1); - - void broadphase(sce::PhysicsEffects::PfxSortData32* proxies, int numRigidBodies, int axis, btDispatcher* dispatcher); - - sce::PhysicsEffects::PfxBroadphasePair* getCurrentPairs(); - const sce::PhysicsEffects::PfxBroadphasePair* getCurrentPairs() const; - int getNumCurrentPairs() const; - - - - /* Methods */ - btLowLevelBroadphase(btLowLevelData* lowLevelData, btOverlappingPairCache* paircache, int maxProxies = 16384);//,class PfxAllocator* allocator,class PfxStackAllocator* stackPool,void* spursInstance); - virtual ~btLowLevelBroadphase(); - - /* btBroadphaseInterface Implementation */ - btBroadphaseProxy* createProxy(const btVector3& aabbMin,const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiSapProxy); - void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher); - void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatcher); - virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)) - { - } - - virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback) - { - } - - - virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const; - void calculateOverlappingPairs(btDispatcher* dispatcher); - btOverlappingPairCache* getOverlappingPairCache(); - const btOverlappingPairCache* getOverlappingPairCache() const; - void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const; - virtual void printStats(); - - virtual void setNumTasks(int numTasks); - -}; - -#endif diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.cpp deleted file mode 100644 index 76fe85774..000000000 Binary files a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.cpp and /dev/null differ diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.h deleted file mode 100644 index 98b12145b..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com - -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 BT_LOW_LEVEL_COLLISION__DISPATCHER_H -#define BT_LOW_LEVEL_COLLISION__DISPATCHER_H - -#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" -struct btLowLevelBroadphase;//struct instead of class? -struct btLowLevelData; -///Tuning value to optimized SPU utilization -///Too small value means Task overhead is large compared to computation (too fine granularity) -///Too big value might render some SPUs are idle, while a few other SPUs are doing all work. -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 8 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 16 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64 -#define SPU_BATCHSIZE_BROADPHASE_PAIRS 128 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 256 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 512 -//#define SPU_BATCHSIZE_BROADPHASE_PAIRS 1024 -#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" - -class btLowLevelCollisionAlgorithm : public btCollisionAlgorithm -{ - btPersistentManifold* m_manifold; - -public: - - btLowLevelCollisionAlgorithm() - :m_manifold(0) - { - } - - btLowLevelCollisionAlgorithm(btPersistentManifold* manifold, btCollisionDispatcher* dispatcher) - :m_manifold(manifold) - { - m_dispatcher = dispatcher; - } - virtual ~btLowLevelCollisionAlgorithm() - { - if (m_manifold) - m_dispatcher->releaseManifold(m_manifold); - } - virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) - { - btAssert(0); - } - - virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) - { - btAssert(0); - return 0.f; - } - - virtual void getAllContactManifolds(btManifoldArray& manifoldArray) - { - manifoldArray.push_back(m_manifold); - } - -}; - - -///btLowLevelCollisionDispatcher can use SPU to gather and calculate collision detection -///Time of Impact, Closest Points and Penetration Depth. -class btLowLevelCollisionDispatcher : public btCollisionDispatcher -{ - - btLowLevelData* m_lowLevelData; - - btAlignedObjectArray m_manifoldArray; - btAlignedObjectArray m_algorithms; - -protected: - - void collision(); - -public: - - - btLowLevelCollisionDispatcher (btLowLevelData* lowLevelData, btCollisionConfiguration* collisionConfiguration, int maxNumManifolds); - - virtual ~btLowLevelCollisionDispatcher(); - - bool supportsDispatchPairOnSpu(int proxyType0,int proxyType1); - - virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ; - - - - virtual btPersistentManifold* getNewManifold(void* b0,void* b1) - { - btAssert(0); - return 0; - } - virtual void releaseManifold(btPersistentManifold* manifold); - - - virtual void* allocateCollisionAlgorithm(int size) - { - btAssert(0); - return 0; - } - - virtual void freeCollisionAlgorithm(void* ptr) - { - - } - - - -}; - - - -#endif //BT_LOW_LEVEL_COLLISION__DISPATCHER_H - - diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.cpp deleted file mode 100644 index 7770da119..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.cpp +++ /dev/null @@ -1,1410 +0,0 @@ -/* - Copyright (C) 2010 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. - -*/ - - -#include "btLowLevelConstraintSolver.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" - -#include "LinearMath/btQuickprof.h" -#include "BulletMultiThreaded/btThreadSupportInterface.h" - -#include "vecmath/vmInclude.h" - -#include "BulletMultiThreaded/HeapManager.h" - -#include "BulletMultiThreaded/PlatformDefinitions.h" - -//#include "PfxSimdUtils.h" -#include "LinearMath/btScalar.h" - -#include "BulletMultiThreaded/TrbStateVec.h" - - - -///////////////// - - -#define TMP_BUFF_BYTES (15*1024*1024) -unsigned char ATTRIBUTE_ALIGNED128(tmp_buff[TMP_BUFF_BYTES]); - - -static SIMD_FORCE_INLINE vmVector3 btReadVector3(const double* p) -{ - float tmp[3] = {float(p[0]),float(p[1]),float(p[2])}; - vmVector3 v; - loadXYZ(v, tmp); - return v; -} - -static SIMD_FORCE_INLINE vmQuat btReadQuat(const double* p) -{ - float tmp[4] = {float(p[0]),float(p[1]),float(p[2]),float(p[4])}; - vmQuat vq; - loadXYZW(vq, tmp); - return vq; -} - -static SIMD_FORCE_INLINE void btStoreVector3(const vmVector3 &src, double* p) -{ - float tmp[3]; - vmVector3 v = src; - storeXYZ(v, tmp); - p[0] = tmp[0]; - p[1] = tmp[1]; - p[2] = tmp[2]; -} - - -static SIMD_FORCE_INLINE vmVector3 btReadVector3(const float* p) -{ - vmVector3 v; - loadXYZ(v, p); - return v; -} - -static SIMD_FORCE_INLINE vmQuat btReadQuat(const float* p) -{ - vmQuat vq; - loadXYZW(vq, p); - return vq; -} - -static SIMD_FORCE_INLINE void btStoreVector3(const vmVector3 &src, float* p) -{ - vmVector3 v = src; - storeXYZ(v, p); -} - - - - - -// Project Gauss Seidel or the equivalent Sequential Impulse - inline void resolveSingleConstraintRowGeneric(PfxSolverBody& body1,PfxSolverBody& body2,const btSolverConstraint& c) -{ - - btScalar deltaImpulse = c.m_rhs-btScalar(c.m_appliedImpulse)*c.m_cfm; - const btScalar deltaVel1Dotn = c.m_contactNormal.dot((btVector3&)body1.m_deltaLinearVelocity) + c.m_relpos1CrossNormal.dot((btVector3&)body1.m_deltaAngularVelocity); - const btScalar deltaVel2Dotn = -c.m_contactNormal.dot((btVector3&)body2.m_deltaLinearVelocity) + c.m_relpos2CrossNormal.dot((btVector3&)body2.m_deltaAngularVelocity); - -// const btScalar delta_rel_vel = deltaVel1Dotn-deltaVel2Dotn; - deltaImpulse -= deltaVel1Dotn*c.m_jacDiagABInv; - deltaImpulse -= deltaVel2Dotn*c.m_jacDiagABInv; - - const btScalar sum = btScalar(c.m_appliedImpulse) + deltaImpulse; - if (sum < c.m_lowerLimit) - { - deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse; - c.m_appliedImpulse = c.m_lowerLimit; - } - else if (sum > c.m_upperLimit) - { - deltaImpulse = c.m_upperLimit-c.m_appliedImpulse; - c.m_appliedImpulse = c.m_upperLimit; - } - else - { - c.m_appliedImpulse = sum; - } - - - if (body1.m_massInv) - { - btVector3 linearComponent = c.m_contactNormal*body1.m_massInv; - ((btVector3&)body1.m_deltaLinearVelocity) += linearComponent*deltaImpulse; - ((btVector3&)body1.m_deltaAngularVelocity) += c.m_angularComponentA*(btVector3(deltaImpulse,deltaImpulse,deltaImpulse));//*m_angularFactor); - } - - if (body2.m_massInv) - { - btVector3 linearComponent = -c.m_contactNormal*body2.m_massInv; - ((btVector3&)body2.m_deltaLinearVelocity) += linearComponent*deltaImpulse; - ((btVector3&)body2.m_deltaAngularVelocity) += c.m_angularComponentB*((btVector3(deltaImpulse,deltaImpulse,deltaImpulse)));//*m_angularFactor); - } - - //body1.internalApplyImpulse(c.m_contactNormal*body1.internalGetInvMass(),c.m_angularComponentA,deltaImpulse); - //body2.internalApplyImpulse(-c.m_contactNormal*body2.internalGetInvMass(),c.m_angularComponentB,deltaImpulse); - -} - - -static SIMD_FORCE_INLINE -void pfxSolveLinearConstraintRow(btConstraintRow &constraint, - vmVector3 &deltaLinearVelocityA,vmVector3 &deltaAngularVelocityA, - float massInvA,const vmMatrix3 &inertiaInvA,const vmVector3 &rA, - vmVector3 &deltaLinearVelocityB,vmVector3 &deltaAngularVelocityB, - float massInvB,const vmMatrix3 &inertiaInvB,const vmVector3 &rB) -{ - const vmVector3 normal(btReadVector3(constraint.m_normal)); - btScalar deltaImpulse = constraint.m_rhs; - vmVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); - vmVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); - deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); - btScalar oldImpulse = constraint.m_accumImpulse; - constraint.m_accumImpulse = btClamped(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); - deltaImpulse = constraint.m_accumImpulse - oldImpulse; - deltaLinearVelocityA += deltaImpulse * massInvA * normal; - deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); - deltaLinearVelocityB -= deltaImpulse * massInvB * normal; - deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); - -} - -void btSolveContactConstraint( - btConstraintRow &constraintResponse, - btConstraintRow &constraintFriction1, - btConstraintRow &constraintFriction2, - const vmVector3 &contactPointA, - const vmVector3 &contactPointB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - float friction - ) -{ - vmVector3 rA = rotate(solverBodyA.m_orientation,contactPointA); - vmVector3 rB = rotate(solverBodyB.m_orientation,contactPointB); - - pfxSolveLinearConstraintRow(constraintResponse, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - float mf = friction*fabsf(constraintResponse.m_accumImpulse); - constraintFriction1.m_lowerLimit = -mf; - constraintFriction1.m_upperLimit = mf; - constraintFriction2.m_lowerLimit = -mf; - constraintFriction2.m_upperLimit = mf; - - pfxSolveLinearConstraintRow(constraintFriction1, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRow(constraintFriction2, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); -} - - -void CustomSolveConstraintsTaskParallel( - const PfxParallelGroup *contactParallelGroup,const PfxParallelBatch *contactParallelBatches, - PfxConstraintPair *contactPairs,uint32_t numContactPairs, - btPersistentManifold* offsetContactManifolds__, - const PfxParallelGroup *jointParallelGroup,const PfxParallelBatch *jointParallelBatches, - PfxConstraintPair *jointPairs,uint32_t numJointPairs, - TrbState *offsetRigStates, - PfxSolverBody *offsetSolverBodies, - uint32_t numRigidBodies, - int iteration,unsigned int taskId,unsigned int numTasks,btBarrier *barrier) -{ - - PfxSolverBody staticBody; - staticBody.m_massInv = 0.f; - staticBody.m_deltaAngularVelocity=vmVector3(0,0,0); - staticBody.m_deltaLinearVelocity =vmVector3(0,0,0); - - - for(int k=0;knumPhases;phaseId++) { - for(uint32_t batchId=0;batchIdnumBatches[phaseId];batchId++) { - uint32_t numPairs = jointParallelGroup->numPairs[phaseId*SCE_PFX_MAX_SOLVER_BATCHES+batchId]; - if(batchId%numTasks == taskId && numPairs > 0) { - const PfxParallelBatch &batch = jointParallelBatches[phaseId*SCE_PFX_MAX_SOLVER_BATCHES+batchId]; - for(uint32_t i=0;isync(); - } - - // Contact - for(uint32_t phaseId=0;phaseIdnumPhases;phaseId++) { - for(uint32_t batchId=0;batchIdnumBatches[phaseId];batchId++) { - uint32_t numPairs = contactParallelGroup->numPairs[phaseId*SCE_PFX_MAX_SOLVER_BATCHES+batchId]; - if(batchId%numTasks == taskId && numPairs > 0) { - const PfxParallelBatch &batch = contactParallelBatches[phaseId*SCE_PFX_MAX_SOLVER_BATCHES+batchId]; - for(uint32_t i=0;isync(); - } - } -} - -void CustomPostSolverTask( - TrbState *states, - PfxSolverBody *solverBodies, - uint32_t numRigidBodies) -{ - for(uint32_t i=0;i 0.707f) { - // choose p in y-z plane - float a = n[1]*n[1] + n[2]*n[2]; - float k = 1.0f/sqrtf(a); - p[0] = 0; - p[1] = -n[2]*k; - p[2] = n[1]*k; - // set q = n x p - q[0] = a*k; - q[1] = -n[0]*p[2]; - q[2] = n[0]*p[1]; - } - else { - // choose p in x-y plane - float a = n[0]*n[0] + n[1]*n[1]; - float k = 1.0f/sqrtf(a); - p[0] = -n[1]*k; - p[1] = n[0]*k; - p[2] = 0; - // set q = n x p - q[0] = -n[2]*p[1]; - q[1] = n[2]*p[0]; - q[2] = a*k; - } -} - - - -#define PFX_CONTACT_SLOP 0.001f - -void btSetupContactConstraint( - btConstraintRow &constraintResponse, - btConstraintRow &constraintFriction1, - btConstraintRow &constraintFriction2, - float penetrationDepth, - float restitution, - float friction, - const vmVector3 &contactNormal, - const vmVector3 &contactPointA, - const vmVector3 &contactPointB, - const TrbState &stateA, - const TrbState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - float separateBias, - float timeStep - ) -{ - vmVector3 rA = rotate(solverBodyA.m_orientation,contactPointA); - vmVector3 rB = rotate(solverBodyB.m_orientation,contactPointB); - - vmMatrix3 K = vmMatrix3::scale(vmVector3(solverBodyA.m_massInv + solverBodyB.m_massInv)) - - crossMatrix(rA) * solverBodyA.m_inertiaInv * crossMatrix(rA) - - crossMatrix(rB) * solverBodyB.m_inertiaInv * crossMatrix(rB); - - vmVector3 vA = stateA.getLinearVelocity() + cross(stateA.getAngularVelocity(),rA); - vmVector3 vB = stateB.getLinearVelocity() + cross(stateB.getAngularVelocity(),rB); - vmVector3 vAB = vA-vB; - - vmVector3 tangent1,tangent2; - btPlaneSpace1(contactNormal,tangent1,tangent2); - -// constraintResponse.m_accumImpulse = 0.f; -// constraintFriction1.m_accumImpulse = 0.f; -// constraintFriction2.m_accumImpulse = 0.f; - - // Contact Constraint - { - vmVector3 normal = contactNormal; - - float denom = dot(K*normal,normal); - - constraintResponse.m_rhs = -(1.0f+restitution)*dot(vAB,normal); // velocity error - constraintResponse.m_rhs -= (separateBias * btMin(0.0f,penetrationDepth+PFX_CONTACT_SLOP)) / timeStep; // position error - constraintResponse.m_rhs /= denom; - constraintResponse.m_jacDiagInv = 1.0f/denom; - constraintResponse.m_lowerLimit = 0.0f; - constraintResponse.m_upperLimit = SIMD_INFINITY; - btStoreVector3(normal,constraintResponse.m_normal); - } - - // Friction Constraint 1 - { - vmVector3 normal = tangent1; - - float denom = dot(K*normal,normal); - - constraintFriction1.m_jacDiagInv = 1.0f/denom; - constraintFriction1.m_rhs = -dot(vAB,normal); - constraintFriction1.m_rhs *= constraintFriction1.m_jacDiagInv; - constraintFriction1.m_lowerLimit = 0.0f; - constraintFriction1.m_upperLimit = SIMD_INFINITY; - btStoreVector3(normal,constraintFriction1.m_normal); - } - - // Friction Constraint 2 - { - vmVector3 normal = tangent2; - - float denom = dot(K*normal,normal); - - constraintFriction2.m_jacDiagInv = 1.0f/denom; - constraintFriction2.m_rhs = -dot(vAB,normal); - constraintFriction2.m_rhs *= constraintFriction2.m_jacDiagInv; - constraintFriction2.m_lowerLimit = 0.0f; - constraintFriction2.m_upperLimit = SIMD_INFINITY; - btStoreVector3(normal,constraintFriction2.m_normal); - } -} - - -void CustomSetupContactConstraintsTask( - PfxConstraintPair *contactPairs,uint32_t numContactPairs, - TrbState *offsetRigStates, - PfxSolverBody *offsetSolverBodies, - uint32_t numRigidBodies, - float separateBias, - float timeStep) -{ - for(uint32_t i=0;iio); - btCriticalSection* criticalsection = io->setupContactConstraints.criticalSection; - - - //CustomCriticalSection *criticalsection = &io->m_cs; - switch(io->cmd) { - - case PFX_CONSTRAINT_SOLVER_CMD_SOLVE_CONSTRAINTS: - CustomSolveConstraintsTaskParallel( - io->solveConstraints.contactParallelGroup, - io->solveConstraints.contactParallelBatches, - io->solveConstraints.contactPairs, - io->solveConstraints.numContactPairs, - io->solveConstraints.offsetContactManifolds, - - io->solveConstraints.jointParallelGroup, - io->solveConstraints.jointParallelBatches, - io->solveConstraints.jointPairs, - io->solveConstraints.numJointPairs, - - io->solveConstraints.offsetRigStates, - io->solveConstraints.offsetSolverBodies, - io->solveConstraints.numRigidBodies, - io->solveConstraints.iteration, - - io->solveConstraints.taskId, - io->maxTasks1, - io->solveConstraints.barrier - ); - break; - - case PFX_CONSTRAINT_SOLVER_CMD_POST_SOLVER: - CustomPostSolverTask( io->postSolver.states,io->postSolver.solverBodies, io->postSolver.numRigidBodies); - break; - - - case PFX_CONSTRAINT_SOLVER_CMD_SETUP_CONTACT_CONSTRAINTS: - { - bool empty = false; - while(!empty) { - int start,batch; - - criticalsection->lock(); - - start = (int)criticalsection->getSharedParam(0); - batch = (int)criticalsection->getSharedParam(1); - - //PFX_PRINTF("taskId %d start %d num %d\n",arg->taskId,start,batch); - - // ŽŸ‚̃oƒbƒtƒ@‚ðƒZƒbƒg - int nextStart = start + batch; - int rest = btMax((int)io->setupContactConstraints.numContactPairs1 - nextStart,0); - int nextBatch = (rest > batch)?batch:rest; - - criticalsection->setSharedParam(0,nextStart); - criticalsection->setSharedParam(1,nextBatch); - - criticalsection->unlock(); - - if(batch > 0) { - CustomSetupContactConstraintsTask( - io->setupContactConstraints.offsetContactPairs+start,batch, -// io->setupContactConstraints.offsetContactManifolds, - io->setupContactConstraints.offsetRigStates, -// io->setupContactConstraints.offsetRigBodies, - io->setupContactConstraints.offsetSolverBodies, - io->setupContactConstraints.numRigidBodies, - io->setupContactConstraints.separateBias, - io->setupContactConstraints.timeStep); - } - else { - empty = true; - } - } - } - break; - - default: - { - btAssert(0); - } - } - -} - - -void CustomSetupContactConstraintsNew( - PfxConstraintPair *contactPairs1,uint32_t numContactPairs, - btPersistentManifold *offsetContactManifolds, - TrbState *offsetRigStates, - PfxSolverBody *offsetSolverBodies, - uint32_t numRigidBodies, - float separationBias, - float timeStep, - class btThreadSupportInterface* threadSupport, - btCriticalSection* criticalSection, - btConstraintSolverIO *io - ) -{ - int maxTasks = threadSupport->getNumTasks(); - - int div = (int)maxTasks * 4; - int batch = ((int)numContactPairs + div - 1) / div; -#ifdef __PPU__ - BulletPE2ConstraintSolverSpursSupport* spursThread = (BulletPE2ConstraintSolverSpursSupport*) threadSupport; -#endif - if (criticalSection) - { - criticalSection->setSharedParam(0,0); - criticalSection->setSharedParam(1,btMin(batch,64)); // batched number - } else - { -#ifdef __PPU__ - spursThread->setSharedParam(0,0); - spursThread->setSharedParam(1,btMin(batch,64)); // batched number -#endif //__PPU__ - } - - for(int t=0;tgetBarrierAddress(); - io[t].criticalsectionAddr2 = (unsigned int)spursThread->getCriticalSectionAddress(); -#endif - - -//#define SEQUENTIAL_SETUP -#ifdef SEQUENTIAL_SETUP - CustomSetupContactConstraintsTask(contactPairs1,numContactPairs,offsetRigStates,offsetSolverBodies,numRigidBodies,separationBias,timeStep); -#else - threadSupport->sendRequest(1,(ppu_address_t)&io[t],t); -#endif - - } -#ifndef SEQUENTIAL_SETUP - unsigned int arg0,arg1; - for(int t=0;twaitForResponse(&arg0,&arg1); - } -#endif //SEQUENTIAL_SETUP - -} - - -void CustomSplitConstraints( - PfxConstraintPair *pairs,uint32_t numPairs, - PfxParallelGroup &group,PfxParallelBatch *batches, - uint32_t numTasks, - uint32_t numRigidBodies, - void *poolBuff, - uint32_t poolBytes - ) -{ - HeapManager pool((unsigned char*)poolBuff,poolBytes); - - // ƒXƒe[ƒgƒ`ƒFƒbƒN—pƒrƒbƒgƒtƒ‰ƒOƒe[ƒuƒ‹ - int bufSize = sizeof(uint8_t)*numRigidBodies; - bufSize = ((bufSize+127)>>7)<<7; // 128 bytes alignment - uint8_t *bodyTable = (uint8_t*)pool.allocate(bufSize,HeapManager::ALIGN128); - - // ƒyƒAƒ`ƒFƒbƒN—pƒrƒbƒgƒtƒ‰ƒOƒe[ƒuƒ‹ - uint32_t *pairTable; - size_t allocSize = sizeof(uint32_t)*((numPairs+31)/32); - pairTable = (uint32_t*)pool.allocate(allocSize); - memset(pairTable,0,allocSize); - - // –Ú•W‚Æ‚·‚é•ªŠ„” - uint32_t targetCount = btMax(uint32_t(SCE_PFX_MIN_SOLVER_PAIRS),btMin(numPairs / (numTasks*2),uint32_t(SCE_PFX_MAX_SOLVER_PAIRS))); - uint32_t startIndex = 0; - - uint32_t phaseId; - uint32_t batchId; - uint32_t totalCount=0; - - uint32_t maxBatches = btMin(numTasks,uint32_t(SCE_PFX_MAX_SOLVER_BATCHES)); - - for(phaseId=0;phaseId>5; - uint32_t maskP = 1L << (i & 31); - - //pair is already assigned to a phase/batch - if(pairTable[idxP] & maskP) { - continue; - } - - uint32_t idxA = pfxGetObjectIdA(pairs[i]); - uint32_t idxB = pfxGetObjectIdB(pairs[i]); - - // —¼•û‚Æ‚àƒAƒNƒeƒBƒu‚łȂ¢A‚Ü‚½‚ÍÕ“Ë“_‚ª‚O‚̃yƒA‚Í“o˜^‘ÎÛ‚©‚ç‚Í‚¸‚· - if(!pfxGetActive(pairs[i]) || pfxGetNumConstraints(pairs[i]) == 0 || - ((pfxGetMotionMaskA(pairs[i])&PFX_MOTION_MASK_STATIC) && (pfxGetMotionMaskB(pairs[i])&PFX_MOTION_MASK_STATIC)) ) { - if(startIndexCheck) - startIndex++; - //assign pair -> skip it because it has no constraints - pairTable[idxP] |= maskP; - totalCount++; - continue; - } - - // ˆË‘¶«‚̃`ƒFƒbƒN - if( (bodyTable[idxA] != batchId && bodyTable[idxA] != 0xff) || - (bodyTable[idxB] != batchId && bodyTable[idxB] != 0xff) ) { - startIndexCheck = false; - //bodies of the pair are already assigned to another batch within this phase - continue; - } - - // ˆË‘¶«”»’èƒe[ƒuƒ‹‚É“o˜^ - if(pfxGetMotionMaskA(pairs[i])&PFX_MOTION_MASK_DYNAMIC) - bodyTable[idxA] = batchId; - if(pfxGetMotionMaskB(pairs[i])&PFX_MOTION_MASK_DYNAMIC) - bodyTable[idxB] = batchId; - - if(startIndexCheck) - startIndex++; - - pairTable[idxP] |= maskP; - //add the pair 'i' to the current batch - batch.pairIndices[pairId++] = i; - pairCount++; - } - - group.numPairs[phaseId*SCE_PFX_MAX_SOLVER_BATCHES+batchId] = (uint16_t)pairId; - totalCount += pairCount; - } - - group.numBatches[phaseId] = batchId; - } - - group.numPhases = phaseId; - - pool.clear(); -} - - - -void CustomSolveConstraintsParallel( - PfxConstraintPair *contactPairs,uint32_t numContactPairs, - - PfxConstraintPair *jointPairs,uint32_t numJointPairs, - - TrbState *offsetRigStates, - PfxSolverBody *offsetSolverBodies, - uint32_t numRigidBodies, - struct btConstraintSolverIO* io, - class btThreadSupportInterface* threadSupport, - int iteration, - void* poolBuf, - int poolBytes, - class btBarrier* barrier) - { - - int maxTasks = threadSupport->getNumTasks(); -// config.taskManager->setTaskEntry(PFX_SOLVER_ENTRY); - - HeapManager pool((unsigned char*)poolBuf,poolBytes); - - { - PfxParallelGroup *cgroup = (PfxParallelGroup*)pool.allocate(sizeof(PfxParallelGroup)); - PfxParallelBatch *cbatches = (PfxParallelBatch*)pool.allocate(sizeof(PfxParallelBatch)*(SCE_PFX_MAX_SOLVER_PHASES*SCE_PFX_MAX_SOLVER_BATCHES),128); - PfxParallelGroup *jgroup = (PfxParallelGroup*)pool.allocate(sizeof(PfxParallelGroup)); - PfxParallelBatch *jbatches = (PfxParallelBatch*)pool.allocate(sizeof(PfxParallelBatch)*(SCE_PFX_MAX_SOLVER_PHASES*SCE_PFX_MAX_SOLVER_BATCHES),128); - - uint32_t tmpBytes = poolBytes - 2 * (sizeof(PfxParallelGroup) + sizeof(PfxParallelBatch)*(SCE_PFX_MAX_SOLVER_PHASES*SCE_PFX_MAX_SOLVER_BATCHES) + 128); - void *tmpBuff = pool.allocate(tmpBytes); - - { - BT_PROFILE("CustomSplitConstraints"); - CustomSplitConstraints(contactPairs,numContactPairs,*cgroup,cbatches,maxTasks,numRigidBodies,tmpBuff,tmpBytes); - CustomSplitConstraints(jointPairs,numJointPairs,*jgroup,jbatches,maxTasks,numRigidBodies,tmpBuff,tmpBytes); - } - - { - BT_PROFILE("PFX_CONSTRAINT_SOLVER_CMD_SOLVE_CONSTRAINTS"); -//#define SOLVE_SEQUENTIAL -#ifdef SOLVE_SEQUENTIAL - CustomSolveConstraintsTask( - io->solveConstraints.contactParallelGroup, - io->solveConstraints.contactParallelBatches, - io->solveConstraints.contactPairs, - io->solveConstraints.numContactPairs, - io->solveConstraints.offsetContactManifolds, - - io->solveConstraints.jointParallelGroup, - io->solveConstraints.jointParallelBatches, - io->solveConstraints.jointPairs, - io->solveConstraints.numJointPairs, - io->solveConstraints.offsetJoints, - - io->solveConstraints.offsetRigStates, - io->solveConstraints.offsetSolverBodies, - io->solveConstraints.numRigidBodies, - io->solveConstraints.iteration,0,1,0);//arg->taskId,1,0);//,arg->maxTasks,arg->barrier); -#else - for(int t=0;tgetBarrierAddress(); - io[t].criticalsectionAddr2 = (unsigned int)spursThread->getCriticalSectionAddress(); -#endif - - threadSupport->sendRequest(1,(ppu_address_t)&io[t],t); - } - - unsigned int arg0,arg1; - for(int t=0;twaitForResponse(&arg0,&arg1); - } -#endif - } - pool.clear(); - } - - { - BT_PROFILE("PFX_CONSTRAINT_SOLVER_CMD_POST_SOLVER"); - int batch = ((int)numRigidBodies + maxTasks - 1) / maxTasks; - int rest = (int)numRigidBodies; - int start = 0; - - for(int t=0;t 0 ? batch : rest; - io[t].cmd = PFX_CONSTRAINT_SOLVER_CMD_POST_SOLVER; - io[t].postSolver.states = offsetRigStates + start; - io[t].postSolver.solverBodies = offsetSolverBodies + start; - io[t].postSolver.numRigidBodies = (uint32_t)num; - io[t].maxTasks1 = maxTasks; -#ifdef __PPU__ - BulletPE2ConstraintSolverSpursSupport* spursThread = (BulletPE2ConstraintSolverSpursSupport*) threadSupport; - io[t].barrierAddr2 = (unsigned int)spursThread->getBarrierAddress(); - io[t].criticalsectionAddr2 = (unsigned int)spursThread->getCriticalSectionAddress(); -#endif - -#ifdef SOLVE_SEQUENTIAL - CustomPostSolverTask( io[t].postSolver.states,io[t].postSolver.solverBodies, io[t].postSolver.numRigidBodies); -#else - threadSupport->sendRequest(1,(ppu_address_t)&io[t],t); -#endif - rest -= num; - start += num; - } - - unsigned int arg0,arg1; - for(int t=0;twaitForResponse(&arg0,&arg1); -#endif - } - } - -} - - - -void BPE_customConstraintSolverSequentialNew(unsigned int new_num, PfxBroadphasePair *new_pairs1 , - TrbState* states,int numRigidBodies, - struct PfxSolverBody* solverBodies, - btPersistentManifold* contacts, - PfxConstraintPair* jointPairs, unsigned int numJoints, - float separateBias, - float timeStep, - int iteration, - btThreadSupportInterface* solverThreadSupport, - btCriticalSection* criticalSection, - struct btConstraintSolverIO* solverIO, - btBarrier* barrier - ) -{ - - { - BT_PROFILE("pfxSetupConstraints"); - - for(uint32_t i=0;i m_mystates; - btAlignedObjectArray m_mysolverbodies; - btAlignedObjectArray m_mypairs; - btAlignedObjectArray m_jointPairs; - -}; - - -btConstraintSolverIO* createSolverIO(int numThreads) -{ - return new btConstraintSolverIO[numThreads]; -} - -btLowLevelConstraintSolver::btLowLevelConstraintSolver(btThreadSupportInterface* solverThreadSupport) -{ - - m_solverThreadSupport = solverThreadSupport;//createSolverThreadSupport(maxNumThreads); - m_solverIO = createSolverIO(m_solverThreadSupport->getNumTasks()); - - m_barrier = m_solverThreadSupport->createBarrier(); - m_criticalSection = m_solverThreadSupport->createCriticalSection(); - - m_memoryCache = new btParallelSolverMemoryCache(); -} - -btLowLevelConstraintSolver::~btLowLevelConstraintSolver() -{ - delete m_memoryCache; - delete m_solverIO; -} - - - -btScalar btLowLevelConstraintSolver::solveGroup(btCollisionObject** bodies1,int numRigidBodies,btPersistentManifold** manifoldPtr,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) -{ - -/* int sz = sizeof(PfxSolverBody); - int sz2 = sizeof(vmVector3); - int sz3 = sizeof(vmMatrix3); - int sz4 = sizeof(vmQuat); - int sz5 = sizeof(btConstraintRow); - int sz6 = sizeof(btSolverConstraint); - int sz7 = sizeof(TrbState); -*/ - - - m_memoryCache->m_mysolverbodies.resize(numRigidBodies); - m_memoryCache->m_mystates.resize(numRigidBodies); - - { - BT_PROFILE("create states and solver bodies"); - for (int i=0;isetCompanionId(i); - - PfxSolverBody& solverBody = m_memoryCache->m_mysolverbodies[i]; - btRigidBody* rb = btRigidBody::upcast(obj); - TrbState& state = m_memoryCache->m_mystates[i]; - - state.reset(); - const btQuaternion& orgOri = obj->getWorldTransform().getRotation(); - vmQuat orn(orgOri.getX(),orgOri.getY(),orgOri.getZ(),orgOri.getW()); - state.setPosition((vmVector3&) obj->getWorldTransform().getOrigin()); - state.setOrientation(orn); - state.setPosition(state.getPosition()); - state.setRigidBodyId(i); - state.setAngularDamping(0); - state.setLinearDamping(0); - - - solverBody.m_orientation = state.getOrientation(); - solverBody.m_deltaLinearVelocity = vmVector3(0.0f); - solverBody.m_deltaAngularVelocity = vmVector3(0.0f); -#ifdef SOLVERBODY_FRICTION - solverBody.friction = obj->getFriction(); - solverBody.restitution = obj->getRestitution(); -#endif //SOLVERBODY_FRICTION - state.resetSleepCount(); - - //if(state.getMotionMask()&PFX_MOTION_MASK_DYNAMIC) { - if (rb && (rb->getInvMass()>0.f)) - { - state.setAngularVelocity(vmVector3(rb->getAngularVelocity().getX(),rb->getAngularVelocity().getY(),rb->getAngularVelocity().getZ())); - state.setLinearVelocity(vmVector3(rb->getLinearVelocity().getX(),rb->getLinearVelocity().getY(),rb->getLinearVelocity().getZ())); - - state.setMotionType(PfxMotionTypeActive); - vmMatrix3 ori(solverBody.m_orientation); - vmMatrix3 localInvInertia = vmMatrix3::identity(); - localInvInertia.setCol(0,vmVector3(rb->getInvInertiaDiagLocal().getX(),0,0)); - localInvInertia.setCol(1,vmVector3(0, rb->getInvInertiaDiagLocal().getY(),0)); - localInvInertia.setCol(2,vmVector3(0,0, rb->getInvInertiaDiagLocal().getZ())); - - solverBody.m_massInv = rb->getInvMass(); - solverBody.m_inertiaInv = ori * localInvInertia * transpose(ori); - } else - { - state.setAngularVelocity(vmVector3(0)); - state.setLinearVelocity(vmVector3(0)); - - state.setMotionType(PfxMotionTypeFixed); - m_memoryCache->m_mysolverbodies[i].m_massInv = 0.f; - m_memoryCache->m_mysolverbodies[i].m_inertiaInv = vmMatrix3(0.0f); - } - - } - } - - - - int totalPoints = 0; -#ifndef USE_C_ARRAYS - m_memoryCache->m_mypairs.resize(numManifolds); - m_memoryCache->m_jointPairs.resize(numConstraints); -#endif//USE_C_ARRAYS - - int actualNumManifolds= 0; - { - BT_PROFILE("convert manifolds"); - for (int i1=0;i1getNumContacts()>0) - { - btPersistentManifold* m = manifoldPtr[i1]; - btCollisionObject* obA = (btCollisionObject*)m->getBody0(); - btCollisionObject* obB = (btCollisionObject*)m->getBody1(); - bool obAisActive = !obA->isStaticOrKinematicObject() && obA->isActive(); - bool obBisActive = !obB->isStaticOrKinematicObject() && obB->isActive(); - - if (!obAisActive && !obBisActive) - continue; - - - //int contactId = i1;//actualNumManifolds; - - PfxBroadphasePair& pair = m_memoryCache->m_mypairs[actualNumManifolds]; - //init those - float compFric = obA->getFriction()*obB->getFriction();//@todo - int idA = obA->getCompanionId(); - int idB = obB->getCompanionId(); - - m->m_companionIdA = idA; - m->m_companionIdB = idB; - - - // if ((mysolverbodies[idA].m_massInv!=0)&&(mysolverbodies[idB].m_massInv!=0)) - // continue; - int numPosPoints=0; - for (int p=0;pgetNumContacts();p++) - { - //btManifoldPoint& pt = m->getContactPoint(p); - //float dist = pt.getDistance(); - //if (dist<0.001) - numPosPoints++; - } - - - numPosPoints = numPosPoints; - totalPoints+=numPosPoints; - pfxSetObjectIdA(pair,idA); - pfxSetObjectIdB(pair,idB); - pfxSetMotionMaskA(pair,m_memoryCache->m_mystates[idA].getMotionMask()); - pfxSetMotionMaskB(pair,m_memoryCache->m_mystates[idB].getMotionMask()); - pfxSetActive(pair,numPosPoints>0); - - pfxSetBroadphaseFlag(pair,0); - pfxSetContactId(pair,(uint32_t)m);//contactId); - pfxSetNumConstraints(pair,numPosPoints);//manifoldPtr[i]->getNumContacts()); - actualNumManifolds++; - } - - } - } - - PfxConstraintPair* jointPairs=0; - jointPairs = numConstraints? &m_memoryCache->m_jointPairs[0]:0; - int actualNumJoints=0; - - - //if (1) - { - BT_PROFILE("convert constraints"); - { - - int totalNumRows = 0; - int i; - - m_tmpConstraintSizesPool.resize(numConstraints); - //calculate the total number of contraint rows - for (i=0;igetInfo1(&info1); - totalNumRows += info1.m_numConstraintRows; - } - m_tmpSolverNonContactConstraintPool.resize(totalNumRows); - - - ///setup the btSolverConstraints - int currentRow = 0; - - for (i=0;igetRigidBodyA(); - btRigidBody& rbB = constraint->getRigidBodyB(); - - - int j; - for ( j=0;jm_contactNormal; - info2.m_J1angularAxis = currentConstraintRow->m_relpos1CrossNormal; - info2.m_J2linearAxis = 0; - info2.m_J2angularAxis = currentConstraintRow->m_relpos2CrossNormal; - info2.rowskip = sizeof(btSolverConstraint)/sizeof(btScalar);//check this - ///the size of btSolverConstraint needs be a multiple of btScalar - btAssert(info2.rowskip*sizeof(btScalar)== sizeof(btSolverConstraint)); - info2.m_constraintError = ¤tConstraintRow->m_rhs; - currentConstraintRow->m_cfm = infoGlobal.m_globalCfm; - info2.cfm = ¤tConstraintRow->m_cfm; - info2.m_lowerLimit = ¤tConstraintRow->m_lowerLimit; - info2.m_upperLimit = ¤tConstraintRow->m_upperLimit; - info2.m_numIterations = infoGlobal.m_numIterations; - constraints[i]->getInfo2(&info2); - - int idA = constraint->getRigidBodyA().getCompanionId(); - int idB = constraint->getRigidBodyB().getCompanionId(); - - - ///finalize the constraint setup - for ( j=0;jgetRigidBodyA().getInvInertiaTensorWorld()*ftorqueAxis1*constraint->getRigidBodyA().getAngularFactor(); - } - { - const btVector3& ftorqueAxis2 = solverConstraint.m_relpos2CrossNormal; - solverConstraint.m_angularComponentB = constraint->getRigidBodyB().getInvInertiaTensorWorld()*ftorqueAxis2*constraint->getRigidBodyB().getAngularFactor(); - } - - { - btVector3 iMJlA = solverConstraint.m_contactNormal*rbA.getInvMass(); - btVector3 iMJaA = rbA.getInvInertiaTensorWorld()*solverConstraint.m_relpos1CrossNormal; - btVector3 iMJlB = solverConstraint.m_contactNormal*rbB.getInvMass();//sign of normal? - btVector3 iMJaB = rbB.getInvInertiaTensorWorld()*solverConstraint.m_relpos2CrossNormal; - - btScalar sum = iMJlA.dot(solverConstraint.m_contactNormal); - sum += iMJaA.dot(solverConstraint.m_relpos1CrossNormal); - sum += iMJlB.dot(solverConstraint.m_contactNormal); - sum += iMJaB.dot(solverConstraint.m_relpos2CrossNormal); - - solverConstraint.m_jacDiagABInv = btScalar(1.)/sum; - } - - - ///fix rhs - ///todo: add force/torque accelerators - { - btScalar rel_vel; - btScalar vel1Dotn = solverConstraint.m_contactNormal.dot(rbA.getLinearVelocity()) + solverConstraint.m_relpos1CrossNormal.dot(rbA.getAngularVelocity()); - btScalar vel2Dotn = -solverConstraint.m_contactNormal.dot(rbB.getLinearVelocity()) + solverConstraint.m_relpos2CrossNormal.dot(rbB.getAngularVelocity()); - - rel_vel = vel1Dotn+vel2Dotn; - - btScalar restitution = 0.f; - btScalar positionalError = solverConstraint.m_rhs;//already filled in by getConstraintInfo2 - btScalar velocityError = restitution - rel_vel;// * damping; - btScalar penetrationImpulse = positionalError*solverConstraint.m_jacDiagABInv; - btScalar velocityImpulse = velocityError *solverConstraint.m_jacDiagABInv; - solverConstraint.m_rhs = penetrationImpulse+velocityImpulse; - solverConstraint.m_appliedImpulse = 0.f; - - } - } - - PfxConstraintPair& pair = jointPairs[actualNumJoints]; - - int numConstraintRows= info1.m_numConstraintRows; - pfxSetNumConstraints(pair,numConstraintRows); - - - - pfxSetObjectIdA(pair,idA); - pfxSetObjectIdB(pair,idB); - //is this needed? - pfxSetMotionMaskA(pair,m_memoryCache->m_mystates[idA].getMotionMask()); - pfxSetMotionMaskB(pair,m_memoryCache->m_mystates[idB].getMotionMask()); - - pfxSetActive(pair,true); - pfxSetContactId(pair,(uint32_t)currentConstraintRow);//contactId); - actualNumJoints++; - - - } - currentRow+=m_tmpConstraintSizesPool[i].m_numConstraintRows; - } - } - } - - - - float separateBias=0.1;//info.m_erp;//or m_erp2? - float timeStep=infoGlobal.m_timeStep; - int iteration=infoGlobal.m_numIterations; - - //create a pair for each constraints, copy over info etc - - - - - - { - BT_PROFILE("compute num contacts"); - int totalContacts =0; - - for (int i=0;im_mypairs[i]; - totalContacts += pfxGetNumConstraints(*pair); - } - //printf("numManifolds = %d\n",numManifolds); - //printf("totalContacts=%d\n",totalContacts); - } - - - -// printf("actualNumManifolds=%d\n",actualNumManifolds); - { - BT_PROFILE("BPE_customConstraintSolverSequentialNew"); - if (numRigidBodies>0 && (actualNumManifolds+actualNumJoints)>0) - { -// PFX_PRINTF("num points = %d\n",totalPoints); -// PFX_PRINTF("num points PFX = %d\n",total); - - BPE_customConstraintSolverSequentialNew( - actualNumManifolds, - &m_memoryCache->m_mypairs[0], - &m_memoryCache->m_mystates[0],numRigidBodies, - &m_memoryCache->m_mysolverbodies[0], - 0,//manifoldArray, - jointPairs,actualNumJoints,separateBias,timeStep,iteration, - m_solverThreadSupport,m_criticalSection,m_solverIO,m_barrier); - } - } - - //copy results back to bodies - { - BT_PROFILE("copy back"); - for (int i=0;im_mystates[i]; - if (rb && (rb->getInvMass()>0.f)) - { - rb->setLinearVelocity(btVector3(state.getLinearVelocity().getX(),state.getLinearVelocity().getY(),state.getLinearVelocity().getZ())); - rb->setAngularVelocity(btVector3(state.getAngularVelocity().getX(),state.getAngularVelocity().getY(),state.getAngularVelocity().getZ())); - } - } - } - - - return 0.f; -} diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.h deleted file mode 100644 index e9b1f2759..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright (C) 2010 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 __BT_LOW_LEVEL_CONSTRAINT_SOLVER_H -#define __BT_LOW_LEVEL_CONSTRAINT_SOLVER_H - -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" - - - - -#include "LinearMath/btScalar.h" -#include "BulletMultiThreaded/PlatformDefinitions.h" -#include "physics_effects/low_level/pfx_low_level_include.h" -#include "../src/low_level/solver/pfx_parallel_group.h" - -using namespace sce::PhysicsEffects; - - -class btPersistentManifold; - -enum { - PFX_CONSTRAINT_SOLVER_CMD_SETUP_SOLVER_BODIES, - PFX_CONSTRAINT_SOLVER_CMD_SETUP_CONTACT_CONSTRAINTS, - PFX_CONSTRAINT_SOLVER_CMD_SETUP_JOINT_CONSTRAINTS, - PFX_CONSTRAINT_SOLVER_CMD_SOLVE_CONSTRAINTS, - PFX_CONSTRAINT_SOLVER_CMD_POST_SOLVER -}; - - -struct PfxSetupContactConstraintsIO { - PfxConstraintPair *offsetContactPairs; - uint32_t numContactPairs1; - class TrbState *offsetRigStates; - struct PfxSolverBody *offsetSolverBodies; - uint32_t numRigidBodies; - float separateBias; - float timeStep; - class btCriticalSection* criticalSection; -}; - - - -struct PfxSolveConstraintsIO { - PfxParallelGroup *contactParallelGroup; - PfxParallelBatch *contactParallelBatches; - PfxConstraintPair *contactPairs; - uint32_t numContactPairs; - btPersistentManifold *offsetContactManifolds; - PfxParallelGroup *jointParallelGroup; - PfxParallelBatch *jointParallelBatches; - PfxConstraintPair *jointPairs; - uint32_t numJointPairs; - TrbState *offsetRigStates; - PfxSolverBody *offsetSolverBodies; - uint32_t numRigidBodies; - uint32_t iteration; - - uint32_t taskId; - - class btBarrier* barrier; - -}; - -struct PfxPostSolverIO { - TrbState *states; - PfxSolverBody *solverBodies; - uint32_t numRigidBodies; -}; - -ATTRIBUTE_ALIGNED16(struct) btConstraintSolverIO { - uint8_t cmd; - union { - PfxSetupContactConstraintsIO setupContactConstraints; - PfxSolveConstraintsIO solveConstraints; - PfxPostSolverIO postSolver; - }; - - //SPU only - uint32_t barrierAddr2; - uint32_t criticalsectionAddr2; - uint32_t maxTasks1; -}; - - - - -void SolverThreadFunc(void* userPtr,void* lsMemory); -void* SolverlsMemoryFunc(); -///The btLowLevelConstraintSolver performs computations on constraint rows in parallel -///Using the cross-platform threading it supports Windows, Linux, Mac OSX and PlayStation 3 Cell SPUs -class btLowLevelConstraintSolver : public btSequentialImpulseConstraintSolver -{ - -protected: - struct btParallelSolverMemoryCache* m_memoryCache; - - class btThreadSupportInterface* m_solverThreadSupport; - - struct btConstraintSolverIO* m_solverIO; - class btBarrier* m_barrier; - class btCriticalSection* m_criticalSection; - - -public: - - btLowLevelConstraintSolver(class btThreadSupportInterface* solverThreadSupport); - - virtual ~btLowLevelConstraintSolver(); - - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); - -}; - - - -#endif //__BT_LOW_LEVEL_CONSTRAINT_SOLVER_H \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.cpp deleted file mode 100644 index e879da46e..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - Copyright (C) 2010 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. - -*/ - - -#include "btLowLevelConstraintSolver2.h" -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" - -#include "LinearMath/btQuickprof.h" -#include "BulletMultiThreaded/btThreadSupportInterface.h" -#include "BulletMultiThreaded/HeapManager.h" -#include "BulletMultiThreaded/PlatformDefinitions.h" -#include "BulletPhysicsEffects/btLowLevelData.h" -#include "BulletMultiThreaded/vectormath2bullet.h" -//#include "PfxSimdUtils.h" -#include "LinearMath/btScalar.h" -#include "BulletMultiThreaded/HeapManager.h" - - - -///////////////// - - -#define TMP_BUFF_BYTES (15*1024*1024) -static unsigned char ATTRIBUTE_ALIGNED128(tmp_buff[TMP_BUFF_BYTES]); - - - - -btLowLevelConstraintSolver2::btLowLevelConstraintSolver2(btLowLevelData* lowLevelData) -:m_lowLevelData(lowLevelData) -{ - -} - -btLowLevelConstraintSolver2::~btLowLevelConstraintSolver2() -{ - -} - - -static void solveConstraints(btLowLevelData* lowLevelData, btScalar timeStep, btScalar separateBias, int iteration) -{ - PfxPerfCounter pc; - HeapManager pool((unsigned char*)tmp_buff,TMP_BUFF_BYTES); - - unsigned int numCurrentPairs = lowLevelData->m_numPairs[lowLevelData->m_pairSwap]; - PfxBroadphasePair *currentPairs = lowLevelData->m_pairsBuff[lowLevelData->m_pairSwap]; - - pc.countBegin("setup solver bodies"); - { - PfxSetupSolverBodiesParam param; - param.states = lowLevelData->m_states; - param.bodies = lowLevelData->m_bodies; - param.solverBodies = lowLevelData->m_solverBodies; - param.numRigidBodies = lowLevelData->m_numRigidBodies; - - int ret = pfxSetupSolverBodies(param); - if(ret != SCE_PFX_OK) - SCE_PFX_PRINTF("pfxSetupSolverBodies failed %d\n",ret); - } - pc.countEnd(); - - pc.countBegin("setup contact constraints"); - { - PfxSetupContactConstraintsParam param; - param.contactPairs = currentPairs; - param.numContactPairs = numCurrentPairs; - param.offsetContactManifolds = lowLevelData->m_contacts; - param.offsetRigidStates = lowLevelData->m_states; - param.offsetRigidBodies = lowLevelData->m_bodies; - param.offsetSolverBodies = lowLevelData->m_solverBodies; - param.numRigidBodies = lowLevelData->m_numRigidBodies; - param.timeStep = timeStep; - param.separateBias = separateBias; - - int ret = pfxSetupContactConstraints(param); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxSetupJointConstraints failed %d\n",ret); - } - pc.countEnd(); -#if 0 - pc.countBegin("setup joint constraints"); - { - PfxSetupJointConstraintsParam param; - param.jointPairs = 0;//jointPairs; - param.numJointPairs = 0;//numJoints; - param.offsetJoints = 0;//joints; - param.offsetRigidStates = lowLevelData->m_states; - param.offsetRigidBodies = lowLevelData->m_bodies; - param.offsetSolverBodies = lowLevelData->m_solverBodies; - param.numRigidBodies = lowLevelData->m_numRigidBodies; - param.timeStep = timeStep; - - for(int i=0;im_numRigidBodies,numCurrentPairs,0);//numJoints); - param.workBuff = pool.allocate(param.workBytes); - param.contactPairs = currentPairs; - param.numContactPairs = numCurrentPairs; - param.offsetContactManifolds = lowLevelData->m_contacts; - param.jointPairs = 0;//jointPairs; - param.numJointPairs = 0;//numJoints; - param.offsetJoints = 0;//joints; - param.offsetRigidStates = lowLevelData->m_states; - param.offsetSolverBodies = lowLevelData->m_solverBodies; - param.numRigidBodies = lowLevelData->m_numRigidBodies; - param.iteration = iteration; - - int ret = pfxSolveConstraints(param); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxSolveConstraints failed %d\n",ret); - - pool.deallocate(param.workBuff); - } - pc.countEnd(); - - - //pc.printCount(); -} - - - -btScalar btLowLevelConstraintSolver2::solveGroup(btCollisionObject** bodies1,int numRigidBodies,btPersistentManifold** manifoldPtr,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher) -{ - - //copy velocity from BT to PE - { - BT_PROFILE("copy back"); - for (int i=0;igetInvMass()>0.f)) - { - int objectIndex = rb->getBroadphaseProxy()->m_uniqueId; - sce::PhysicsEffects::PfxRigidState& state = m_lowLevelData->m_states[objectIndex]; - - state.setLinearVelocity(getVmVector3(rb->getLinearVelocity())); - state.setAngularVelocity(getVmVector3(rb->getAngularVelocity())); - - } - } - } - - btScalar separateBias = 0.1f; - solveConstraints(m_lowLevelData, infoGlobal.m_timeStep, separateBias, infoGlobal.m_numIterations); - - - //copy resulting velocity back from PE to BT - { - BT_PROFILE("copy back"); - for (int i=0;igetInvMass()>0.f)) - { - int objectIndex = rb->getBroadphaseProxy()->m_uniqueId; - sce::PhysicsEffects::PfxRigidState& state = m_lowLevelData->m_states[objectIndex]; - - rb->setLinearVelocity(btVector3(state.getLinearVelocity().getX(),state.getLinearVelocity().getY(),state.getLinearVelocity().getZ())); - rb->setAngularVelocity(btVector3(state.getAngularVelocity().getX(),state.getAngularVelocity().getY(),state.getAngularVelocity().getZ())); - } - } - } - - return 0.f; -} diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.h deleted file mode 100644 index 6fa3921ff..000000000 --- a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2010 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 __BT_LOW_LEVEL_CONSTRAINT_SOLVER2_H -#define __BT_LOW_LEVEL_CONSTRAINT_SOLVER2_H - -#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" - - - - -#include "LinearMath/btScalar.h" -#include "BulletMultiThreaded/PlatformDefinitions.h" -#include "physics_effects/low_level/pfx_low_level_include.h" -#include "../src/low_level/solver/pfx_parallel_group.h" - -using namespace sce::PhysicsEffects; - - -class btPersistentManifold; -struct btLowLevelData; - -class btLowLevelConstraintSolver2 : public btSequentialImpulseConstraintSolver -{ - -protected: - - btLowLevelData* m_lowLevelData; - -public: - - btLowLevelConstraintSolver2(btLowLevelData* lowLevelData); - - virtual ~btLowLevelConstraintSolver2(); - - virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); - -}; - - - -#endif //__BT_LOW_LEVEL_CONSTRAINT_SOLVER2_H \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelData.cpp b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelData.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelData.h b/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelData.h deleted file mode 100644 index 949299cff..000000000 Binary files a/Extras/PhysicsEffects/include/BulletPhysicsEffects/btLowLevelData.h and /dev/null differ diff --git a/Extras/PhysicsEffects/include/physics_effects.h b/Extras/PhysicsEffects/include/physics_effects.h deleted file mode 100644 index e270c470c..000000000 --- a/Extras/PhysicsEffects/include/physics_effects.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PHYSICS_EFFECTS_H -#define _SCE_PHYSICS_EFFECTS_H - -#include "physics_effects/low_level/pfx_low_level_include.h" -#include "physics_effects/util/pfx_util_include.h" - -#endif // __PHYSICS_EFFECTS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_common.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_common.h deleted file mode 100644 index c40b733bd..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_common.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_COMMON_H -#define _SCE_PFX_COMMON_H - -// Include common headers -#ifdef _WIN32 - #include - #include - #include -#else - #include - #include -#endif - -#include -#include -#include - -#if defined(_WIN32) - #include "pfx_vectormath_include.win32.h" -#else - #include "pfx_vectormath_include.h" -#endif - -namespace sce { -namespace PhysicsEffects { -// Basic Types -#if defined(_WIN32) - typedef char PfxInt8; - typedef unsigned char PfxUInt8; - typedef short PfxInt16; - typedef unsigned short PfxUInt16; - typedef int PfxInt32; - typedef unsigned int PfxUInt32; - typedef long long PfxInt64; - typedef unsigned long long PfxUInt64; -#else - typedef int8_t PfxInt8; - typedef uint8_t PfxUInt8; - typedef int16_t PfxInt16; - typedef uint16_t PfxUInt16; - typedef int32_t PfxInt32; - typedef uint32_t PfxUInt32; - typedef int64_t PfxInt64; - typedef uint64_t PfxUInt64; -#endif - -typedef bool PfxBool; -typedef float PfxFloat; -} //namespace PhysicsEffects -} //namespace sce - -// Debug Print -#ifdef _WIN32 -static void pfxOutputDebugString(const char *str, ...) -{ - char strDebug[1024]={0}; - va_list argList; - va_start(argList, str); - vsprintf_s(strDebug,str,argList); - OutputDebugStringA(strDebug); - va_end(argList); -} -#endif - -#if defined(_DEBUG) - #if defined(_WIN32) - #define SCE_PFX_DPRINT pfxOutputDebugString - #else - #define SCE_PFX_DPRINT(...) printf(__VA_ARGS__) - #endif -#else - #ifdef _WIN32 - #define SCE_PFX_DPRINT - #else - #define SCE_PFX_DPRINT(...) - #endif -#endif - -// Printf -#if defined(_WIN32) - #define SCE_PFX_PRINTF pfxOutputDebugString -#else -// ARA begin insert new code - #ifdef __ANDROID__ - #include - #define SCE_PFX_PRINTF(...) __android_log_print(ANDROID_LOG_VERBOSE, "SCE_PFX_PRINTF", __VA_ARGS__) - #else - #define SCE_PFX_PRINTF(...) printf(__VA_ARGS__) - #endif -// ARA end, old baseline code block was: -// #define SCE_PFX_PRINTF(...) printf(__VA_ARGS__) -// -#endif - -#define SCE_PFX_UNLIKELY(a) (a) -#define SCE_PFX_LIKELY(a) (a) - -// Inline -#if defined(_MSC_VER) - #define SCE_PFX_FORCE_INLINE __forceinline -#elif defined(__SNC__) || defined(__GNUC__) - #define SCE_PFX_FORCE_INLINE inline __attribute__((always_inline)) -#endif - -// Assert -#define SCE_PFX_HALT() abort() - -#ifdef _DEBUG - #define SCE_PFX_ASSERT(test) {if(!(test)){SCE_PFX_PRINTF("Assert "__FILE__ ":%u ("#test")\n", __LINE__);SCE_PFX_HALT();}} - #define SCE_PFX_ASSERT_MSG(test,msg) {if(!(test)){SCE_PFX_PRINTF("Assert " msg " " __FILE__ ":%u ("#test")\n",__LINE__);SCE_PFX_HALT();}} -#else - #define SCE_PFX_ASSERT(test) - #define SCE_PFX_ASSERT_MSG(test,msg) -#endif - -#define SCE_PFX_ALWAYS_ASSERT(test) {if(!(test)){SCE_PFX_PRINTF("Assert "__FILE__ ":%u ("#test")\n", __LINE__);SCE_PFX_HALT();}} -#define SCE_PFX_ALWAYS_ASSERT_MSG(test,msg) {if(!(test)){SCE_PFX_PRINTF("Assert:" msg " " __FILE__ ":%u ("#test")\n",__LINE__);SCE_PFX_HALT();}} - -// Aligned -#if defined(_MSC_VER) - #define SCE_PFX_ALIGNED(alignment) __declspec(align(alignment)) -#elif defined(__SNC__) || defined(__GNUC__) - #define SCE_PFX_ALIGNED(alignment) __attribute__((__aligned__((alignment)))) -#endif - -// Etc -#define SCE_PFX_MIN(a,b) (((a)<(b))?(a):(b)) -#define SCE_PFX_MAX(a,b) (((a)>(b))?(a):(b)) -#define SCE_PFX_CLAMP(v,a,b) SCE_PFX_MAX(a,SCE_PFX_MIN(v,b)) -#define SCE_PFX_SWAP(type, x, y) do {type t; t=x; x=y; y=t; } while (0) -#define SCE_PFX_SQR(a) ((a)*(a)) - -#define SCE_PFX_ALIGN16(count,size) ((((((count) * (size)) + 15) & (~15)) + (size)-1) / (size)) -#define SCE_PFX_ALIGN128(count,size) ((((((count) * (size)) + 127) & (~127)) + (size)-1) / (size)) - -#define SCE_PFX_AVAILABLE_BYTES_ALIGN16(ptr,bytes) (bytes-((uintptr_t)(ptr)&0x0f)) -#define SCE_PFX_AVAILABLE_BYTES_ALIGN128(ptr,bytes) (bytes-((uintptr_t)(ptr)&0x7f)) - -#define SCE_PFX_BYTES_ALIGN16(bytes) (((bytes)+15)&(~15)) -#define SCE_PFX_BYTES_ALIGN128(bytes) (((bytes)+127)&(~127)) - -#define SCE_PFX_PTR_ALIGN16(ptr) (((uintptr_t)(ptr)+15)&(~15)) -#define SCE_PFX_PTR_ALIGN128(ptr) (((uintptr_t)(ptr)+127)&(~127)) - -#define SCE_PFX_PTR_IS_ALIGNED16(ptr) (((uintptr_t)(ptr)&0x0f)==0) -#define SCE_PFX_PTR_IS_ALIGNED128(ptr) (((uintptr_t)(ptr)&0x7f)==0) - -#define SCE_PFX_GET_POINTER(offset,stride,id) ((uintptr_t)(offset)+(stride)*(id)) - -#define SCE_PFX_FLT_MAX 1e+38f -#define SCE_PFX_PI 3.14159265358979f - -#define SCE_PFX_RANGE_CHECK(val,minVal,maxVal) (((val)>=(minVal))&&((val)<=(maxVal))) - -#define SCE_PFX_IS_RUNNING_ON_64BIT_ENV() ( ( sizeof(void*)==8 )? true : false ) - -#if defined(__SNC__) || defined(__GNUC__) - #define SCE_PFX_PADDING(count,bytes) PfxUInt8 padding##count[bytes]; -#else - #define SCE_PFX_PADDING(count,bytes) -#endif - -#include "pfx_error_code.h" - -#endif // _SCE_PFX_COMMON_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_error_code.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_error_code.h deleted file mode 100644 index ca117b79c..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_error_code.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_ERROR_CODE_H -#define _SCE_PFX_ERROR_CODE_H - -#define SCE_PFX_OK 0 -#define SCE_PFX_ERR_INVALID_VALUE 0x80880001 -#define SCE_PFX_ERR_INVALID_ALIGN 0x80880002 -#define SCE_PFX_ERR_OUT_OF_BUFFER 0x80880003 -#define SCE_PFX_ERR_OUT_OF_MAX_PAIRS 0x80880004 -#define SCE_PFX_ERR_OUT_OF_RANGE 0x80880005 -#define SCE_PFX_ERR_OUT_OF_WORLD 0x80880006 -#define SCE_PFX_ERR_INVALID_FLAG 0x80880007 - -#endif // _SCE_PFX_ERROR_CODE_H - diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_heap_manager.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_heap_manager.h deleted file mode 100644 index 10ad5afce..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_heap_manager.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_HEAP_MANAGER_H -#define _SCE_PFX_HEAP_MANAGER_H - -#include "pfx_common.h" - -//J プールã•れãŸãƒ¡ãƒ¢ãƒªã‚’管ç†ã™ã‚‹ã‚¹ã‚¿ãƒƒã‚¯ã®ã‚µã‚¤ã‚º -//E Size of a stack which used to manage pool memory -#define SCE_PFX_HEAP_STACK_SIZE 64 - -#define SCE_PFX_MIN_ALLOC_SIZE 16 - -#define SCE_PFX_ALLOC_BYTES_ALIGN16(bytes) SCE_PFX_MAX(16,SCE_PFX_BYTES_ALIGN16(bytes)) -#define SCE_PFX_ALLOC_BYTES_ALIGN128(bytes) SCE_PFX_MAX(128,SCE_PFX_BYTES_ALIGN128(bytes)) - -#if defined (_WIN64) || defined (__LP64__) - #define SCE_PFX_ALIGN_MASK_16 0xfffffffffffffff0 - #define SCE_PFX_ALIGN_MASK_128 0xffffffffffffff80 -#else - #define SCE_PFX_ALIGN_MASK_16 0xfffffff0 - #define SCE_PFX_ALIGN_MASK_128 0xffffff80 -#endif - -/////////////////////////////////////////////////////////////////////////////// -// PfxHeapManager - -//J <補足> -//J メモリã¯ã‚¹ã‚¿ãƒƒã‚¯ã§ç®¡ç†ã•れã¦ã„ã¾ã™ã€‚å–å¾—ã—ãŸé †ã¨é€†ã«é–‹æ”¾ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€‚ -//J メモリを一気ã«é–‹æ”¾ã—ãŸã„å ´åˆã¯clear()を呼ã³å‡ºã—ã¦ãã ã•ã„。 -//J 最å°å‰²ã‚Šå½“ã¦ã‚µã‚¤ã‚ºã¯SCE_PFX_MIN_ALLOC_SIZEã§å®šç¾©ã•れã¾ã™ã€‚ - -//E -//E Memory is managed as a stack, so deallocate() needs to be called in reverse order. -//E Use clear() to deallocate all allocated memory at once. -//E SCE_PFX_MIN_ALLOC_SIZE defines the smallest amount of buffer. - -namespace sce { -namespace PhysicsEffects { - -class PfxHeapManager -{ -private: - PfxUInt8 *m_heap; - PfxUInt8 *m_poolStack[SCE_PFX_HEAP_STACK_SIZE]; - PfxInt32 m_heapBytes; - PfxInt32 m_curStack; - PfxInt32 m_rest; - -public: - enum {ALIGN16=16,ALIGN128=128}; - - PfxHeapManager(PfxUInt8 *buf,PfxInt32 bytes) - { - m_heap = buf; - m_heapBytes = bytes; - clear(); - } - - ~PfxHeapManager() - { - } - - PfxInt32 getAllocated() - { - return (PfxInt32)(m_poolStack[m_curStack]-m_heap); - } - - PfxInt32 getRest() - { - return m_heapBytes-getAllocated(); - } - - void *allocate(size_t bytes,PfxInt32 alignment = ALIGN16) - { - SCE_PFX_ALWAYS_ASSERT(m_curStack -#endif -// ARA end - -//J パフォーマンス測定ã™ã‚‹å ´åˆã¯PFX_USE_PERFCOUNTERを定義 -//J ブックマークを使用ã™ã‚‹å ´åˆã¯PFX_USE_BOOKMARKを定義 - -//E Define SCE_PFX_USE_PERFCOUNTER to check performance -//E Define SCE_PFX_USE_BOOKMARK to use bookmark - - -#define SCE_PFX_MAX_PERF_STR 32 -#define SCE_PFX_MAX_PERF_COUNT 20 - -//#define SCE_PFX_USE_PERFCOUNTER -//#define SCE_PFX_USE_BOOKMARK - -namespace sce { -namespace PhysicsEffects { -#ifdef SCE_PFX_USE_PERFCOUNTER - -class PfxPerfCounter -{ -private: - int m_count,m_strCount; - char m_str[SCE_PFX_MAX_PERF_COUNT][SCE_PFX_MAX_PERF_STR]; - float m_freq; - - SCE_PFX_PADDING(1,4) -#ifdef _WIN32 - LONGLONG m_cnt[SCE_PFX_MAX_PERF_COUNT*2]; -#else -// ARA begin insert new code - timespec m_cnt[SCE_PFX_MAX_PERF_COUNT*2]; -// ARA end -#endif - - void count(int i) - { -#ifdef _WIN32 - QueryPerformanceCounter( (LARGE_INTEGER *)&m_cnt[i] ); -#else -// ARA begin insert new code - clock_gettime(CLOCK_MONOTONIC, &m_cnt[i]); -// ARA end -#endif - } - -public: - PfxPerfCounter() - { -#ifdef _WIN32 - LARGE_INTEGER sPerfCountFreq; - QueryPerformanceFrequency(&sPerfCountFreq); - m_freq = (float)sPerfCountFreq.QuadPart; -#else -// ARA begin insert new code - m_freq = 1000000000.0f; // clock_gettime reports time in nanoseconds (though accuracy is platform dependent) -// ARA end -#endif - resetCount(); - } - - ~PfxPerfCounter() - { - //printCount(); - } - - void countBegin(const char *name) - { - SCE_PFX_ASSERT(m_strCount < SCE_PFX_MAX_PERF_COUNT); - strncpy(m_str[m_strCount],name,SCE_PFX_MAX_PERF_STR-1); - m_str[m_strCount][SCE_PFX_MAX_PERF_STR-1] = 0x00; - m_strCount++; - count(m_count++); - } - - void countEnd() - { - count(m_count++); - } - - void resetCount() - { - m_strCount = 0; - m_count = 0; - } - - float getCountTime(int i) - { -#if _WIN32 - return (float)(m_cnt[i+1]-m_cnt[i]) / m_freq * 1000.0f; -#else -// ARA begin insert new code - return float(m_cnt[i+1].tv_sec - m_cnt[i].tv_sec) + - (float(m_cnt[i+1].tv_nsec - m_cnt[i].tv_nsec) / m_freq); -// ARA end -#endif -} - - void printCount() - { - if(m_count%2 != 0) countEnd(); - SCE_PFX_PRINTF("*** PfxPerfCounter results ***\n"); - float total = 0.0f; - for(int i=0;i+1>1],getCountTime(i),getCountTime(i)/total*100.0f); - } - SCE_PFX_PRINTF(" -- Total %fms\n",total); - } -}; - -#else /* SCE_PFX_USE_PERFCOUNTER */ - -class PfxPerfCounter -{ -public: - PfxPerfCounter() {} - ~PfxPerfCounter() {} - void countBegin(const char *name) {(void) name;} - void countEnd() {} - void resetCount() {} - float getCountTime(int i) {(void)i;return 0.0f;} - void printCount() {} -}; - -#endif /* SCE_PFX_USE_PERFCOUNTER */ - -#define pfxInsertBookmark(bookmark) - -#ifdef SCE_PFX_USE_BOOKMARK - #define SCE_PFX_PUSH_MARKER(name) - #define SCE_PFX_POP_MARKER() -#else - #define SCE_PFX_PUSH_MARKER(name) - #define SCE_PFX_POP_MARKER() -#endif - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_PERF_COUNTER_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_int3.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_int3.h deleted file mode 100644 index 2c588bf20..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_int3.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_VEC_INT3_H -#define _SCE_PFX_VEC_INT3_H - -#include "pfx_common.h" - - - -namespace sce { -namespace PhysicsEffects { - -class SCE_PFX_ALIGNED(16) PfxVecInt3 -{ -private: -PfxInt32 m_x,m_y,m_z,m_w; - -public: -PfxVecInt3() {m_x=m_y=m_z=m_w=0;} -PfxVecInt3(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG vec) {m_x=(PfxInt32)vec[0];m_y=(PfxInt32)vec[1];m_z=(PfxInt32)vec[2];m_w=0;} -PfxVecInt3(PfxFloat fx,PfxFloat fy,PfxFloat fz) {m_x=(PfxInt32)fx;m_y=(PfxInt32)fy;m_z=(PfxInt32)fz;m_w=0;} -PfxVecInt3(PfxInt32 iv) {m_x=m_y=m_z=iv;m_w=0;} -PfxVecInt3(PfxInt32 ix,PfxInt32 iy,PfxInt32 iz) {m_x=ix;m_y=iy;m_z=iz;m_w=0;} - - inline PfxVecInt3 &operator =( const PfxVecInt3 &vec); - -inline PfxInt32 get(PfxInt32 i) const {return *(&m_x+i);} -inline PfxInt32 getX() const {return m_x;} -inline PfxInt32 getY() const {return m_y;} -inline PfxInt32 getZ() const {return m_z;} -inline void set(PfxInt32 i,PfxInt32 v) {*(&m_x+i) = v;} -inline void setX(PfxInt32 v) {m_x = v;} -inline void setY(PfxInt32 v) {m_y = v;} -inline void setZ(PfxInt32 v) {m_z = v;} - - inline const PfxVecInt3 operator +( const PfxVecInt3 & vec ) const; - inline const PfxVecInt3 operator -( const PfxVecInt3 & vec ) const; - inline const PfxVecInt3 operator *( PfxInt32 scalar ) const; - inline const PfxVecInt3 operator /( PfxInt32 scalar ) const; - - inline PfxVecInt3 & operator +=( const PfxVecInt3 & vec ); - inline PfxVecInt3 & operator -=( const PfxVecInt3 & vec ); - inline PfxVecInt3 & operator *=( PfxInt32 scalar ); - inline PfxVecInt3 & operator /=( PfxInt32 scalar ); - - inline const PfxVecInt3 operator -() const; - -operator PfxVector3() const -{ - return PfxVector3((PfxFloat)m_x,(PfxFloat)m_y,(PfxFloat)m_z); -} -}; - -inline PfxVecInt3 &PfxVecInt3::operator =( const PfxVecInt3 &vec) -{ - m_x = vec.m_x; - m_y = vec.m_y; - m_z = vec.m_z; - return *this; -} - -inline const PfxVecInt3 PfxVecInt3::operator +( const PfxVecInt3 & vec ) const -{ - return PfxVecInt3(m_x+vec.m_x, m_y+vec.m_y, m_z+vec.m_z); -} - -inline const PfxVecInt3 PfxVecInt3::operator -( const PfxVecInt3 & vec ) const -{ - return PfxVecInt3(m_x-vec.m_x, m_y-vec.m_y, m_z-vec.m_z); -} - -inline const PfxVecInt3 PfxVecInt3::operator *( PfxInt32 scalar ) const -{ - return PfxVecInt3(m_x*scalar, m_y*scalar, m_z*scalar); -} - -inline const PfxVecInt3 PfxVecInt3::operator /( PfxInt32 scalar ) const -{ - return PfxVecInt3(m_x/scalar, m_y/scalar, m_z/scalar); -} - -inline PfxVecInt3 &PfxVecInt3::operator +=( const PfxVecInt3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline PfxVecInt3 &PfxVecInt3::operator -=( const PfxVecInt3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline PfxVecInt3 &PfxVecInt3::operator *=( PfxInt32 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline PfxVecInt3 &PfxVecInt3::operator /=( PfxInt32 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const PfxVecInt3 PfxVecInt3::operator -() const -{ -return PfxVecInt3(-m_x,-m_y,-m_z); -} - -inline const PfxVecInt3 operator *( PfxInt32 scalar, const PfxVecInt3 & vec ) -{ - return vec * scalar; -} - -inline const PfxVecInt3 mulPerElem( const PfxVecInt3 & vec0, const PfxVecInt3 & vec1 ) -{ -return PfxVecInt3(vec0.getX()*vec1.getX(), vec0.getY()*vec1.getY(), vec0.getZ()*vec1.getZ()); -} - -inline const PfxVecInt3 divPerElem( const PfxVecInt3 & vec0, const PfxVecInt3 & vec1 ) -{ -return PfxVecInt3(vec0.getX()/vec1.getX(), vec0.getY()/vec1.getY(), vec0.getZ()/vec1.getZ()); -} - -inline const PfxVecInt3 absPerElem( const PfxVecInt3 & vec ) -{ -return PfxVecInt3(abs(vec.getX()), abs(vec.getY()), abs(vec.getZ())); -} - -inline const PfxVecInt3 maxPerElem( const PfxVecInt3 & vec0, const PfxVecInt3 & vec1 ) -{ - return PfxVecInt3( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline const PfxVecInt3 minPerElem( const PfxVecInt3 & vec0, const PfxVecInt3 & vec1 ) -{ - return PfxVecInt3( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} -} //namespace PhysicsEffects -} //namespace sce - - -#endif // _SCE_PFX_VEC_INT3_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_utils.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_utils.h deleted file mode 100644 index 2b50db5df..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vec_utils.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_VEC_UTILS_H -#define _SCE_PFX_VEC_UTILS_H - -#include "pfx_common.h" -#include "pfx_vec_int3.h" - -namespace sce { -namespace PhysicsEffects { -static SCE_PFX_FORCE_INLINE PfxVector3 pfxReadVector3(const PfxFloat* fptr) -{ - PfxVector3 v; - -loadXYZ(v, fptr); - - return v; -} - -static SCE_PFX_FORCE_INLINE PfxPoint3 pfxReadPoint3(const PfxFloat* fptr) -{ - PfxPoint3 v; - -loadXYZ(v, fptr); - - return v; -} - -static SCE_PFX_FORCE_INLINE PfxQuat pfxReadQuat(const PfxFloat* fptr) -{ - PfxQuat vq; - -loadXYZW(vq, fptr); - - return vq; -} - -static SCE_PFX_FORCE_INLINE void pfxStoreVector3(const PfxVector3 &src, PfxFloat* fptr) -{ -storeXYZ(src, fptr); -} - -static SCE_PFX_FORCE_INLINE void pfxStorePoint3(const PfxPoint3 &src, PfxFloat* fptr) -{ -storeXYZ(src, fptr); -} - -static SCE_PFX_FORCE_INLINE void pfxStoreQuat(const PfxQuat &src, PfxFloat* fptr) -{ -storeXYZW(src, fptr); -} - -} // namespace PhysicsEffects -} // namespace sce - -namespace sce { -namespace PhysicsEffects { -static SCE_PFX_FORCE_INLINE -void pfxGetPlaneSpace(const PfxVector3& n, PfxVector3& fptr, PfxVector3& q) -{ - if(fabsf(n[2]) > 0.707f) { - // choose fptr in y-z plane - PfxFloat a = n[1]*n[1] + n[2]*n[2]; - PfxFloat k = 1.0f/sqrtf(a); - fptr[0] = 0; - fptr[1] = -n[2]*k; - fptr[2] = n[1]*k; - // set q = n x fptr - q[0] = a*k; - q[1] = -n[0]*fptr[2]; - q[2] = n[0]*fptr[1]; - } - else { - // choose fptr in x-y plane - PfxFloat a = n[0]*n[0] + n[1]*n[1]; - PfxFloat k = 1.0f/sqrtf(a); - fptr[0] = -n[1]*k; - fptr[1] = n[0]*k; - fptr[2] = 0; - // set q = n x fptr - q[0] = -n[2]*fptr[1]; - q[1] = n[2]*fptr[0]; - q[2] = a*k; - } -} - -static SCE_PFX_FORCE_INLINE -void pfxGetRotationAngleAndAxis(const PfxQuat &unitQuat,PfxFloat &angle,PfxVector3 &axis) -{ - const PfxFloat epsilon=0.00001f; - - if(fabsf(unitQuat.getW()) < 1.0f-epsilon && lengthSqr(unitQuat.getXYZ()) > epsilon) { - PfxFloat angleHalf = acosf(unitQuat.getW()); - PfxFloat sinAngleHalf = sinf(angleHalf); - - if(fabsf(sinAngleHalf) > 1.0e-10f) { - axis = unitQuat.getXYZ()/sinAngleHalf; - } else { - axis = unitQuat.getXYZ(); - } - angle = 2.0f*angleHalf; - } else { - angle = 0.0f; - axis = PfxVector3(1.0f, 0.0f, 0.0f); - } -} - -static SCE_PFX_FORCE_INLINE -PfxFloat pfxSafeAtan2(PfxFloat y,PfxFloat x) -{ - if(SCE_PFX_SQR(x) < 0.000001f || SCE_PFX_SQR(y) < 0.000001f) { - return 0.0f; - } - return atan2f(y,x); -} - -static SCE_PFX_FORCE_INLINE -PfxVector3 pfxSafeNormalize(const PfxVector3 &vec) -{ - float lenSqr = lengthSqr( vec ); - - if( lenSqr > 0.000001f ) { - return normalize(vec); - }else { - return PfxVector3( 1.0f, 0.0f, 0.0f ); - } -} - -static SCE_PFX_FORCE_INLINE -PfxVecInt3 pfxConvertCoordWorldToLocal(const PfxVector3 &coord,const PfxVector3 ¢er,const PfxVector3 &half) -{ - const PfxVector3 sz(65535.0f); - PfxVector3 q = divPerElem(coord - center + half,2.0f*half); - q = minPerElem(maxPerElem(q,PfxVector3(0.0f)),PfxVector3(1.0f)); // clamp 0.0 - 1.0 - q = mulPerElem(q,sz); - return PfxVecInt3(q); -} - -static SCE_PFX_FORCE_INLINE -void pfxConvertCoordWorldToLocal( - const PfxVector3 ¢er,const PfxVector3 &half, - const PfxVector3 &coordMin,const PfxVector3 &coordMax, - PfxVecInt3 &localMin,PfxVecInt3 &localMax) -{ - const PfxVector3 sz(65535.0f); - PfxVector3 qmin = divPerElem(coordMin - center + half,2.0f*half); - qmin = minPerElem(maxPerElem(qmin,PfxVector3(0.0f)),PfxVector3(1.0f)); // clamp 0.0 - 1.0 - qmin = mulPerElem(qmin,sz); - - PfxVector3 qmax = divPerElem(coordMax - center + half,2.0f*half); - qmax = minPerElem(maxPerElem(qmax,PfxVector3(0.0f)),PfxVector3(1.0f)); // clamp 0.0 - 1.0 - qmax = mulPerElem(qmax,sz); -localMin = PfxVecInt3(floorf(qmin[0]),floorf(qmin[1]),floorf(qmin[2])); -localMax = PfxVecInt3(ceilf(qmax[0]),ceilf(qmax[1]),ceilf(qmax[2])); -} - -static SCE_PFX_FORCE_INLINE -PfxVector3 pfxConvertCoordLocalToWorld(const PfxVecInt3 &coord,const PfxVector3 ¢er,const PfxVector3 &half) -{ - PfxVector3 sz(65535.0f),vcoord(coord); - PfxVector3 q = divPerElem(vcoord,sz); - return mulPerElem(q,2.0f*half) + center - half; -} -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_VEC_UTILS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.h deleted file mode 100644 index 1cd3590d0..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_VECTORMATH_INCLUDE_H -#define _SCE_PFX_VECTORMATH_INCLUDE_H - -// If you want to use the free/open sourced vectormath, you need to -// put codes in the include/vecmath folder and set following define. -#define SCE_PFX_USE_FREE_VECTORMATH - -// If you want to use vectomath with SIMD, -// following define is needed. -//#define SCE_PFX_USE_SIMD_VECTORMATH - -// This option enables to replace original implementation with -// vector geometry library. -//#define SCE_PFX_USE_GEOMETRY - -// vectormath include -#ifdef SCE_PFX_USE_FREE_VECTORMATH - // ARA begin insert new code - #if defined(SCE_PFX_USE_SIMD_VECTORMATH) && defined(__ANDROID__) && defined(__ARM_NEON__) - // For Android targets supporting NEON instructions, - // use NEON-optimized vector math library - #include "../../../vecmath/neon/vectormath_aos.h" - #include "../../../vecmath/neon/floatInVec.h" - #else - // ARA end - // use standard free vector math library - #include "../../../vecmath/std/vectormath_aos.h" - #include "../../../vecmath/std/floatInVec.h" - // ARA begin insert new code - #endif - // ARA end - #define SCE_VECTORMATH_AOS_VECTOR_ARG - #define SCE_VECTORMATH_AOS_MATRIX_ARG - - namespace sce { - namespace PhysicsEffects { - typedef Vectormath::Aos::Point3 PfxPoint3; - typedef Vectormath::Aos::Vector3 PfxVector3; - typedef Vectormath::Aos::Vector4 PfxVector4; - typedef Vectormath::Aos::Quat PfxQuat; - typedef Vectormath::Aos::Matrix3 PfxMatrix3; - typedef Vectormath::Aos::Matrix4 PfxMatrix4; - typedef Vectormath::Aos::Transform3 PfxTransform3; - typedef Vectormath::floatInVec PfxFloatInVec; - typedef Vectormath::boolInVec PfxBoolInVec; - } //namespace PhysicsEffects - } //namespace sce -#else - #include - #define SCE_GEOMETRY_USE_SCALAR_MATH - #define SCE_VECTORMATH_AOS_VECTOR_ARG SCE_VECTORMATH_SCALAR_AOS_VECTOR_ARG - #define SCE_VECTORMATH_AOS_MATRIX_ARG SCE_VECTORMATH_SCALAR_AOS_MATRIX_ARG - - namespace sce { - namespace PhysicsEffects { - typedef sce::Vectormath::Scalar::Aos::Point3 PfxPoint3; - typedef sce::Vectormath::Scalar::Aos::Vector3 PfxVector3; - typedef sce::Vectormath::Scalar::Aos::Vector4 PfxVector4; - typedef sce::Vectormath::Scalar::Aos::Quat PfxQuat; - typedef sce::Vectormath::Scalar::Aos::Matrix3 PfxMatrix3; - typedef sce::Vectormath::Scalar::Aos::Matrix4 PfxMatrix4; - typedef sce::Vectormath::Scalar::Aos::Transform3 PfxTransform3; - typedef sce::Vectormath::Scalar::floatInVec PfxFloatInVec; - typedef sce::Vectormath::Scalar::boolInVec PfxBoolInVec; - } //namespace PhysicsEffects - } //namespace sce - - #ifdef SCE_PFX_USE_GEOMETRY - #include - namespace sce { - namespace PhysicsEffects { - typedef sce::Geometry::Aos::Line PfxGeomLine; - typedef sce::Geometry::Aos::Segment PfxGeomSegment; - typedef sce::Geometry::Aos::Plane PfxGeomPlane; - typedef sce::Geometry::Aos::Sphere PfxGeomSphere; - typedef sce::Geometry::Aos::Capsule PfxGeomCapsule; - typedef sce::Geometry::Aos::Bounds PfxGeomBounds; - typedef sce::Geometry::Aos::Aabb PfxGeomAabb; - typedef sce::Geometry::Aos::Obb PfxGeomObb; - } //namespace PhysicsEffects - } //namespace sce - #endif -#endif - -#endif // _SCE_PFX_VECTORMATH_INCLUDE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.win32.h b/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.win32.h deleted file mode 100644 index 4d5673a82..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/base/pfx_vectormath_include.win32.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_VECTORMATH_INCLUDE_WIN32_H -#define _SCE_PFX_VECTORMATH_INCLUDE_WIN32_H - -// If you want to use the free/open sourced vectormath, you need to -// put codes in the include/vecmath folder and set following define. -#define SCE_PFX_USE_FREE_VECTORMATH - -// If you want to use vectomath with SIMD, -// following define is needed. -// #define SCE_PFX_USE_SIMD_VECTORMATH - -// This option enables to replace original implementation with -// vector geometry library. -//#define SCE_PFX_USE_GEOMETRY - -// vectormath include -#ifdef SCE_PFX_USE_FREE_VECTORMATH - #ifdef SCE_PFX_USE_SIMD_VECTORMATH - #include "../../../vecmath/sse/vectormath_aos.h" - #include "../../../vecmath/sse/floatInVec.h" - #define SCE_VECTORMATH_AOS_VECTOR_ARG & - #define SCE_VECTORMATH_AOS_MATRIX_ARG & - #else - #include "../../../vecmath/std/vectormath_aos.h" - #include "../../../vecmath/std/floatInVec.h" - #define SCE_VECTORMATH_AOS_VECTOR_ARG - #define SCE_VECTORMATH_AOS_MATRIX_ARG - #endif - - namespace sce { - namespace PhysicsEffects { - typedef Vectormath::Aos::Point3 PfxPoint3; - typedef Vectormath::Aos::Vector3 PfxVector3; - typedef Vectormath::Aos::Vector4 PfxVector4; - typedef Vectormath::Aos::Quat PfxQuat; - typedef Vectormath::Aos::Matrix3 PfxMatrix3; - typedef Vectormath::Aos::Matrix4 PfxMatrix4; - typedef Vectormath::Aos::Transform3 PfxTransform3; - typedef Vectormath::floatInVec PfxFloatInVec; - typedef Vectormath::boolInVec PfxBoolInVec; - } //namespace PhysicsEffects - } //namespace sce -#else - #include - - #ifdef SCE_PFX_USE_SIMD_VECTORMATH - #define SCE_VECTORMATH_AOS_VECTOR_ARG SCE_VECTORMATH_SIMD_AOS_VECTOR_ARG - #define SCE_VECTORMATH_AOS_MATRIX_ARG SCE_VECTORMATH_SIMD_AOS_MATRIX_ARG - - namespace sce { - namespace PhysicsEffects { - typedef sce::Vectormath::Simd::Aos::Point3 PfxPoint3; - typedef sce::Vectormath::Simd::Aos::Vector3 PfxVector3; - typedef sce::Vectormath::Simd::Aos::Vector4 PfxVector4; - typedef sce::Vectormath::Simd::Aos::Quat PfxQuat; - typedef sce::Vectormath::Simd::Aos::Matrix3 PfxMatrix3; - typedef sce::Vectormath::Simd::Aos::Matrix4 PfxMatrix4; - typedef sce::Vectormath::Simd::Aos::Transform3 PfxTransform3; - typedef sce::Vectormath::Simd::floatInVec PfxFloatInVec; - typedef sce::Vectormath::Simd::boolInVec PfxBoolInVec; - } //namespace PhysicsEffects - } //namespace sce - #else - #define SCE_GEOMETRY_USE_SCALAR_MATH - #define SCE_VECTORMATH_AOS_VECTOR_ARG SCE_VECTORMATH_SCALAR_AOS_VECTOR_ARG - #define SCE_VECTORMATH_AOS_MATRIX_ARG SCE_VECTORMATH_SCALAR_AOS_MATRIX_ARG - - namespace sce { - namespace PhysicsEffects { - typedef sce::Vectormath::Scalar::Aos::Point3 PfxPoint3; - typedef sce::Vectormath::Scalar::Aos::Vector3 PfxVector3; - typedef sce::Vectormath::Scalar::Aos::Vector4 PfxVector4; - typedef sce::Vectormath::Scalar::Aos::Quat PfxQuat; - typedef sce::Vectormath::Scalar::Aos::Matrix3 PfxMatrix3; - typedef sce::Vectormath::Scalar::Aos::Matrix4 PfxMatrix4; - typedef sce::Vectormath::Scalar::Aos::Transform3 PfxTransform3; - typedef sce::Vectormath::Scalar::floatInVec PfxFloatInVec; - typedef sce::Vectormath::Scalar::boolInVec PfxBoolInVec; - } //namespace PhysicsEffects - } //namespace sce - #endif -#endif - -#ifdef SCE_PFX_USE_GEOMETRY -#include -namespace sce { -namespace PhysicsEffects { -typedef sce::Geometry::Aos::Line PfxGeomLine; -typedef sce::Geometry::Aos::Segment PfxGeomSegment; -typedef sce::Geometry::Aos::Plane PfxGeomPlane; -typedef sce::Geometry::Aos::Sphere PfxGeomSphere; -typedef sce::Geometry::Aos::Capsule PfxGeomCapsule; -typedef sce::Geometry::Aos::Bounds PfxGeomBounds; -typedef sce::Geometry::Aos::Aabb PfxGeomAabb; -typedef sce::Geometry::Aos::Obb PfxGeomObb; -} //namespace PhysicsEffects -} //namespace sce -#endif - -#endif // _SCE_PFX_VECTORMATH_INCLUDE_WIN32_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_pair.h b/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_pair.h deleted file mode 100644 index 5fe10d945..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_pair.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_BROADPHASE_PAIR_H -#define _SCE_PFX_BROADPHASE_PAIR_H - -#include "../sort/pfx_sort_data.h" - -namespace sce { -namespace PhysicsEffects { - -typedef PfxSortData16 PfxBroadphasePair; - -SCE_PFX_FORCE_INLINE void pfxSetObjectIdA(PfxBroadphasePair &pair,PfxUInt16 i) {pair.set16(0,i);} -SCE_PFX_FORCE_INLINE void pfxSetObjectIdB(PfxBroadphasePair &pair,PfxUInt16 i) {pair.set16(1,i);} -SCE_PFX_FORCE_INLINE void pfxSetMotionMaskA(PfxBroadphasePair &pair,PfxUInt8 i) {pair.set8(4,i);} -SCE_PFX_FORCE_INLINE void pfxSetMotionMaskB(PfxBroadphasePair &pair,PfxUInt8 i) {pair.set8(5,i);} -SCE_PFX_FORCE_INLINE void pfxSetBroadphaseFlag(PfxBroadphasePair &pair,PfxUInt8 f) {pair.set8(6,(pair.get8(6)&0xf0)|(f&0x0f));} -SCE_PFX_FORCE_INLINE void pfxSetActive(PfxBroadphasePair &pair,PfxBool b) {pair.set8(6,(pair.get8(6)&0x0f)|((b?1:0)<<4));} -SCE_PFX_FORCE_INLINE void pfxSetContactId(PfxBroadphasePair &pair,PfxUInt32 i) {pair.set32(2,i);} - -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetObjectIdA(const PfxBroadphasePair &pair) {return pair.get16(0);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetObjectIdB(const PfxBroadphasePair &pair) {return pair.get16(1);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetMotionMaskA(const PfxBroadphasePair &pair) {return pair.get8(4);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetMotionMaskB(const PfxBroadphasePair &pair) {return pair.get8(5);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetBroadphaseFlag(const PfxBroadphasePair &pair) {return pair.get8(6)&0x0f;} -SCE_PFX_FORCE_INLINE PfxBool pfxGetActive(const PfxBroadphasePair &pair) {return (pair.get8(6)>>4)!=0;} -SCE_PFX_FORCE_INLINE PfxUInt32 pfxGetContactId(const PfxBroadphasePair &pair) {return pair.get32(2);} - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_BROADPHASE_PAIR_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_proxy.h b/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_proxy.h deleted file mode 100644 index a0b062957..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_broadphase_proxy.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_BROADPHASE_PROXY_H -#define _SCE_PFX_BROADPHASE_PROXY_H - -namespace sce { -namespace PhysicsEffects { - -typedef PfxSortData32 PfxBroadphaseProxy; - -//J AABBパラメータã¯PfxAabbã¨å…±é€š -//E PfxBroadphaseProxy shares AABB parameters with PfxAabb32 - -SCE_PFX_FORCE_INLINE void pfxSetObjectId(PfxBroadphaseProxy &proxy,PfxUInt16 i) {proxy.set16(6,i);} -SCE_PFX_FORCE_INLINE void pfxSetMotionMask(PfxBroadphaseProxy &proxy,PfxUInt8 i) {proxy.set8(14,i);} -SCE_PFX_FORCE_INLINE void pfxSetProxyFlag(PfxBroadphaseProxy &proxy,PfxUInt8 i) {proxy.set8(15,i);} -SCE_PFX_FORCE_INLINE void pfxSetSelf(PfxBroadphaseProxy &proxy,PfxUInt32 i) {proxy.set32(5,i);} -SCE_PFX_FORCE_INLINE void pfxSetTarget(PfxBroadphaseProxy &proxy,PfxUInt32 i) {proxy.set32(6,i);} - -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetObjectId(const PfxBroadphaseProxy &proxy) {return proxy.get16(6);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetMotionMask(const PfxBroadphaseProxy &proxy) {return proxy.get8(14);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetProxyFlag(const PfxBroadphaseProxy &proxy) {return proxy.get8(15);} -SCE_PFX_FORCE_INLINE PfxUInt32 pfxGetSelf(const PfxBroadphaseProxy &proxy) {return proxy.get32(5);} -SCE_PFX_FORCE_INLINE PfxUInt32 pfxGetTarget(const PfxBroadphaseProxy &proxy) {return proxy.get32(6);} - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_BROADPHASE_PROXY_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_update_broadphase_proxy.h b/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_update_broadphase_proxy.h deleted file mode 100644 index 941d595cc..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/broadphase/pfx_update_broadphase_proxy.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_UPDATE_BROADPHASE_PROXY_H -#define _SCE_PFX_UPDATE_BROADPHASE_PROXY_H - -#include "pfx_broadphase_pair.h" -#include "pfx_broadphase_proxy.h" -#include "../rigidbody/pfx_rigid_state.h" -#include "../collision/pfx_collidable.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Update Broadphase Proxy - -//E For single axis -//J å˜ä¸€è»¸ã«å¯¾ã—ã¦ä½œæˆ -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxy, - const PfxRigidState &state, - const PfxCollidable &coll, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent, - PfxUInt32 axis); - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxy, - const PfxRigidState &state, - const PfxVector3 &objectCenter, - const PfxVector3 &objectHalf, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent, - PfxUInt32 axis); - -//E For all axes -//J 全軸ã«å¯¾ã—ã¦ä½œæˆ -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxyX, - PfxBroadphaseProxy &proxyY, - PfxBroadphaseProxy &proxyZ, - PfxBroadphaseProxy &proxyXb, - PfxBroadphaseProxy &proxyYb, - PfxBroadphaseProxy &proxyZb, - const PfxRigidState &state, - const PfxCollidable &coll, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent); - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxyX, - PfxBroadphaseProxy &proxyY, - PfxBroadphaseProxy &proxyZ, - PfxBroadphaseProxy &proxyXb, - PfxBroadphaseProxy &proxyYb, - PfxBroadphaseProxy &proxyZb, - const PfxRigidState &state, - const PfxVector3 &objectCenter, - const PfxVector3 &objectHalf, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent); - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_UPDATE_BROADPHASE_PROXY_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_aabb.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_aabb.h deleted file mode 100644 index dc238eb7e..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_aabb.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_AABB_H -#define _SCE_PFX_AABB_H - -#include "../sort/pfx_sort_data.h" - -namespace sce { -namespace PhysicsEffects { - -typedef PfxSortData16 PfxAabb16; -typedef PfxSortData32 PfxAabb32; - -SCE_PFX_FORCE_INLINE void pfxSetXMin(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(0,i);} -SCE_PFX_FORCE_INLINE void pfxSetXMax(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(1,i);} -SCE_PFX_FORCE_INLINE void pfxSetYMin(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(2,i);} -SCE_PFX_FORCE_INLINE void pfxSetYMax(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(3,i);} -SCE_PFX_FORCE_INLINE void pfxSetZMin(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(4,i);} -SCE_PFX_FORCE_INLINE void pfxSetZMax(PfxAabb16& aabb,PfxUInt16 i) {aabb.set16(5,i);} -SCE_PFX_FORCE_INLINE void pfxSetXYZMin(PfxAabb16 &aabb,PfxUInt16 i,int axis) {aabb.set16(axis<<1,i);} -SCE_PFX_FORCE_INLINE void pfxSetXYZMax(PfxAabb16 &aabb,PfxUInt16 i,int axis) {aabb.set16((axis<<1)+1,i);} - -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXMin(const PfxAabb16& aabb) {return aabb.get16(0);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXMax(const PfxAabb16& aabb) {return aabb.get16(1);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetYMin(const PfxAabb16& aabb) {return aabb.get16(2);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetYMax(const PfxAabb16& aabb) {return aabb.get16(3);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetZMin(const PfxAabb16& aabb) {return aabb.get16(4);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetZMax(const PfxAabb16& aabb) {return aabb.get16(5);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXYZMin(const PfxAabb16 &aabb,int axis) {return aabb.get16(axis<<1);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXYZMax(const PfxAabb16 &aabb,int axis) {return aabb.get16((axis<<1)+1);} - -SCE_PFX_FORCE_INLINE void pfxSetXMin(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(0,i);} -SCE_PFX_FORCE_INLINE void pfxSetXMax(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(1,i);} -SCE_PFX_FORCE_INLINE void pfxSetYMin(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(2,i);} -SCE_PFX_FORCE_INLINE void pfxSetYMax(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(3,i);} -SCE_PFX_FORCE_INLINE void pfxSetZMin(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(4,i);} -SCE_PFX_FORCE_INLINE void pfxSetZMax(PfxAabb32& aabb,PfxUInt16 i) {aabb.set16(5,i);} -SCE_PFX_FORCE_INLINE void pfxSetXYZMin(PfxAabb32 &aabb,PfxUInt16 i,int axis) {aabb.set16(axis<<1,i);} -SCE_PFX_FORCE_INLINE void pfxSetXYZMax(PfxAabb32 &aabb,PfxUInt16 i,int axis) {aabb.set16((axis<<1)+1,i);} - -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXMin(const PfxAabb32& aabb) {return aabb.get16(0);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXMax(const PfxAabb32& aabb) {return aabb.get16(1);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetYMin(const PfxAabb32& aabb) {return aabb.get16(2);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetYMax(const PfxAabb32& aabb) {return aabb.get16(3);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetZMin(const PfxAabb32& aabb) {return aabb.get16(4);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetZMax(const PfxAabb32& aabb) {return aabb.get16(5);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXYZMin(const PfxAabb32 &aabb,int axis) {return aabb.get16(axis<<1);} -SCE_PFX_FORCE_INLINE PfxUInt16 pfxGetXYZMax(const PfxAabb32 &aabb,int axis) {return aabb.get16((axis<<1)+1);} - - -#define SCE_PFX_TEST_AABB(aabbA,aabbB) \ -if(pfxGetXMax(aabbA) < pfxGetXMin(aabbB) || pfxGetXMin(aabbA) > pfxGetXMax(aabbB)) return false;\ -if(pfxGetYMax(aabbA) < pfxGetYMin(aabbB) || pfxGetYMin(aabbA) > pfxGetYMax(aabbB)) return false;\ -if(pfxGetZMax(aabbA) < pfxGetZMin(aabbB) || pfxGetZMin(aabbA) > pfxGetZMax(aabbB)) return false;\ -return true; - -SCE_PFX_FORCE_INLINE -bool pfxTestAabb(const PfxAabb16 &aabbA,const PfxAabb16 &aabbB) -{ -SCE_PFX_TEST_AABB(aabbA,aabbB) -} - -SCE_PFX_FORCE_INLINE -bool pfxTestAabb(const PfxAabb32 &aabbA,const PfxAabb32 &aabbB) -{ -SCE_PFX_TEST_AABB(aabbA,aabbB) -} - -SCE_PFX_FORCE_INLINE -bool pfxTestAabb(const PfxAabb32 &aabbA,const PfxAabb16 &aabbB) -{ -SCE_PFX_TEST_AABB(aabbA,aabbB) -} - -SCE_PFX_FORCE_INLINE -bool pfxTestAabb(const PfxAabb16 &aabbA,const PfxAabb32 &aabbB) -{ -SCE_PFX_TEST_AABB(aabbA,aabbB) -} - - -SCE_PFX_FORCE_INLINE -PfxAabb16 pfxMergeAabb(const PfxAabb16 &aabbA,const PfxAabb16 &aabbB) -{ - PfxAabb16 aabb = aabbA; - pfxSetXMin(aabb,SCE_PFX_MIN(pfxGetXMin(aabbA),pfxGetXMin(aabbB))); - pfxSetXMax(aabb,SCE_PFX_MAX(pfxGetXMax(aabbA),pfxGetXMax(aabbB))); - pfxSetYMin(aabb,SCE_PFX_MIN(pfxGetYMin(aabbA),pfxGetYMin(aabbB))); - pfxSetYMax(aabb,SCE_PFX_MAX(pfxGetYMax(aabbA),pfxGetYMax(aabbB))); - pfxSetZMin(aabb,SCE_PFX_MIN(pfxGetZMin(aabbA),pfxGetZMin(aabbB))); - pfxSetZMax(aabb,SCE_PFX_MAX(pfxGetZMax(aabbA),pfxGetZMax(aabbB))); - return aabb; -} - -SCE_PFX_FORCE_INLINE -PfxAabb32 pfxMergeAabb(const PfxAabb32 &aabbA,const PfxAabb32 &aabbB) -{ - PfxAabb32 aabb = aabbA; - pfxSetXMin(aabb,SCE_PFX_MIN(pfxGetXMin(aabbA),pfxGetXMin(aabbB))); - pfxSetXMax(aabb,SCE_PFX_MAX(pfxGetXMax(aabbA),pfxGetXMax(aabbB))); - pfxSetYMin(aabb,SCE_PFX_MIN(pfxGetYMin(aabbA),pfxGetYMin(aabbB))); - pfxSetYMax(aabb,SCE_PFX_MAX(pfxGetYMax(aabbA),pfxGetYMax(aabbB))); - pfxSetZMin(aabb,SCE_PFX_MIN(pfxGetZMin(aabbA),pfxGetZMin(aabbB))); - pfxSetZMax(aabb,SCE_PFX_MAX(pfxGetZMax(aabbA),pfxGetZMax(aabbB))); - return aabb; -} -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_AABB_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_box.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_box.h deleted file mode 100644 index 4de797686..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_box.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_BOX_H -#define _SCE_PFX_BOX_H - -#include "../base/pfx_common.h" - -namespace sce{ -namespace PhysicsEffects{ -struct PfxBox { - PfxVector3 m_half; - - inline PfxBox() {} - inline PfxBox(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG half); - inline PfxBox(PfxFloat hx, PfxFloat hy, PfxFloat hz); - - inline void set(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG half); - inline void set(PfxFloat hx, PfxFloat hy, PfxFloat hz); -}; - -inline -PfxBox::PfxBox(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG half) -{ - set(half); -} - -inline -PfxBox::PfxBox(PfxFloat hx, PfxFloat hy, PfxFloat hz) -{ - set(hx, hy, hz); -} - -inline -void PfxBox::set(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG half) -{ - m_half = half; -} - -inline -void PfxBox::set(PfxFloat hx, PfxFloat hy, PfxFloat hz) -{ - m_half = PfxVector3(hx, hy, hz); -} -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_BOX_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_capsule.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_capsule.h deleted file mode 100644 index a1c1af574..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_capsule.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CAPSULE_H -#define _SCE_PFX_CAPSULE_H - -#include "../base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxCapsule -{ - PfxFloat m_halfLen; - PfxFloat m_radius; - - PfxCapsule() {} - PfxCapsule(PfxFloat halfLength, PfxFloat radius); - - void set(PfxFloat halfLength, PfxFloat radius); -}; - -inline -PfxCapsule::PfxCapsule(PfxFloat halfLength, PfxFloat radius) -{ - m_halfLen = halfLength; - m_radius = radius; -} - -inline -void PfxCapsule::set(PfxFloat halfLength, PfxFloat radius) -{ - m_halfLen = halfLength; - m_radius = radius; -} - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_CAPSULE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable.h deleted file mode 100644 index 7f65eeb32..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_COLLIDABLE_H -#define _SCE_PFX_COLLIDABLE_H - -#include "pfx_shape.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_NUMPRIMS 64 - -/////////////////////////////////////////////////////////////////////////////// -// Collidable Object - -class SCE_PFX_ALIGNED(128) PfxCollidable -{ -friend class PfxShapeIterator; - -private: - PfxShape *m_shapeBase; - PfxUInt16 m_shapeIds[SCE_PFX_NUMPRIMS]; - PfxUInt8 m_numShapes; - PfxUInt8 m_maxShapes; - SCE_PFX_PADDING(1,2) - PfxFloat m_center[3]; // AABB center (Local) - PfxFloat m_half[3]; // AABB half (Local) - PfxShape m_defShape; - SCE_PFX_PADDING(2,32) - - inline PfxShape &getNewShape(); - -public: - inline void reset(); - inline void reset(PfxShape *base,PfxUInt16 *ids,int n=1); - - void finish(); - - void addShape(const PfxShape &shape); - - inline PfxUInt32 getNumShapes() const; - const PfxShape& getDefShape() const {return m_defShape;} - PfxShape& getDefShape() {return m_defShape;} - - inline PfxUInt16 getShapeId(int i) const; - - inline const PfxShape& getShape(int i) const; - inline PfxShape& getShape(int i); - - inline PfxVector3 getHalf() const; - inline PfxVector3 getCenter() const; -}; - -#include "pfx_collidable_implementation.h" - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_COLLIDABLE_H - diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable_implementation.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable_implementation.h deleted file mode 100644 index 0e434f6dd..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_collidable_implementation.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_COLLIDABLE_IMPLEMENTATION_H -#define _SCE_PFX_COLLIDABLE_IMPLEMENTATION_H - -inline -void PfxCollidable::reset() -{ - m_shapeBase = NULL; - m_numShapes = 0; - m_maxShapes = 1; - m_center[0] = 0.0f; - m_center[1] = 0.0f; - m_center[2] = 0.0f; - m_half[0] = 0.0f; - m_half[1] = 0.0f; - m_half[2] = 0.0f; -} - -inline -void PfxCollidable::reset(PfxShape *base,PfxUInt16 *ids,int n) -{ - m_shapeBase = base; - m_numShapes = 0; - m_maxShapes = n; - for(int i=0;i0); - return m_shapeIds[i-1]; -} - -inline -const PfxShape& PfxCollidable::getShape(int i) const -{ - SCE_PFX_ASSERT(i0) { - return m_shapeBase[m_shapeIds[i-1]]; - } - else { - return m_defShape; - } -} - -inline -PfxShape& PfxCollidable::getShape(int i) -{ - SCE_PFX_ASSERT(i0) { - return m_shapeBase[m_shapeIds[i-1]]; - } - else { - return m_defShape; - } -} - -inline -PfxShape &PfxCollidable::getNewShape() -{ - SCE_PFX_ASSERT(m_numShapes<=m_maxShapes); - if(m_numShapes == 0) { - m_numShapes++; - return m_defShape; - } - else { - m_numShapes++; - return m_shapeBase[m_shapeIds[m_numShapes-2]]; - } -} - -inline -PfxVector3 PfxCollidable::getHalf() const -{ - return pfxReadVector3(m_half); -} - -inline -PfxVector3 PfxCollidable::getCenter() const -{ - return pfxReadVector3(m_center); -} - -#endif // _SCE_PFX_COLLIDABLE_IMPLEMENTATION_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_contact_manifold.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_contact_manifold.h deleted file mode 100644 index f257974a4..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_contact_manifold.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_MANIFOLD_H -#define _SCE_PFX_CONTACT_MANIFOLD_H - -#include "../base/pfx_common.h" -#include "../base/pfx_vec_utils.h" -#include "pfx_sub_data.h" -#include "../solver/pfx_constraint_row.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_NUMCONTACTS_PER_BODIES 4 - -/////////////////////////////////////////////////////////////////////////////// -// Contact Point - -struct PfxContactPoint -{ - PfxUInt8 m_duration; - PfxUInt8 m_shapeIdA; - PfxUInt8 m_shapeIdB; - SCE_PFX_PADDING(1,1) - PfxSubData m_subData; - PfxFloat m_distance; - PfxFloat m_localPointA[3]; - PfxFloat m_localPointB[3]; - SCE_PFX_PADDING(2,8) - PfxConstraintRow m_constraintRow[3]; - - void reset() - { - m_duration = 0; - m_shapeIdA = m_shapeIdB = 0; - m_subData = PfxSubData(); - m_distance = SCE_PFX_FLT_MAX; - m_constraintRow[0].m_accumImpulse = 0.0f; - m_constraintRow[1].m_accumImpulse = 0.0f; - m_constraintRow[2].m_accumImpulse = 0.0f; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// Contact Manifold - -//J åŒä¸€ãƒšã‚¢ã®è¡çªãŒç¶šãé™ã‚Šä¿æŒã•れるコンタクト情報 -//E PfxContactManifold keeps contact information until two rigid bodies are separated. - -class SCE_PFX_ALIGNED(128) PfxContactManifold -{ -private: - PfxUInt16 m_rigidBodyIdA,m_rigidBodyIdB; - PfxUInt16 m_duration; - PfxUInt16 m_numContacts; - PfxFloat m_compositeFriction; - PfxUInt32 m_internalFlag; - PfxContactPoint m_contactPoints[SCE_PFX_NUMCONTACTS_PER_BODIES]; - void *m_userData; - PfxUInt32 m_userParam[4]; - SCE_PFX_PADDING(1,28) - - int findNearestContactPoint(const PfxPoint3 &newPoint,const PfxVector3 &newNormal); - int sort4ContactPoints(const PfxPoint3 &newPoint,PfxFloat newDistance); - -public: - // Internal method - PfxFloat getCompositeFriction() const {return m_compositeFriction;} - void setCompositeFriction(PfxFloat f) {m_compositeFriction = f;} - - PfxUInt32 getInternalFlag() const {return m_internalFlag;} - void setInternalFlag(PfxUInt32 f) {m_internalFlag = f;} - -public: - void reset(PfxUInt16 rigidBodyIdA,PfxUInt16 rigidBodyIdB) - { - m_userData = 0; - m_userParam[0] = m_userParam[1] = m_userParam[2] = m_userParam[3] = 0; - m_numContacts = 0; - m_duration = 0; - m_rigidBodyIdA = rigidBodyIdA; - m_rigidBodyIdB = rigidBodyIdB; - } - - void addContactPoint( - PfxFloat newDistance, - const PfxVector3 &newNormal, // world coords - const PfxPoint3 &newPointA, // local coords to the objectA - const PfxPoint3 &newPointB, // local coords to the objectB - PfxSubData subData); - - void addContactPoint(const PfxContactPoint &cp); - - void removeContactPoint(int i) - { - SCE_PFX_ASSERT(i>=0&&i pfxGetXMax(m_aabbList[islandId])) return false; - if(aabbMaxL.getY() < pfxGetYMin(m_aabbList[islandId]) || aabbMinL.getY() > pfxGetYMax(m_aabbList[islandId])) return false; - if(aabbMaxL.getZ() < pfxGetZMin(m_aabbList[islandId]) || aabbMinL.getZ() > pfxGetZMax(m_aabbList[islandId])) return false; - - return true; -} - -inline -PfxVecInt3 PfxLargeTriMesh::getLocalPosition(const PfxVector3 &worldPosition) const -{ - const PfxVector3 sz(65535.0f); - PfxVector3 tmp = divPerElem(worldPosition+m_half,2.0f*m_half); - tmp = mulPerElem(sz,minPerElem(maxPerElem(tmp,PfxVector3(0.0f)),PfxVector3(1.0f))); // clamp 0.0 - 1.0 - return PfxVecInt3(tmp); -} - -inline -void PfxLargeTriMesh::getLocalPosition( - const PfxVector3 &worldMinPosition,const PfxVector3 &worldMaxPosition, - PfxVecInt3 &localMinPosition,PfxVecInt3 &localMaxPosition) const -{ - const PfxVector3 sz(65535.0f); - PfxVector3 qmin = divPerElem(worldMinPosition+m_half,2.0f*m_half); - qmin = mulPerElem(sz,minPerElem(maxPerElem(qmin,PfxVector3(0.0f)),PfxVector3(1.0f))); // clamp 0.0 - 1.0 - - PfxVector3 qmax = divPerElem(worldMaxPosition+m_half,2.0f*m_half); - qmax = mulPerElem(sz,minPerElem(maxPerElem(qmax,PfxVector3(0.0f)),PfxVector3(1.0f))); // clamp 0.0 - 1.0 - -localMinPosition = PfxVecInt3(floorf(qmin[0]),floorf(qmin[1]),floorf(qmin[2])); -localMaxPosition = PfxVecInt3(ceilf(qmax[0]),ceilf(qmax[1]),ceilf(qmax[2])); -} - -inline -PfxVector3 PfxLargeTriMesh::getWorldPosition(const PfxVecInt3 &localPosition) const -{ - PfxVector3 sz(65535.0f),lp(localPosition); - PfxVector3 tmp = divPerElem(lp,sz); - return mulPerElem(tmp,2.0f*m_half) - m_half; -} - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_LARGE_TRI_MESH_H \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_ray.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_ray.h deleted file mode 100644 index 92fc3f258..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_ray.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_RAY_H -#define _SCE_PFX_RAY_H - -#include "../base/pfx_common.h" -#include "pfx_sub_data.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_RAY_FACET_MODE_FRONT_ONLY 0 -#define SCE_PFX_RAY_FACET_MODE_BACK_ONLY 1 -#define SCE_PFX_RAY_FACET_MODE_FRONT_AND_BACK 2 - -struct SCE_PFX_ALIGNED(16) PfxRayInput -{ - PfxVector3 m_startPosition; - PfxVector3 m_direction; - PfxUInt32 m_contactFilterSelf; - PfxUInt32 m_contactFilterTarget; - PfxUInt8 m_facetMode; - SCE_PFX_PADDING(1,7) - - void reset() - { - m_contactFilterSelf = m_contactFilterTarget = 0xffffffff; - m_facetMode = SCE_PFX_RAY_FACET_MODE_FRONT_ONLY; - } -}; - -struct SCE_PFX_ALIGNED(16) PfxRayOutput -{ - PfxVector3 m_contactPoint; - PfxVector3 m_contactNormal; - PfxFloat m_variable; - PfxUInt16 m_objectId; - PfxUInt8 m_shapeId; - PfxBool m_contactFlag : 1; - PfxSubData m_subData; -}; -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_RAY_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape.h deleted file mode 100644 index b4f9c2a0d..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SHAPE_H -#define _SCE_PFX_SHAPE_H - -#include "../base/pfx_common.h" -#include "../base/pfx_vec_utils.h" -#include "pfx_box.h" -#include "pfx_sphere.h" -#include "pfx_capsule.h" -#include "pfx_cylinder.h" -#include "pfx_tri_mesh.h" -#include "pfx_large_tri_mesh.h" - -namespace sce { -namespace PhysicsEffects { - -enum ePfxShapeType -{ - kPfxShapeSphere = 0, - kPfxShapeBox, - kPfxShapeCapsule, - kPfxShapeCylinder, - kPfxShapeConvexMesh, - kPfxShapeLargeTriMesh, - kPfxShapeReserved0, - kPfxShapeReserved1, - kPfxShapeReserved2, - kPfxShapeUser0, - kPfxShapeUser1, - kPfxShapeUser2, - kPfxShapeCount // =12 -}; - -class SCE_PFX_ALIGNED(16) PfxShape -{ -friend class PfxCollidable; - -private: - union { - PfxFloat m_vecDataF[3]; - PfxUInt32 m_vecDataI[3]; - void *m_vecDataPtr[2]; - }; - PfxUInt8 m_type; - SCE_PFX_PADDING(1,3) - PfxFloat m_offsetPosition[3]; - PfxFloat m_offsetOrientation[4]; - PfxUInt32 m_contactFilterSelf; - PfxUInt32 m_contactFilterTarget; - SCE_PFX_PADDING(2,12) - -public: - inline void reset(); - - // Shape - inline void setBox(PfxBox SCE_VECTORMATH_AOS_VECTOR_ARG box); - inline void setCapsule(PfxCapsule capsule); - inline void setCylinder(PfxCylinder cylinder); - inline void setSphere(PfxSphere sphere); - inline void setConvexMesh(const PfxConvexMesh *convexMesh); - inline void setLargeTriMesh(const PfxLargeTriMesh *largeMesh); - - inline PfxUInt8 getType() const; - inline PfxBox getBox()const ; - inline PfxCapsule getCapsule() const; - inline PfxCylinder getCylinder() const; - inline PfxSphere getSphere() const; - inline const PfxConvexMesh* getConvexMesh() const; - inline const PfxLargeTriMesh* getLargeTriMesh() const; - - // Offset - inline void setOffsetTransform(const PfxTransform3 & xfrm); - inline void setOffsetOrientation(const PfxQuat SCE_VECTORMATH_AOS_VECTOR_ARG rot) {return pfxStoreQuat(rot,m_offsetOrientation);} - inline void setOffsetPosition(const PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG pos) {return pfxStoreVector3(pos,m_offsetPosition);} - - inline PfxTransform3 getOffsetTransform() const; - inline PfxVector3 getOffsetPosition() const {return pfxReadVector3(m_offsetPosition);} - inline PfxQuat getOffsetOrientation() const {return pfxReadQuat(m_offsetOrientation);} - - // Raw data access - inline void setDataFloat(int i,PfxFloat v) {m_vecDataF[i]=v;} - inline void setDataInteger(int i,PfxUInt32 v) {m_vecDataI[i]=v;} - - inline PfxFloat getDataFloat(int i) const {return m_vecDataF[i];} - inline PfxUInt32 getDataInteger(int i) const {return m_vecDataI[i];} - - // Contact Filter - PfxUInt32 getContactFilterSelf() const {return m_contactFilterSelf;} - void setContactFilterSelf(PfxUInt32 filter) {m_contactFilterSelf = filter;} - - PfxUInt32 getContactFilterTarget() const {return m_contactFilterTarget;} - void setContactFilterTarget(PfxUInt32 filter) {m_contactFilterTarget = filter;} - - // Bouding Volume - void getAabb(PfxVector3 &aabbMin,PfxVector3 &aabbMax) const; -}; - -#include "pfx_shape_implementation.h" - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_SHAPE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_implementation.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_implementation.h deleted file mode 100644 index 8996141c3..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_implementation.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SHAPE_IMPLEMENTATION_H -#define _SCE_PFX_SHAPE_IMPLEMENTATION_H - -inline -void PfxShape::reset() -{ - m_type = kPfxShapeSphere; - m_offsetPosition[0] = m_offsetPosition[1] = m_offsetPosition[2]= 0.0f; - m_offsetOrientation[0] = m_offsetOrientation[1] = m_offsetOrientation[2]= 0.0f; - m_offsetOrientation[3] = 1.0f; - m_contactFilterSelf = m_contactFilterTarget = 0xffffffff; -} - -inline -void PfxShape::setBox(PfxBox SCE_VECTORMATH_AOS_VECTOR_ARG box) -{ - m_vecDataF[0] = box.m_half[0]; - m_vecDataF[1] = box.m_half[1]; - m_vecDataF[2] = box.m_half[2]; - m_type = kPfxShapeBox; -} - -inline -void PfxShape::setCapsule(PfxCapsule capsule) -{ - m_vecDataF[0] = capsule.m_halfLen; - m_vecDataF[1] = capsule.m_radius; - m_vecDataF[2] = 0.0f; - m_type = kPfxShapeCapsule; -} - -inline -void PfxShape::setCylinder(PfxCylinder cylinder) -{ - m_vecDataF[0] = cylinder.m_halfLen; - m_vecDataF[1] = cylinder.m_radius; - m_vecDataF[2] = 0.0f; - m_type = kPfxShapeCylinder; -} - -inline -void PfxShape::setSphere(PfxSphere sphere) -{ - m_vecDataF[0] = sphere.m_radius; - m_vecDataF[1] = 0.0f; - m_vecDataF[2] = 0.0f; - m_type = kPfxShapeSphere; -} - -inline -void PfxShape::setConvexMesh(const PfxConvexMesh *convexMesh) -{ - m_vecDataPtr[0] = (void*)convexMesh; - m_vecDataPtr[1] = NULL; - m_type = kPfxShapeConvexMesh; -} - -inline -void PfxShape::setLargeTriMesh(const PfxLargeTriMesh *largeMesh) -{ - m_vecDataPtr[0] = (void*)largeMesh; - m_vecDataPtr[1] = NULL; - m_type = kPfxShapeLargeTriMesh; -} - -inline -void PfxShape::setOffsetTransform(const PfxTransform3 & xfrm) -{ - setOffsetOrientation(PfxQuat(xfrm.getUpper3x3())); - setOffsetPosition(xfrm.getTranslation()); -} - -inline -PfxUInt8 PfxShape::getType() const -{ - return m_type; -} - -inline -PfxBox PfxShape::getBox() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeBox); - return PfxBox(m_vecDataF[0],m_vecDataF[1],m_vecDataF[2]); -} - -inline -PfxCapsule PfxShape::getCapsule() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeCapsule); - return PfxCapsule(m_vecDataF[0], m_vecDataF[1]); -} - -inline -PfxCylinder PfxShape::getCylinder() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeCylinder); - return PfxCylinder(m_vecDataF[0], m_vecDataF[1]); -} - -inline -PfxSphere PfxShape::getSphere() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeSphere); - return PfxSphere(m_vecDataF[0]); -} - -inline -const PfxConvexMesh *PfxShape::getConvexMesh() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeConvexMesh); - SCE_PFX_ALWAYS_ASSERT(m_vecDataPtr[0]!=NULL); - return (PfxConvexMesh*)m_vecDataPtr[0]; -} - -inline -const PfxLargeTriMesh *PfxShape::getLargeTriMesh() const -{ - SCE_PFX_ALWAYS_ASSERT(m_type==kPfxShapeLargeTriMesh); - SCE_PFX_ALWAYS_ASSERT(m_vecDataPtr[0]!=NULL); - return (PfxLargeTriMesh*)m_vecDataPtr[0]; -} - -inline -PfxTransform3 PfxShape::getOffsetTransform() const -{ - return PfxTransform3(getOffsetOrientation(),getOffsetPosition()); -} - -#endif // _SCE_PFX_SHAPE_IMPLEMENTATION_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_iterator.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_iterator.h deleted file mode 100644 index 7a0a3005c..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_shape_iterator.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SHAPE_ITERATOR_H -#define _SCE_PFX_SHAPE_ITERATOR_H - -#include "pfx_collidable.h" - - -namespace sce { -namespace PhysicsEffects { - -class PfxShapeIterator -{ -private: -PfxUInt32 m_numShapes; -PfxShape *m_shapeBase; -const PfxUInt16 *m_shapeIds; -const PfxShape *m_curShape; -PfxUInt32 m_index; - -public: -PfxShapeIterator(const PfxCollidable &coll) : m_shapeIds(coll.m_shapeIds) -{ - m_numShapes = coll.m_numShapes; - m_shapeBase = coll.m_shapeBase; - m_index = 0; - m_curShape = &coll.m_defShape; -} - -~PfxShapeIterator() {} - -inline PfxShapeIterator& operator++() -{ - m_curShape = &m_shapeBase[m_shapeIds[m_index++]]; - return *this; -} - -const PfxShape& operator*() const {return *m_curShape;} -}; - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_SHAPE_ITERATOR_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sphere.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sphere.h deleted file mode 100644 index 477d7f9c8..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sphere.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SPHERE_H -#define _SCE_PFX_SPHERE_H - -#include "../base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxSphere { - PfxFloat m_radius; - - PfxSphere() {} - PfxSphere( PfxFloat radius ); - - void set( PfxFloat radius ); -}; - -inline -PfxSphere::PfxSphere( PfxFloat radius ) -{ - m_radius = radius; -} - -inline -void PfxSphere::set( PfxFloat radius ) -{ - m_radius = radius; -} - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_SPHERE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sub_data.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sub_data.h deleted file mode 100644 index 82f5c0cc9..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_sub_data.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SUB_DATA_H -#define _SCE_PFX_SUB_DATA_H - -namespace sce { -namespace PhysicsEffects { - -struct PfxSubData { - enum { - NONE = 0, - MESH_INFO - }; - - union { - struct { - PfxUInt8 m_type; - SCE_PFX_PADDING(1,1) - - struct { - PfxUInt8 islandId; - PfxUInt8 facetId; - PfxUInt16 s; - PfxUInt16 t; - - } m_facetLocal; - }; - PfxUInt32 param[2]; - }; - - PfxSubData() - { - param[0] = param[1] = 0; - } - - void setIslandId(PfxUInt8 i) {m_facetLocal.islandId = i;} - void setFacetId(PfxUInt8 i) {m_facetLocal.facetId = i;} - void setFacetLocalS(PfxFloat s) {m_facetLocal.s = (PfxUInt16)(s * 65535.0f);} - void setFacetLocalT(PfxFloat t) {m_facetLocal.t = (PfxUInt16)(t * 65535.0f);} - - PfxUInt8 getIslandId() {return m_facetLocal.islandId;} - PfxUInt8 getFacetId() {return m_facetLocal.facetId;} - PfxFloat getFacetLocalS() {return m_facetLocal.s / 65535.0f;} - PfxFloat getFacetLocalT() {return m_facetLocal.t / 65535.0f;} -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_SUB_DATA_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_tri_mesh.h b/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_tri_mesh.h deleted file mode 100644 index 2370afe02..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/collision/pfx_tri_mesh.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_TRI_MESH_H -#define _SCE_PFX_TRI_MESH_H - -#include "../base/pfx_common.h" -#include "../base/pfx_vec_utils.h" -#include "pfx_aabb.h" - -namespace sce { -namespace PhysicsEffects { - -//J メッシュã®ãƒªã‚½ãƒ¼ã‚¹åˆ¶é™ -//E Define some limitations of a triangle mesh -#define SCE_PFX_NUMMESHFACETS 64 -#define SCE_PFX_NUMMESHEDGES 192 -#define SCE_PFX_NUMMESHVERTICES 128 - -//J エッジã®è§’ -//E Edge types -#define SCE_PFX_EDGE_FLAT 0 -#define SCE_PFX_EDGE_CONVEX 1 -#define SCE_PFX_EDGE_CONCAVE 2 - -/////////////////////////////////////////////////////////////////////////////// -// Edge -struct PfxEdge -{ - PfxUInt8 m_vertId[2]; - PfxUInt8 m_angleType; - PfxUInt8 m_tilt; -}; - -inline -bool operator ==(const PfxEdge &e1,const PfxEdge &e2) -{ - return (e1.m_vertId[0] == e2.m_vertId[0] && e1.m_vertId[1] == e2.m_vertId[1]) || - (e1.m_vertId[1] == e2.m_vertId[0] && e1.m_vertId[0] == e2.m_vertId[1]); -} - -/////////////////////////////////////////////////////////////////////////////// -// Facet - -struct PfxFacet -{ - PfxFloat m_normal[3]; - PfxFloat m_thickness; - PfxUInt8 m_group; - PfxUInt8 m_vertIds[3]; - PfxUInt8 m_edgeIds[3]; - PfxUInt8 m_userData; - PfxFloat m_half[3]; - PfxFloat m_center[3]; -}; - -/////////////////////////////////////////////////////////////////////////////// -// Mesh - -struct SCE_PFX_ALIGNED(16) PfxTriMesh -{ - PfxUInt8 m_numVerts; - PfxUInt8 m_numEdges; - PfxUInt8 m_numFacets; - PfxUInt8 m_reserved; - PfxFacet m_facets[SCE_PFX_NUMMESHFACETS]; - PfxEdge m_edges[SCE_PFX_NUMMESHEDGES]; - SCE_PFX_PADDING(1,12) - PfxVector3 m_verts[SCE_PFX_NUMMESHVERTICES]; - PfxVector3 m_half; - - PfxTriMesh() - { - m_numVerts = m_numEdges = m_numFacets = 0; - } - - inline void updateAABB(); -}; - -inline -void PfxTriMesh::updateAABB() -{ - PfxVector3 halfMax(0); - - for(PfxUInt8 i=0;i0.0f?1.0f/mass:0.0f;} - - const PfxMatrix3& getInertia() const {return m_inertia;} - void setInertia(const PfxMatrix3 SCE_VECTORMATH_AOS_MATRIX_ARG inertia) {m_inertia = inertia;m_inertiaInv = inverse(inertia);} - - PfxFloat getRestitution() const {return m_restitution;} - void setRestitution(PfxFloat restitution) {m_restitution = restitution;} - - PfxFloat getFriction() const {return m_friction;} - void setFriction(PfxFloat friction) {m_friction = friction;} -}; - -inline -void PfxRigidBody::reset() -{ - m_mass = 0.0f; - m_restitution = 0.2f; - m_friction = 0.6f; -} - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_RIGID_BODY_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/rigidbody/pfx_rigid_state.h b/Extras/PhysicsEffects/include/physics_effects/base_level/rigidbody/pfx_rigid_state.h deleted file mode 100644 index 356b67ed5..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/rigidbody/pfx_rigid_state.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_RIGID_STATE_H -#define _SCE_PFX_RIGID_STATE_H - -#include "../base/pfx_common.h" -#include "../base/pfx_vec_utils.h" - -namespace sce { -namespace PhysicsEffects { - -// Motion Type -enum ePfxMotionType { - kPfxMotionTypeFixed = 0, - kPfxMotionTypeActive, - kPfxMotionTypeKeyframe, - kPfxMotionTypeOneWay, - kPfxMotionTypeTrigger, - kPfxMotionTypeCount -}; - -#define SCE_PFX_MOTION_MASK_DYNAMIC(motion) ((1<<(motion))&0x0a) // Active,OneWay -#define SCE_PFX_MOTION_MASK_STATIC(motion) ((1<<(motion))&0x95) // Fixed,Keyframe -#define SCE_PFX_MOTION_MASK_CAN_SLEEP(motion) ((1<<(motion))&0x0e) // Can sleep - -#define SCE_PFX_MOTION_MASK_SLEEPING 0x80 // Is sleeping -#define SCE_PFX_MOTION_MASK_TYPE 0x7f // Motion Type - -class SCE_PFX_ALIGNED(128) PfxRigidState -{ -private: - union { - struct { - PfxUInt8 m_useSleep : 1; - PfxUInt8 m_sleeping : 1; - PfxUInt8 m_reserved1 : 1; - PfxUInt8 m_reserved2 : 1; - PfxUInt8 m_reserved3 : 1; - PfxUInt8 m_reserved4 : 1; - PfxUInt8 m_reserved5 : 1; - PfxUInt8 m_reserved6 : 1; - }; - PfxUInt8 m_flags; - }; - PfxUInt8 m_motionType; - PfxUInt16 m_sleepCount; - PfxUInt16 m_rigidBodyId; - - SCE_PFX_PADDING(1,2) - - PfxUInt32 m_contactFilterSelf; - PfxUInt32 m_contactFilterTarget; - - PfxFloat m_linearDamping; - PfxFloat m_angularDamping; - - PfxFloat m_maxLinearVelocity; - PfxFloat m_maxAngularVelocity; - - PfxVector3 m_position; - PfxQuat m_orientation; - PfxVector3 m_linearVelocity; - PfxVector3 m_angularVelocity; - - void *m_userData; - PfxUInt32 m_userParam[4]; - - SCE_PFX_PADDING(2,12) - -public: - inline void reset(); - - PfxUInt16 getRigidBodyId() const {return m_rigidBodyId;} - void setRigidBodyId(PfxUInt16 i) {m_rigidBodyId = i;} - - PfxUInt32 getContactFilterSelf() const {return m_contactFilterSelf;} - void setContactFilterSelf(PfxUInt32 filter) {m_contactFilterSelf = filter;} - - PfxUInt32 getContactFilterTarget() const {return m_contactFilterTarget;} - void setContactFilterTarget(PfxUInt32 filter) {m_contactFilterTarget = filter;} - - ePfxMotionType getMotionType() const {return (ePfxMotionType)m_motionType;} - void setMotionType(ePfxMotionType t) {SCE_PFX_ALWAYS_ASSERT(t 0.0f); - - setLinearVelocity((pos - getPosition()) / timeStep); -} - -inline -void PfxRigidState::moveOrientation(const PfxQuat &rot,PfxFloat timeStep) -{ - if(getMotionType()!=kPfxMotionTypeKeyframe) return; - - SCE_PFX_ASSERT(timeStep > 0.0f); - - PfxQuat ori1 = getOrientation(); - PfxQuat ori2 = rot; - - if(dot(ori2,ori1) < 0.0f) { - ori2 = -rot; - } - - PfxQuat dq = ( ori2 - ori1 ) / timeStep; - dq = dq * 2.0f * conj(ori1); - PfxVector3 omega = dq.getXYZ(); - - setAngularVelocity(omega); -} -} // namespace PhysicsEffects -} // namespace sce -#endif // _SCE_PFX_RIGID_STATE_H - diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_pair.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_pair.h deleted file mode 100644 index 2663df97d..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_pair.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONSTRAINT_PAIR_H -#define _SCE_PFX_CONSTRAINT_PAIR_H - -#include "../sort/pfx_sort_data.h" -#include "../broadphase/pfx_broadphase_pair.h" - -namespace sce { -namespace PhysicsEffects { - -typedef PfxSortData16 PfxConstraintPair; - -//J PfxBroadphasePairã¨å…±é€š -//E Same as PfxBroadphasePair - -SCE_PFX_FORCE_INLINE void pfxSetConstraintId(PfxConstraintPair &pair,PfxUInt32 i) {pair.set32(2,i);} -SCE_PFX_FORCE_INLINE void pfxSetNumConstraints(PfxConstraintPair &pair,PfxUInt8 n) {pair.set8(7,n);} - -SCE_PFX_FORCE_INLINE PfxUInt32 pfxGetConstraintId(const PfxConstraintPair &pair) {return pair.get32(2);} -SCE_PFX_FORCE_INLINE PfxUInt8 pfxGetNumConstraints(const PfxConstraintPair &pair) {return pair.get8(7);} - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_CONSTRAINT_PAIR_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_row.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_row.h deleted file mode 100644 index b5ae65638..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_constraint_row.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONSTRAINT_ROW_H -#define _SCE_PFX_CONSTRAINT_ROW_H - -#include "../base/pfx_vec_utils.h" - -namespace sce { -namespace PhysicsEffects { - - -#include "../base/pfx_common.h" - -//E Don't change following order of parameters -struct SCE_PFX_ALIGNED(16) PfxConstraintRow { - PfxFloat m_normal[3]; - PfxFloat m_rhs; - PfxFloat m_jacDiagInv; - PfxFloat m_lowerLimit; - PfxFloat m_upperLimit; - PfxFloat m_accumImpulse; -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_CONSTRAINT_ROW_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_contact_constraint.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_contact_constraint.h deleted file mode 100644 index d1b5cebba..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_contact_constraint.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_CONSTRAINT_H -#define _SCE_PFX_CONTACT_CONSTRAINT_H - -#include "../rigidbody/pfx_rigid_state.h" -#include "pfx_constraint_row.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -void pfxSetupContactConstraint( - PfxConstraintRow &constraintResponse, - PfxConstraintRow &constraintFriction1, - PfxConstraintRow &constraintFriction2, - PfxFloat penetrationDepth, - PfxFloat restitution, - PfxFloat friction, - const PfxVector3 &contactNormal, - const PfxVector3 &contactPointA, - const PfxVector3 &contactPointB, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat separateBias, - PfxFloat timeStep - ); - -void pfxSolveContactConstraint( - PfxConstraintRow &constraintResponse, - PfxConstraintRow &constraintFriction1, - PfxConstraintRow &constraintFriction2, - const PfxVector3 &contactPointA, - const PfxVector3 &contactPointB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat friction - ); - - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_CONTACT_CONSTRAINT_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_integrate.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_integrate.h deleted file mode 100644 index 4253182cc..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_integrate.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTEGRATE_H_ -#define _SCE_PFX_INTEGRATE_H_ - -#include "../base/pfx_common.h" -#include "../rigidbody/pfx_rigid_body.h" -#include "../rigidbody/pfx_rigid_state.h" - -namespace sce { -namespace PhysicsEffects { - -template -static SCE_PFX_FORCE_INLINE T pfxRungeKutta(const T &deriv,PfxFloat dt) -{ - T k0, k1, k2, k3; - k0 = deriv * dt; - k1 = (deriv + k0 * 0.5f) * dt; - k2 = (deriv + k1 * 0.5f) * dt; - k3 = (deriv + k2) * dt; - return (k0 + k1*2.0f + k2*2.0f + k3) / 6.0f; -} - -#define SCE_PFX_MOTION_MASK_INTEGRATE ((1< state.getMaxLinearVelocity()) - { - nv = normalize( nv ) * state.getMaxLinearVelocity(); - } - if(length(nw) > state.getMaxAngularVelocity()) - { - nw = normalize( nw ) * state.getMaxAngularVelocity(); - } - - state.setLinearVelocity(nv); - state.setAngularVelocity(nw); -} -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_INTEGRATE_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint.h deleted file mode 100644 index 1c2be0799..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_H -#define _SCE_PFX_JOINT_H - -#include "../rigidbody/pfx_rigid_state.h" -#include "pfx_joint_constraint.h" -#include "pfx_constraint_pair.h" - -namespace sce { -namespace PhysicsEffects { - -// Joint Type -enum ePfxJointType { - kPfxJointBall = 0, - kPfxJointSwingtwist, - kPfxJointHinge, - kPfxJointSlider, - kPfxJointFix, - kPfxJointUniversal, - kPfxJointAnimation, - kPfxJointReserved0, - kPfxJointReserved1, - kPfxJointReserved2, - kPfxJointUser0, - kPfxJointUser1, - kPfxJointUser2, - kPfxJointUser3, - kPfxJointUser4, - kPfxJointCount // = 15 -}; - -// Joint Structure -struct SCE_PFX_ALIGNED(128) PfxJoint { - PfxUInt8 m_active; - PfxUInt8 m_numConstraints; - PfxUInt8 m_type; - SCE_PFX_PADDING(1,1) - PfxUInt16 m_rigidBodyIdA; - PfxUInt16 m_rigidBodyIdB; - SCE_PFX_PADDING(2,8) - PfxJointConstraint m_constraints[6]; - void *m_userData; - SCE_PFX_PADDING(3,12) - PfxVector3 m_param[4]; // Used by some joints for specific features - PfxVector3 m_anchorA; - PfxVector3 m_anchorB; - PfxMatrix3 m_frameA; - PfxMatrix3 m_frameB; - SCE_PFX_PADDING(4,32) -}; - -SCE_PFX_FORCE_INLINE -void pfxUpdateJointPairs( - PfxConstraintPair &pair, - PfxUInt32 jointId, - const PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB - ) -{ - SCE_PFX_ALWAYS_ASSERT(stateA.getRigidBodyId()==joint.m_rigidBodyIdA); - SCE_PFX_ALWAYS_ASSERT(stateB.getRigidBodyId()==joint.m_rigidBodyIdB); - pfxSetObjectIdA(pair,stateA.getRigidBodyId()); - pfxSetObjectIdB(pair,stateB.getRigidBodyId()); - pfxSetMotionMaskA(pair,stateA.getMotionMask()); - pfxSetMotionMaskB(pair,stateB.getMotionMask()); - pfxSetConstraintId(pair,jointId); - pfxSetNumConstraints(pair,joint.m_numConstraints); - pfxSetActive(pair,joint.m_active>0); -} -} //namespace PhysicsEffects -} //namespace sce - - -#endif // _PFX_JOINT_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_ball.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_ball.h deleted file mode 100644 index f18ec8cdc..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_ball.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_BALL_H -#define _SCE_PFX_JOINT_BALL_H - -#include "pfx_joint.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxBallJointInitParam { - PfxVector3 anchorPoint; - - PfxBallJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - } -}; - -PfxInt32 pfxInitializeBallJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxBallJointInitParam ¶m); - -void pfxSetupBallJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep); - -void pfxWarmStartBallJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -void pfxSolveBallJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_JOINT_BALL_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_constraint.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_constraint.h deleted file mode 100644 index 2d4b10fb1..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_constraint.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_CONSTRAINT_H -#define _SCE_PFX_JOINT_CONSTRAINT_H - -#include "../base/pfx_common.h" -#include "../base/pfx_vec_utils.h" -#include "pfx_constraint_row.h" - -namespace sce { -namespace PhysicsEffects { - -// Lock type -#define SCE_PFX_JOINT_LOCK_FREE 0 -#define SCE_PFX_JOINT_LOCK_LIMIT 1 -#define SCE_PFX_JOINT_LOCK_FIX 2 - -// Slop -#define SCE_PFX_JOINT_LINEAR_SLOP 0.01f -#define SCE_PFX_JOINT_ANGULAR_SLOP 0.01f - -///////////////////////////////////////////////////////////////////////////////// Joint Constraint - -struct PfxJointConstraint { - PfxInt8 m_lock; - PfxInt8 m_warmStarting; - SCE_PFX_PADDING(1,2) - PfxFloat m_movableLowerLimit; - PfxFloat m_movableUpperLimit; - PfxFloat m_bias; - PfxFloat m_weight; - PfxFloat m_damping; - PfxFloat m_maxImpulse; - SCE_PFX_PADDING(2,4) - PfxConstraintRow m_constraintRow; - - void reset() - { - m_lock = SCE_PFX_JOINT_LOCK_FIX; - m_warmStarting = 0; - m_movableLowerLimit = 0.0f; - m_movableUpperLimit = 0.0f; - m_bias = 0.2f; - m_weight = 1.0f; - m_damping = 0.0f; - m_maxImpulse = SCE_PFX_FLT_MAX; - memset(&m_constraintRow,0,sizeof(PfxConstraintRow)); - } -}; -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_JOINT_CONSTRAINT_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_fix.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_fix.h deleted file mode 100644 index 7d4408253..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_fix.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_FIX_H -#define _SCE_PFX_JOINT_FIX_H - -#include "pfx_joint.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxFixJointInitParam { - PfxVector3 anchorPoint; - - PfxFixJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - } -}; - -PfxInt32 pfxInitializeFixJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxFixJointInitParam ¶m); - -// pfxSetupFixJoint = pfxSetupSwingTwistJoint - -// pfxWarmStartFixJoint = pfxWarmStartSwingTwistJoint - -// pfxSolveFixJoint = pfxSolveSwingTwistJoint -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_JOINT_FIX_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_hinge.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_hinge.h deleted file mode 100644 index 357f47e57..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_hinge.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_HINGE_H_ -#define _SCE_PFX_JOINT_HINGE_H_ - -#include "pfx_joint.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxHingeJointInitParam { - PfxVector3 anchorPoint; - PfxVector3 axis; - PfxFloat lowerAngle; - PfxFloat upperAngle; - SCE_PFX_PADDING(1,8) - - PfxHingeJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - axis = PfxVector3(1.0f,0.0f,0.0f); - lowerAngle = 0.0f; - upperAngle = 0.0f; - } -}; - -PfxInt32 pfxInitializeHingeJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxHingeJointInitParam ¶m); - -// pfxSetupHingeJoint = pfxSetupSwingTwistJoint - -// pfxWarmStartHingeJoint = pfxWarmStartSwingTwistJoint - -// pfxSolveHingeJoint = pfxSolveSwingTwistJoint - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_JOINT_HINGE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_slider.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_slider.h deleted file mode 100644 index 23b576921..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_slider.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_SLIDER_H -#define _SCE_PFX_JOINT_SLIDER_H - -#include "pfx_joint.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxSliderJointInitParam { - PfxVector3 anchorPoint; - PfxVector3 direction; - PfxFloat lowerDistance; - PfxFloat upperDistance; - SCE_PFX_PADDING(1,8) - - PfxSliderJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - direction = PfxVector3(1.0f,0.0f,0.0f); - lowerDistance = 0.0f; - upperDistance = 0.0f; - } -}; - -PfxInt32 pfxInitializeSliderJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxSliderJointInitParam ¶m); - -// pfxSetupSliderJoint = pfxSetupSwingTwistJoint - -// pfxWarmStartSliderJoint = pfxWarmStartSwingTwistJoint - -// pfxSolveSliderJoint = pfxSolveSwingTwistJoint - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_JOINT_SLIDER_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_swing_twist.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_swing_twist.h deleted file mode 100644 index de0774dd6..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_swing_twist.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_SWING_TWIST_H -#define _SCE_PFX_JOINT_SWING_TWIST_H - -#include "pfx_joint.h" -#include "pfx_solver_body.h" -namespace sce { -namespace PhysicsEffects { - -struct PfxSwingTwistJointInitParam { - PfxVector3 anchorPoint; - PfxVector3 twistAxis; - PfxFloat twistLowerAngle; - PfxFloat twistUpperAngle; - PfxFloat swingLowerAngle; - PfxFloat swingUpperAngle; - - PfxSwingTwistJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - twistAxis = PfxVector3(1.0f,0.0f,0.0f); - twistLowerAngle = -0.26f; - twistUpperAngle = 0.26f; - swingLowerAngle = 0.0f; - swingUpperAngle = 0.7f; - } -}; - -PfxInt32 pfxInitializeSwingTwistJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxSwingTwistJointInitParam ¶m); - -void pfxSetupSwingTwistJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep); - -void pfxWarmStartSwingTwistJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -void pfxSolveSwingTwistJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_JOINT_SWING_TWIST_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_universal.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_universal.h deleted file mode 100644 index 7e9148d45..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_joint_universal.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_UNIVERSAL_H -#define _SCE_PFX_JOINT_UNIVERSAL_H - -#include "pfx_joint.h" -#include "pfx_solver_body.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxUniversalJointInitParam { - PfxVector3 anchorPoint; - PfxVector3 axis; - PfxFloat swing1LowerAngle; - PfxFloat swing1UpperAngle; - PfxFloat swing2LowerAngle; - PfxFloat swing2UpperAngle; - - PfxUniversalJointInitParam() - { - anchorPoint = PfxVector3(0.0f); - axis = PfxVector3(1.0f,0.0f,0.0f); - swing1LowerAngle = -0.7f; - swing1UpperAngle = 0.7f; - swing2LowerAngle = -0.7f; - swing2UpperAngle = 0.7f; - } -}; - -PfxInt32 pfxInitializeUniversalJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - const PfxUniversalJointInitParam ¶m); - -void pfxSetupUniversalJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep); - -// pfxWarmStartUniversalJoint = pfxWarmStartSwingTwistJoint - -// pfxSolveUniversalJoint = pfxSolveSwingTwistJoint - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_JOINT_UNIVERSAL_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_solver_body.h b/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_solver_body.h deleted file mode 100644 index f26370d49..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/solver/pfx_solver_body.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SOLVER_BODY_H -#define _SCE_PFX_SOLVER_BODY_H - -#include "../base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -struct SCE_PFX_ALIGNED(128) PfxSolverBody { - PfxVector3 m_deltaLinearVelocity; - PfxVector3 m_deltaAngularVelocity; - PfxQuat m_orientation; - PfxMatrix3 m_inertiaInv; - PfxFloat m_massInv; - PfxUInt32 m_motionType; - SCE_PFX_PADDING(1,24) -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_SOLVER_BODY_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort.h b/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort.h deleted file mode 100644 index 346910c28..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SORT_H -#define _SCE_PFX_SORT_H - -#include "pfx_sort_data.h" -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Single Sort - -void pfxSort(PfxSortData16 *data,PfxSortData16 *buff,unsigned int n); -void pfxSort(PfxSortData32 *data,PfxSortData32 *buff,unsigned int n); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_SORT_H diff --git a/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort_data.h b/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort_data.h deleted file mode 100644 index b048d1720..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/base_level/sort/pfx_sort_data.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SORT_DATA_H -#define _SCE_PFX_SORT_DATA_H - -#include "../base/pfx_common.h" - - - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_SENTINEL_KEY 0xffffffff - -struct SCE_PFX_ALIGNED(16) PfxSortData16 { - union { - PfxUInt8 i8data[16]; - PfxUInt16 i16data[8]; - PfxUInt32 i32data[4]; - }; - -void set8(int slot,PfxUInt8 data) {i8data[slot] = data;} -void set16(int slot,PfxUInt16 data) {i16data[slot] = data;} -void set32(int slot,PfxUInt32 data) {i32data[slot] = data;} -PfxUInt8 get8(int slot) const {return i8data[slot];} -PfxUInt16 get16(int slot) const {return i16data[slot];} -PfxUInt32 get32(int slot) const {return i32data[slot];} -}; - -struct SCE_PFX_ALIGNED(16) PfxSortData32 { - union { - PfxUInt8 i8data[32]; - PfxUInt16 i16data[16]; - PfxUInt32 i32data[8]; - }; - -void set8(int slot,PfxUInt8 data) {i8data[slot] = data;} -void set16(int slot,PfxUInt16 data) {i16data[slot] = data;} -void set32(int slot,PfxUInt32 data) {i32data[slot] = data;} -PfxUInt8 get8(int slot) const {return i8data[slot];} -PfxUInt16 get16(int slot) const {return i16data[slot];} -PfxUInt32 get32(int slot) const {return i32data[slot];} -}; - -SCE_PFX_FORCE_INLINE -void pfxSetKey(PfxSortData16 &sortData,PfxUInt32 key) {sortData.set32(3,key);} - -SCE_PFX_FORCE_INLINE -PfxUInt32 pfxGetKey(const PfxSortData16 &sortData) {return sortData.get32(3);} - -SCE_PFX_FORCE_INLINE -void pfxSetKey(PfxSortData32 &sortData,PfxUInt32 key) {sortData.set32(7,key);} - -SCE_PFX_FORCE_INLINE -PfxUInt32 pfxGetKey(const PfxSortData32 &sortData) {return sortData.get32(7);} - -SCE_PFX_FORCE_INLINE -PfxUInt32 pfxCreateUniqueKey(PfxUInt32 i,PfxUInt32 j) -{ - PfxUInt32 minIdx = SCE_PFX_MIN(i,j); - PfxUInt32 maxIdx = SCE_PFX_MAX(i,j); - return (maxIdx<<16)|(minIdx&0xffff); -} - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_SORT_DATA_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/broadphase/pfx_broadphase.h b/Extras/PhysicsEffects/include/physics_effects/low_level/broadphase/pfx_broadphase.h deleted file mode 100644 index 18832d7bc..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/broadphase/pfx_broadphase.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_BROADPHASE_H_ -#define _SCE_PFX_BROADPHASE_H_ - -#include "../../base_level/broadphase/pfx_broadphase_pair.h" -#include "../../base_level/broadphase/pfx_broadphase_proxy.h" -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/collision/pfx_collidable.h" -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Update Broadphase Proxies - -#define SCE_PFX_OUT_OF_WORLD_BEHAVIOR_FIX_MOTION 0x01 -#define SCE_PFX_OUT_OF_WORLD_BEHAVIOR_REMOVE_PROXY 0x02 - -struct PfxUpdateBroadphaseProxiesParam { - void *workBuff; - PfxUInt32 workBytes; - PfxBroadphaseProxy *proxiesX; - PfxBroadphaseProxy *proxiesY; - PfxBroadphaseProxy *proxiesZ; - PfxBroadphaseProxy *proxiesXb; - PfxBroadphaseProxy *proxiesYb; - PfxBroadphaseProxy *proxiesZb; - PfxRigidState *offsetRigidStates; - PfxCollidable *offsetCollidables; - PfxUInt32 numRigidBodies; - PfxUInt32 outOfWorldBehavior; - PfxVector3 worldCenter; - PfxVector3 worldExtent; - - PfxUpdateBroadphaseProxiesParam() : outOfWorldBehavior(0) {} -}; - -struct PfxUpdateBroadphaseProxiesResult { - PfxInt32 numOutOfWorldProxies; -}; - -PfxUInt32 pfxGetWorkBytesOfUpdateBroadphaseProxies(PfxUInt32 numRigidBodies); - -PfxUInt32 pfxGetWorkBytesOfUpdateBroadphaseProxies(PfxUInt32 numRigidBodies,PfxUInt32 maxTasks); - -PfxInt32 pfxUpdateBroadphaseProxies(PfxUpdateBroadphaseProxiesParam ¶m,PfxUpdateBroadphaseProxiesResult &result); - -PfxInt32 pfxUpdateBroadphaseProxies(PfxUpdateBroadphaseProxiesParam ¶m,PfxUpdateBroadphaseProxiesResult &result,PfxTaskManager *taskManager); - -/////////////////////////////////////////////////////////////////////////////// -// Find Pairs - -struct PfxFindPairsParam { - void *workBuff; - PfxUInt32 workBytes; - void *pairBuff; - PfxUInt32 pairBytes; - PfxBroadphaseProxy *proxies; - PfxUInt32 numProxies; - PfxUInt32 maxPairs; - int axis; -}; - -struct PfxFindPairsResult { - PfxBroadphasePair *pairs; - PfxUInt32 numPairs; -}; - -PfxUInt32 pfxGetWorkBytesOfFindPairs(PfxUInt32 maxPairs,PfxUInt32 maxTasks=1); -PfxUInt32 pfxGetPairBytesOfFindPairs(PfxUInt32 maxPairs); - -PfxInt32 pfxFindPairs(PfxFindPairsParam ¶m,PfxFindPairsResult &result); - -PfxInt32 pfxFindPairs(PfxFindPairsParam ¶m,PfxFindPairsResult &result,PfxTaskManager *taskManager); - -/////////////////////////////////////////////////////////////////////////////// -// Decompose Pairs - -struct PfxDecomposePairsParam { - void *workBuff; - PfxUInt32 workBytes; - void *pairBuff; - PfxUInt32 pairBytes; - PfxBroadphasePair *previousPairs; - PfxUInt32 numPreviousPairs; - PfxBroadphasePair *currentPairs; - PfxUInt32 numCurrentPairs; -}; - -struct PfxDecomposePairsResult { - PfxBroadphasePair *outNewPairs; - PfxUInt32 numOutNewPairs; - PfxBroadphasePair *outKeepPairs; - PfxUInt32 numOutKeepPairs; - PfxBroadphasePair *outRemovePairs; - PfxUInt32 numOutRemovePairs; -}; - -PfxUInt32 pfxGetWorkBytesOfDecomposePairs(PfxUInt32 numPreviousPairs,PfxUInt32 numCurrentPairs,int maxTasks=1); -PfxUInt32 pfxGetPairBytesOfDecomposePairs(PfxUInt32 numPreviousPairs,PfxUInt32 numCurrentPairs); - -PfxInt32 pfxDecomposePairs(PfxDecomposePairsParam ¶m,PfxDecomposePairsResult &result); - -PfxInt32 pfxDecomposePairs(PfxDecomposePairsParam ¶m,PfxDecomposePairsResult &result,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce -#endif /* _SCE_PFX_BROADPHASE_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_batched_ray_cast.h b/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_batched_ray_cast.h deleted file mode 100644 index 5ecb90c4f..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_batched_ray_cast.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_BATCHED_RAY_CAST_H -#define _SCE_PFX_BATCHED_RAY_CAST_H - -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/collision/pfx_collidable.h" -#include "../../base_level/broadphase/pfx_broadphase_proxy.h" -#include "../task/pfx_task_manager.h" -#include "pfx_ray_cast.h" - -/////////////////////////////////////////////////////////////////////////////// -// Batched RayCast -namespace sce { -namespace PhysicsEffects { - -void pfxCastRays(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays,PfxRayCastParam ¶m); - -void pfxCastRays(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays,PfxRayCastParam ¶m,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_BATCHED_RAY_CAST_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_collision_detection.h b/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_collision_detection.h deleted file mode 100644 index 3838fb92a..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_collision_detection.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_COLLISION_DETECTION_H_ -#define _SCE_PFX_COLLISION_DETECTION_H_ - -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/collision/pfx_collidable.h" -#include "../../base_level/collision/pfx_contact_manifold.h" -#include "../../base_level/solver/pfx_constraint_pair.h" -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Detect Collision - -struct PfxDetectCollisionParam { - PfxConstraintPair *contactPairs; - PfxUInt32 numContactPairs; - PfxContactManifold *offsetContactManifolds; - PfxRigidState *offsetRigidStates; - PfxCollidable *offsetCollidables; - PfxUInt32 numRigidBodies; -}; - -PfxInt32 pfxDetectCollision(PfxDetectCollisionParam ¶m); - -PfxInt32 pfxDetectCollision(PfxDetectCollisionParam ¶m,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_COLLISION_DETECTION_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_island_generation.h b/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_island_generation.h deleted file mode 100644 index cb01d255b..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_island_generation.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_ISLAND_GENERATION_H_ -#define _SCE_PFX_ISLAND_GENERATION_H_ - -#include "../../base_level/solver/pfx_constraint_pair.h" -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Island Generation - -struct PfxIsland; -struct PfxIslandUnit; - -struct PfxGenerateIslandParam { - void *islandBuff; - PfxUInt32 islandBytes; - PfxConstraintPair *pairs; - PfxUInt32 numPairs; - PfxUInt32 numObjects; -}; - -struct PfxGenerateIslandResult { - PfxIsland *island; -}; - -//J アイランド情報を使ã„終ã‚ã‚‹ã¾ã§islandBuffを破棄ã—ãªã„ã§ãã ã•ã„ -//E Keep islandBuff while the island is used -PfxUInt32 pfxGetIslandBytesOfGenerateIsland(PfxUInt32 numObjects); - -PfxInt32 pfxGenerateIsland(PfxGenerateIslandParam ¶m,PfxGenerateIslandResult &result); - -//E Access to island information -//J アイランド情報ã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ - -//E Get the number of islands -//J アイランド数をå–å¾—ã™ã‚‹ -PfxUInt32 pfxGetNumIslands(const PfxIsland *islands); - -//E Get a island unit in a island -//J 指定ã—ãŸã‚¢ã‚¤ãƒ©ãƒ³ãƒ‰ã«å«ã¾ã‚Œã‚‹ãƒ¦ãƒ‹ãƒƒãƒˆï¼ˆå‰›ä½“)ã«ã‚¢ã‚¯ã‚»ã‚¹ -PfxIslandUnit *pfxGetFirstUnitInIsland(const PfxIsland *islands,PfxUInt32 islandId); -PfxIslandUnit *pfxGetNextUnitInIsland(const PfxIslandUnit *islandUnit); -PfxUInt32 pfxGetUnitId(const PfxIslandUnit *islandUnit); - -//E Get an index of an island which includes a specific unit -//J 指定ã—ãŸãƒ¦ãƒ‹ãƒƒãƒˆï¼ˆå‰›ä½“)ã®ã‚¢ã‚¤ãƒ©ãƒ³ãƒ‰ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ã‚’å–å¾—ã™ã‚‹ -PfxUInt32 pfxGetIslandId(const PfxIsland *islands,PfxUInt32 unitId); - -//E Add pairs and construct islands -//J アイランドã«ãƒšã‚¢ã‚’追加ã™ã‚‹ -PfxInt32 pfxAppendPairs(PfxIsland *island,PfxConstraintPair *pairs,PfxUInt32 numPairs); - -//E Reset islands -//J アイランドリセット -void pfxResetIsland(PfxIsland *island); - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_ISLAND_GENERATION_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_ray_cast.h b/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_ray_cast.h deleted file mode 100644 index 3bfba4054..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_ray_cast.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_RAY_CAST_H -#define _SCE_PFX_RAY_CAST_H - -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/collision/pfx_collidable.h" -#include "../../base_level/collision/pfx_ray.h" -#include "../../base_level/broadphase/pfx_broadphase_proxy.h" - -/////////////////////////////////////////////////////////////////////////////// -// RayCast - -namespace sce { -namespace PhysicsEffects { - -struct PfxRayCastParam { - PfxRigidState *offsetRigidStates; - PfxCollidable *offsetCollidables; - PfxBroadphaseProxy *proxiesX; - PfxBroadphaseProxy *proxiesY; - PfxBroadphaseProxy *proxiesZ; - PfxBroadphaseProxy *proxiesXb; - PfxBroadphaseProxy *proxiesYb; - PfxBroadphaseProxy *proxiesZb; - PfxUInt32 numProxies; - SCE_PFX_PADDING(1,12) - PfxVector3 rangeCenter; - PfxVector3 rangeExtent; -}; - -void pfxCastSingleRay(const PfxRayInput &rayInput,PfxRayOutput &rayOutput,const PfxRayCastParam ¶m); - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_RAY_CAST_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_refresh_contacts.h b/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_refresh_contacts.h deleted file mode 100644 index 10cf10438..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/collision/pfx_refresh_contacts.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_REFRESH_CONTACTS_H -#define _SCE_PFX_REFRESH_CONTACTS_H - -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/solver/pfx_constraint_pair.h" -#include "../../base_level/collision/pfx_contact_manifold.h" -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Refresh Contacts - -struct PfxRefreshContactsParam { - PfxConstraintPair *contactPairs; - PfxUInt32 numContactPairs; - PfxContactManifold *offsetContactManifolds; - PfxRigidState *offsetRigidStates; - PfxUInt32 numRigidBodies; -}; - -PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m); - -PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_REFRESH_CONTACTS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/pfx_low_level_include.h b/Extras/PhysicsEffects/include/physics_effects/low_level/pfx_low_level_include.h deleted file mode 100644 index 5b513c71e..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/pfx_low_level_include.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_LOW_LEVEL_INCLUDE_H -#define _SCE_PFX_LOW_LEVEL_INCLUDE_H - -/////////////////////////////////////////////////////////////////////////////// -// Physics Effects Low Level Headers - -// Include base level headers -#include "../base_level/pfx_base_level_include.h" - -// Include low level headers -#include "broadphase/pfx_broadphase.h" - -#include "collision/pfx_collision_detection.h" -#include "collision/pfx_refresh_contacts.h" -#include "collision/pfx_batched_ray_cast.h" -#include "collision/pfx_ray_cast.h" -#include "collision/pfx_island_generation.h" - -#include "solver/pfx_constraint_solver.h" -#include "solver/pfx_update_rigid_states.h" - -#include "sort/pfx_parallel_sort.h" - -// ARA begin insert new code -#ifdef USE_PTHREADS -#include "task/pfx_pthreads.h" -#endif -// ARA end - -#endif // _SCE_PFX_LOW_LEVEL_INCLUDE_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_constraint_solver.h b/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_constraint_solver.h deleted file mode 100644 index 64837d495..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_constraint_solver.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONSTRAINT_SOLVER_H -#define _SCE_PFX_CONSTRAINT_SOLVER_H - -#include "../../base_level/rigidbody/pfx_rigid_body.h" -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/solver/pfx_solver_body.h" -#include "../../base_level/solver/pfx_constraint_pair.h" -#include "../../base_level/solver/pfx_joint.h" -#include "../../base_level/collision/pfx_contact_manifold.h" - -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Setup Solver Bodies - -struct PfxSetupSolverBodiesParam { - PfxRigidState *states; - PfxRigidBody *bodies; - PfxSolverBody *solverBodies; - PfxUInt32 numRigidBodies; -}; - -PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m); - -PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m,PfxTaskManager *taskManager); - -/////////////////////////////////////////////////////////////////////////////// -// Setup Constraints - -struct PfxSetupContactConstraintsParam { - PfxConstraintPair *contactPairs; - PfxUInt32 numContactPairs; - PfxContactManifold *offsetContactManifolds; - PfxRigidState *offsetRigidStates; - PfxRigidBody *offsetRigidBodies; - PfxSolverBody *offsetSolverBodies; - PfxUInt32 numRigidBodies; - PfxFloat timeStep; - PfxFloat separateBias; - - PfxSetupContactConstraintsParam() - { - timeStep = 0.016f; - separateBias = 0.2f; - } -}; - -PfxInt32 pfxSetupContactConstraints(PfxSetupContactConstraintsParam ¶m); - -PfxInt32 pfxSetupContactConstraints(PfxSetupContactConstraintsParam ¶m,PfxTaskManager *taskManager); - -struct PfxSetupJointConstraintsParam { - PfxConstraintPair *jointPairs; - PfxUInt32 numJointPairs; - PfxJoint *offsetJoints; - PfxRigidState *offsetRigidStates; - PfxRigidBody *offsetRigidBodies; - PfxSolverBody *offsetSolverBodies; - PfxUInt32 numRigidBodies; - PfxFloat timeStep; - - PfxSetupJointConstraintsParam() - { - timeStep = 0.016f; - } -}; - -PfxInt32 pfxSetupJointConstraints(PfxSetupJointConstraintsParam ¶m); - -PfxInt32 pfxSetupJointConstraints(PfxSetupJointConstraintsParam ¶m,PfxTaskManager *taskManager); - -/////////////////////////////////////////////////////////////////////////////// -// Solve Constraints - -struct PfxSolveConstraintsParam { - void *workBuff; - PfxUInt32 workBytes; - PfxConstraintPair *contactPairs; - PfxUInt32 numContactPairs; - PfxContactManifold *offsetContactManifolds; - PfxConstraintPair *jointPairs; - PfxUInt32 numJointPairs; - PfxJoint *offsetJoints; - PfxRigidState *offsetRigidStates; - PfxSolverBody *offsetSolverBodies; - PfxUInt32 numRigidBodies; - PfxUInt32 iteration; - - PfxSolveConstraintsParam() - { - iteration = 5; - } -}; - -PfxUInt32 pfxGetWorkBytesOfSolveConstraints(PfxUInt32 numRigidBodies,PfxUInt32 numContactPairs,PfxUInt32 numJointPairs,PfxUInt32 maxTasks=1); - -PfxInt32 pfxSolveConstraints(PfxSolveConstraintsParam ¶m); - -PfxInt32 pfxSolveConstraints(PfxSolveConstraintsParam ¶m,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_CONSTRAINT_SOLVER_H - diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_joint_constraint_func.h b/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_joint_constraint_func.h deleted file mode 100644 index d8e6d4e6e..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_joint_constraint_func.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_JOINT_CONSTRAINT_FUNC_H_ -#define _SCE_PFX_JOINT_CONSTRAINT_FUNC_H_ - -#include "../../base_level/rigidbody/pfx_rigid_state.h" -#include "../../base_level/solver/pfx_solver_body.h" -#include "../../base_level/solver/pfx_joint.h" -#include "../../base_level/solver/pfx_joint_constraint.h" - -namespace sce { -namespace PhysicsEffects { -/////////////////////////////////////////////////////////////////////////////// -// Setup Joint Constraint Func - -typedef void (*PfxSetupJointConstraintFunc)( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep); - -PfxSetupJointConstraintFunc pfxGetSetupJointConstraintFunc(PfxUInt8 jointType); - -int pfxSetSetupJointConstraintFunc(PfxUInt8 jointType,PfxSetupJointConstraintFunc func); - -/////////////////////////////////////////////////////////////////////////////// -// Warm Start Joint Constraint Func - -typedef void (*PfxWarmStartJointConstraintFunc)( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -PfxWarmStartJointConstraintFunc pfxGetWarmStartJointConstraintFunc(PfxUInt8 jointType); - -int pfxSetWarmStartJointConstraintFunc(PfxUInt8 jointType,PfxWarmStartJointConstraintFunc func); - -/////////////////////////////////////////////////////////////////////////////// -// Solve Joint Constraint Func - -typedef void (*PfxSolveJointConstraintFunc)( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB); - -PfxSolveJointConstraintFunc pfxGetSolveJointConstraintFunc(PfxUInt8 jointType); - -int pfxSetSolveJointConstraintFunc(PfxUInt8 jointType,PfxSolveJointConstraintFunc func); - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _PFX_JOINT_CONSTRAINT_FUNC_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_update_rigid_states.h b/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_update_rigid_states.h deleted file mode 100644 index b16a81eb2..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/solver/pfx_update_rigid_states.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_UPDATE_RIGID_STATES_H_ -#define _SCE_PFX_UPDATE_RIGID_STATES_H_ - -#include "../../base_level/rigidbody/pfx_rigid_body.h" -#include "../../base_level/rigidbody/pfx_rigid_state.h" - -#include "../task/pfx_task_manager.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Update Rigid Body States - -struct PfxUpdateRigidStatesParam { - PfxRigidState *states; - PfxRigidBody *bodies; - PfxUInt32 numRigidBodies; - PfxFloat timeStep; -}; - -PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m); - -PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m,PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_UPDATE_RIGID_STATES_H_ */ diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/sort/pfx_parallel_sort.h b/Extras/PhysicsEffects/include/physics_effects/low_level/sort/pfx_parallel_sort.h deleted file mode 100644 index 66d3b1575..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/sort/pfx_parallel_sort.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_PARALLEL_SORT_H -#define _SCE_PFX_PARALLEL_SORT_H - -#include "../../base_level/sort/pfx_sort_data.h" -#include "../task/pfx_task_manager.h" - -/////////////////////////////////////////////////////////////////////////////// -// Parallel Sort -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxParallelSort(PfxSortData16 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes); - -PfxInt32 pfxParallelSort(PfxSortData32 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes); - -PfxInt32 pfxParallelSort(PfxSortData16 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes, - PfxTaskManager *taskManager); - -PfxInt32 pfxParallelSort(PfxSortData32 *data,PfxUInt32 numData,void *workBuff,PfxUInt32 workBytes, - PfxTaskManager *taskManager); - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_PARALLEL_SORT_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_pthreads.h b/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_pthreads.h deleted file mode 100644 index 3b38faefa..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_pthreads.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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 _SCE_PFX_PTHREADS_H -#define _SCE_PFX_PTHREADS_H - -#include "../../base_level/base/pfx_common.h" -#include - -namespace sce { -namespace PhysicsEffects { - -class PfxBarrier; -class PfxCriticalSection; -class PfxTaskManager; - -#define SCE_PFX_CHECK_PTHREADS_OUTCOME(result) \ - if(0 != result) \ - { \ - SCE_PFX_PRINTF("pthreads problem at line %i in file %s: %i %d\n", __LINE__, __FILE__, result, errno); \ - } - -PfxBarrier *PfxCreateBarrierPthreads(int n); -PfxCriticalSection *PfxCreateCriticalSectionPthreads(); -PfxTaskManager *PfxCreateTaskManagerPthreads(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_PTHREADS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_sync_components.h b/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_sync_components.h deleted file mode 100644 index 1f64672f3..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_sync_components.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SYNC_COMPONENTS_H -#define _SCE_PFX_SYNC_COMPONENTS_H - -#include "../../base_level/base/pfx_common.h" - -//J スレッド間ã®åŒæœŸã‚’ã¨ã‚‹ãŸã‚ã®åŒæœŸã‚³ãƒ³ãƒãƒãƒ³ãƒˆ -//E Components for threads sychronization -namespace sce { -namespace PhysicsEffects { - -class PfxBarrier { -public: - PfxBarrier() {} - virtual ~PfxBarrier() {} - - virtual void sync() = 0; - virtual void setMaxCount(int n) = 0; - virtual int getMaxCount() = 0; -}; - -class PfxCriticalSection { -public: - PfxCriticalSection() {} - virtual ~PfxCriticalSection() {} - -PfxUInt32 m_commonBuff[32]; - - virtual PfxUInt32 getSharedParam(int i) = 0; - virtual void setSharedParam(int i,PfxUInt32 p) = 0; - - virtual void lock() = 0; - virtual void unlock() = 0; -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_SYNC_COMPONENTS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_task_manager.h b/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_task_manager.h deleted file mode 100644 index 5f398c1d1..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/low_level/task/pfx_task_manager.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_TASK_MANAGER_H -#define _SCE_PFX_TASK_MANAGER_H - -#include "../../base_level/base/pfx_common.h" -#include "../../base_level/base/pfx_heap_manager.h" -#include "pfx_sync_components.h" - -#define SCE_PFX_IO_BUFF_BYTES 1048576 -namespace sce { -namespace PhysicsEffects { - -//J 並列処ç†ã™ã‚‹ãŸã‚ã®ã‚¿ã‚¹ã‚¯ãƒžãƒãƒ¼ã‚¸ãƒ£ã‚¯ãƒ©ã‚¹ -//E Task manager class for parallel computation - -struct PfxTaskArg -{ - int taskId; - int maxTasks; - PfxBarrier *barrier; - PfxCriticalSection *criticalSection; - void *io; - PfxUInt32 data[4]; -}; - -typedef void (*PfxTaskEntry)(PfxTaskArg *arg); - -class PfxTaskManager -{ -protected: - PfxUInt32 m_numTasks; - PfxUInt32 m_maxTasks; - SCE_PFX_PADDING(1,4) - PfxUInt8 SCE_PFX_ALIGNED(16) m_ioBuff[SCE_PFX_IO_BUFF_BYTES]; - PfxHeapManager m_pool; - PfxHeapManager m_ioPool; - PfxTaskEntry m_taskEntry; - PfxTaskArg *m_taskArg; - SCE_PFX_PADDING(2,8) - - PfxTaskManager() : m_pool(NULL,0),m_ioPool(NULL,0) {} - -public: - void *allocate(size_t bytes) {return m_ioPool.allocate(bytes);} - void deallocate(void *p) {m_ioPool.deallocate(p);} - void clearPool() {m_ioPool.clear();} - - virtual PfxUInt32 getSharedParam(int i) = 0; - virtual void setSharedParam(int i,PfxUInt32 p) = 0; - - virtual void startTask(int taskId,void *io,PfxUInt32 data1,PfxUInt32 data2,PfxUInt32 data3,PfxUInt32 data4) = 0; - virtual void waitTask(int &taskId,PfxUInt32 &data1,PfxUInt32 &data2,PfxUInt32 &data3,PfxUInt32 &data4) = 0; - - virtual void setTaskEntry(void *entry) {m_taskEntry = (PfxTaskEntry)entry;} - -public: - PfxTaskManager(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes) - : m_pool((unsigned char*)workBuff,workBytes),m_ioPool(m_ioBuff,SCE_PFX_IO_BUFF_BYTES) - { - SCE_PFX_ASSERT(numTasks>0); - SCE_PFX_ASSERT(numTasks<=maxTasks); - m_numTasks = numTasks; - m_maxTasks = maxTasks; - m_taskArg = (PfxTaskArg*)m_pool.allocate(sizeof(PfxTaskArg)*m_maxTasks); - } - - virtual ~PfxTaskManager() - { - m_pool.clear(); - } - - virtual PfxUInt32 getNumTasks() const {return m_numTasks;} - virtual void setNumTasks(PfxUInt32 tasks) {m_numTasks = SCE_PFX_MIN(tasks,m_maxTasks);} - - virtual void initialize() = 0; - virtual void finalize() = 0; -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_TASK_MANAGER_H \ No newline at end of file diff --git a/Extras/PhysicsEffects/include/physics_effects/util/pfx_mass.h b/Extras/PhysicsEffects/include/physics_effects/util/pfx_mass.h deleted file mode 100644 index 14d70d40a..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/util/pfx_mass.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -/////////////////////////////////////////////////////////////////////////////// -//E Mass , Inertia tensor calculation -//J 質é‡ãƒ»æ…£æ€§ãƒ†ãƒ³ã‚½ãƒ«ã®ç®—出 - -#ifndef _SCE_PFX_MASS_H -#define _SCE_PFX_MASS_H - -#include "../base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -// Box -PfxFloat pfxCalcMassBox(PfxFloat density,const PfxVector3 &halfExtent); -PfxMatrix3 pfxCalcInertiaBox(const PfxVector3 &halfExtent,PfxFloat mass); - -// Sphere -PfxFloat pfxCalcMassSphere(PfxFloat density,PfxFloat radius); -PfxMatrix3 pfxCalcInertiaSphere(PfxFloat radius,PfxFloat mass); - -// Cylinder -PfxFloat pfxCalcMassCylinder(PfxFloat density,PfxFloat halfLength,PfxFloat radius); -PfxMatrix3 pfxCalcInertiaCylinderX(PfxFloat halfLength,PfxFloat radius,PfxFloat mass); -PfxMatrix3 pfxCalcInertiaCylinderY(PfxFloat halfLength,PfxFloat radius,PfxFloat mass); -PfxMatrix3 pfxCalcInertiaCylinderZ(PfxFloat halfLength,PfxFloat radius,PfxFloat mass); - -/////////////////////////////////////////////////////////////////////////////// -//E Mass convertion -//J 質é‡ã®ç§»å‹•ãƒ»å›žè»¢ãƒ»åˆæˆ - -// translation -//E returns translated inertia tensor -//J ç§»å‹•å¾Œã®æ…£æ€§ãƒ†ãƒ³ã‚½ãƒ«ã‚’è¿”ã—ã¾ã™ -PfxMatrix3 pfxMassTranslate(PfxFloat mass,const PfxMatrix3 &inertia,const PfxVector3 &translation); - -// rotation -//E returns rotated inertia tensor -//J å›žè»¢å¾Œã®æ…£æ€§ãƒ†ãƒ³ã‚½ãƒ«ã‚’è¿”ã—ã¾ã™ -PfxMatrix3 pfxMassRotate(const PfxMatrix3 &inertia,const PfxMatrix3 &rotate); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_MASS_H diff --git a/Extras/PhysicsEffects/include/physics_effects/util/pfx_mesh_creator.h b/Extras/PhysicsEffects/include/physics_effects/util/pfx_mesh_creator.h deleted file mode 100644 index f481dd1e4..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/util/pfx_mesh_creator.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_MESH_CREATOR_H -#define _SCE_PFX_MESH_CREATOR_H - -#include "../base_level/collision/pfx_large_tri_mesh.h" - -namespace sce { -namespace PhysicsEffects { - -//J ãƒ•ãƒ©ã‚°ã«æŒ‡å®šã™ã‚‹å€¤ -//E Specify these values to a flag parameter -#define SCE_PFX_MESH_FLAG_NORMAL_FLIP 0x01 -#define SCE_PFX_MESH_FLAG_16BIT_INDEX 0x02 -#define SCE_PFX_MESH_FLAG_32BIT_INDEX 0x04 -#define SCE_PFX_MESH_FLAG_AUTO_ELIMINATION 0x08 -#define SCE_PFX_MESH_FLAG_AUTO_THICKNESS 0x10 - -/////////////////////////////////////////////////////////////////////////////// -// Convex Mesh - -struct PfxCreateConvexMeshParam { - PfxUInt32 flag; - PfxFloat *verts; - PfxUInt32 numVerts; - void *triangles; - PfxUInt32 numTriangles; - PfxUInt32 vertexStrideBytes; - PfxUInt32 triangleStrideBytes; - - PfxCreateConvexMeshParam() - { - flag = SCE_PFX_MESH_FLAG_16BIT_INDEX|SCE_PFX_MESH_FLAG_AUTO_ELIMINATION; - verts = NULL; - triangles = NULL; - numVerts = 0; - numTriangles = 0; - vertexStrideBytes = sizeof(PfxFloat)*3; - triangleStrideBytes = sizeof(PfxUInt16)*3; - } -}; - -PfxInt32 pfxCreateConvexMesh(PfxConvexMesh &convex,const PfxCreateConvexMeshParam ¶m); - -/////////////////////////////////////////////////////////////////////////////// -// Large Mesh - -struct PfxCreateLargeTriMeshParam { - PfxUInt32 flag; - PfxFloat *verts; - PfxUInt32 numVerts; - void *triangles; - PfxUInt32 numTriangles; - PfxUInt32 vertexStrideBytes; - PfxUInt32 triangleStrideBytes; - PfxUInt32 numFacetsLimit; - PfxFloat islandsRatio; - PfxFloat defaultThickness; - - PfxCreateLargeTriMeshParam() - { - flag = SCE_PFX_MESH_FLAG_16BIT_INDEX|SCE_PFX_MESH_FLAG_AUTO_ELIMINATION; - verts = NULL; - triangles = NULL; - numVerts = 0; - numTriangles = 0; - vertexStrideBytes = sizeof(PfxFloat)*3; - triangleStrideBytes = sizeof(PfxUInt16)*3; - numFacetsLimit = 15; - islandsRatio = 0.2f; - defaultThickness = 0.025f; - } -}; - -PfxInt32 pfxCreateLargeTriMesh(PfxLargeTriMesh &lmesh,const PfxCreateLargeTriMeshParam ¶m); - -void pfxReleaseLargeTriMesh(PfxLargeTriMesh &lmesh); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_MESH_CREATOR_H diff --git a/Extras/PhysicsEffects/include/physics_effects/util/pfx_util_include.h b/Extras/PhysicsEffects/include/physics_effects/util/pfx_util_include.h deleted file mode 100644 index 0e637b222..000000000 --- a/Extras/PhysicsEffects/include/physics_effects/util/pfx_util_include.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_UTIL_INCLUDE_H -#define _SCE_PFX_UTIL_INCLUDE_H - -/////////////////////////////////////////////////////////////////////////////// -// Physics Effects Utility Headers - -#include "pfx_mass.h" -#include "pfx_mesh_creator.h" - -#endif // _SCE_PFX_UTIL_INCLUDE_H diff --git a/Extras/PhysicsEffects/include/vecmath/neon/boolInVec.h b/Extras/PhysicsEffects/include/vecmath/neon/boolInVec.h deleted file mode 100644 index 7ea380f91..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/boolInVec.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2006-2010 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_SCALAR_H -#define _BOOLINVEC_SCALAR_H - -#include -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 diff --git a/Extras/PhysicsEffects/include/vecmath/neon/floatInVec.h b/Extras/PhysicsEffects/include/vecmath/neon/floatInVec.h deleted file mode 100644 index 1aa2ee1cc..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/floatInVec.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - Copyright (C) 2006-2010 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__SCALAR_H -#define _FLOATINVEC__SCALAR_H - -#include -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 diff --git a/Extras/PhysicsEffects/include/vecmath/neon/mat_aos.h b/Extras/PhysicsEffects/include/vecmath/neon/mat_aos.h deleted file mode 100644 index 32a6bbe43..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/mat_aos.h +++ /dev/null @@ -1,1645 +0,0 @@ -/* - Copyright (C) 2006-2010 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_MAT_AOS_CPP__SCALAR_H -#define _VECTORMATH_MAT_AOS_CPP__SCALAR_H - -// ARA begin insert new code -#include "vectormath_neon_assembly_prototypes.h" -// ARA end - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = ( qx + qx ); - qy2 = ( qy + qy ); - qz2 = ( qz + qz ); - qxqx2 = ( qx * qx2 ); - qxqy2 = ( qx * qy2 ); - qxqz2 = ( qx * qz2 ); - qxqw2 = ( qw * qx2 ); - qyqy2 = ( qy * qy2 ); - qyqz2 = ( qy * qz2 ); - qyqw2 = ( qw * qy2 ); - qzqz2 = ( qz * qz2 ); - qzqw2 = ( qw * qz2 ); - mCol0 = Vector3( ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); - mCol1 = Vector3( ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); - mCol2 = Vector3( ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - float detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = ( 1.0f / dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ), - Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ), - Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ) - ); -} - -inline float determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -// ARA begin insert new code -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - Matrix3 __attribute__((__aligned__((64)))) result; - pfxMatrix3Matrix3ProductNEON(*this, mat, result); - return(result); -} -// ARA end - -// ARA begin insert new code -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - pfxMatrix3Matrix3ProductNEON(*this, mat, *this); - return *this; -} -// ARA end - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix3( - Vector3( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ), - Vector3( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ), - Vector3( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - res0.setX( ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); - res0.setY( ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); - res0.setZ( ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); - res0.setW( ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); - detInv = ( 1.0f / ( ( ( ( mA * res0.getX() ) + ( mE * res0.getY() ) ) + ( mI * res0.getZ() ) ) + ( mM * res0.getW() ) ) ); - res1.setX( ( mI * tmp1 ) ); - res1.setY( ( mM * tmp0 ) ); - res1.setZ( ( mA * tmp1 ) ); - res1.setW( ( mE * tmp0 ) ); - res3.setX( ( mI * tmp3 ) ); - res3.setY( ( mM * tmp2 ) ); - res3.setZ( ( mA * tmp3 ) ); - res3.setW( ( mE * tmp2 ) ); - res2.setX( ( mI * tmp5 ) ); - res2.setY( ( mM * tmp4 ) ); - res2.setZ( ( mA * tmp5 ) ); - res2.setW( ( mE * tmp4 ) ); - tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); - tmp1 = ( ( mM * mF ) - ( mE * mN ) ); - tmp2 = ( ( mI * mD ) - ( mA * mL ) ); - tmp3 = ( ( mM * mH ) - ( mE * mP ) ); - tmp4 = ( ( mI * mC ) - ( mA * mK ) ); - tmp5 = ( ( mM * mG ) - ( mE * mO ) ); - res2.setX( ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.getX() ) ); - res2.setY( ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.getY() ) ); - res2.setZ( ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.getZ() ) ); - res2.setW( ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.getW() ) ); - res3.setX( ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.getX() ) ); - res3.setY( ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.getY() ) ); - res3.setZ( ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.getZ() ) ); - res3.setW( ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.getW() ) ); - res1.setX( ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.getX() ) ); - res1.setY( ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.getY() ) ); - res1.setZ( ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.getZ() ) ); - res1.setW( ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline float determinant( const Matrix4 & mat ) -{ - float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); - dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); - dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); - dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); - return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), - ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), - ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), - ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ), - ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ), - ( ( ( ( mCol0.getW() * pnt.getX() ) + ( mCol1.getW() * pnt.getY() ) ) + ( mCol2.getW() * pnt.getZ() ) ) + mCol3.getW() ) - ); -} - -// ARA begin insert new code -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - Matrix4 __attribute__((__aligned__((64)))) result; - pfxMatrix4Matrix4ProductNEON(*this, mat, result); - return(result); -} -// ARA end - -// ARA begin insert new code -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - pfxMatrix4Matrix4ProductNEON(*this, mat, *this); - return *this; -} -// ARA end - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4::xAxis( ), - Vector4( 0.0f, c, s, 0.0f ), - Vector4( 0.0f, -s, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, 0.0f, -s, 0.0f ), - Vector4::yAxis( ), - Vector4( s, 0.0f, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, s, 0.0f, 0.0f ), - Vector4( -s, c, 0.0f, 0.0f ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix4( - Vector4( ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ), - Vector4( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ), - Vector4( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix4( - Vector4( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ), - Vector4( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ), - Vector4( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, scaleVec.getY(), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, scaleVec.getZ(), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); - rangeInv = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( f / aspect ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, f, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - n2 = ( zNear + zNear ); - return Matrix4( - Vector4( ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ), - Vector4( ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ), - Vector4( ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - float detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = ( 1.0f / dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ); - inv1 = Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ); - inv2 = Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -// ARA begin insert new code -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Transform3 __attribute__((__aligned__((64)))) result; - pfxTransform3OrthoInverseNEON(tfrm, result); - return(result); -} -// ARA end - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -// ARA begin insert new code -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - Vector3 __attribute__((__aligned__((64)))) result; - pfxTransform3Vector3MultiplyNEON(*this, vec, result); - return(result); -} -// ARA end - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Transform3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - int negTrace, ZgtX, ZgtY, YgtX; - int largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = ( ( xx + yy ) + zz ); - - negTrace = ( trace < 0.0f ); - ZgtX = zz > xx; - ZgtY = zz > yy; - YgtX = yy > xx; - largestXorY = ( !ZgtX || !ZgtY ) && negTrace; - largestYorZ = ( YgtX || ZgtX ) && negTrace; - largestZorX = ( ZgtY || !YgtX ) && negTrace; - - if ( largestXorY ) - { - zz = -zz; - xy = -xy; - } - if ( largestYorZ ) - { - xx = -xx; - yz = -yz; - } - if ( largestZorX ) - { - yy = -yy; - zx = -zx; - } - - radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); - scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); - - tmpx = ( ( zy - yz ) * scale ); - tmpy = ( ( xz - zx ) * scale ); - tmpz = ( ( yx - xy ) * scale ); - tmpw = ( radicand * scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - if ( largestXorY ) - { - qx = tmpw; - qy = tmpz; - qz = tmpy; - qw = tmpx; - } - if ( largestYorZ ) - { - tmpx = qx; - tmpz = qz; - qx = qy; - qy = tmpx; - qz = qw; - qw = tmpz; - } - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - ( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ), - ( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ), - ( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( 0.0f, vec.getZ(), -vec.getY() ), - Vector3( -vec.getZ(), 0.0f, vec.getX() ), - Vector3( vec.getY(), -vec.getX(), 0.0f ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/neon/quat_aos.h b/Extras/PhysicsEffects/include/vecmath/neon/quat_aos.h deleted file mode 100644 index 6a4a0f212..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/quat_aos.h +++ /dev/null @@ -1,446 +0,0 @@ -/* - Copyright (C) 2006-2010 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 { - -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 diff --git a/Extras/PhysicsEffects/include/vecmath/neon/vec_aos.h b/Extras/PhysicsEffects/include/vecmath/neon/vec_aos.h deleted file mode 100644 index 3772deab3..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/vec_aos.h +++ /dev/null @@ -1,1526 +0,0 @@ -/* - Copyright (C) 2006-2010 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H - -// ARA begin insert new code -#include "vectormath_neon_assembly_prototypes.h" -// ARA end - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Aos { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Vector3::Vector3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( 1.0f, 0.0f, 0.0f ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( 0.0f, 1.0f, 0.0f ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( 0.0f, 0.0f, 1.0f ); -} - -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZ( Vector3 & vec, const float * fptr ) -{ - vec = Vector3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Vector3 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - ( mX + pnt.getX() ), - ( mY + pnt.getY() ), - ( mZ + pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return Vector3( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return Vector3( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - -mX, - -mY, - -mZ - ); -} - -inline const Vector3 operator *( float scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float maxElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float minElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - return result; -} - -inline float sum( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - return result; -} - -// ARA begin insert new code -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ -#if 1 // pure assembly - - float __attribute__((__aligned__((64)))) result[2]; // space for 2 floats since neon vst1.32 wants to store a double register - pfxVector3DotProductNEON(vec0, vec1, result); - return(result[0]); - -#else // inline assembly - // Note that this inline assembly does NOT work correctly though it is *identical* to the dedicated assembly - // version and has (in theory) properly assigned register constraints and clobbers. In fact, it produces a - // correct numerical result, but gcc seems to not properly manage registers and this causes trouble downstream. - // Forum discussions indicate gcc is not great at supporting inline assembly using NEON registers. Even the - // two different but theoretically equivalent clobber lists produce different simulation results! - float __attribute__((__aligned__((64)))) result[2]; // space for 2 floats since neon vst1.32 wants to store a double register - asm volatile - ( - // Note this code is explicitly using register q0-q2 (and corresponding d/s registers) - // so that we can avoid the need to preserve them. We are applying instructions directly - // to s registers, which prevents us from using q8 and above, and would rather not - // use registers that gcc expects us to preserve, to avoid the cost of doing that. - "vld1.32 {d0,d1}, [%1] @ input = d0,d1\n\t" - "vld1.32 {d2,d3}, [%0] @ input = d2,d3\n\t" - "vmul.f32 d4, d0, d2 @ d4 = \n\t" - "vpadd.f32 d4, d4, d4 @ d4 = \n\t" - "vmla.f32 s8, s2, s6 @ s8 = = d18,d19\n\t" - "vld1.32 {d16,d17}, [%0] @ input = d16,d17\n\t" - "vtrn.32 d18,d19 @ q9 = = d18,d19\n\t" - "vrev64.32 d16,d16 @ q8 = = d16,d17\n\t" - "vrev64.32 d18,d18 @ q9 = = d18,d19\n\t" - "vtrn.32 d16,d17 @ q8 = = d16,d17\n\t" - "vmul.f32 q10, q8, q9 @ q10 = \n\t" - "vtrn.32 d18,d19 @ q9 = = d18,d19\n\t" - "vrev64.32 d16,d16 @ q8 = = d16,d17\n\t" - "vrev64.32 d18,d18 @ q9 = = d18,d19\n\t" - "vtrn.32 d16,d17 @ q8 = = d16,d17\n\t" - "vmls.f32 q10, q8, q9 @ q10 = \n\t" - "vst1.32 {q10}, [%2]\n\t" - : // NO explicit outputs! - : "r" (&vec0), "r" (&vec1), "r" (&result) //inputs. output indirectly stored in result - : "memory", "q8", "q9", "q10" // clobbers - ); - return result; -#endif -} -// ARA end - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ) -{ - return Vector3( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, float _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = 0.0f; -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = 1.0f; -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( 1.0f, 0.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( 0.0f, 1.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( 0.0f, 0.0f, 1.0f, 0.0f ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZW( Vector4 & vec, const float * fptr ) -{ - vec = Vector4( fptr[0], fptr[1], fptr[2], fptr[3] ); -} - -inline void storeXYZW( const Vector4 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); - fptr[3] = vec.getW(); -} - -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( float _w ) -{ - mW = _w; - return *this; -} - -inline float Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ), - ( mW + vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ), - ( mW - vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return Vector4( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ), - ( mW * scalar ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return Vector4( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ), - ( mW / scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - -mX, - -mY, - -mZ, - -mW - ); -} - -inline const Vector4 operator *( float scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ), - ( vec0.getW() * vec1.getW() ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ), - ( vec0.getW() / vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ), - ( 1.0f / vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ), - sqrtf( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ), - ( 1.0f / sqrtf( vec.getW() ) ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ), - fabsf( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ), - ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float maxElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - result = (vec.getW() > result)? vec.getW() : result; - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float minElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - result = (vec.getW() < result)? vec.getW() : result; - return result; -} - -inline float sum( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - result = ( result + vec.getW() ); - return result; -} - -// ARA begin insert new code -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - float __attribute__((__aligned__((64)))) result[2]; // space for 2 floats since neon vst1.32 wants to store a double register - pfxVector4DotProductNEON(vec0, vec1, result); - return(result[0]); -} -// ARA end - -inline float lengthSqr( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - result = ( result + ( vec.getW() * vec.getW() ) ); - return result; -} - -inline float length( const Vector4 & vec ) -{ - return ::sqrtf( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector4( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ), - ( vec.getW() * lenInv ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ) -{ - return Vector4( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ(), - ( select1 )? vec1.getW() : vec0.getW() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Point3::Point3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline Point3::Point3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -// ARA begin insert new code - d = 0.0f; -// ARA end -} - -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline void loadXYZ( Point3 & pnt, const float * fptr ) -{ - pnt = Point3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Point3 & pnt, float * fptr ) -{ - fptr[0] = pnt.getX(); - fptr[1] = pnt.getY(); - fptr[2] = pnt.getZ(); -} - -inline void loadHalfFloats( Point3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Point3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - ( mX - pnt.mX ), - ( mY - pnt.mY ), - ( mZ - pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - ( mX + vec.getX() ), - ( mY + vec.getY() ), - ( mZ + vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - ( mX - vec.getX() ), - ( mY - vec.getY() ), - ( mZ - vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() * pnt1.getX() ), - ( pnt0.getY() * pnt1.getY() ), - ( pnt0.getZ() * pnt1.getZ() ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() / pnt1.getX() ), - ( pnt0.getY() / pnt1.getY() ), - ( pnt0.getZ() / pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / pnt.getX() ), - ( 1.0f / pnt.getY() ), - ( 1.0f / pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf( pnt.getX() ), - sqrtf( pnt.getY() ), - sqrtf( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / sqrtf( pnt.getX() ) ), - ( 1.0f / sqrtf( pnt.getY() ) ), - ( 1.0f / sqrtf( pnt.getZ() ) ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf( pnt.getX() ), - fabsf( pnt.getY() ), - fabsf( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ), - ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ), - ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float maxElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() > result)? pnt.getZ() : result; - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float minElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() < result)? pnt.getZ() : result; - return result; -} - -inline float sum( const Point3 & pnt ) -{ - float result; - result = ( pnt.getX() + pnt.getY() ); - result = ( result + pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, float scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline float projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - float result; - result = ( pnt.getX() * unitVec.getX() ); - result = ( result + ( pnt.getY() * unitVec.getY() ) ); - result = ( result + ( pnt.getZ() * unitVec.getZ() ) ); - return result; -} - -inline float distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline float distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ) -{ - return Point3( - ( select1 )? pnt1.getX() : pnt0.getX(), - ( select1 )? pnt1.getY() : pnt0.getY(), - ( select1 )? pnt1.getZ() : pnt0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_aos.h b/Extras/PhysicsEffects/include/vecmath/neon/vectormath_aos.h deleted file mode 100644 index d884e8727..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_aos.h +++ /dev/null @@ -1,1893 +0,0 @@ -/* - 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_AOS_CPP_SCALAR_H -#define _VECTORMATH_AOS_CPP_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - float mX; - float mY; - float mZ; -// ARA begin code change -// Removed #ifndef __GNUC__ condition - float d; -// ARA end - -public: - // Default constructor; does no initialization - // - // ARA begin insert new code - // Added explicit initialization of d = 0.0f; - inline Vector3( ) { d = 0.0f; }; - // ARA end - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Get the x element of a 3-D vector - // - inline float getX( ) const; - - // Get the y element of a 3-D vector - // - inline float getY( ) const; - - // Get the z element of a 3-D vector - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline float maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline float minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline float sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline float lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline float length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Vector3 & vec, const float * fptr ); - -// Store x, y, and z elements of a 3-D vector in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Vector3 & vec, float * fptr ); - -// Load three-half-floats as a 3-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ); - -// Store a 3-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, float w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Get the x element of a 4-D vector - // - inline float getX( ) const; - - // Get the y element of a 4-D vector - // - inline float getY( ) const; - - // Get the z element of a 4-D vector - // - inline float getZ( ) const; - - // Get the w element of a 4-D vector - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline float maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline float minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline float sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline float lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline float length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Vector4 & vec, const float * fptr ); - -// Store x, y, z, and w elements of a 4-D vector in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Vector4 & vec, float * fptr ); - -// Load four-half-floats as a 4-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ); - -// Store a 4-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - float mX; - float mY; - float mZ; -// ARA begin code change -// Removed #ifndef __GNUC__ condition - float d; -// ARA end - -public: - // Default constructor; does no initialization - // - // ARA begin insert new code - // Added explicit initialization of d = 0.0f; - inline Point3( ) { d = 0.0f; }; - // ARA end - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Get the x element of a 3-D point - // - inline float getX( ) const; - - // Get the y element of a 3-D point - // - inline float getY( ) const; - - // Get the z element of a 3-D point - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline float maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline float minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline float sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, float scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline float projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline float distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline float distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Point3 & pnt, const float * fptr ); - -// Store x, y, and z elements of a 3-D point in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Point3 & pnt, float * fptr ); - -// Load three-half-floats as a 3-D point -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Point3 & pnt, const unsigned short * hfptr ); - -// Store a 3-D point as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Point3 & pnt, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, float w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Get the x element of a quaternion - // - inline float getX( ) const; - - // Get the y element of a quaternion - // - inline float getY( ) const; - - // Get the z element of a quaternion - // - inline float getZ( ) const; - - // Get the w element of a quaternion - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline float dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline float norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline float length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// -inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Quat & quat, const float * fptr ); - -// Store x, y, z, and w elements of a quaternion in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Quat & quat, float * fptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline float determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline float determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_implementations.S b/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_implementations.S deleted file mode 100644 index c4c6d121c..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_implementations.S +++ /dev/null @@ -1,310 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ -@---------------------------------------------------------------- -@ -@ This file contains ARM/NEON assembly versions of some vectormath -@ atomic functions. We have implemented here instead of inline assembly -@ because we have found gcc 4.4.3 to be too inconsistent and inadequate -@ to properly support either NEON intrinsics or inline assembly. (See -@ the inline assembly version of the vector3 dot product, which is -@ contained in vec_aos.h but compiled out, for an example of a simple -@ inline assembly function that wreaks havok if used.) -@ -@ Note that the certain NEON registers must be preserved across -@ function calls according to the following document: -@ -@ "Procedure Call Standard for the ARM? Architecture," ARM document -@ number ARM IHI 0042D, current through ABI release 2.08, -@ 16th October, 2009, section 5.1.2.1 -@ -@ The registers are: q4-q7 (and their double-word and single word -@ counterparts) -@ -@ These functions preserve all non-scratch general purpose registers -@ as well as the ones listed, and so we do not need to have extra -@ code to do the register preservation -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@---------------------------------------------------------------- -@ pfxVector3DotProductNEON -@ -@ Vector3 dot product, result stored directly to memory -@ -@ Result stored in memory pointed to by r2. r2 must point to -@ memory sufficient to store two 32 bit floats, though only the -@ first value is of interest -@---------------------------------------------------------------- - .global pfxVector3DotProductNEON - .thumb_func -pfxVector3DotProductNEON: - .fnstart - vld1.32 {d0,d1}, [r1] @ input = d0,d1\n\t" - vld1.32 {d2,d3}, [r0] @ input = d2,d3\n\t" - vmul.f32 d4, d0, d2 @ d4 = \n\t" - vpadd.f32 d4, d4, d4 @ d4 = \n\t" - vmla.f32 s8, s2, s6 @ s8 = - vld1.32 {d18,d19}, [r1] @ input - vmul.f32 d14, d16, d18 @ d14= - @ non-fused multiple accumulate - vmla.f32 d14, d17, d19 @ d14=d14+= - @ fused multiple accumulate - listed here for reference but we use vmla above - @ instead since the fused version is not recognized by GNU assembler (as part - @ of the gcc 4.4.3 Android distribution) - @ vfma.f32 {d14}, d17, d19 @ d14=d14+= - vpadd.f32 d14, d14, d14 @ add the two halves of d14 together, same result in each lane - vst1.32 {d14}, [r2] - bx lr - .fnend - -@---------------------------------------------------------------- -@ pfxVector3CrossProductNEON -@ -@ Vector3 cross product, result stored directly to memory -@ -@ Result stored in memory pointed to by r2. r2 must point to -@ memory sufficient to store four 32 bit floats, though only the -@ first 3 values are of interest -@---------------------------------------------------------------- - .global pfxVector3CrossProductNEON - .thumb_func -pfxVector3CrossProductNEON: - .fnstart - vld1.32 {d18,d19}, [r1] @ input = d18,d19 - vld1.32 {d16,d17}, [r0] @ input = d16,d17 - @ rearrange inputs into convenient order - vtrn.32 d18,d19 @ q9 = = d18,d19 - vrev64.32 d16,d16 @ q8 = = d16,d17 - vrev64.32 d18,d18 @ q9 = = d18,d19 - vtrn.32 d16,d17 @ q8 = = d16,d17 - @ perform first half of cross product using rearranged inputs - vmul.f32 q10, q8, q9 @ q10 = - @ rearrange inputs again - vtrn.32 d18,d19 @ q9 = = d18,d19 - vrev64.32 d16,d16 @ q8 = = d16,d17 - vrev64.32 d18,d18 @ q9 = = d18,d19 - vtrn.32 d16,d17 @ q8 = = d16,d17 - @ perform last half of cross product using rearranged inputs - vmls.f32 q10, q8, q9 @ q10 = - @ and store the result - vst1.32 {q10}, [r2] - bx lr - .fnend - -@---------------------------------------------------------------- -@ pfxMatrix3Matrix3ProductNEON -@ -@ Matrix3 * Matrix3 product, result stored directly to memory -@ -@ Result stored in memory pointed to by r2. r2 must point to -@ memory sufficient to store 12 32-bit floats. The reason for -@ 12 rather than 9 is that each column vector actually has -@ 4 32-bit floats rather than just 3....since NEON works with -@ double and quad vectors. -@ -@ Note that, since the inputs are loaded into registers then -@ never used again, r2 can point to one of the inputs, e.g., -@ result can be stored back out to one of the input memory -@ locations. -@---------------------------------------------------------------- - .global pfxMatrix3Matrix3ProductNEON - .thumb_func -pfxMatrix3Matrix3ProductNEON: - .fnstart - vld1.32 {d16-d19}, [r0]! @ load first eight elements of matrix 0 - vld1.32 {d20-d21}, [r0] @ load second eight elements of matrix 0 - vld1.32 {d0-d3}, [r1]! @ load first eight elements of matrix 1 - vld1.32 {d4-d5}, [r1] @ load second eight elements of matrix 1 - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmul.f32 q13, q8, d2[0] @ rslt col1 = (mat0 col0) * (mat1 col1 elt0) - vmul.f32 q14, q8, d4[0] @ rslt col2 = (mat0 col0) * (mat1 col2 elt0) - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q13, q9, d2[1] @ rslt col1 += (mat0 col1) * (mat1 col1 elt1) - vmla.f32 q14, q9, d4[1] @ rslt col2 += (mat0 col1) * (mat1 col2 elt1) - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vmla.f32 q13, q10, d3[0] @ rslt col1 += (mat0 col2) * (mat1 col1 elt2) - vmla.f32 q14, q10, d5[0] @ rslt col2 += (mat0 col2) * (mat1 col2 elt2) - vst1.32 {d24-d27}, [r2]! @ store first eight elements of result (each column has an extra float as stored) - vst1.32 {d28-d29}, [r2] @ store last four elements of result (each column has an extra float as stored) - bx lr - .fnend - -@---------------------------------------------------------------- -@ pfxMatrix4Matrix4ProductNEON -@ -@ Matrix4 * Matrix4 product, result stored directly to memory -@ -@ Result stored in memory pointed to by r2. r2 must point to -@ memory sufficient to store 16 32 bit floats. -@ -@ Note that, since the inputs are loaded into registers then -@ never used again, r2 can point to one of the inputs, e.g., -@ result can be stored back out to one of the input memory -@ locations. -@---------------------------------------------------------------- - .global pfxMatrix4Matrix4ProductNEON - .thumb_func -pfxMatrix4Matrix4ProductNEON: - .fnstart - vld1.32 {d16-d19}, [r0]! @ load first eight elements of matrix 0 - vld1.32 {d20-d23}, [r0] @ load second eight elements of matrix 0 - vld1.32 {d0-d3}, [r1]! @ load first eight elements of matrix 1 - vld1.32 {d4-d7}, [r1] @ load second eight elements of matrix 1 - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmul.f32 q13, q8, d2[0] @ rslt col1 = (mat0 col0) * (mat1 col1 elt0) - vmul.f32 q14, q8, d4[0] @ rslt col2 = (mat0 col0) * (mat1 col2 elt0) - vmul.f32 q15, q8, d6[0] @ rslt col3 = (mat0 col0) * (mat1 col3 elt0) - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q13, q9, d2[1] @ rslt col1 += (mat0 col1) * (mat1 col1 elt1) - vmla.f32 q14, q9, d4[1] @ rslt col2 += (mat0 col1) * (mat1 col2 elt1) - vmla.f32 q15, q9, d6[1] @ rslt col3 += (mat0 col1) * (mat1 col3 elt1) - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vmla.f32 q13, q10, d3[0] @ rslt col1 += (mat0 col2) * (mat1 col1 elt2) - vmla.f32 q14, q10, d5[0] @ rslt col2 += (mat0 col2) * (mat1 col2 elt2) - vmla.f32 q15, q10, d7[0] @ rslt col3 += (mat0 col2) * (mat1 col2 elt2) - vmla.f32 q12, q11, d1[1] @ rslt col0 += (mat0 col3) * (mat1 col0 elt3) - vmla.f32 q13, q11, d3[1] @ rslt col1 += (mat0 col3) * (mat1 col1 elt3) - vmla.f32 q14, q11, d5[1] @ rslt col2 += (mat0 col3) * (mat1 col2 elt3) - vmla.f32 q15, q11, d7[1] @ rslt col3 += (mat0 col3) * (mat1 col3 elt3) - vst1.32 {d24-d27}, [r2]! @ store first eight elements of result - vst1.32 {d28-d31}, [r2] @ store second eight elements of result - bx lr - .fnend - -@---------------------------------------------------------------- -@ pfxTransform3OrthoInverseNEON -@ -@ Computes the ortho inverse of a Transform 3. -@ -@ Result stored in memory pointed to by r1. r1 must point to -@ memory sufficient to store 16 32 bit floats. -@ -@ Note that, since the inputs are loaded into registers then -@ never used again, r1 can point to one of the inputs, e.g., -@ result can be stored back out to one of the input memory -@ locations. -@ -@ Note that this expects the inputs to have 4 floats per row, -@ (to be consistent with NEON quad vector), and the last float -@ in each row should be 0.0 for the math to work out. -@---------------------------------------------------------------- - .global pfxTransform3OrthoInverseNEON - .thumb_func -pfxTransform3OrthoInverseNEON: - .fnstart - @ direct load the first column of the ortho inverse result - vld1.f32 d0[0], [r0]! - vld1.f32 d2[0], [r0]! - vld1.f32 d4[0], [r0]! - vld1.f32 d1[1], [r0]! - - @ direct load the second column of the ortho inverse result - vld1.f32 d0[1], [r0]! - vld1.f32 d2[1], [r0]! - vld1.f32 d4[1], [r0]! - vld1.f32 d3[1], [r0]! - - @ direct load the third column of the ortho inverse result - vld1.f32 d1[0], [r0]! - vld1.f32 d3[0], [r0]! - - vst1.f32 {d0-d3}, [r1]! @ store first eight elements of result (1st two columns) - - vld1.f32 d5[0], [r0]! - vld1.f32 d5[1], [r0]! - - vst1.f32 {d4-d5}, [r1]! @ store next four elements of result (3rd column) - - @ move q0 into q8 so we can reuse q0 to load fourth column - @ of input. We do this to avoid using q4-q7 (which have to - @ be preserved during the function call)....needed to work - @ around some limitation rules that prevent us from accessing - @ single s registers associated with q8 and above. - vmov.f32 q8, q0 - - @ direct load the last column of the input - vld1.f32 {q0}, [r0] - - @ prepare the last column of the output - vmul.f32 q3, q8, d0[0] @ multiply result column 1 by x coord of input column 3 - vmla.f32 q3, q1, d0[1] @ multiply result column 2 by y coord of input column 3 and add - vmla.f32 q3, q2, d1[0] @ multiply result column 3 by z coord of input column 3 and add - vneg.f32 q3, q3 @ negate final column - - vst1.f32 {q3}, [r1] @ store last four elements of result (4th column) - - bx lr - .fnend - -@---------------------------------------------------------------- -@ pfxTransform3Vector3MultiplyNEON -@ -@ Computes the product of a Transform3 and a Vector3, e.g., it -@ applies the transform to the vector. -@ -@ Result stored in memory pointed to by r2. r2 must point to -@ memory sufficient to store 4 32-bit floats. -@---------------------------------------------------------------- - .global pfxTransform3Vector3MultiplyNEON - .thumb_func -pfxTransform3Vector3MultiplyNEON: - .fnstart - - vld1.32 {d16-d19}, [r0]! @ load first eight elements of transform matrix - vld1.32 {d20-d21}, [r0] @ load second eight elements of transform matrix - vld1.32 {d0-d1}, [r1] @ load the four elements of vector3 (last one is just padding) - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vst1.32 {d24-d25}, [r2] @ store four elements of result (last one is padding) - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_prototypes.h b/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_prototypes.h deleted file mode 100644 index e3a9286d2..000000000 --- a/Extras/PhysicsEffects/include/vecmath/neon/vectormath_neon_assembly_prototypes.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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_NEON_ASSEMBLY_PROTOTYPES_H -#define _VECTORMATH_NEON_ASSEMBLY_PROTOTYPES_H - -// Prototypes for NEON assembly implementations -extern "C" -{ - // NEON assembly implementations of Vector3 functions - void pfxVector3DotProductNEON(const Vectormath::Aos::Vector3 &vec0, const Vectormath::Aos::Vector3 &vec1, float *result); - void pfxVector3CrossProductNEON(const Vectormath::Aos::Vector3 &vec0, const Vectormath::Aos::Vector3 &vec1, - Vectormath::Aos::Vector3 &result); - - // NEON assembly implementations of Matrix3 functions - void pfxMatrix3Matrix3ProductNEON(const Vectormath::Aos::Matrix3 &mat0, const Vectormath::Aos::Matrix3 &mat1, - Vectormath::Aos::Matrix3 &result); - - // NEON assembly implementations of Transform3 functions - void pfxTransform3OrthoInverseNEON(const Vectormath::Aos::Transform3 &trn, Vectormath::Aos::Transform3 &result); - void pfxTransform3Vector3MultiplyNEON(const Vectormath::Aos::Transform3 &trn, const Vectormath::Aos::Vector3 &vec, - Vectormath::Aos::Vector3 &result); - - // NEON assembly implementations of Vector4 functions - void pfxVector4DotProductNEON(const Vectormath::Aos::Vector4 &vec0, const Vectormath::Aos::Vector4 &vec1, float *result); - - // NEON assembly implementations of Matrix4 functions - void pfxMatrix4Matrix4ProductNEON(const Vectormath::Aos::Matrix4 &mat0, const Vectormath::Aos::Matrix4 &mat1, - Vectormath::Aos::Matrix4 &result); -} - -#endif // _VECTORMATH_NEON_ASSEMBLY_PROTOTYPES_H diff --git a/Extras/PhysicsEffects/include/vecmath/sse/boolInVec.h b/Extras/PhysicsEffects/include/vecmath/sse/boolInVec.h deleted file mode 100644 index d18cb15ce..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/boolInVec.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - 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 - -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 diff --git a/Extras/PhysicsEffects/include/vecmath/sse/floatInVec.h b/Extras/PhysicsEffects/include/vecmath/sse/floatInVec.h deleted file mode 100644 index 6443865b1..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/floatInVec.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - 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 -#include - -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 diff --git a/Extras/PhysicsEffects/include/vecmath/sse/mat_aos.h b/Extras/PhysicsEffects/include/vecmath/sse/mat_aos.h deleted file mode 100644 index fe6aa62b9..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/mat_aos.h +++ /dev/null @@ -1,2190 +0,0 @@ -/* - 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_MAT_AOS_CPP_H -#define _VECTORMATH_MAT_AOS_CPP_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) -#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) -#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -VECTORMATH_FORCE_INLINE Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -VECTORMATH_FORCE_INLINE Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -VECTORMATH_FORCE_INLINE Matrix3::Matrix3( const floatInVec &scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -VECTORMATH_FORCE_INLINE Matrix3::Matrix3( const Quat &unitQuat ) -{ - __m128 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - VM_ATTRIBUTE_ALIGN16 unsigned int sx[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int sz[4] = {0, 0, 0xffffffff, 0}; - __m128 select_x = _mm_load_ps((float *)sx); - __m128 select_z = _mm_load_ps((float *)sz); - - xyzw_2 = _mm_add_ps( unitQuat.get128(), unitQuat.get128() ); - wwww = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,3,3,3) ); - yzxw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,0,2,1) ); - zxyw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,1,0,2) ); - yzxw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,0,2,1) ); - zxyw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,1,0,2) ); - - tmp0 = _mm_mul_ps( yzxw_2, wwww ); // tmp0 = 2yw, 2zw, 2xw, 2w2 - tmp1 = _mm_sub_ps( _mm_set1_ps(1.0f), _mm_mul_ps(yzxw, yzxw_2) ); // tmp1 = 1 - 2y2, 1 - 2z2, 1 - 2x2, 1 - 2w2 - tmp2 = _mm_mul_ps( yzxw, xyzw_2 ); // tmp2 = 2xy, 2yz, 2xz, 2w2 - tmp0 = _mm_add_ps( _mm_mul_ps(zxyw, xyzw_2), tmp0 ); // tmp0 = 2yw + 2zx, 2zw + 2xy, 2xw + 2yz, 2w2 + 2w2 - tmp1 = _mm_sub_ps( tmp1, _mm_mul_ps(zxyw, zxyw_2) ); // tmp1 = 1 - 2y2 - 2z2, 1 - 2z2 - 2x2, 1 - 2x2 - 2y2, 1 - 2w2 - 2w2 - tmp2 = _mm_sub_ps( tmp2, _mm_mul_ps(zxyw_2, wwww) ); // tmp2 = 2xy - 2zw, 2yz - 2xw, 2xz - 2yw, 2w2 -2w2 - - tmp3 = vec_sel( tmp0, tmp1, select_x ); - tmp4 = vec_sel( tmp1, tmp2, select_x ); - tmp5 = vec_sel( tmp2, tmp0, select_x ); - mCol0 = Vector3( vec_sel( tmp3, tmp2, select_z ) ); - mCol1 = Vector3( vec_sel( tmp4, tmp0, select_z ) ); - mCol2 = Vector3( vec_sel( tmp5, tmp1, select_z ) ); -} - -VECTORMATH_FORCE_INLINE Matrix3::Matrix3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setCol0( const Vector3 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setCol1( const Vector3 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setCol2( const Vector3 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setCol( int col, const Vector3 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setRow( int row, const Vector3 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::setElem( int col, int row, const floatInVec &val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 transpose( const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, res0, res1, res2; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - res0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - //res1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - res1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - res1 = vec_sel(res1, mat.getCol1().get128(), select_y); - //res2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - res2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - res2 = vec_sel(res2, vec_splat(mat.getCol1().get128(), 2), select_y); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 inverse( const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); - tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); - tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); - dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tmp1, select_y); - //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); - inv0 = vec_mul( inv0, invdet ); - inv1 = vec_mul( inv1, invdet ); - inv2 = vec_mul( inv2, invdet ); - return Matrix3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ) - ); -} - -VECTORMATH_FORCE_INLINE const floatInVec determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator *( const floatInVec &scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return floatInVec(scalar) * mat; -} - -VECTORMATH_FORCE_INLINE const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix3::operator *( const Vector3 &vec ) const -{ - __m128 res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_mul( mCol0.get128(), xxxx ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Matrix3( - Vector3( vec_mul( Z0, Y0 ) ), - Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); - axisS = vec_mul( axis, s ); - negAxisS = negatef4( axisS ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); - tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); - //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); - //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); - tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); - tmp0 = vec_sel( tmp0, c, select_x ); - tmp1 = vec_sel( tmp1, c, select_y ); - tmp2 = vec_sel( tmp2, c, select_z ); - return Matrix3( - Vector3( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector3( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector3( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::rotation( const Quat &unitQuat ) -{ - return Matrix3( unitQuat ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix3::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Matrix3( - Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -VECTORMATH_FORCE_INLINE void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const floatInVec &scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const Vector4 &_col0, const Vector4 &_col1, const Vector4 &_col2, const Vector4 &_col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const Matrix3 & mat, const Vector3 &translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -VECTORMATH_FORCE_INLINE Matrix4::Matrix4( const Quat &unitQuat, const Vector3 &translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setCol0( const Vector4 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setCol1( const Vector4 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setCol2( const Vector4 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setCol3( const Vector4 &_col3 ) -{ - mCol3 = _col3; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setCol( int col, const Vector4 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setRow( int row, const Vector4 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setElem( int col, int row, const floatInVec &val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix4 transpose( const Matrix4 & mat ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergeh( mat.getCol1().get128(), mat.getCol3().get128() ); - tmp2 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp3 = vec_mergel( mat.getCol1().get128(), mat.getCol3().get128() ); - res0 = vec_mergeh( tmp0, tmp1 ); - res1 = vec_mergel( tmp0, tmp1 ); - res2 = vec_mergeh( tmp2, tmp3 ); - res3 = vec_mergel( tmp2, tmp3 ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4( res2 ), - Vector4( res3 ) - ); -} - -// TODO: Tidy -static VM_ATTRIBUTE_ALIGN16 const unsigned int _vmathPNPN[4] = {0x00000000, 0x80000000, 0x00000000, 0x80000000}; -static VM_ATTRIBUTE_ALIGN16 const unsigned int _vmathNPNP[4] = {0x80000000, 0x00000000, 0x80000000, 0x00000000}; -static VM_ATTRIBUTE_ALIGN16 const float _vmathZERONE[4] = {1.0f, 0.0f, 0.0f, 1.0f}; - -VECTORMATH_FORCE_INLINE const Matrix4 inverse( const Matrix4 & mat ) -{ - __m128 Va,Vb,Vc; - __m128 r1,r2,r3,tt,tt2; - __m128 sum,Det,RDet; - __m128 trns0,trns1,trns2,trns3; - - __m128 _L1 = mat.getCol0().get128(); - __m128 _L2 = mat.getCol1().get128(); - __m128 _L3 = mat.getCol2().get128(); - __m128 _L4 = mat.getCol3().get128(); - // Calculating the minterms for the first line. - - // _mm_ror_ps is just a macro using _mm_shuffle_ps(). - tt = _L4; tt2 = _mm_ror_ps(_L3,1); - Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3'dot V4 - Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3'dot V4" - Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3' dot V4^ - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3" dot V4^ - V3^ dot V4" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^ dot V4' - V3' dot V4^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3' dot V4" - V3" dot V4' - - tt = _L2; - Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); - Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); - Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); - - // Calculating the determinant. - Det = _mm_mul_ps(sum,_L1); - Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); - - const __m128 Sign_PNPN = _mm_load_ps((float *)_vmathPNPN); - const __m128 Sign_NPNP = _mm_load_ps((float *)_vmathNPNP); - - __m128 mtL1 = _mm_xor_ps(sum,Sign_PNPN); - - // Calculating the minterms of the second line (using previous results). - tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL2 = _mm_xor_ps(sum,Sign_NPNP); - - // Testing the determinant. - Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); - - // Calculating the minterms of the third line. - tt = _mm_ror_ps(_L1,1); - Va = _mm_mul_ps(tt,Vb); // V1' dot V2" - Vb = _mm_mul_ps(tt,Vc); // V1' dot V2^ - Vc = _mm_mul_ps(tt,_L2); // V1' dot V2 - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V1" dot V2^ - V1^ dot V2" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V1^ dot V2' - V1' dot V2^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V1' dot V2" - V1" dot V2' - - tt = _mm_ror_ps(_L4,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL3 = _mm_xor_ps(sum,Sign_PNPN); - - // Dividing is FASTER than rcp_nr! (Because rcp_nr causes many register-memory RWs). - RDet = _mm_div_ss(_mm_load_ss((float *)&_vmathZERONE), Det); // TODO: just 1.0f? - RDet = _mm_shuffle_ps(RDet,RDet,0x00); - - // Devide the first 12 minterms with the determinant. - mtL1 = _mm_mul_ps(mtL1, RDet); - mtL2 = _mm_mul_ps(mtL2, RDet); - mtL3 = _mm_mul_ps(mtL3, RDet); - - // Calculate the minterms of the forth line and devide by the determinant. - tt = _mm_ror_ps(_L3,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL4 = _mm_xor_ps(sum,Sign_NPNP); - mtL4 = _mm_mul_ps(mtL4, RDet); - - // Now we just have to transpose the minterms matrix. - trns0 = _mm_unpacklo_ps(mtL1,mtL2); - trns1 = _mm_unpacklo_ps(mtL3,mtL4); - trns2 = _mm_unpackhi_ps(mtL1,mtL2); - trns3 = _mm_unpackhi_ps(mtL3,mtL4); - _L1 = _mm_movelh_ps(trns0,trns1); - _L2 = _mm_movehl_ps(trns1,trns0); - _L3 = _mm_movelh_ps(trns2,trns3); - _L4 = _mm_movehl_ps(trns3,trns2); - - return Matrix4( - Vector4( _L1 ), - Vector4( _L2 ), - Vector4( _L3 ), - Vector4( _L4 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec determinant( const Matrix4 & mat ) -{ - __m128 Va,Vb,Vc; - __m128 r1,r2,r3,tt,tt2; - __m128 sum,Det; - - __m128 _L1 = mat.getCol0().get128(); - __m128 _L2 = mat.getCol1().get128(); - __m128 _L3 = mat.getCol2().get128(); - __m128 _L4 = mat.getCol3().get128(); - // Calculating the minterms for the first line. - - // _mm_ror_ps is just a macro using _mm_shuffle_ps(). - tt = _L4; tt2 = _mm_ror_ps(_L3,1); - Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3' dot V4 - Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3' dot V4" - Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3' dot V4^ - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3" dot V4^ - V3^ dot V4" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^ dot V4' - V3' dot V4^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3' dot V4" - V3" dot V4' - - tt = _L2; - Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); - Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); - Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); - - // Calculating the determinant. - Det = _mm_mul_ps(sum,_L1); - Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); - - // Calculating the minterms of the second line (using previous results). - tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - - // Testing the determinant. - Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); - return floatInVec(Det, 0); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator *( const floatInVec &scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return floatInVec(scalar) * mat; -} - -VECTORMATH_FORCE_INLINE const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::operator *( const Vector4 &vec ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2))), _mm_mul_ps(mCol3.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(3,3,3,3))))) - ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::operator *( const Vector3 &vec ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2)))) - ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Matrix4::operator *( const Point3 &pnt ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(2,2,2,2))), mCol3.get128())) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -VECTORMATH_FORCE_INLINE Matrix4 & Matrix4::setTranslation( const Vector3 &translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4::xAxis( ), - Vector4( res1 ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4( res0 ), - Vector4::yAxis( ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Matrix4( - Vector4( vec_mul( Z0, Y0 ) ), - Vector4( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector4( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); - axisS = vec_mul( axis, s ); - negAxisS = negatef4( axisS ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); - tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); - //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); - //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); - tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); - tmp0 = vec_sel( tmp0, c, select_x ); - tmp1 = vec_sel( tmp1, c, select_y ); - tmp2 = vec_sel( tmp2, c, select_z ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - axis = vec_and( axis, _mm_load_ps( (float *)select_xyz ) ); - tmp0 = vec_and( tmp0, _mm_load_ps( (float *)select_xyz ) ); - tmp1 = vec_and( tmp1, _mm_load_ps( (float *)select_xyz ) ); - tmp2 = vec_and( tmp2, _mm_load_ps( (float *)select_xyz ) ); - return Matrix4( - Vector4( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector4( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector4( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::rotation( const Quat &unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Matrix4( - Vector4( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector4( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector4( vec_sel( zero, scaleVec.get128(), select_z ) ), - Vector4::wAxis( ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::translation( const Vector3 &translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - __m128 zero, col0, col1, col2, col3; - union { __m128 v; float s[4]; } tmp; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = _mm_setzero_ps(); - tmp.v = zero; - tmp.s[0] = f / aspect; - col0 = tmp.v; - tmp.v = zero; - tmp.s[1] = f; - col1 = tmp.v; - tmp.v = zero; - tmp.s[2] = ( zNear + zFar ) * rangeInv; - tmp.s[3] = -1.0f; - col2 = tmp.v; - tmp.v = zero; - tmp.s[2] = zNear * zFar * rangeInv * 2.0f; - col3 = tmp.v; - return Matrix4( - Vector4( col0 ), - Vector4( col1 ), - Vector4( col2 ), - Vector4( col3 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - __m128 lbf, rtn; - __m128 diff, sum, inv_diff; - __m128 diagonal, column, near2; - __m128 zero = _mm_setzero_ps(); - union { __m128 v; float s[4]; } l, f, r, n, b, t; // TODO: Union? - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = vec_splat( n.v, 0 ); - near2 = vec_add( near2, near2 ); - diagonal = vec_mul( near2, inv_diff ); - column = vec_mul( sum, inv_diff ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - return Matrix4( - Vector4( vec_sel( zero, diagonal, select_x ) ), - Vector4( vec_sel( zero, diagonal, select_y ) ), - Vector4( vec_sel( column, _mm_set1_ps(-1.0f), select_w ) ), - Vector4( vec_sel( zero, vec_mul( diagonal, vec_splat( f.v, 0 ) ), select_z ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - __m128 lbf, rtn; - __m128 diff, sum, inv_diff, neg_inv_diff; - __m128 diagonal, column; - __m128 zero = _mm_setzero_ps(); - union { __m128 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = vec_add( inv_diff, inv_diff ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - column = vec_mul( sum, vec_sel( neg_inv_diff, inv_diff, select_z ) ); // TODO: no madds with zero - return Matrix4( - Vector4( vec_sel( zero, diagonal, select_x ) ), - Vector4( vec_sel( zero, diagonal, select_y ) ), - Vector4( vec_sel( zero, diagonal, select_z ) ), - Vector4( vec_sel( column, _mm_set1_ps(1.0f), select_w ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -VECTORMATH_FORCE_INLINE void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -VECTORMATH_FORCE_INLINE Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -VECTORMATH_FORCE_INLINE Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -VECTORMATH_FORCE_INLINE Transform3::Transform3( const floatInVec &scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -VECTORMATH_FORCE_INLINE Transform3::Transform3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2, const Vector3 &_col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -VECTORMATH_FORCE_INLINE Transform3::Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -VECTORMATH_FORCE_INLINE Transform3::Transform3( const Quat &unitQuat, const Vector3 &translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setCol0( const Vector3 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setCol1( const Vector3 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setCol2( const Vector3 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setCol3( const Vector3 &_col3 ) -{ - mCol3 = _col3; - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setCol( int col, const Vector3 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setRow( int row, const Vector4 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setElem( int col, int row, const floatInVec &val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -VECTORMATH_FORCE_INLINE const Transform3 inverse( const Transform3 & tfrm ) -{ - __m128 inv0, inv1, inv2, inv3; - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - __m128 xxxx, yyyy, zzzz; - tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); - tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); - tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - xxxx = vec_splat( inv3, 0 ); - //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tmp1, select_y); - //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_mul( inv0, xxxx ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - inv0 = vec_mul( inv0, invdet ); - inv1 = vec_mul( inv1, invdet ); - inv2 = vec_mul( inv2, invdet ); - inv3 = vec_mul( inv3, invdet ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - __m128 inv0, inv1, inv2, inv3; - __m128 tmp0, tmp1; - __m128 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - tmp1 = vec_mergel( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - inv0 = vec_mergeh( tmp0, tfrm.getCol1().get128() ); - xxxx = vec_splat( inv3, 0 ); - //inv1 = vec_perm( tmp0, tfrm.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tfrm.getCol1().get128(), select_y); - //inv2 = vec_perm( tmp1, tfrm.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tfrm.getCol1().get128(), 2), select_y); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_mul( inv0, xxxx ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::operator *( const Vector3 &vec ) const -{ - __m128 res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_mul( mCol0.get128(), xxxx ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -VECTORMATH_FORCE_INLINE const Point3 Transform3::operator *( const Point3 &pnt ) const -{ - __m128 tmp0, tmp1, res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( pnt.get128(), 0 ); - yyyy = vec_splat( pnt.get128(), 1 ); - zzzz = vec_splat( pnt.get128(), 2 ); - tmp0 = vec_mul( mCol0.get128(), xxxx ); - tmp1 = vec_mul( mCol1.get128(), yyyy ); - tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = vec_add( mCol3.get128(), tmp1 ); - res = vec_add( tmp0, tmp1 ); - return Point3( res ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -VECTORMATH_FORCE_INLINE const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -VECTORMATH_FORCE_INLINE const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -VECTORMATH_FORCE_INLINE Transform3 & Transform3::setTranslation( const Vector3 &translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ), - Vector3( _mm_setzero_ps() ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __m128 zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Transform3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Transform3( - Vector3( vec_mul( Z0, Y0 ) ), - Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), - Vector3( 0.0f ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::rotation( const Quat &unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Transform3( - Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ), - Vector3( 0.0f ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 Transform3::translation( const Vector3 &translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -VECTORMATH_FORCE_INLINE const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -VECTORMATH_FORCE_INLINE void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -VECTORMATH_FORCE_INLINE Quat::Quat( const Matrix3 & tfrm ) -{ - __m128 res; - __m128 col0, col1, col2; - __m128 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - __m128 zy_xz_yx, yz_zx_xy, sum, diff; - __m128 radicand, invSqrt, scale; - __m128 res0, res1, res2, res3; - __m128 xx, yy, zz; - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - - col0 = tfrm.getCol0().get128(); - col1 = tfrm.getCol1().get128(); - col2 = tfrm.getCol2().get128(); - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = vec_sel( col0, col1, select_y ); - //xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); - //yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); - //zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); - xx_yy_zz_xx = _mm_shuffle_ps( xx_yy, xx_yy, _MM_SHUFFLE(0,0,1,0) ); - xx_yy_zz_xx = vec_sel( xx_yy_zz_xx, col2, select_z ); // TODO: Ck - yy_zz_xx_yy = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(1,0,2,1) ); - zz_xx_yy_zz = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(2,1,0,2) ); - - diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), _mm_set1_ps(1.0f) ); - // invSqrt = rsqrtf4( radicand ); - invSqrt = newtonrapson_rsqrt4( radicand ); - - - - zy_xz_yx = vec_sel( col0, col1, select_z ); // zy_xz_yx = 00 01 12 03 - //zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); - zy_xz_yx = _mm_shuffle_ps( zy_xz_yx, zy_xz_yx, _MM_SHUFFLE(0,1,2,2) ); // zy_xz_yx = 12 12 01 00 - zy_xz_yx = vec_sel( zy_xz_yx, vec_splat(col2, 0), select_y ); // zy_xz_yx = 12 20 01 00 - yz_zx_xy = vec_sel( col0, col1, select_x ); // yz_zx_xy = 10 01 02 03 - //yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); - yz_zx_xy = _mm_shuffle_ps( yz_zx_xy, yz_zx_xy, _MM_SHUFFLE(0,0,2,0) ); // yz_zx_xy = 10 02 10 10 - yz_zx_xy = vec_sel( yz_zx_xy, vec_splat(col2, 1), select_x ); // yz_zx_xy = 21 02 10 10 - - sum = vec_add( zy_xz_yx, yz_zx_xy ); - diff = vec_sub( zy_xz_yx, yz_zx_xy ); - - scale = vec_mul( invSqrt, _mm_set1_ps(0.5f) ); - - //res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); - res0 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,1,2,0) ); - res0 = vec_sel( res0, vec_splat(diff, 0), select_w ); // TODO: Ck - //res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); - res1 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,2) ); - res1 = vec_sel( res1, vec_splat(diff, 1), select_w ); // TODO: Ck - //res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); - res2 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,1) ); - res2 = vec_sel( res2, vec_splat(diff, 2), select_w ); // TODO: Ck - res3 = diff; - res0 = vec_sel( res0, radicand, select_x ); - res1 = vec_sel( res1, radicand, select_y ); - res2 = vec_sel( res2, radicand, select_z ); - res3 = vec_sel( res3, radicand, select_w ); - res0 = vec_mul( res0, vec_splat( scale, 0 ) ); - res1 = vec_mul( res1, vec_splat( scale, 1 ) ); - res2 = vec_mul( res2, vec_splat( scale, 2 ) ); - res3 = vec_mul( res3, vec_splat( scale, 3 ) ); - - /* determine case and select answer */ - - xx = vec_splat( col0, 0 ); - yy = vec_splat( col1, 1 ); - zz = vec_splat( col2, 2 ); - res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); - res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); - res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), _mm_setzero_ps() ) ); - mVec128 = res; -} - -VECTORMATH_FORCE_INLINE const Matrix3 outer( const Vector3 &tfrm0, const Vector3 &tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix4 outer( const Vector4 &tfrm0, const Vector4 &tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -VECTORMATH_FORCE_INLINE const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, mcol0, mcol1, mcol2, res; - __m128 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - xxxx = vec_splat( vec.get128(), 0 ); - mcol0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - //mcol1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - mcol1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - mcol1 = vec_sel(mcol1, mat.getCol1().get128(), select_y); - //mcol2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - mcol2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - mcol2 = vec_sel(mcol2, vec_splat(mat.getCol1().get128(), 2), select_y); - yyyy = vec_splat( vec.get128(), 1 ); - res = vec_mul( mcol0, xxxx ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mcol1, yyyy, res ); - res = vec_madd( mcol2, zzzz, res ); - return Vector3( res ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 crossMatrix( const Vector3 &vec ) -{ - __m128 neg, res0, res1, res2; - neg = negatef4( vec.get128() ); - VM_ATTRIBUTE_ALIGN16 unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - VM_ATTRIBUTE_ALIGN16 unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //res0 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_XZBX ); - res0 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,2,2,0) ); - res0 = vec_sel(res0, vec_splat(neg, 1), select_z); - //res1 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_CXXX ); - res1 = vec_sel(vec_splat(vec.get128(), 0), vec_splat(neg, 2), select_x); - //res2 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_YAXX ); - res2 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,1,1) ); - res2 = vec_sel(res2, vec_splat(neg, 0), select_y); - VM_ATTRIBUTE_ALIGN16 unsigned int filter_x[4] = {0, 0xffffffff, 0xffffffff, 0xffffffff}; - VM_ATTRIBUTE_ALIGN16 unsigned int filter_y[4] = {0xffffffff, 0, 0xffffffff, 0xffffffff}; - VM_ATTRIBUTE_ALIGN16 unsigned int filter_z[4] = {0xffffffff, 0xffffffff, 0, 0xffffffff}; - res0 = vec_and( res0, _mm_load_ps((float *)filter_x ) ); - res1 = vec_and( res1, _mm_load_ps((float *)filter_y ) ); - res2 = vec_and( res2, _mm_load_ps((float *)filter_z ) ); // TODO: Use selects? - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -VECTORMATH_FORCE_INLINE const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/sse/quat_aos.h b/Extras/PhysicsEffects/include/vecmath/sse/quat_aos.h deleted file mode 100644 index d7091ecf8..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/quat_aos.h +++ /dev/null @@ -1,579 +0,0 @@ -/* - 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 diff --git a/Extras/PhysicsEffects/include/vecmath/sse/vec_aos.h b/Extras/PhysicsEffects/include/vecmath/sse/vec_aos.h deleted file mode 100644 index 05ebac55a..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/vec_aos.h +++ /dev/null @@ -1,1455 +0,0 @@ -/* - 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H - -//----------------------------------------------------------------------------- -// Constants -// for permutes words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } -#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } -#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } -#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } -#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } -#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } -#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } -#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } -#define _VECTORMATH_UNIT_1000 _mm_setr_ps(1.0f,0.0f,0.0f,0.0f) // (__m128){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 _mm_setr_ps(0.0f,1.0f,0.0f,0.0f) // (__m128){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 _mm_setr_ps(0.0f,0.0f,1.0f,0.0f) // (__m128){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 _mm_setr_ps(0.0f,0.0f,0.0f,1.0f) // (__m128){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f -//_VECTORMATH_SLERP_TOLF - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#define _vmath_shufps(a, b, immx, immy, immz, immw) _mm_shuffle_ps(a, b, _MM_SHUFFLE(immw, immz, immy, immx)) -static VECTORMATH_FORCE_INLINE __m128 _vmathVfDot3( __m128 vec0, __m128 vec1 ) -{ - __m128 result = _mm_mul_ps( vec0, vec1); - return _mm_add_ps( vec_splat( result, 0 ), _mm_add_ps( vec_splat( result, 1 ), vec_splat( result, 2 ) ) ); -} - -static VECTORMATH_FORCE_INLINE __m128 _vmathVfDot4( __m128 vec0, __m128 vec1 ) -{ - __m128 result = _mm_mul_ps(vec0, vec1); - return _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(0,0,0,0)), - _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(1,1,1,1)), - _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(2,2,2,2)), _mm_shuffle_ps(result, result, _MM_SHUFFLE(3,3,3,3))))); -} - -static VECTORMATH_FORCE_INLINE __m128 _vmathVfCross( __m128 vec0, __m128 vec1 ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,0,2,1) ); - tmp1 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,1,0,2) ); - tmp2 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,1,0,2) ); - tmp3 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,0,2,1) ); - result = vec_mul( tmp0, tmp1 ); - result = vec_nmsub( tmp2, tmp3, result ); - return result; -} -/* -static VECTORMATH_FORCE_INLINE vec_uint4 _vmathVfToHalfFloatsUnpacked(__m128 v) -{ -#if 0 - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = (vec_uint4)(0x00007c00u); - const vec_uint4 mergeMant = (vec_uint4)(0x000003ffu); - const vec_uint4 mergeSign = (vec_uint4)(0x00008000u); - - sign = vec_sr((vec_uint4)v, (vec_uint4)16); - mant = vec_sr((vec_uint4)v, (vec_uint4)13); - bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4)23), (vec_int4)0xff); - - notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4)112); - isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4)142); - - bexp = _mm_add_ps(bexp, (vec_int4)-112); - bexp = vec_sl(bexp, (vec_uint4)10); - - hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = vec_sel((vec_uint4)(0), hfloat, notZero); - hfloat = vec_sel(hfloat, hfloatInf, isInf); - hfloat = vec_sel(hfloat, sign, mergeSign); - - return hfloat; -#else - assert(0); - return _mm_setzero_ps(); -#endif -} - -static VECTORMATH_FORCE_INLINE vec_ushort8 _vmath2VfToHalfFloats(__m128 u, __m128 v) -{ -#if 0 - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); -#else - assert(0); - return _mm_setzero_si128(); -#endif -} -*/ - -static VECTORMATH_FORCE_INLINE __m128 _vmathVfInsert(__m128 dst, __m128 src, int slot) -{ - SSEFloat s; - s.m128 = src; - SSEFloat d; - d.m128 = dst; - d.f[slot] = s.f[slot]; - return d.m128; -} - -#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar - -static VECTORMATH_FORCE_INLINE __m128 _vmathVfSplatScalar(float scalar) -{ - return _mm_set1_ps(scalar); -} - -#endif - -namespace Vectormath { -namespace Aos { - - -#ifdef _VECTORMATH_NO_SCALAR_CAST -VECTORMATH_FORCE_INLINE VecIdx::operator floatInVec() const -{ - return floatInVec(ref, i); -} - -VECTORMATH_FORCE_INLINE float VecIdx::getAsFloat() const -#else -VECTORMATH_FORCE_INLINE VecIdx::operator float() const -#endif -{ - return ((float *)&ref)[i]; -} - -VECTORMATH_FORCE_INLINE float VecIdx::operator =( float scalar ) -{ - _vmathVfSetElement(ref, scalar, i); - return scalar; -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator =( const floatInVec &scalar ) -{ - ref = _vmathVfInsert(ref, scalar.get128(), i); - return scalar; -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator =( const VecIdx& scalar ) -{ - return *this = floatInVec(scalar.ref, scalar.i); -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator *=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) * scalar; -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator /=( float scalar ) -{ - return *this /= floatInVec(scalar); -} - -inline floatInVec VecIdx::operator /=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) / scalar; -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator +=( float scalar ) -{ - return *this += floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator +=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) + scalar; -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator -=( float scalar ) -{ - return *this -= floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE floatInVec VecIdx::operator -=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) - scalar; -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3(const Vector3& vec) -{ - set128(vec.get128()); -} - -VECTORMATH_FORCE_INLINE void Vector3::set128(vec_float4 vec) -{ - mVec128 = vec; -} - - -VECTORMATH_FORCE_INLINE Vector3::Vector3( float _x, float _y, float _z ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) -{ - __m128 xz = _mm_unpacklo_ps( _x.get128(), _z.get128() ); - mVec128 = _mm_unpacklo_ps( xz, _y.get128() ); -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3( const Point3 &pnt ) -{ - mVec128 = pnt.get128(); -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -VECTORMATH_FORCE_INLINE Vector3::Vector3( __m128 vf4 ) -{ - mVec128 = vf4; -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::xAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_1000 ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::yAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0100 ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::zAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0010 ); -} - -VECTORMATH_FORCE_INLINE const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -VECTORMATH_FORCE_INLINE const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -VECTORMATH_FORCE_INLINE const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) -{ - __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); - angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t - angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t - angles = _mm_mul_ps( angles, angle ); - 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 Vector3( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); -} - -VECTORMATH_FORCE_INLINE __m128 Vector3::get128( ) const -{ - return mVec128; -} - -VECTORMATH_FORCE_INLINE void loadXYZ(Point3& vec, const float* fptr) -{ -#ifdef USE_SSE3_LDDQU - vec = Point3( 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]; - vec = Point3( fl.m128); -#endif //USE_SSE3_LDDQU - -} - - - -VECTORMATH_FORCE_INLINE void loadXYZ(Vector3& vec, const float* fptr) -{ -#ifdef USE_SSE3_LDDQU - vec = Vector3( 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]; - vec = Vector3( fl.m128); -#endif //USE_SSE3_LDDQU - -} - -VECTORMATH_FORCE_INLINE void storeXYZ( const Vector3 &vec, __m128 * quad ) -{ - __m128 dstVec = *quad; - VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize - dstVec = vec_sel(vec.get128(), dstVec, sw); - *quad = dstVec; -} - -VECTORMATH_FORCE_INLINE void storeXYZ(const Point3& vec, float* fptr) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - -VECTORMATH_FORCE_INLINE void storeXYZ(const Vector3& vec, float* fptr) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - - -VECTORMATH_FORCE_INLINE void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ) -{ - const float *quads = (float *)threeQuads; - vec0 = Vector3( _mm_load_ps(quads) ); - vec1 = Vector3( _mm_loadu_ps(quads + 3) ); - vec2 = Vector3( _mm_loadu_ps(quads + 6) ); - vec3 = Vector3( _mm_loadu_ps(quads + 9) ); -} - -VECTORMATH_FORCE_INLINE void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ) -{ - __m128 xxxx = _mm_shuffle_ps( vec1.get128(), vec1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); - __m128 zzzz = _mm_shuffle_ps( vec2.get128(), vec2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); - VM_ATTRIBUTE_ALIGN16 unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; - VM_ATTRIBUTE_ALIGN16 unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; - threeQuads[0] = vec_sel( vec0.get128(), xxxx, xsw ); - threeQuads[1] = _mm_shuffle_ps( vec1.get128(), vec2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); - threeQuads[2] = vec_sel( _mm_shuffle_ps( vec3.get128(), vec3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); -} -/* -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ) -{ - assert(0); -#if 0 - __m128 xyz0[3]; - __m128 xyz1[3]; - storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -#endif -} -*/ -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator =( const Vector3 &vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE VecIdx Vector3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator +( const Vector3 &vec ) const -{ - return Vector3( _mm_add_ps( mVec128, vec.mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator -( const Vector3 &vec ) const -{ - return Vector3( _mm_sub_ps( mVec128, vec.mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 Vector3::operator +( const Point3 &pnt ) const -{ - return Point3( _mm_add_ps( mVec128, pnt.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator *( const floatInVec &scalar ) const -{ - return Vector3( _mm_mul_ps( mVec128, scalar.get128() ) ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator +=( const Vector3 &vec ) -{ - *this = *this + vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator -=( const Vector3 &vec ) -{ - *this = *this - vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator /( const floatInVec &scalar ) const -{ - return Vector3( _mm_div_ps( mVec128, scalar.get128() ) ); -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector3 & Vector3::operator /=( const floatInVec &scalar ) -{ - *this = *this / scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector3 Vector3::operator -( ) const -{ - //return Vector3(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); - - VM_ATTRIBUTE_ALIGN16 static const int array[] = {0x80000000, 0x80000000, 0x80000000, 0x80000000}; - __m128 NEG_MASK = SSEFloat(*(const vec_float4*)array).vf; - return Vector3(_mm_xor_ps(get128(),NEG_MASK)); -} - -VECTORMATH_FORCE_INLINE const Vector3 operator *( float scalar, const Vector3 &vec ) -{ - return floatInVec(scalar) * vec; -} - -VECTORMATH_FORCE_INLINE const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ) -{ - return vec * scalar; -} - -VECTORMATH_FORCE_INLINE const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_div_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 recipPerElem( const Vector3 &vec ) -{ - return Vector3( _mm_rcp_ps( vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 absPerElem( const Vector3 &vec ) -{ - return Vector3( fabsf4( vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Vector3( _mm_or_ps( - _mm_and_ps ( vmask, vec0.get128() ), // Value - _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs -} - -VECTORMATH_FORCE_INLINE const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_max_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Vector3 &vec ) -{ - return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_min_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Vector3 &vec ) -{ - return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec sum( const Vector3 &vec ) -{ - return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return floatInVec( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); -} - -VECTORMATH_FORCE_INLINE const floatInVec lengthSqr( const Vector3 &vec ) -{ - return floatInVec( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); -} - -VECTORMATH_FORCE_INLINE const floatInVec length( const Vector3 &vec ) -{ - return floatInVec( _mm_sqrt_ps(_vmathVfDot3( vec.get128(), vec.get128() )), 0 ); -} - - -VECTORMATH_FORCE_INLINE const Vector3 normalizeApprox( const Vector3 &vec ) -{ - return Vector3( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 normalize( const Vector3 &vec ) -{ - return Vector3( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - - -VECTORMATH_FORCE_INLINE const Vector4 select(const Vector4& vec0, const Vector4& vec1, const boolInVec& select1) -{ - return Vector4(vec_sel(vec0.get128(), vec1.get128(), select1.get128())); -} - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Vector3 &vec ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -VECTORMATH_FORCE_INLINE void print( const Vector3 &vec, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -VECTORMATH_FORCE_INLINE Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, _w); - } - -VECTORMATH_FORCE_INLINE Vector4::Vector4( 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 Vector4::Vector4( const Vector3 &xyz, float _w ) -{ - mVec128 = xyz.get128(); - _vmathVfSetElement(mVec128, _w, 3); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( const Vector3 &xyz, const floatInVec &_w ) -{ - mVec128 = xyz.get128(); - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( const Vector3 &vec ) -{ - mVec128 = vec.get128(); - mVec128 = _vmathVfInsert(mVec128, _mm_setzero_ps(), 3); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( const Point3 &pnt ) -{ - mVec128 = pnt.get128(); - mVec128 = _vmathVfInsert(mVec128, _mm_set1_ps(1.0f), 3); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( const Quat &quat ) -{ - mVec128 = quat.get128(); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -VECTORMATH_FORCE_INLINE Vector4::Vector4( __m128 vf4 ) -{ - mVec128 = vf4; -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::xAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_1000 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::yAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0100 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::zAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0010 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::wAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0001 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) -{ - __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); - __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); - angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t - angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t - angles = _mm_mul_ps( angles, angle ); - 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 Vector4( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); -} - -VECTORMATH_FORCE_INLINE __m128 Vector4::get128( ) const -{ - return mVec128; -} -/* -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); -} -*/ -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator =( const Vector4 &vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::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 Vector4::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setW( float _w ) -{ - _vmathVfSetElement(mVec128, _w, 3); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setW( const floatInVec &_w ) -{ - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::getW( ) const -{ - return floatInVec( mVec128, 3 ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE VecIdx Vector4::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const floatInVec Vector4::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator +( const Vector4 &vec ) const -{ - return Vector4( _mm_add_ps( mVec128, vec.mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator -( const Vector4 &vec ) const -{ - return Vector4( _mm_sub_ps( mVec128, vec.mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator *( const floatInVec &scalar ) const -{ - return Vector4( _mm_mul_ps( mVec128, scalar.get128() ) ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator +=( const Vector4 &vec ) -{ - *this = *this + vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator -=( const Vector4 &vec ) -{ - *this = *this - vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator /( const floatInVec &scalar ) const -{ - return Vector4( _mm_div_ps( mVec128, scalar.get128() ) ); -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE Vector4 & Vector4::operator /=( const floatInVec &scalar ) -{ - *this = *this / scalar; - return *this; -} - -VECTORMATH_FORCE_INLINE const Vector4 Vector4::operator -( ) const -{ - return Vector4(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 operator *( float scalar, const Vector4 &vec ) -{ - return floatInVec(scalar) * vec; -} - -VECTORMATH_FORCE_INLINE const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ) -{ - return vec * scalar; -} - -VECTORMATH_FORCE_INLINE const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_div_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 recipPerElem( const Vector4 &vec ) -{ - return Vector4( _mm_rcp_ps( vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 absPerElem( const Vector4 &vec ) -{ - return Vector4( fabsf4( vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Vector4( _mm_or_ps( - _mm_and_ps ( vmask, vec0.get128() ), // Value - _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs -} - -VECTORMATH_FORCE_INLINE const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_max_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Vector4 &vec ) -{ - return floatInVec( _mm_max_ps( - _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_max_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_min_ps( vec0.get128(), vec1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Vector4 &vec ) -{ - return floatInVec( _mm_min_ps( - _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_min_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec sum( const Vector4 &vec ) -{ - return floatInVec( _mm_add_ps( - _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_add_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return floatInVec( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); -} - -VECTORMATH_FORCE_INLINE const floatInVec lengthSqr( const Vector4 &vec ) -{ - return floatInVec( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); -} - -VECTORMATH_FORCE_INLINE const floatInVec length( const Vector4 &vec ) -{ - return floatInVec( _mm_sqrt_ps(_vmathVfDot4( vec.get128(), vec.get128() )), 0 ); -} - -VECTORMATH_FORCE_INLINE const Vector4 normalizeApprox( const Vector4 &vec ) -{ - return Vector4( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 normalize( const Vector4 &vec ) -{ - return Vector4( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); -} - -VECTORMATH_FORCE_INLINE const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Vector4 &vec ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.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 Vector4 &vec, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -VECTORMATH_FORCE_INLINE Point3::Point3( float _x, float _y, float _z ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); -} - -VECTORMATH_FORCE_INLINE Point3::Point3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) -{ - mVec128 = _mm_unpacklo_ps( _mm_unpacklo_ps( _x.get128(), _z.get128() ), _y.get128() ); -} - -VECTORMATH_FORCE_INLINE Point3::Point3( const Vector3 &vec ) -{ - mVec128 = vec.get128(); -} - -VECTORMATH_FORCE_INLINE Point3::Point3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -VECTORMATH_FORCE_INLINE Point3::Point3( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -VECTORMATH_FORCE_INLINE Point3::Point3( __m128 vf4 ) -{ - mVec128 = vf4; -} - -VECTORMATH_FORCE_INLINE const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ) -{ - return lerp( floatInVec(t), pnt0, pnt1 ); -} - -VECTORMATH_FORCE_INLINE const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -VECTORMATH_FORCE_INLINE __m128 Point3::get128( ) const -{ - return mVec128; -} - -VECTORMATH_FORCE_INLINE void storeXYZ( const Point3 &pnt, __m128 * quad ) -{ - __m128 dstVec = *quad; - VM_ATTRIBUTE_ALIGN16 unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize - dstVec = vec_sel(pnt.get128(), dstVec, sw); - *quad = dstVec; -} - -VECTORMATH_FORCE_INLINE void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ) -{ - const float *quads = (float *)threeQuads; - pnt0 = Point3( _mm_load_ps(quads) ); - pnt1 = Point3( _mm_loadu_ps(quads + 3) ); - pnt2 = Point3( _mm_loadu_ps(quads + 6) ); - pnt3 = Point3( _mm_loadu_ps(quads + 9) ); -} - -VECTORMATH_FORCE_INLINE void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ) -{ - __m128 xxxx = _mm_shuffle_ps( pnt1.get128(), pnt1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); - __m128 zzzz = _mm_shuffle_ps( pnt2.get128(), pnt2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); - VM_ATTRIBUTE_ALIGN16 unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; - VM_ATTRIBUTE_ALIGN16 unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; - threeQuads[0] = vec_sel( pnt0.get128(), xxxx, xsw ); - threeQuads[1] = _mm_shuffle_ps( pnt1.get128(), pnt2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); - threeQuads[2] = vec_sel( _mm_shuffle_ps( pnt3.get128(), pnt3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); -} -/* -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ) -{ -#if 0 - __m128 xyz0[3]; - __m128 xyz1[3]; - storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -#else - assert(0); -#endif -} -*/ -VECTORMATH_FORCE_INLINE Point3 & Point3::operator =( const Point3 &pnt ) -{ - mVec128 = pnt.mVec128; - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Point3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Point3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Point3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -VECTORMATH_FORCE_INLINE const floatInVec Point3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE VecIdx Point3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const floatInVec Point3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -VECTORMATH_FORCE_INLINE const Vector3 Point3::operator -( const Point3 &pnt ) const -{ - return Vector3( _mm_sub_ps( mVec128, pnt.mVec128 ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 Point3::operator +( const Vector3 &vec ) const -{ - return Point3( _mm_add_ps( mVec128, vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 Point3::operator -( const Vector3 &vec ) const -{ - return Point3( _mm_sub_ps( mVec128, vec.get128() ) ); -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::operator +=( const Vector3 &vec ) -{ - *this = *this + vec; - return *this; -} - -VECTORMATH_FORCE_INLINE Point3 & Point3::operator -=( const Vector3 &vec ) -{ - *this = *this - vec; - return *this; -} - -VECTORMATH_FORCE_INLINE const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_mul_ps( pnt0.get128(), pnt1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_div_ps( pnt0.get128(), pnt1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 recipPerElem( const Point3 &pnt ) -{ - return Point3( _mm_rcp_ps( pnt.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 absPerElem( const Point3 &pnt ) -{ - return Point3( fabsf4( pnt.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Point3( _mm_or_ps( - _mm_and_ps ( vmask, pnt0.get128() ), // Value - _mm_andnot_ps( vmask, pnt1.get128() ) ) ); // Signs -} - -VECTORMATH_FORCE_INLINE const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_max_ps( pnt0.get128(), pnt1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Point3 &pnt ) -{ - return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_min_ps( pnt0.get128(), pnt1.get128() ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Point3 &pnt ) -{ - return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec sum( const Point3 &pnt ) -{ - return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, float scaleVal ) -{ - return scale( pnt, floatInVec( scaleVal ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ) -{ - return floatInVec( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); -} - -VECTORMATH_FORCE_INLINE const floatInVec distSqrFromOrigin( const Point3 &pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec distFromOrigin( const Point3 &pnt ) -{ - return length( Vector3( pnt ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -VECTORMATH_FORCE_INLINE const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -VECTORMATH_FORCE_INLINE const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ) -{ - return select( pnt0, pnt1, boolInVec(select1) ); -} - -VECTORMATH_FORCE_INLINE const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ) -{ - return Point3( vec_sel( pnt0.get128(), pnt1.get128(), select1.get128() ) ); -} - - - -#ifdef _VECTORMATH_DEBUG - -VECTORMATH_FORCE_INLINE void print( const Point3 &pnt ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -VECTORMATH_FORCE_INLINE void print( const Point3 &pnt, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/sse/vecidx_aos.h b/Extras/PhysicsEffects/include/vecmath/sse/vecidx_aos.h deleted file mode 100644 index 32e837a52..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/vecidx_aos.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - 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 diff --git a/Extras/PhysicsEffects/include/vecmath/sse/vectormath_aos.h b/Extras/PhysicsEffects/include/vecmath/sse/vectormath_aos.h deleted file mode 100644 index b802810df..000000000 --- a/Extras/PhysicsEffects/include/vecmath/sse/vectormath_aos.h +++ /dev/null @@ -1,2547 +0,0 @@ -/* - 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_AOS_CPP_SSE_H -#define _VECTORMATH_AOS_CPP_SSE_H - -#include -#include -#include -#include - -#define Vector3Ref Vector3& -#define QuatRef Quat& -#define Matrix3Ref Matrix3& - -#if (defined (_WIN32) && (_MSC_VER) && _MSC_VER >= 1400) - #define USE_SSE3_LDDQU - - #define VM_ATTRIBUTE_ALIGNED_CLASS16(a) __declspec(align(16)) a - #define VM_ATTRIBUTE_ALIGN16 __declspec(align(16)) - #define VECTORMATH_FORCE_INLINE __forceinline -#else - #define VM_ATTRIBUTE_ALIGNED_CLASS16(a) a __attribute__ ((aligned (16))) - #define VM_ATTRIBUTE_ALIGN16 __attribute__ ((aligned (16))) - #define VECTORMATH_FORCE_INLINE inline - #ifdef __SSE3__ - #define USE_SSE3_LDDQU - #endif //__SSE3__ -#endif//_WIN32 - - -#ifdef USE_SSE3_LDDQU -#include //_mm_lddqu_si128 -#endif //USE_SSE3_LDDQU - - -// TODO: Tidy -typedef __m128 vec_float4; -typedef __m128 vec_uint4; -typedef __m128 vec_int4; -typedef __m128i vec_uchar16; -typedef __m128i vec_ushort8; - -#define vec_splat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) - -#define _mm_ror_ps(vec,i) \ - (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(i+3)%4,(unsigned char)(i+2)%4,(unsigned char)(i+1)%4,(unsigned char)(i+0)%4))) : (vec)) -#define _mm_rol_ps(vec,i) \ - (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(7-i)%4,(unsigned char)(6-i)%4,(unsigned char)(5-i)%4,(unsigned char)(4-i)%4))) : (vec)) - -#define vec_sld(vec,vec2,x) _mm_ror_ps(vec, ((x)/4)) - -#define _mm_abs_ps(vec) _mm_andnot_ps(_MASKSIGN_,vec) -#define _mm_neg_ps(vec) _mm_xor_ps(_MASKSIGN_,vec) - -#define vec_madd(a, b, c) _mm_add_ps(c, _mm_mul_ps(a, b) ) - -union SSEFloat -{ - __m128i vi; - __m128 m128; - __m128 vf; - unsigned int ui[4]; - unsigned short s[8]; - float f[4]; - SSEFloat(__m128 v) : m128(v) {} - SSEFloat(__m128i v) : vi(v) {} - SSEFloat() {}//uninitialized -}; - -static VECTORMATH_FORCE_INLINE __m128 vec_sel(__m128 a, __m128 b, __m128 mask) -{ - return _mm_or_ps(_mm_and_ps(mask, b), _mm_andnot_ps(mask, a)); -} -static VECTORMATH_FORCE_INLINE __m128 vec_sel(__m128 a, __m128 b, const unsigned int *_mask) -{ - return vec_sel(a, b, _mm_load_ps((float *)_mask)); -} -static VECTORMATH_FORCE_INLINE __m128 vec_sel(__m128 a, __m128 b, unsigned int _mask) -{ - return vec_sel(a, b, _mm_set1_ps(*(float *)&_mask)); -} - -static VECTORMATH_FORCE_INLINE __m128 toM128(unsigned int x) -{ - return _mm_set1_ps( *(float *)&x ); -} - -static VECTORMATH_FORCE_INLINE __m128 fabsf4(__m128 x) -{ - return _mm_and_ps( x, toM128( 0x7fffffff ) ); -} -/* -union SSE64 -{ - __m128 m128; - struct - { - __m64 m01; - __m64 m23; - } m64; -}; - -static VECTORMATH_FORCE_INLINE __m128 vec_cts(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - SSE64 sse64; - sse64.m64.m01 = _mm_cvttps_pi32(x); - sse64.m64.m23 = _mm_cvttps_pi32(_mm_ror_ps(x,2)); - _mm_empty(); - return sse64.m128; -} - -static VECTORMATH_FORCE_INLINE __m128 vec_ctf(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - SSE64 sse64; - sse64.m128 = x; - __m128 result =_mm_movelh_ps( - _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m01), - _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m23)); - _mm_empty(); - return result; -} -*/ -static VECTORMATH_FORCE_INLINE __m128 vec_cts(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - __m128i result = _mm_cvtps_epi32(x); - return (__m128 &)result; -} - -static VECTORMATH_FORCE_INLINE __m128 vec_ctf(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - return _mm_cvtepi32_ps((__m128i &)x); -} - -#define vec_nmsub(a,b,c) _mm_sub_ps( c, _mm_mul_ps( a, b ) ) -#define vec_sub(a,b) _mm_sub_ps( a, b ) -#define vec_add(a,b) _mm_add_ps( a, b ) -#define vec_mul(a,b) _mm_mul_ps( a, b ) -#define vec_xor(a,b) _mm_xor_ps( a, b ) -#define vec_and(a,b) _mm_and_ps( a, b ) -#define vec_cmpeq(a,b) _mm_cmpeq_ps( a, b ) -#define vec_cmpgt(a,b) _mm_cmpgt_ps( a, b ) - -#define vec_mergeh(a,b) _mm_unpacklo_ps( a, b ) -#define vec_mergel(a,b) _mm_unpackhi_ps( a, b ) - -#define vec_andc(a,b) _mm_andnot_ps( b, a ) - -#define sqrtf4(x) _mm_sqrt_ps( x ) -#define rsqrtf4(x) _mm_rsqrt_ps( x ) -#define recipf4(x) _mm_rcp_ps( x ) -#define negatef4(x) _mm_sub_ps( _mm_setzero_ps(), x ) - -static VECTORMATH_FORCE_INLINE __m128 newtonrapson_rsqrt4( const __m128 v ) -{ -#define _half4 _mm_setr_ps(.5f,.5f,.5f,.5f) -#define _three _mm_setr_ps(3.f,3.f,3.f,3.f) -const __m128 approx = _mm_rsqrt_ps( v ); -const __m128 muls = _mm_mul_ps(_mm_mul_ps(v, approx), approx); -return _mm_mul_ps(_mm_mul_ps(_half4, approx), _mm_sub_ps(_three, muls) ); -} - -static VECTORMATH_FORCE_INLINE __m128 acosf4(__m128 x) -{ - __m128 xabs = fabsf4(x); - __m128 select = _mm_cmplt_ps( x, _mm_setzero_ps() ); - __m128 t1 = sqrtf4(vec_sub(_mm_set1_ps(1.0f), xabs)); - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - __m128 xabs2 = _mm_mul_ps(xabs, xabs); - __m128 xabs4 = _mm_mul_ps(xabs2, xabs2); - __m128 hi = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0012624911f), - xabs, _mm_set1_ps(0.0066700901f)), - xabs, _mm_set1_ps(-0.0170881256f)), - xabs, _mm_set1_ps( 0.0308918810f)); - __m128 lo = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0501743046f), - xabs, _mm_set1_ps(0.0889789874f)), - xabs, _mm_set1_ps(-0.2145988016f)), - xabs, _mm_set1_ps( 1.5707963050f)); - - __m128 result = vec_madd(hi, xabs4, lo); - - // Adjust the result if x is negactive. - return vec_sel( - vec_mul(t1, result), // Positive - vec_nmsub(t1, result, _mm_set1_ps(3.1415926535898f)), // Negative - select); -} - -static VECTORMATH_FORCE_INLINE __m128 sinf4(vec_float4 x) -{ - -// -// Common constants used to evaluate sinf4/cosf4/tanf4 -// -#define _SINCOS_CC0 -0.0013602249f -#define _SINCOS_CC1 0.0416566950f -#define _SINCOS_CC2 -0.4999990225f -#define _SINCOS_SC0 -0.0001950727f -#define _SINCOS_SC1 0.0083320758f -#define _SINCOS_SC2 -0.1666665247f - -#define _SINCOS_KC1 1.57079625129f -#define _SINCOS_KC2 7.54978995489e-8f - - vec_float4 xl,xl2,xl3,res; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - vec_int4 q = vec_cts(xl,0); - - // Compute an offset based on the quadrant that the angle falls in - // - vec_int4 offset = _mm_and_ps(q,toM128(0x3)); - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = vec_ctf(q,0); - xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); - - // Compute x^2 and x^3 - // - xl2 = vec_mul(xl,xl); - xl3 = vec_mul(xl2,xl); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - - vec_float4 cx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); - vec_float4 sx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - res = vec_sel(cx,sx,vec_cmpeq(vec_and(offset, - toM128(0x1)), - _mm_setzero_ps())); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - return vec_sel( - vec_xor(toM128(0x80000000U), res), // Negative - res, // Positive - vec_cmpeq(vec_and(offset,toM128(0x2)),_mm_setzero_ps())); -} - -static VECTORMATH_FORCE_INLINE void sincosf4(vec_float4 x, vec_float4* s, vec_float4* c) -{ - vec_float4 xl,xl2,xl3; - vec_int4 offsetSin, offsetCos; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - //vec_int4 q = vec_cts(vec_add(xl,vec_sel(_mm_set1_ps(0.5f),xl,(0x80000000))),0); - vec_int4 q = vec_cts(xl,0); - - // Compute the offset based on the quadrant that the angle falls in. - // Add 1 to the offset for the cosine. - // - offsetSin = vec_and(q,toM128((int)0x3)); - __m128i temp = _mm_add_epi32(_mm_set1_epi32(1),(__m128i &)offsetSin); - offsetCos = (__m128 &)temp; - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = vec_ctf(q,0); - xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); - - // Compute x^2 and x^3 - // - xl2 = vec_mul(xl,xl); - xl3 = vec_mul(xl2,xl); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vec_float4 cx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); - vec_float4 sx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vec_uint4 sinMask = (vec_uint4)vec_cmpeq(vec_and(offsetSin,toM128(0x1)),_mm_setzero_ps()); - vec_uint4 cosMask = (vec_uint4)vec_cmpeq(vec_and(offsetCos,toM128(0x1)),_mm_setzero_ps()); - *s = vec_sel(cx,sx,sinMask); - *c = vec_sel(cx,sx,cosMask); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - sinMask = vec_cmpeq(vec_and(offsetSin,toM128(0x2)),_mm_setzero_ps()); - cosMask = vec_cmpeq(vec_and(offsetCos,toM128(0x2)),_mm_setzero_ps()); - - *s = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*s),*s,sinMask); - *c = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*c),*c,cosMask); -} - -#include "vecidx_aos.h" -#include "floatInVec.h" -#include "boolInVec.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - __m128 mVec128; - - VECTORMATH_FORCE_INLINE void set128(vec_float4 vec); - - VECTORMATH_FORCE_INLINE vec_float4& get128Ref(); - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Vector3( ) { }; - - // Default copy constructor - // - VECTORMATH_FORCE_INLINE Vector3(const Vector3& vec); - - // Construct a 3-D vector from x, y, and z elements - // - VECTORMATH_FORCE_INLINE Vector3( float x, float y, float z ); - - // Construct a 3-D vector from x, y, and z elements (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit VECTORMATH_FORCE_INLINE Vector3( const Point3 &pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Vector3( float scalar ); - - // Set all elements of a 3-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Vector3( const floatInVec &scalar ); - - // Set vector float data in a 3-D vector - // - explicit VECTORMATH_FORCE_INLINE Vector3( __m128 vf4 ); - - // Get vector float data from a 3-D vector - // - VECTORMATH_FORCE_INLINE __m128 get128( ) const; - - // Assign one 3-D vector to another - // - VECTORMATH_FORCE_INLINE Vector3 & operator =( const Vector3 &vec ); - - // Set the x element of a 3-D vector - // - VECTORMATH_FORCE_INLINE Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - VECTORMATH_FORCE_INLINE Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - VECTORMATH_FORCE_INLINE Vector3 & setZ( float z ); - - // Set the x element of a 3-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & setX( const floatInVec &x ); - - // Set the y element of a 3-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & setY( const floatInVec &y ); - - // Set the z element of a 3-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & setZ( const floatInVec &z ); - - // Get the x element of a 3-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getX( ) const; - - // Get the y element of a 3-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getY( ) const; - - // Get the z element of a 3-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - VECTORMATH_FORCE_INLINE Vector3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D vector by index (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, or z element of a 3-D vector by index - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - VECTORMATH_FORCE_INLINE VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - VECTORMATH_FORCE_INLINE const floatInVec operator []( int idx ) const; - - // Add two 3-D vectors - // - VECTORMATH_FORCE_INLINE const Vector3 operator +( const Vector3 &vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - VECTORMATH_FORCE_INLINE const Vector3 operator -( const Vector3 &vec ) const; - - // Add a 3-D vector to a 3-D point - // - VECTORMATH_FORCE_INLINE const Point3 operator +( const Point3 &pnt ) const; - - // Multiply a 3-D vector by a scalar - // - VECTORMATH_FORCE_INLINE const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - VECTORMATH_FORCE_INLINE const Vector3 operator /( float scalar ) const; - - // Multiply a 3-D vector by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Vector3 operator *( const floatInVec &scalar ) const; - - // Divide a 3-D vector by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Vector3 operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - VECTORMATH_FORCE_INLINE Vector3 & operator +=( const Vector3 &vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - VECTORMATH_FORCE_INLINE Vector3 & operator -=( const Vector3 &vec ); - - // Perform compound assignment and multiplication by a scalar - // - VECTORMATH_FORCE_INLINE Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - VECTORMATH_FORCE_INLINE Vector3 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector3 & operator /=( const floatInVec &scalar ); - - // Negate all elements of a 3-D vector - // - VECTORMATH_FORCE_INLINE const Vector3 operator -( ) const; - - // Construct x axis - // - static VECTORMATH_FORCE_INLINE const Vector3 xAxis( ); - - // Construct y axis - // - static VECTORMATH_FORCE_INLINE const Vector3 yAxis( ); - - // Construct z axis - // - static VECTORMATH_FORCE_INLINE const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -VECTORMATH_FORCE_INLINE const Vector3 operator *( float scalar, const Vector3 &vec ); - -// Multiply a 3-D vector by a scalar (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ); - -// Multiply two 3-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -VECTORMATH_FORCE_INLINE const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -VECTORMATH_FORCE_INLINE const Vector3 recipPerElem( const Vector3 &vec ); - -// Compute the absolute value of a 3-D vector per element -// -VECTORMATH_FORCE_INLINE const Vector3 absPerElem( const Vector3 &vec ); - -// Copy sign from one 3-D vector to another, per element -// -VECTORMATH_FORCE_INLINE const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Maximum of two 3-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Minimum of two 3-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Maximum element of a 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Vector3 &vec ); - -// Minimum element of a 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Vector3 &vec ); - -// Compute the sum of all elements of a 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec sum( const Vector3 &vec ); - -// Compute the dot product of two 3-D vectors -// -VECTORMATH_FORCE_INLINE const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ); - -// Compute the square of the length of a 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec lengthSqr( const Vector3 &vec ); - -// Compute the length of a 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec length( const Vector3 &vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -VECTORMATH_FORCE_INLINE const Vector3 normalize( const Vector3 &vec ); - -// Compute cross product of two 3-D vectors -// -VECTORMATH_FORCE_INLINE const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ); - -// Outer product of two 3-D vectors -// -VECTORMATH_FORCE_INLINE const Matrix3 outer( const Vector3 &vec0, const Vector3 &vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// NOTE: -// Slower than column post-multiply. -// -VECTORMATH_FORCE_INLINE const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -VECTORMATH_FORCE_INLINE const Matrix3 crossMatrix( const Vector3 &vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -VECTORMATH_FORCE_INLINE const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ); - -// Linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); - -// Spherical linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ); - -// Conditionally select between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, const boolInVec &select1 ); - -// Store x, y, and z elements of 3-D vector in first three words of a quadword, preserving fourth word -// -VECTORMATH_FORCE_INLINE void storeXYZ( const Vector3 &vec, __m128 * quad ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -VECTORMATH_FORCE_INLINE void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ); - -// Store four 3-D vectors in three quadwords -// -VECTORMATH_FORCE_INLINE void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ); - -// Store eight 3-D vectors as half-floats -// -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Vector3 &vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Vector3 &vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Vector4( ) { }; - - // Construct a 4-D vector from x, y, z, and w elements - // - VECTORMATH_FORCE_INLINE Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from x, y, z, and w elements (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - VECTORMATH_FORCE_INLINE Vector4( const Vector3 &xyz, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4( const Vector3 &xyz, const floatInVec &w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit VECTORMATH_FORCE_INLINE Vector4( const Vector3 &vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit VECTORMATH_FORCE_INLINE Vector4( const Point3 &pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit VECTORMATH_FORCE_INLINE Vector4( const Quat &quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Vector4( float scalar ); - - // Set all elements of a 4-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Vector4( const floatInVec &scalar ); - - // Set vector float data in a 4-D vector - // - explicit VECTORMATH_FORCE_INLINE Vector4( __m128 vf4 ); - - // Get vector float data from a 4-D vector - // - VECTORMATH_FORCE_INLINE __m128 get128( ) const; - - // Assign one 4-D vector to another - // - VECTORMATH_FORCE_INLINE Vector4 & operator =( const Vector4 &vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - VECTORMATH_FORCE_INLINE Vector4 & setXYZ( const Vector3 &vec ); - - // Get the x, y, and z elements of a 4-D vector - // - VECTORMATH_FORCE_INLINE const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & setW( float w ); - - // Set the x element of a 4-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & setX( const floatInVec &x ); - - // Set the y element of a 4-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & setY( const floatInVec &y ); - - // Set the z element of a 4-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & setZ( const floatInVec &z ); - - // Set the w element of a 4-D vector (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & setW( const floatInVec &w ); - - // Get the x element of a 4-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getX( ) const; - - // Get the y element of a 4-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getY( ) const; - - // Get the z element of a 4-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getZ( ) const; - - // Get the w element of a 4-D vector - // - VECTORMATH_FORCE_INLINE const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - VECTORMATH_FORCE_INLINE Vector4 & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a 4-D vector by index (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - VECTORMATH_FORCE_INLINE VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - VECTORMATH_FORCE_INLINE const floatInVec operator []( int idx ) const; - - // Add two 4-D vectors - // - VECTORMATH_FORCE_INLINE const Vector4 operator +( const Vector4 &vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - VECTORMATH_FORCE_INLINE const Vector4 operator -( const Vector4 &vec ) const; - - // Multiply a 4-D vector by a scalar - // - VECTORMATH_FORCE_INLINE const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - VECTORMATH_FORCE_INLINE const Vector4 operator /( float scalar ) const; - - // Multiply a 4-D vector by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Vector4 operator *( const floatInVec &scalar ) const; - - // Divide a 4-D vector by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Vector4 operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & operator +=( const Vector4 &vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - VECTORMATH_FORCE_INLINE Vector4 & operator -=( const Vector4 &vec ); - - // Perform compound assignment and multiplication by a scalar - // - VECTORMATH_FORCE_INLINE Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - VECTORMATH_FORCE_INLINE Vector4 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Vector4 & operator /=( const floatInVec &scalar ); - - // Negate all elements of a 4-D vector - // - VECTORMATH_FORCE_INLINE const Vector4 operator -( ) const; - - // Construct x axis - // - static VECTORMATH_FORCE_INLINE const Vector4 xAxis( ); - - // Construct y axis - // - static VECTORMATH_FORCE_INLINE const Vector4 yAxis( ); - - // Construct z axis - // - static VECTORMATH_FORCE_INLINE const Vector4 zAxis( ); - - // Construct w axis - // - static VECTORMATH_FORCE_INLINE const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -VECTORMATH_FORCE_INLINE const Vector4 operator *( float scalar, const Vector4 &vec ); - -// Multiply a 4-D vector by a scalar (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ); - -// Multiply two 4-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -VECTORMATH_FORCE_INLINE const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -VECTORMATH_FORCE_INLINE const Vector4 recipPerElem( const Vector4 &vec ); - -// Compute the absolute value of a 4-D vector per element -// -VECTORMATH_FORCE_INLINE const Vector4 absPerElem( const Vector4 &vec ); - -// Copy sign from one 4-D vector to another, per element -// -VECTORMATH_FORCE_INLINE const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Maximum of two 4-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Minimum of two 4-D vectors per element -// -VECTORMATH_FORCE_INLINE const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Maximum element of a 4-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Vector4 &vec ); - -// Minimum element of a 4-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Vector4 &vec ); - -// Compute the sum of all elements of a 4-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec sum( const Vector4 &vec ); - -// Compute the dot product of two 4-D vectors -// -VECTORMATH_FORCE_INLINE const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ); - -// Compute the square of the length of a 4-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec lengthSqr( const Vector4 &vec ); - -// Compute the length of a 4-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec length( const Vector4 &vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -VECTORMATH_FORCE_INLINE const Vector4 normalize( const Vector4 &vec ); - -// Outer product of two 4-D vectors -// -VECTORMATH_FORCE_INLINE const Matrix4 outer( const Vector4 &vec0, const Vector4 &vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ); - -// Linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); - -// Spherical linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ); - -// Conditionally select between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, const boolInVec &select1 ); - -// Store four 4-D vectors as half-floats -// -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Vector4 &vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Vector4 &vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Point3( ) { }; - - // Construct a 3-D point from x, y, and z elements - // - VECTORMATH_FORCE_INLINE Point3( float x, float y, float z ); - - // Construct a 3-D point from x, y, and z elements (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Point3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit VECTORMATH_FORCE_INLINE Point3( const Vector3 &vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Point3( float scalar ); - - // Set all elements of a 3-D point to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Point3( const floatInVec &scalar ); - - // Set vector float data in a 3-D point - // - explicit VECTORMATH_FORCE_INLINE Point3( __m128 vf4 ); - - // Get vector float data from a 3-D point - // - VECTORMATH_FORCE_INLINE __m128 get128( ) const; - - // Assign one 3-D point to another - // - VECTORMATH_FORCE_INLINE Point3 & operator =( const Point3 &pnt ); - - // Set the x element of a 3-D point - // - VECTORMATH_FORCE_INLINE Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - VECTORMATH_FORCE_INLINE Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - VECTORMATH_FORCE_INLINE Point3 & setZ( float z ); - - // Set the x element of a 3-D point (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Point3 & setX( const floatInVec &x ); - - // Set the y element of a 3-D point (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Point3 & setY( const floatInVec &y ); - - // Set the z element of a 3-D point (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Point3 & setZ( const floatInVec &z ); - - // Get the x element of a 3-D point - // - VECTORMATH_FORCE_INLINE const floatInVec getX( ) const; - - // Get the y element of a 3-D point - // - VECTORMATH_FORCE_INLINE const floatInVec getY( ) const; - - // Get the z element of a 3-D point - // - VECTORMATH_FORCE_INLINE const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - VECTORMATH_FORCE_INLINE Point3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D point by index (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Point3 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, or z element of a 3-D point by index - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - VECTORMATH_FORCE_INLINE VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - VECTORMATH_FORCE_INLINE const floatInVec operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - VECTORMATH_FORCE_INLINE const Vector3 operator -( const Point3 &pnt ) const; - - // Add a 3-D point to a 3-D vector - // - VECTORMATH_FORCE_INLINE const Point3 operator +( const Vector3 &vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - VECTORMATH_FORCE_INLINE const Point3 operator -( const Vector3 &vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - VECTORMATH_FORCE_INLINE Point3 & operator +=( const Vector3 &vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - VECTORMATH_FORCE_INLINE Point3 & operator -=( const Vector3 &vec ); - -}; - -// Multiply two 3-D points per element -// -VECTORMATH_FORCE_INLINE const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -VECTORMATH_FORCE_INLINE const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -VECTORMATH_FORCE_INLINE const Point3 recipPerElem( const Point3 &pnt ); - -// Compute the absolute value of a 3-D point per element -// -VECTORMATH_FORCE_INLINE const Point3 absPerElem( const Point3 &pnt ); - -// Copy sign from one 3-D point to another, per element -// -VECTORMATH_FORCE_INLINE const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Maximum of two 3-D points per element -// -VECTORMATH_FORCE_INLINE const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Minimum of two 3-D points per element -// -VECTORMATH_FORCE_INLINE const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Maximum element of a 3-D point -// -VECTORMATH_FORCE_INLINE const floatInVec maxElem( const Point3 &pnt ); - -// Minimum element of a 3-D point -// -VECTORMATH_FORCE_INLINE const floatInVec minElem( const Point3 &pnt ); - -// Compute the sum of all elements of a 3-D point -// -VECTORMATH_FORCE_INLINE const floatInVec sum( const Point3 &pnt ); - -// Apply uniform scale to a 3-D point -// -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, float scaleVal ); - -// Apply uniform scale to a 3-D point (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -VECTORMATH_FORCE_INLINE const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -VECTORMATH_FORCE_INLINE const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -VECTORMATH_FORCE_INLINE const floatInVec distSqrFromOrigin( const Point3 &pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -VECTORMATH_FORCE_INLINE const floatInVec distFromOrigin( const Point3 &pnt ); - -// Compute the square of the distance between two 3-D points -// -VECTORMATH_FORCE_INLINE const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ); - -// Compute the distance between two 3-D points -// -VECTORMATH_FORCE_INLINE const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ); - -// Linear interpolation between two 3-D points (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ); - -// Conditionally select between two 3-D points (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ); - -// Store x, y, and z elements of 3-D point in first three words of a quadword, preserving fourth word -// -VECTORMATH_FORCE_INLINE void storeXYZ( const Point3 &pnt, __m128 * quad ); - -// Load four three-float 3-D points, stored in three quadwords -// -VECTORMATH_FORCE_INLINE void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ); - -// Store four 3-D points in three quadwords -// -VECTORMATH_FORCE_INLINE void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ); - -// Store eight 3-D points as half-floats -// -VECTORMATH_FORCE_INLINE void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Point3 &pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Point3 &pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Quat( ) { }; - - VECTORMATH_FORCE_INLINE Quat(const Quat& quat); - - // Construct a quaternion from x, y, z, and w elements - // - VECTORMATH_FORCE_INLINE Quat( float x, float y, float z, float w ); - - // Construct a quaternion from x, y, z, and w elements (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - VECTORMATH_FORCE_INLINE Quat( const Vector3 &xyz, float w ); - - // Construct a quaternion from a 3-D vector and a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat( const Vector3 &xyz, const floatInVec &w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit VECTORMATH_FORCE_INLINE Quat( const Vector4 &vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit VECTORMATH_FORCE_INLINE Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Quat( float scalar ); - - // Set all elements of a quaternion to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Quat( const floatInVec &scalar ); - - // Set vector float data in a quaternion - // - explicit VECTORMATH_FORCE_INLINE Quat( __m128 vf4 ); - - // Get vector float data from a quaternion - // - VECTORMATH_FORCE_INLINE __m128 get128( ) const; - - // Set a quaterion from vector float data - // - VECTORMATH_FORCE_INLINE void set128(vec_float4 vec); - - // Assign one quaternion to another - // - VECTORMATH_FORCE_INLINE Quat & operator =( const Quat &quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - VECTORMATH_FORCE_INLINE Quat & setXYZ( const Vector3 &vec ); - - // Get the x, y, and z elements of a quaternion - // - VECTORMATH_FORCE_INLINE const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - VECTORMATH_FORCE_INLINE Quat & setX( float x ); - - // Set the y element of a quaternion - // - VECTORMATH_FORCE_INLINE Quat & setY( float y ); - - // Set the z element of a quaternion - // - VECTORMATH_FORCE_INLINE Quat & setZ( float z ); - - // Set the w element of a quaternion - // - VECTORMATH_FORCE_INLINE Quat & setW( float w ); - - // Set the x element of a quaternion (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & setX( const floatInVec &x ); - - // Set the y element of a quaternion (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & setY( const floatInVec &y ); - - // Set the z element of a quaternion (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & setZ( const floatInVec &z ); - - // Set the w element of a quaternion (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & setW( const floatInVec &w ); - - // Get the x element of a quaternion - // - VECTORMATH_FORCE_INLINE const floatInVec getX( ) const; - - // Get the y element of a quaternion - // - VECTORMATH_FORCE_INLINE const floatInVec getY( ) const; - - // Get the z element of a quaternion - // - VECTORMATH_FORCE_INLINE const floatInVec getZ( ) const; - - // Get the w element of a quaternion - // - VECTORMATH_FORCE_INLINE const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - VECTORMATH_FORCE_INLINE Quat & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a quaternion by index (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & setElem( int idx, const floatInVec &value ); - - // Get an x, y, z, or w element of a quaternion by index - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - VECTORMATH_FORCE_INLINE VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - VECTORMATH_FORCE_INLINE const floatInVec operator []( int idx ) const; - - // Add two quaternions - // - VECTORMATH_FORCE_INLINE const Quat operator +( const Quat &quat ) const; - - // Subtract a quaternion from another quaternion - // - VECTORMATH_FORCE_INLINE const Quat operator -( const Quat &quat ) const; - - // Multiply two quaternions - // - VECTORMATH_FORCE_INLINE const Quat operator *( const Quat &quat ) const; - - // Multiply a quaternion by a scalar - // - VECTORMATH_FORCE_INLINE const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - VECTORMATH_FORCE_INLINE const Quat operator /( float scalar ) const; - - // Multiply a quaternion by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Quat operator *( const floatInVec &scalar ) const; - - // Divide a quaternion by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Quat operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - VECTORMATH_FORCE_INLINE Quat & operator +=( const Quat &quat ); - - // Perform compound assignment and subtraction by a quaternion - // - VECTORMATH_FORCE_INLINE Quat & operator -=( const Quat &quat ); - - // Perform compound assignment and multiplication by a quaternion - // - VECTORMATH_FORCE_INLINE Quat & operator *=( const Quat &quat ); - - // Perform compound assignment and multiplication by a scalar - // - VECTORMATH_FORCE_INLINE Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - VECTORMATH_FORCE_INLINE Quat & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Quat & operator /=( const floatInVec &scalar ); - - // Negate all elements of a quaternion - // - VECTORMATH_FORCE_INLINE const Quat operator -( ) const; - - // Construct an identity quaternion - // - static VECTORMATH_FORCE_INLINE const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static VECTORMATH_FORCE_INLINE const Quat rotation( const Vector3 &unitVec0, const Vector3 &unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static VECTORMATH_FORCE_INLINE const Quat rotation( float radians, const Vector3 &unitVec ); - - // Construct a quaternion to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Quat rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static VECTORMATH_FORCE_INLINE const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static VECTORMATH_FORCE_INLINE const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static VECTORMATH_FORCE_INLINE const Quat rotationZ( float radians ); - - // Construct a quaternion to rotate around the x axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Quat rotationX( const floatInVec &radians ); - - // Construct a quaternion to rotate around the y axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Quat rotationY( const floatInVec &radians ); - - // Construct a quaternion to rotate around the z axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Quat rotationZ( const floatInVec &radians ); - -}; - -// Multiply a quaternion by a scalar -// -VECTORMATH_FORCE_INLINE const Quat operator *( float scalar, const Quat &quat ); - -// Multiply a quaternion by a scalar (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Quat operator *( const floatInVec &scalar, const Quat &quat ); - -// Compute the conjugate of a quaternion -// -VECTORMATH_FORCE_INLINE const Quat conj( const Quat &quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -VECTORMATH_FORCE_INLINE const Vector3 rotate( const Quat &unitQuat, const Vector3 &vec ); - -// Compute the dot product of two quaternions -// -VECTORMATH_FORCE_INLINE const floatInVec dot( const Quat &quat0, const Quat &quat1 ); - -// Compute the norm of a quaternion -// -VECTORMATH_FORCE_INLINE const floatInVec norm( const Quat &quat ); - -// Compute the length of a quaternion -// -VECTORMATH_FORCE_INLINE const floatInVec length( const Quat &quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -VECTORMATH_FORCE_INLINE const Quat normalize( const Quat &quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Quat lerp( float t, const Quat &quat0, const Quat &quat1 ); - -// Linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 ); - -// Spherical linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -VECTORMATH_FORCE_INLINE const Quat slerp( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1 ); - -// Spherical quadrangle interpolation -// -VECTORMATH_FORCE_INLINE const Quat squad( float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); - -// Spherical quadrangle interpolation (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Quat squad( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Quat select( const Quat &quat0, const Quat &quat1, bool select1 ); - -// Conditionally select between two quaternions (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Quat &quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Quat &quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Matrix3( ) { }; - - // Copy a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - VECTORMATH_FORCE_INLINE Matrix3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit VECTORMATH_FORCE_INLINE Matrix3( const Quat &unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Matrix3( float scalar ); - - // Set all elements of a 3x3 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Matrix3( const floatInVec &scalar ); - - // Assign one 3x3 matrix to another - // - VECTORMATH_FORCE_INLINE Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & setCol0( const Vector3 &col0 ); - - // Set column 1 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & setCol1( const Vector3 &col1 ); - - // Set column 2 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & setCol2( const Vector3 &col2 ); - - // Get column 0 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Matrix3 & setCol( int col, const Vector3 &vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Matrix3 & setRow( int row, const Vector3 &vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - VECTORMATH_FORCE_INLINE Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - VECTORMATH_FORCE_INLINE const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE Matrix3 & setElem( int col, int row, float val ); - - // Set the element of a 3x3 matrix referred to by column and row indices (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Matrix3 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - VECTORMATH_FORCE_INLINE const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - VECTORMATH_FORCE_INLINE const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - VECTORMATH_FORCE_INLINE const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - VECTORMATH_FORCE_INLINE const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Matrix3 operator *( const floatInVec &scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - VECTORMATH_FORCE_INLINE const Vector3 operator *( const Vector3 &vec ) const; - - // Multiply two 3x3 matrices - // - VECTORMATH_FORCE_INLINE const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - VECTORMATH_FORCE_INLINE Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Matrix3 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - VECTORMATH_FORCE_INLINE Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static VECTORMATH_FORCE_INLINE const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationX( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationY( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationZ( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static VECTORMATH_FORCE_INLINE const Matrix3 rotation( const Quat &unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static VECTORMATH_FORCE_INLINE const Matrix3 scale( const Vector3 &scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -VECTORMATH_FORCE_INLINE const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -VECTORMATH_FORCE_INLINE const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -VECTORMATH_FORCE_INLINE const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -VECTORMATH_FORCE_INLINE const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -VECTORMATH_FORCE_INLINE const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -VECTORMATH_FORCE_INLINE const floatInVec determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -// Conditionally select between two 3x3 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Matrix4( ) { }; - - // Copy a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - VECTORMATH_FORCE_INLINE Matrix4( const Vector4 &col0, const Vector4 &col1, const Vector4 &col2, const Vector4 &col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit VECTORMATH_FORCE_INLINE Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - VECTORMATH_FORCE_INLINE Matrix4( const Matrix3 & mat, const Vector3 &translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - VECTORMATH_FORCE_INLINE Matrix4( const Quat &unitQuat, const Vector3 &translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Matrix4( float scalar ); - - // Set all elements of a 4x4 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Matrix4( const floatInVec &scalar ); - - // Assign one 4x4 matrix to another - // - VECTORMATH_FORCE_INLINE Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - VECTORMATH_FORCE_INLINE Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - VECTORMATH_FORCE_INLINE Matrix4 & setTranslation( const Vector3 &translateVec ); - - // Get the translation component of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & setCol0( const Vector4 &col0 ); - - // Set column 1 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & setCol1( const Vector4 &col1 ); - - // Set column 2 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & setCol2( const Vector4 &col2 ); - - // Set column 3 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & setCol3( const Vector4 &col3 ); - - // Get column 0 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Matrix4 & setCol( int col, const Vector4 &vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Matrix4 & setRow( int row, const Vector4 &vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - VECTORMATH_FORCE_INLINE Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - VECTORMATH_FORCE_INLINE const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE Matrix4 & setElem( int col, int row, float val ); - - // Set the element of a 4x4 matrix referred to by column and row indices (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Matrix4 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - VECTORMATH_FORCE_INLINE const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - VECTORMATH_FORCE_INLINE const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - VECTORMATH_FORCE_INLINE const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE const Matrix4 operator *( const floatInVec &scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - VECTORMATH_FORCE_INLINE const Vector4 operator *( const Vector4 &vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - VECTORMATH_FORCE_INLINE const Vector4 operator *( const Vector3 &vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - VECTORMATH_FORCE_INLINE const Vector4 operator *( const Point3 &pnt ) const; - - // Multiply two 4x4 matrices - // - VECTORMATH_FORCE_INLINE const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - VECTORMATH_FORCE_INLINE Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Matrix4 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static VECTORMATH_FORCE_INLINE const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationX( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationY( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationZ( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static VECTORMATH_FORCE_INLINE const Matrix4 rotation( const Quat &unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static VECTORMATH_FORCE_INLINE const Matrix4 scale( const Vector3 &scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static VECTORMATH_FORCE_INLINE const Matrix4 translation( const Vector3 &translateVec ); - - // Construct viewing matrix based on eye, position looked at, and up direction - // - static VECTORMATH_FORCE_INLINE const Matrix4 lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ); - - // Construct a perspective projection matrix - // - static VECTORMATH_FORCE_INLINE const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static VECTORMATH_FORCE_INLINE const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static VECTORMATH_FORCE_INLINE const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -VECTORMATH_FORCE_INLINE const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) -// -VECTORMATH_FORCE_INLINE const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -VECTORMATH_FORCE_INLINE const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -VECTORMATH_FORCE_INLINE const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -VECTORMATH_FORCE_INLINE const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -VECTORMATH_FORCE_INLINE const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -VECTORMATH_FORCE_INLINE const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -VECTORMATH_FORCE_INLINE const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -VECTORMATH_FORCE_INLINE const floatInVec determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -// Conditionally select between two 4x4 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - VECTORMATH_FORCE_INLINE Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - VECTORMATH_FORCE_INLINE Transform3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2, const Vector3 &col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - VECTORMATH_FORCE_INLINE Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - VECTORMATH_FORCE_INLINE Transform3( const Quat &unitQuat, const Vector3 &translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit VECTORMATH_FORCE_INLINE Transform3( float scalar ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value (scalar data contained in vector data type) - // - explicit VECTORMATH_FORCE_INLINE Transform3( const floatInVec &scalar ); - - // Assign one 3x4 transformation matrix to another - // - VECTORMATH_FORCE_INLINE Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - VECTORMATH_FORCE_INLINE Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - VECTORMATH_FORCE_INLINE Transform3 & setTranslation( const Vector3 &translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3 & setCol0( const Vector3 &col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3 & setCol1( const Vector3 &col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3 & setCol2( const Vector3 &col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3 & setCol3( const Vector3 &col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Transform3 & setCol( int col, const Vector3 &vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE Transform3 & setRow( int row, const Vector4 &vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - VECTORMATH_FORCE_INLINE const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - VECTORMATH_FORCE_INLINE Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - VECTORMATH_FORCE_INLINE const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE Transform3 & setElem( int col, int row, float val ); - - // Set the element of a 3x4 transformation matrix referred to by column and row indices (scalar data contained in vector data type) - // - VECTORMATH_FORCE_INLINE Transform3 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - VECTORMATH_FORCE_INLINE const floatInVec getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - VECTORMATH_FORCE_INLINE const Vector3 operator *( const Vector3 &vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - VECTORMATH_FORCE_INLINE const Point3 operator *( const Point3 &pnt ) const; - - // Multiply two 3x4 transformation matrices - // - VECTORMATH_FORCE_INLINE const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - VECTORMATH_FORCE_INLINE Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static VECTORMATH_FORCE_INLINE const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationX( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationY( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationZ( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static VECTORMATH_FORCE_INLINE const Transform3 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static VECTORMATH_FORCE_INLINE const Transform3 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static VECTORMATH_FORCE_INLINE const Transform3 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static VECTORMATH_FORCE_INLINE const Transform3 rotation( const Quat &unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static VECTORMATH_FORCE_INLINE const Transform3 scale( const Vector3 &scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static VECTORMATH_FORCE_INLINE const Transform3 translation( const Vector3 &translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -VECTORMATH_FORCE_INLINE const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -VECTORMATH_FORCE_INLINE const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -VECTORMATH_FORCE_INLINE const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -VECTORMATH_FORCE_INLINE const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -VECTORMATH_FORCE_INLINE const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -VECTORMATH_FORCE_INLINE const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -// Conditionally select between two 3x4 transformation matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -VECTORMATH_FORCE_INLINE const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -VECTORMATH_FORCE_INLINE void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/std/boolInVec.h b/Extras/PhysicsEffects/include/vecmath/std/boolInVec.h deleted file mode 100644 index 7ea380f91..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/boolInVec.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2006-2010 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_SCALAR_H -#define _BOOLINVEC_SCALAR_H - -#include -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 diff --git a/Extras/PhysicsEffects/include/vecmath/std/floatInVec.h b/Extras/PhysicsEffects/include/vecmath/std/floatInVec.h deleted file mode 100644 index 1aa2ee1cc..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/floatInVec.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - Copyright (C) 2006-2010 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__SCALAR_H -#define _FLOATINVEC__SCALAR_H - -#include -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 diff --git a/Extras/PhysicsEffects/include/vecmath/std/mat_aos.h b/Extras/PhysicsEffects/include/vecmath/std/mat_aos.h deleted file mode 100644 index 3a6d4843e..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/mat_aos.h +++ /dev/null @@ -1,1643 +0,0 @@ -/* - Copyright (C) 2006-2010 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_MAT_AOS_CPP__SCALAR_H -#define _VECTORMATH_MAT_AOS_CPP__SCALAR_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = ( qx + qx ); - qy2 = ( qy + qy ); - qz2 = ( qz + qz ); - qxqx2 = ( qx * qx2 ); - qxqy2 = ( qx * qy2 ); - qxqz2 = ( qx * qz2 ); - qxqw2 = ( qw * qx2 ); - qyqy2 = ( qy * qy2 ); - qyqz2 = ( qy * qz2 ); - qyqw2 = ( qw * qy2 ); - qzqz2 = ( qz * qz2 ); - qzqw2 = ( qw * qz2 ); - mCol0 = Vector3( ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); - mCol1 = Vector3( ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); - mCol2 = Vector3( ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - float detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = ( 1.0f / dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ), - Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ), - Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ) - ); -} - -inline float determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix3( - Vector3( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ), - Vector3( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ), - Vector3( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - res0.setX( ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); - res0.setY( ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); - res0.setZ( ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); - res0.setW( ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); - detInv = ( 1.0f / ( ( ( ( mA * res0.getX() ) + ( mE * res0.getY() ) ) + ( mI * res0.getZ() ) ) + ( mM * res0.getW() ) ) ); - res1.setX( ( mI * tmp1 ) ); - res1.setY( ( mM * tmp0 ) ); - res1.setZ( ( mA * tmp1 ) ); - res1.setW( ( mE * tmp0 ) ); - res3.setX( ( mI * tmp3 ) ); - res3.setY( ( mM * tmp2 ) ); - res3.setZ( ( mA * tmp3 ) ); - res3.setW( ( mE * tmp2 ) ); - res2.setX( ( mI * tmp5 ) ); - res2.setY( ( mM * tmp4 ) ); - res2.setZ( ( mA * tmp5 ) ); - res2.setW( ( mE * tmp4 ) ); - tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); - tmp1 = ( ( mM * mF ) - ( mE * mN ) ); - tmp2 = ( ( mI * mD ) - ( mA * mL ) ); - tmp3 = ( ( mM * mH ) - ( mE * mP ) ); - tmp4 = ( ( mI * mC ) - ( mA * mK ) ); - tmp5 = ( ( mM * mG ) - ( mE * mO ) ); - res2.setX( ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.getX() ) ); - res2.setY( ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.getY() ) ); - res2.setZ( ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.getZ() ) ); - res2.setW( ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.getW() ) ); - res3.setX( ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.getX() ) ); - res3.setY( ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.getY() ) ); - res3.setZ( ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.getZ() ) ); - res3.setW( ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.getW() ) ); - res1.setX( ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.getX() ) ); - res1.setY( ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.getY() ) ); - res1.setZ( ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.getZ() ) ); - res1.setW( ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline float determinant( const Matrix4 & mat ) -{ - float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); - dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); - dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); - dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); - return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), - ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), - ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), - ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ), - ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ), - ( ( ( ( mCol0.getW() * pnt.getX() ) + ( mCol1.getW() * pnt.getY() ) ) + ( mCol2.getW() * pnt.getZ() ) ) + mCol3.getW() ) - ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4::xAxis( ), - Vector4( 0.0f, c, s, 0.0f ), - Vector4( 0.0f, -s, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, 0.0f, -s, 0.0f ), - Vector4::yAxis( ), - Vector4( s, 0.0f, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, s, 0.0f, 0.0f ), - Vector4( -s, c, 0.0f, 0.0f ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix4( - Vector4( ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ), - Vector4( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ), - Vector4( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix4( - Vector4( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ), - Vector4( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ), - Vector4( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, scaleVec.getY(), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, scaleVec.getZ(), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); - rangeInv = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( f / aspect ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, f, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - n2 = ( zNear + zNear ); - return Matrix4( - Vector4( ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ), - Vector4( ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ), - Vector4( ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - float detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = ( 1.0f / dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ); - inv1 = Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ); - inv2 = Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Vector3 inv0, inv1, inv2; - inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); - inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); - inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Transform3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - int negTrace, ZgtX, ZgtY, YgtX; - int largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = ( ( xx + yy ) + zz ); - - negTrace = ( trace < 0.0f ); - ZgtX = zz > xx; - ZgtY = zz > yy; - YgtX = yy > xx; - largestXorY = ( !ZgtX || !ZgtY ) && negTrace; - largestYorZ = ( YgtX || ZgtX ) && negTrace; - largestZorX = ( ZgtY || !YgtX ) && negTrace; - - if ( largestXorY ) - { - zz = -zz; - xy = -xy; - } - if ( largestYorZ ) - { - xx = -xx; - yz = -yz; - } - if ( largestZorX ) - { - yy = -yy; - zx = -zx; - } - - radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); - scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); - - tmpx = ( ( zy - yz ) * scale ); - tmpy = ( ( xz - zx ) * scale ); - tmpz = ( ( yx - xy ) * scale ); - tmpw = ( radicand * scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - if ( largestXorY ) - { - qx = tmpw; - qy = tmpz; - qz = tmpy; - qw = tmpx; - } - if ( largestYorZ ) - { - tmpx = qx; - tmpz = qz; - qx = qy; - qy = tmpx; - qz = qw; - qw = tmpz; - } - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - ( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ), - ( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ), - ( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( 0.0f, vec.getZ(), -vec.getY() ), - Vector3( -vec.getZ(), 0.0f, vec.getX() ), - Vector3( vec.getY(), -vec.getX(), 0.0f ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/std/quat_aos.h b/Extras/PhysicsEffects/include/vecmath/std/quat_aos.h deleted file mode 100644 index 6a4a0f212..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/quat_aos.h +++ /dev/null @@ -1,446 +0,0 @@ -/* - Copyright (C) 2006-2010 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 { - -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 diff --git a/Extras/PhysicsEffects/include/vecmath/std/vec_aos.h b/Extras/PhysicsEffects/include/vecmath/std/vec_aos.h deleted file mode 100644 index 7dcd2526b..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/vec_aos.h +++ /dev/null @@ -1,1439 +0,0 @@ -/* - Copyright (C) 2006-2010 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Aos { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -} - -inline Vector3::Vector3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( 1.0f, 0.0f, 0.0f ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( 0.0f, 1.0f, 0.0f ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( 0.0f, 0.0f, 1.0f ); -} - -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZ( Vector3 & vec, const float * fptr ) -{ - vec = Vector3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Vector3 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - ( mX + pnt.getX() ), - ( mY + pnt.getY() ), - ( mZ + pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return Vector3( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return Vector3( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - -mX, - -mY, - -mZ - ); -} - -inline const Vector3 operator *( float scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float maxElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float minElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - return result; -} - -inline float sum( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - return result; -} - -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - return result; -} - -inline float lengthSqr( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - return result; -} - -inline float length( const Vector3 & vec ) -{ - return ::sqrtf( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( const Vector3 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector3( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ) - ); -} - -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( ( vec0.getY() * vec1.getZ() ) - ( vec0.getZ() * vec1.getY() ) ), - ( ( vec0.getZ() * vec1.getX() ) - ( vec0.getX() * vec1.getZ() ) ), - ( ( vec0.getX() * vec1.getY() ) - ( vec0.getY() * vec1.getX() ) ) - ); -} - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ) -{ - return Vector3( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, float _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = 0.0f; -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = 1.0f; -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( 1.0f, 0.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( 0.0f, 1.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( 0.0f, 0.0f, 1.0f, 0.0f ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZW( Vector4 & vec, const float * fptr ) -{ - vec = Vector4( fptr[0], fptr[1], fptr[2], fptr[3] ); -} - -inline void storeXYZW( const Vector4 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); - fptr[3] = vec.getW(); -} - -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( float _w ) -{ - mW = _w; - return *this; -} - -inline float Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ), - ( mW + vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ), - ( mW - vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return Vector4( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ), - ( mW * scalar ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return Vector4( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ), - ( mW / scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - -mX, - -mY, - -mZ, - -mW - ); -} - -inline const Vector4 operator *( float scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ), - ( vec0.getW() * vec1.getW() ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ), - ( vec0.getW() / vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ), - ( 1.0f / vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ), - sqrtf( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ), - ( 1.0f / sqrtf( vec.getW() ) ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ), - fabsf( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ), - ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float maxElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - result = (vec.getW() > result)? vec.getW() : result; - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float minElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - result = (vec.getW() < result)? vec.getW() : result; - return result; -} - -inline float sum( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - result = ( result + vec.getW() ); - return result; -} - -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - result = ( result + ( vec0.getW() * vec1.getW() ) ); - return result; -} - -inline float lengthSqr( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - result = ( result + ( vec.getW() * vec.getW() ) ); - return result; -} - -inline float length( const Vector4 & vec ) -{ - return ::sqrtf( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector4( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ), - ( vec.getW() * lenInv ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ) -{ - return Vector4( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ(), - ( select1 )? vec1.getW() : vec0.getW() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -} - -inline Point3::Point3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -} - -inline Point3::Point3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline void loadXYZ( Point3 & pnt, const float * fptr ) -{ - pnt = Point3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Point3 & pnt, float * fptr ) -{ - fptr[0] = pnt.getX(); - fptr[1] = pnt.getY(); - fptr[2] = pnt.getZ(); -} - -inline void loadHalfFloats( Point3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Point3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - ( mX - pnt.mX ), - ( mY - pnt.mY ), - ( mZ - pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - ( mX + vec.getX() ), - ( mY + vec.getY() ), - ( mZ + vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - ( mX - vec.getX() ), - ( mY - vec.getY() ), - ( mZ - vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() * pnt1.getX() ), - ( pnt0.getY() * pnt1.getY() ), - ( pnt0.getZ() * pnt1.getZ() ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() / pnt1.getX() ), - ( pnt0.getY() / pnt1.getY() ), - ( pnt0.getZ() / pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / pnt.getX() ), - ( 1.0f / pnt.getY() ), - ( 1.0f / pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf( pnt.getX() ), - sqrtf( pnt.getY() ), - sqrtf( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / sqrtf( pnt.getX() ) ), - ( 1.0f / sqrtf( pnt.getY() ) ), - ( 1.0f / sqrtf( pnt.getZ() ) ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf( pnt.getX() ), - fabsf( pnt.getY() ), - fabsf( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ), - ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ), - ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float maxElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() > result)? pnt.getZ() : result; - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float minElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() < result)? pnt.getZ() : result; - return result; -} - -inline float sum( const Point3 & pnt ) -{ - float result; - result = ( pnt.getX() + pnt.getY() ); - result = ( result + pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, float scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline float projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - float result; - result = ( pnt.getX() * unitVec.getX() ); - result = ( result + ( pnt.getY() * unitVec.getY() ) ); - result = ( result + ( pnt.getZ() * unitVec.getZ() ) ); - return result; -} - -inline float distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline float distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ) -{ - return Point3( - ( select1 )? pnt1.getX() : pnt0.getX(), - ( select1 )? pnt1.getY() : pnt0.getY(), - ( select1 )? pnt1.getZ() : pnt0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/PhysicsEffects/include/vecmath/std/vectormath_aos.h b/Extras/PhysicsEffects/include/vecmath/std/vectormath_aos.h deleted file mode 100644 index c1f39858c..000000000 --- a/Extras/PhysicsEffects/include/vecmath/std/vectormath_aos.h +++ /dev/null @@ -1,1885 +0,0 @@ -/* - 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_AOS_CPP_SCALAR_H -#define _VECTORMATH_AOS_CPP_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Get the x element of a 3-D vector - // - inline float getX( ) const; - - // Get the y element of a 3-D vector - // - inline float getY( ) const; - - // Get the z element of a 3-D vector - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline float maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline float minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline float sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline float lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline float length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Vector3 & vec, const float * fptr ); - -// Store x, y, and z elements of a 3-D vector in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Vector3 & vec, float * fptr ); - -// Load three-half-floats as a 3-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ); - -// Store a 3-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, float w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Get the x element of a 4-D vector - // - inline float getX( ) const; - - // Get the y element of a 4-D vector - // - inline float getY( ) const; - - // Get the z element of a 4-D vector - // - inline float getZ( ) const; - - // Get the w element of a 4-D vector - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline float maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline float minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline float sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline float lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline float length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Vector4 & vec, const float * fptr ); - -// Store x, y, z, and w elements of a 4-D vector in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Vector4 & vec, float * fptr ); - -// Load four-half-floats as a 4-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ); - -// Store a 4-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Get the x element of a 3-D point - // - inline float getX( ) const; - - // Get the y element of a 3-D point - // - inline float getY( ) const; - - // Get the z element of a 3-D point - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline float maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline float minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline float sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, float scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline float projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline float distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline float distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Point3 & pnt, const float * fptr ); - -// Store x, y, and z elements of a 3-D point in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Point3 & pnt, float * fptr ); - -// Load three-half-floats as a 3-D point -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Point3 & pnt, const unsigned short * hfptr ); - -// Store a 3-D point as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Point3 & pnt, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, float w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Get the x element of a quaternion - // - inline float getX( ) const; - - // Get the y element of a quaternion - // - inline float getY( ) const; - - // Get the z element of a quaternion - // - inline float getZ( ) const; - - // Get the w element of a quaternion - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline float dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline float norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline float length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// -inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Quat & quat, const float * fptr ); - -// Store x, y, z, and w elements of a quaternion in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Quat & quat, float * fptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline float determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline float determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/PhysicsEffects/physics_effects_license.txt b/Extras/PhysicsEffects/physics_effects_license.txt deleted file mode 100644 index 7921937ca..000000000 --- a/Extras/PhysicsEffects/physics_effects_license.txt +++ /dev/null @@ -1,10 +0,0 @@ -Copyright (c) 2012, 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 HOLDER 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. diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.cproject b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.cproject deleted file mode 100644 index 16eca1494..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.cproject +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index 381d02593..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.project b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.project deleted file mode 100644 index de96cd774..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_1_Simple - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample1/PfxApp_1_Simple.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple/src/pfx/sample1/PfxApp_1_Simple.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/AndroidManifest.xml deleted file mode 100644 index f62261faf..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/AndroidManifest.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/build.xml deleted file mode 100644 index 83988f374..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Android.mk deleted file mode 100644 index 5560e779b..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Android.mk +++ /dev/null @@ -1,138 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH -# add the following #define to run standalone NEON speedup potential tests -# -DTEST_NEON_PERFORMANCE -# - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary cpufeatures - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_1_Simple -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/1_simple \ - $(LOCAL_PATH)sample/api_physics_effects/common \ - $(LOCAL_PATH)sample/test_ARM_NEON_performance - -# -# The source files located in the test_ARM_NEON_performance folder are used -# to test the potential performance improvements of atomic vector math -# functions using ARM NEON instructions. Note that these are tested outside -# of the vectormath library, to avoid the overhead associated with that -# library. The assembly files contain pure NEON assembly code. -# -# The test_neon_solve_linear_constraint_row.cpp is not an atomic vector -# math operation. Rather it is a NEON assembly implementation of one of the -# leaf functions in the physics effects low level constraint solver. -# -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/1_simple/main.cpp \ - sample/api_physics_effects/1_simple/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp \ - sample/test_ARM_NEON_performance/neon_dot_product.S \ - sample/test_ARM_NEON_performance/neon_cross_product.S \ - sample/test_ARM_NEON_performance/neon_matrix4_operator_multiply.S \ - sample/test_ARM_NEON_performance/neon_matrix3_operator_multiply.S \ - sample/test_ARM_NEON_performance/neon_orthoInverse_transform3.S \ - sample/test_ARM_NEON_performance/neon_transform3_operator_multiply.S \ - sample/test_ARM_NEON_performance/neon_transpose_matrix3.S \ - sample/test_ARM_NEON_performance/test_neon_cross_product.cpp \ - sample/test_ARM_NEON_performance/test_neon_dot_product.cpp \ - sample/test_ARM_NEON_performance/test_neon_matrix3_operator_multiply.cpp \ - sample/test_ARM_NEON_performance/test_neon_matrix4_operator_multiply.cpp \ - sample/test_ARM_NEON_performance/test_neon_orthoInverse_transform3.cpp \ - sample/test_ARM_NEON_performance/test_neon_transform3_operator_multiply.cpp \ - sample/test_ARM_NEON_performance/test_neon_transpose_matrix3.cpp \ - sample/test_ARM_NEON_performance/test_neon_solve_linear_constraint_row.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,android/cpufeatures) - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Application.mk deleted file mode 100644 index 2fb23fb62..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_1_Simple -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/values/strings.xml deleted file mode 100644 index 2310f130f..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 1 Simple - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/sample1/PfxApp_1_Simple.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/sample1/PfxApp_1_Simple.java deleted file mode 100644 index 00782cd15..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple/src/pfx/sample1/PfxApp_1_Simple.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample1; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.util.Log; - -/** - * When program loads it creates a OpenGl ES render window for - * the physics effects sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_1_Simple extends Activity -{ - @Override - protected void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - int numprocessors = Runtime.getRuntime().availableProcessors(); - Log.v("PFX THREADING", "Number of Processors: " + Integer.toString(numprocessors)); - } - - private GLSurfaceView peGLView; - - // This is where you specify which physics effects sample you would like to load - static - { - System.loadLibrary("PfxApp_1_Simple"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.cproject b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.cproject deleted file mode 100644 index 9ac8cbd3c..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.cproject +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index c8e7d6cdc..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.project b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.project deleted file mode 100644 index d8a9d6139..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_1_Simple_Parallel - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample1b/PfxApp_1_Simple_Parallel.java - 1 - PFX_ROOT/project/Android/PfxApp_1_Simple_Parallel/src/pfx/sample1b/PfxApp_1_Simple_Parallel.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/AndroidManifest.xml deleted file mode 100644 index 416b89271..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/AndroidManifest.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/build.xml deleted file mode 100644 index 0839f70e1..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Android.mk deleted file mode 100644 index 21bb098c1..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Android.mk +++ /dev/null @@ -1,109 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -DUSE_PTHREADS -mfpu=neon -mfloat-abi=softfp -pthread -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary cpufeatures - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_1_Simple_Parallel -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/1_simple_parallel \ - $(LOCAL_PATH)sample/api_physics_effects/common \ - $(LOCAL_PATH)sample/test_ARM_NEON_performance - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/1_simple_parallel/main.cpp \ - sample/api_physics_effects/1_simple_parallel/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,android/cpufeatures) - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Application.mk deleted file mode 100644 index 0187aba72..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_1_Simple_Parallel -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/values/strings.xml deleted file mode 100644 index 945bf6f54..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 1 Simple Parallel - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/sample1b/PfxApp_1_Simple_Parallel.java b/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/sample1b/PfxApp_1_Simple_Parallel.java deleted file mode 100644 index d73eba4db..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_1_Simple_Parallel/src/pfx/sample1b/PfxApp_1_Simple_Parallel.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample1b; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; -import android.util.Log; - -/** - * When program loads it creates a OpenGl ES render window for - * the physics effects sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_1_Simple_Parallel extends Activity -{ - @Override - protected void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - int numprocessors = Runtime.getRuntime().availableProcessors(); - Log.v("PFX THREADING", "Number of Processors: " + Integer.toString(numprocessors)); - } - - private GLSurfaceView peGLView; - - // This is where you specify which physics effects sample you would like to load - static - { - System.loadLibrary("PfxApp_1_Simple_Parallel"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index 8c0ed3941..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.project b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.project deleted file mode 100644 index a45e1256d..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_2_Stable - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample2/PfxApp_2_Stable.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable/src/pfx/sample/PfxApp_2_Stable.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/AndroidManifest.xml deleted file mode 100644 index fbb33351f..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/build.xml deleted file mode 100644 index 45b1ef65a..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/default.properties deleted file mode 100644 index 25c028059..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Android.mk deleted file mode 100644 index 4a5175d66..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_2_Stable -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/2_stable \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/2_stable/main.cpp \ - sample/api_physics_effects/2_stable/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Application.mk deleted file mode 100644 index 77151c80c..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_2_Stable -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/values/strings.xml deleted file mode 100644 index e2114da8b..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 2 Stable - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/sample2/PfxApp_2_Stable.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/sample2/PfxApp_2_Stable.java deleted file mode 100644 index 318754e03..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable/src/pfx/sample2/PfxApp_2_Stable.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample2; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_2_Stable extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_2_Stable"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index 37635faf3..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.project b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.project deleted file mode 100644 index 411ca1abe..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_2_Stable_Parallel - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample2b/PfxApp_2_Stable_Parallel.java - 1 - PFX_ROOT/project/Android/PfxApp_2_Stable_Parallel/src/pfx/sample2b/PfxApp_2_Stable_Parallel.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/AndroidManifest.xml deleted file mode 100644 index ca47f66b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/build.xml deleted file mode 100644 index 15bf3cb60..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Android.mk deleted file mode 100644 index 24cb431e2..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -DUSE_PTHREADS -mfpu=neon -mfloat-abi=softfp -pthread -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_2_Stable_Parallel -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/2_stable_parallel \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/2_stable_parallel/main.cpp \ - sample/api_physics_effects/2_stable_parallel/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Application.mk deleted file mode 100644 index acff843aa..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_2_Stable_Parallel -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/values/strings.xml deleted file mode 100644 index 630b3001d..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 2 Stable Parallel - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/sample2b/PfxApp_2_Stable_Parallel.java b/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/sample2b/PfxApp_2_Stable_Parallel.java deleted file mode 100644 index 40ff1450a..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_2_Stable_Parallel/src/pfx/sample2b/PfxApp_2_Stable_Parallel.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample2b; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_2_Stable_Parallel extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_2_Stable_Parallel"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index dfb6be45c..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.project b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.project deleted file mode 100644 index b255ca0e6..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_3_Sleep - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample3/PfxApp_3_Sleep.java - 1 - PFX_ROOT/project/Android/PfxApp_3_Sleep/src/pfx/sample/PfxApp_3_Sleep.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/AndroidManifest.xml deleted file mode 100644 index a07242c80..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/build.xml deleted file mode 100644 index cab642bca..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/default.properties deleted file mode 100644 index 25c028059..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Android.mk deleted file mode 100644 index e92d914a6..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_3_Sleep -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/3_sleep \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/3_sleep/main.cpp \ - sample/api_physics_effects/3_sleep/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Application.mk deleted file mode 100644 index 3fdd58bc6..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_3_Sleep -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/values/strings.xml deleted file mode 100644 index 832910db4..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 3 Sleep - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/sample3/PfxApp_3_Sleep.java b/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/sample3/PfxApp_3_Sleep.java deleted file mode 100644 index 29e2b96d5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_3_Sleep/src/pfx/sample3/PfxApp_3_Sleep.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample3; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_3_Sleep extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_3_Sleep"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index 66e0e1c64..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.project b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.project deleted file mode 100644 index 90be27d62..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_4_MotionType - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample4/PfxApp_4_MotionType.java - 1 - PFX_ROOT/project/Android/PfxApp_4_MotionType/src/pfx/PfxApp_4_MotionType.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/AndroidManifest.xml deleted file mode 100644 index e49f9b6ca..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/build.xml deleted file mode 100644 index bf58c3d9f..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Android.mk deleted file mode 100644 index 1666da8c1..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_4_MotionType -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/4_motion_type \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/4_motion_type/main.cpp \ - sample/api_physics_effects/4_motion_type/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Application.mk deleted file mode 100644 index 6f49a4bbe..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_4_MotionType -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/values/strings.xml deleted file mode 100644 index cdeb98a28..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 4 Motion Type - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/sample4/PfxApp_4_MotionType.java b/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/sample4/PfxApp_4_MotionType.java deleted file mode 100644 index 915561419..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_4_MotionType/src/pfx/sample4/PfxApp_4_MotionType.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample4; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_4_MotionType extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_4_MotionType"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index ea5ac97f7..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.project b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.project deleted file mode 100644 index f8f61f0df..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_5_Raycast - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample5/PfxApp_5_Raycast.java - 1 - PFX_ROOT/project/Android/PfxApp_5_Raycast/src/pfx/sample/PfxApp_5_Raycast.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/AndroidManifest.xml deleted file mode 100644 index 4fd40eed9..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/build.xml deleted file mode 100644 index d0ad8b90a..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Android.mk deleted file mode 100644 index 502d45569..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_5_Raycast -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/5_raycast \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/5_raycast/main.cpp \ - sample/api_physics_effects/5_raycast/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Application.mk deleted file mode 100644 index 024f67813..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_5_Raycast -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/values/strings.xml deleted file mode 100644 index c3d96aa74..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 5 Raycast - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/sample5/PfxApp_5_Raycast.java b/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/sample5/PfxApp_5_Raycast.java deleted file mode 100644 index 2f8b31004..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_5_Raycast/src/pfx/sample5/PfxApp_5_Raycast.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample5; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_5_Raycast extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_5_Raycast"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.classpath b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.classpath deleted file mode 100644 index 98132ca43..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.classpath +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.externalToolBuilders/BuildSampleJNICode.launch b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.externalToolBuilders/BuildSampleJNICode.launch deleted file mode 100644 index 59c20e3a8..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.externalToolBuilders/BuildSampleJNICode.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.project b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.project deleted file mode 100644 index 07e46eb54..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/.project +++ /dev/null @@ -1,114 +0,0 @@ - - - - PfxApp_6_Joint - - - PfxLibrary - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - auto,full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/BuildSampleJNICode.launch - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - - - src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - 1 - PFX_ROOT/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java - - - src/pfx/renderingsupport/PhysicsEffectsRenderer.java - 1 - PFX_ROOT/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsRenderer.java - - - src/pfx/sample6/PfxApp_6_Joint.java - 1 - PFX_ROOT/project/Android/PfxApp_6_Joint/src/pfx/sample/PfxApp_6_Joint.java - - - - - 1305070288951 - jni - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - 1305070295995 - src - 26 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-.svn - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/AndroidManifest.xml b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/AndroidManifest.xml deleted file mode 100644 index f8eb60248..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/build.xml b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/build.xml deleted file mode 100644 index 20c3a8aa7..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/build.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/default.properties b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/default.properties deleted file mode 100644 index f4b4f1778..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Android.mk deleted file mode 100644 index 4b00f1323..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Android.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH:= $(BULLET_PFX_ROOT_CYGWIN) - -# Copy the shared static library, libpfxlibrary.a, into the build -include $(CLEAR_VARS) -LOCAL_MODULE := pfxlibrary -LOCAL_SRC_FILES := project/Android/PfxLibrary/obj/local/armeabi-v7a/libpfxlibrary.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. - -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -mfpu=neon -mfloat-abi=softfp -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -# compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -# TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# specify static libraries to link in -LOCAL_STATIC_LIBRARIES := pfxlibrary - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -LOCAL_MODULE := PfxApp_6_Joint -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)sample/api_physics_effects/6_joint \ - $(LOCAL_PATH)sample/api_physics_effects/common - -LOCAL_SRC_FILES := \ - sample/api_physics_effects/common/jni/physicseffects-android.cpp \ - sample/api_physics_effects/6_joint/main.cpp \ - sample/api_physics_effects/6_joint/physics_func.cpp \ - sample/api_physics_effects/common/ctrl_func.android.cpp \ - sample/api_physics_effects/common/render_func.android.cpp \ - sample/api_physics_effects/common/perf_func.android.cpp - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_SHARED_LIBRARY) - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Application.mk deleted file mode 100644 index 738b74a04..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := PfxApp_6_Joint -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/local.properties b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/local.properties deleted file mode 100644 index 1659ad756..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/local.properties +++ /dev/null @@ -1,10 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must *NOT* be checked in Version Control Systems, -# as it contains information specific to your local configuration. - -# location of the SDK. This is only used by Ant -# For customization when using a Version Control System, please read the -# header note. -sdk.dir=F:\\sdks\\Android\\android-sdk diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/proguard.cfg b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/proguard.cfg deleted file mode 100644 index 3e84fc735..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/proguard.cfg +++ /dev/null @@ -1,36 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembernames class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-hdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-hdpi/icon.png deleted file mode 100644 index d7753923a..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-ldpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-ldpi/icon.png deleted file mode 100644 index 0871aa1eb..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-mdpi/icon.png b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-mdpi/icon.png deleted file mode 100644 index ff7be820f..000000000 Binary files a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/layout/main.xml b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/layout/main.xml deleted file mode 100644 index 6c069664e..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/layout/main.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/values/strings.xml b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/values/strings.xml deleted file mode 100644 index 548a32fb2..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/res/values/strings.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - Pfx 6 Joint - diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java deleted file mode 100644 index ec83e64ce..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsGLSurfaceView.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import android.opengl.GLSurfaceView; -import android.content.Context; -import android.view.MotionEvent; - -/** - * Implementation of the OpenGL ES view window and creates/assigns a renderer. - * Handles touch events to allow the user to change scene on tap, move the camera - * around by touch based movement, and allows the user to zoom in and out by pinching. - * @author ahamilton - * - */ -public class PhysicsEffectsGLSurfaceView extends GLSurfaceView { - public PhysicsEffectsGLSurfaceView(Context context) { - super(context); - peRenderer = new PhysicsEffectsRenderer(); - setRenderer(peRenderer); - } - - float x1 = 0, x2, y1 = 0, y2; - long downTime; - - /** - * Function to process touch events for camera and scene control - * - */ - public boolean onTouchEvent(final MotionEvent event) { - switch(event.getAction()) { - case(MotionEvent.ACTION_DOWN): - x1 = event.getX(); - y1 = event.getY(); - downTime = event.getDownTime(); - break; - case(MotionEvent.ACTION_UP): - if(event.getEventTime() - downTime < 100) nativeSceneChange(); - break; - case(MotionEvent.ACTION_MOVE): { - if(event.getPointerCount() == 1){ - x2 = event.getX(); - y2 = event.getY(); - float dx = x2-x1; - float dy = y2-y1; - - // Use dx and dy to determine the direction - if(dx > 0) { - nativeCameraLeft(); - } else { - nativeCameraRight(); - } - if(dy > 0){ - nativeCameraUp(); - } else { - nativeCameraDown(); - } - x1=x2; - y1=y2; - } else if(event.getPointerCount() == 2){ - y2 = event.getY(); - - float dy = y2-y1; - - // Use dy to determine zoom - if(dy > 0){ - nativeCameraZoomIn(); - } else { - nativeCameraZoomOut(); - } - y1=y2; - } - } - } - return true; - } - - PhysicsEffectsRenderer peRenderer; - - private static native void nativeCameraUp(); - private static native void nativeCameraDown(); - private static native void nativeCameraLeft(); - private static native void nativeCameraRight(); - private static native void nativeCameraZoomOut(); - private static native void nativeCameraZoomIn(); - private static native void nativeSceneChange(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsRenderer.java b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsRenderer.java deleted file mode 100644 index 5ca66d4b5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/renderingsupport/PhysicsEffectsRenderer.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.renderingsupport; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * Implementation of the renderer. It calls the native physicseffects code - * to run on the init and drawframe allowing the sample to perform its simulation. - * @author ahamilton - * - */ -public class PhysicsEffectsRenderer implements GLSurfaceView.Renderer { - boolean startup = true; - boolean notEnded = true; - static long startuptime; - static long endtime; - int frameCounter; - - /** - * Initilize the physics simulation after the GL surface is created. - * - */ - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.v("Init physics", "Initing physics"); - nativePhysicsEffectsInit(); - Log.v("Init physics", "Inited physics"); - } - - /** - * Set the viewport for a changed GL surface - * - */ - public void onSurfaceChanged(GL10 gl, int w, int h) - { - gl.glViewport(0, 0, w, h); - } - - /** - * Perform one simulation step and render the scene. - * - */ - public void onDrawFrame(GL10 gl) - { - if(startup){ - startup = false; - frameCounter = 0; - startuptime = System.currentTimeMillis(); - endtime = startuptime + 10000; // sets run time to be 30 seconds - } - - nativePhysicsEffectsSimulate(); - - frameCounter++; - long lCurrentTime = System.currentTimeMillis(); - if(lCurrentTime > endtime && notEnded) { - float fFrameRate = (1000.0f * (float)frameCounter) / ((float)lCurrentTime - startuptime); - Log.v("PHYSICS TIMING STUDY", "Number of Frames: " + Integer.toString(frameCounter)); - Log.v("PHYSICS TIMING STUDY", "Time ellapsed (milliseconds): " + Long.toString(lCurrentTime - startuptime)); - Log.v("PHYSICS TIMING STUDY", "Bullet Frame Rate: " + Float.toString(fFrameRate) + "fps"); - notEnded = false; - } - } - - private static native void nativePhysicsEffectsInit(); - private static native void nativePhysicsEffectsSimulate(); - private static native void nativePhysicsEffectsUpdate(); - private static native void nativePhysicsEffectsPhysStep(); - private static native void nativePhysicsEffectsRender(); -} diff --git a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/sample6/PfxApp_6_Joint.java b/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/sample6/PfxApp_6_Joint.java deleted file mode 100644 index f2f3593f8..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxApp_6_Joint/src/pfx/sample6/PfxApp_6_Joint.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -package pfx.sample6; - -import pfx.renderingsupport.PhysicsEffectsGLSurfaceView; - -import android.app.Activity; -import android.opengl.GLSurfaceView; -import android.os.Bundle; - -/** - * When program loads it creates a OpenGl ES render window for - * the bullet sample projects to run in and loads the complied - * physics effects libraries. - * @author ahamilton - * - */ -public class PfxApp_6_Joint extends Activity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - peGLView = new PhysicsEffectsGLSurfaceView(this); - setContentView(peGLView); - } - - private GLSurfaceView peGLView; - - //This is where you specify which physics effects sample you would like to load - static { - System.loadLibrary("PfxApp_6_Joint"); - } -} diff --git a/Extras/PhysicsEffects/project/Android/PfxLibrary/.cproject b/Extras/PhysicsEffects/project/Android/PfxLibrary/.cproject deleted file mode 100644 index 362560c91..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxLibrary/.cproject +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - - all - true - true - true - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxLibrary/.externalToolBuilders/PfxLibraryBuilder.launch b/Extras/PhysicsEffects/project/Android/PfxLibrary/.externalToolBuilders/PfxLibraryBuilder.launch deleted file mode 100644 index 5b0e3cea5..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxLibrary/.externalToolBuilders/PfxLibraryBuilder.launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxLibrary/.project b/Extras/PhysicsEffects/project/Android/PfxLibrary/.project deleted file mode 100644 index 08860167b..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxLibrary/.project +++ /dev/null @@ -1,157 +0,0 @@ - - - - PfxLibrary - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/PfxLibraryBuilder.launch - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - include - 2 - PFX_ROOT/include - - - src - 2 - PFX_ROOT/src - - - - - 1304973509800 - include - 21 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-*.h - - - - 1304973468596 - src - 21 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-*.cpp - - - - - - PFX_ROOT - $%7BPARENT-3-PROJECT_LOC%7D - - - diff --git a/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Android.mk b/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Android.mk deleted file mode 100644 index b342f5bd3..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Android.mk +++ /dev/null @@ -1,173 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -# NOTE: The local path here is defined based on an environment -# variable that points to the root of the Bullet/PhysicsEffects -# code base. The variable must be set in the Cygwin style, e.g., -# BULLET_PFX_ROOT_CYGWIN = /cygdrive/d/tools/PhysicsEffectsRootPath -# -# The reason for *not* just setting local path := $(call my-dir) -# is that we wish to access local source files that are *not* -# located in a "jni" subfolder and *not* located in a subfolder -# of the project folder. This enables us to have Eclipse and -# Android NDK projects that fit neatly into the Bullet/PhysicsEffects -# folder structure, enabling a multi platform code base, without -# forcing the "jni" and subfolder structure that Android SDK/NDK -# prefer for pure Android projects. -LOCAL_PATH := $(BULLET_PFX_ROOT_CYGWIN) - -include $(CLEAR_VARS) -# Warning: do not enable SIMD vector math functions or NEON for running -# in the Android NDK emulator. NEON requires a physical device -# with NEON support. -# -# Note that in theory we can let LOCAL_ARM_NEON := true determine -# that the flags -mfpu=neon and -mfloat-abi=softfp should be applied. -# However, in practice we have seen one case where the ndk-build -# script "forgets" these flags for the occasional *.cpp file, thus -# causing those files to access the std definition of vectormath -# classes, which are completely different, including different size. -# So, we explicitly apply these flags to avoid having a broken -# build. -# -# Include -DSCE_PFX_USE_SIMD_VECTORMATH to build for ARM NEON SIMD -# intrinsics, and leave it off to use NEON for scalar math but without -# SIMD. -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -DUSE_PTHREADS -mfpu=neon -mfloat-abi=softfp -pthread -DSCE_PFX_USE_SIMD_VECTORMATH - -# apply these flags if needed -# -ffast-math -funsafe-math-optimizations - -# apply this to disable optimization -# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0 - -# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file) -#compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s))) -#TARGET_CFLAGS := $(TARGET_CFLAGS) -S - -# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp -# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS -# to avoid the possibility that ndk-build will "forget" to add them on some files -LOCAL_ARM_NEON := true -TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS)) - -# setup to build static library, libpfxlibrary.a -LOCAL_MODULE := libpfxlibrary -LOCAL_C_INCLUDES := \ - include \ - include/physics_effects/base_level \ - include/physics_effects/base_level/base \ - include/physics_effects/base_level/broadphase \ - include/physics_effects/base_level/collision \ - include/physics_effects/base_level/rigidbody \ - include/physics_effects/base_level/solver \ - include/physics_effects/base_level/sort \ - include/physics_effects/low_level \ - include/physics_effects/low_level/broadphase \ - include/physics_effects/low_level/collision \ - include/physics_effects/low_level/solver \ - include/physics_effects/low_level/sort \ - include/physics_effects/low_level/task \ - include/physics_effects/util \ - include/vecmath/neon \ - src/base_level/broadphase \ - src/base_level/collision \ - src/base_level/solver \ - src/base_level/sort \ - src/low_level/broadphase \ - src/low_level/collision \ - src/low_level/solver \ - src/low_level/sort \ - src/low_level/task \ - src/util \ - src - -# Note that vectormath_neon_assembly_implementations.S is needed here in order to compile, link, and use the -# NEON version of the vectormath library -LOCAL_SRC_FILES := \ - src/base_level/broadphase/pfx_update_broadphase_proxy.cpp \ - src/base_level/collision/pfx_collidable.cpp \ - src/base_level/collision/pfx_contact_box_box.cpp \ - src/base_level/collision/pfx_contact_box_capsule.cpp \ - src/base_level/collision/pfx_contact_box_sphere.cpp \ - src/base_level/collision/pfx_contact_cache.cpp \ - src/base_level/collision/pfx_contact_capsule_capsule.cpp \ - src/base_level/collision/pfx_contact_capsule_sphere.cpp \ - src/base_level/collision/pfx_contact_large_tri_mesh.cpp \ - src/base_level/collision/pfx_contact_manifold.cpp \ - src/base_level/collision/pfx_contact_sphere_sphere.cpp \ - src/base_level/collision/pfx_contact_tri_mesh_box.cpp \ - src/base_level/collision/pfx_contact_tri_mesh_capsule.cpp \ - src/base_level/collision/pfx_contact_tri_mesh_convex.cpp \ - src/base_level/collision/pfx_contact_tri_mesh_cylinder.cpp \ - src/base_level/collision/pfx_contact_tri_mesh_sphere.cpp \ - src/base_level/collision/pfx_gjk_solver.cpp \ - src/base_level/collision/pfx_gjk_support_func.cpp \ - src/base_level/collision/pfx_intersect_ray_box.cpp \ - src/base_level/collision/pfx_intersect_ray_capsule.cpp \ - src/base_level/collision/pfx_intersect_ray_convex.cpp \ - src/base_level/collision/pfx_intersect_ray_cylinder.cpp \ - src/base_level/collision/pfx_intersect_ray_large_tri_mesh.cpp \ - src/base_level/collision/pfx_intersect_ray_sphere.cpp \ - src/base_level/collision/pfx_shape.cpp \ - src/base_level/collision/pfx_simplex_solver.cpp \ - src/base_level/solver/pfx_contact_constraint.cpp \ - src/base_level/solver/pfx_joint_ball.cpp \ - src/base_level/solver/pfx_joint_fix.cpp \ - src/base_level/solver/pfx_joint_hinge.cpp \ - src/base_level/solver/pfx_joint_slider.cpp \ - src/base_level/solver/pfx_joint_swing_twist.cpp \ - src/base_level/solver/pfx_joint_universal.cpp \ - src/base_level/solver/pfx_constraint_row_solver_neon.cpp \ - src/base_level/sort/pfx_sort.cpp \ - src/low_level/broadphase/pfx_broadphase_single.cpp \ - src/low_level/collision/pfx_batched_ray_cast_single.cpp \ - src/low_level/collision/pfx_batched_ray_cast_parallel.cpp \ - src/low_level/collision/pfx_collision_detection_single.cpp \ - src/low_level/collision/pfx_collision_detection_parallel.cpp \ - src/low_level/collision/pfx_detect_collision_func.cpp \ - src/low_level/collision/pfx_intersect_ray_func.cpp \ - src/low_level/collision/pfx_island_generation.cpp \ - src/low_level/collision/pfx_ray_cast.cpp \ - src/low_level/collision/pfx_refresh_contacts_single.cpp \ - src/low_level/collision/pfx_refresh_contacts_parallel.cpp \ - src/low_level/solver/pfx_constraint_solver_single.cpp \ - src/low_level/solver/pfx_constraint_solver_parallel.cpp \ - src/low_level/solver/pfx_joint_constraint_func.cpp \ - src/low_level/solver/pfx_update_rigid_states_single.cpp \ - src/low_level/solver/pfx_update_rigid_states_parallel.cpp \ - src/low_level/sort/pfx_parallel_sort_single.cpp \ - src/low_level/task/pfx_task_manager_pthreads.cpp \ - src/low_level/task/pfx_sync_components_pthreads.cpp \ - src/util/pfx_mass.cpp \ - src/util/pfx_mesh_creator.cpp \ - include/vecmath/neon/vectormath_neon_assembly_implementations.S - -LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -lGLESv1_CM -ldl -lm -llog - -include $(BUILD_STATIC_LIBRARY) diff --git a/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Application.mk b/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Application.mk deleted file mode 100644 index 6c3c6caa7..000000000 --- a/Extras/PhysicsEffects/project/Android/PfxLibrary/jni/Application.mk +++ /dev/null @@ -1,31 +0,0 @@ -# -# Applied Research Associates Inc. (c)2011 -# -# 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 Applied Research Associates 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. -# - -APP_MODULES := libpfxlibrary -APP_ABI := armeabi-v7a -APP_OPTIM := release diff --git a/Extras/PhysicsEffects/project/msvc2008_32/BulletCollision.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/BulletCollision.vcproj deleted file mode 100644 index 79e0c880c..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/BulletCollision.vcproj +++ /dev/null @@ -1,1206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/msvc2008_32/BulletDynamics.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/BulletDynamics.vcproj deleted file mode 100644 index cfc8b14df..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/BulletDynamics.vcproj +++ /dev/null @@ -1,566 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/msvc2008_32/BulletMultiThreaded.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/BulletMultiThreaded.vcproj deleted file mode 100644 index baf77f873..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/BulletMultiThreaded.vcproj +++ /dev/null @@ -1,558 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/msvc2008_32/BulletSoftBody.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/BulletSoftBody.vcproj deleted file mode 100644 index e8f5c40fe..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/BulletSoftBody.vcproj +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/msvc2008_32/LinearMath.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/LinearMath.vcproj deleted file mode 100644 index 28bc4258b..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/LinearMath.vcproj +++ /dev/null @@ -1,478 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/msvc2008_32/MiniCL.vcproj b/Extras/PhysicsEffects/project/msvc2008_32/MiniCL.vcproj deleted file mode 100644 index ccbd8fa55..000000000 --- a/Extras/PhysicsEffects/project/msvc2008_32/MiniCL.vcproj +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/project/physics_effects_lib.oss.sln b/Extras/PhysicsEffects/project/physics_effects_lib.oss.sln deleted file mode 100644 index 7b10ddcc4..000000000 --- a/Extras/PhysicsEffects/project/physics_effects_lib.oss.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_effects_lib.oss", "physics_effects_lib.oss.vcproj", "{4908A1B7-06F4-4517-936A-D81D140004F7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win32 Debug|Win32 = Win32 Debug|Win32 - Win32 Release|Win32 = Win32 Release|Win32 - Win64 Debug|Win32 = Win64 Debug|Win32 - Win64 Release|Win32 = Win64 Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Extras/PhysicsEffects/project/physics_effects_lib.oss.vcproj b/Extras/PhysicsEffects/project/physics_effects_lib.oss.vcproj deleted file mode 100644 index 1ba888a9c..000000000 --- a/Extras/PhysicsEffects/project/physics_effects_lib.oss.vcproj +++ /dev/null @@ -1,1221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/CMakeLists.txt b/Extras/PhysicsEffects/sample/CMakeLists.txt deleted file mode 100644 index 434caf200..000000000 --- a/Extras/PhysicsEffects/sample/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS( - api_physics_effects -) diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/CMakeLists.txt deleted file mode 100644 index 3fabec5d7..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_0_Console) - - -SET(App_0_Console_SRCS - main.cpp - physics_func.cpp - ../common/perf_func.win32.cpp -) - -SET(App_0_Console_HDRS - landscape.h - physics_func.h -) - -INCLUDE_DIRECTORIES( - ${BULLET_PHYSICS_SOURCE_DIR}/include -) - - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_0_Console - ${App_0_Console_SRCS} - ${App_0_Console_HDRS} -) -TARGET_LINK_LIBRARIES(App_0_Console - PfxLowLevel - PfxBaseLevel - PfxUtil -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_0_Console PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_0_Console PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_0_Console PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/main.cpp deleted file mode 100644 index 361c21055..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_effects.h" -#include "physics_func.h" -#include "../common/perf_func.h" - -static int frameCount = 0; -static int sceneId = 2; - -int main() -{ - - perf_init(); - physics_init(); - - physics_create_scene(sceneId); - - frameCount = 0; - - //createScene(); - - while(frameCount<600) { - physics_simulate(); - perf_sync(); - } - - SCE_PFX_PRINTF("program complete\n"); - - return 0; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.cpp deleted file mode 100644 index 250edac85..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.cpp +++ /dev/null @@ -1,861 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.h deleted file mode 100644 index 0aa7e07de..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/0_console/premake4.lua deleted file mode 100644 index b8e18d6eb..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/0_console/premake4.lua +++ /dev/null @@ -1,18 +0,0 @@ - project "0_console_sample" - - kind "ConsoleApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util" - } - - files { - "main.cpp", - "physics_func.cpp", - "physics_func.h", - "../common/perf_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/1_simple.windows.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/1_simple.windows.vcproj deleted file mode 100644 index 3d211cb0d..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/1_simple.windows.vcproj +++ /dev/null @@ -1,713 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/CMakeLists.txt deleted file mode 100644 index 6f38d21e2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_1_Simple) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_1_Simple_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_1_Simple_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_1_Simple WIN32 - ${App_1_Simple_SRCS} - ${App_1_Simple_HDRS} -) -TARGET_LINK_LIBRARIES(App_1_Simple - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_1_Simple PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_1_Simple PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_1_Simple PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/main.cpp deleted file mode 100644 index 5db906fb0..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/main.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include - #include // used to check for presence of NEON on device - #ifdef __ARM_NEON__ - #include -#ifdef TEST_NEON_PERFORMANCE // define this to run NEON performance tests - #include "../../test_ARM_NEON_performance/test_neon.h" -#endif - #endif // __ARM_NEON__ -#endif // __ANDROID__ -// ARA end - -#define SAMPLE_NAME "api_physics_effects/1_simple" - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics.png deleted file mode 100644 index 641c4fc3e..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.cpp deleted file mode 100644 index b45e331e0..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.cpp +++ /dev/null @@ -1,769 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int numPairs; -PfxBroadphasePair pairs[NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - numPairs = 0; - numContacts = 0; - numJoints = 0; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairs[id])]; -} - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.h deleted file mode 100644 index 0aa7e07de..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/premake4.lua deleted file mode 100644 index 4bd42a3dc..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple/premake4.lua +++ /dev/null @@ -1,22 +0,0 @@ - project "1_simple" - - kind "WindowedApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util", - "opengl32" - } - - flags {"WinMain"} - - files { - "main.cpp", - "physics_func.cpp", - "../common/ctrl_func.win32.cpp", - "../common/perf_func.win32.cpp", - "../common/render_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/main.cpp deleted file mode 100644 index 63b82cded..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/main.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif // __ANDROID__ -// ARA end - -#define SAMPLE_NAME "api_physics_effects/1_simple" - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.cpp deleted file mode 100644 index 7954c5443..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 1000 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ??????? -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J ?? -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J ????????????????? -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J ????? -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J ???? -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ????? -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ?? -//E Pairs -unsigned int numPairs; -PfxBroadphasePair pairs[NUM_CONTACTS]; - -//J ????? -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -//J ?????? -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J ???????????????? -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -// ARA begin insert new code -//E task manager for parallel demo -#define NUM_THREADS 2 -PfxTaskManager *taskManager = NULL; -//E need enough bytes for NUM_THREADS PfxTaskArg objects, with the space rounded up to fill a 16-bit aligned space -#define TASK_MANAGER_POOL_BYTES 1024 -unsigned char SCE_PFX_ALIGNED(16) taskPoolBuff[TASK_MANAGER_POOL_BYTES]; -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - //J ????????????????? - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ??????????????? - //E Create broadpahse proxies - { - for(int i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - numPairs = 0; - numContacts = 0; - numJoints = 0; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); - -// ARA begin insert new code -#ifdef USE_PTHREADS - if (!taskManager) - { - taskManager = PfxCreateTaskManagerPthreads(NUM_THREADS, NUM_THREADS, taskPoolBuff, TASK_MANAGER_POOL_BYTES); - taskManager->initialize(); - } -#endif -// ARA end -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -// ARA begin insert new code - if (taskManager) - taskManager->finalize(); -// ARA end -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairs[id])]; -} - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.h deleted file mode 100644 index 0a6d2fe78..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/1_simple_parallel/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J ???????? -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ????? -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J ???????? -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/2_stable.winsows.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/2_stable.winsows.vcproj deleted file mode 100644 index 791d0d6c4..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/2_stable.winsows.vcproj +++ /dev/null @@ -1,713 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/CMakeLists.txt deleted file mode 100644 index 61076def8..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_2_Stable) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_2_Stable_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_2_Stable_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_2_Stable WIN32 - ${App_2_Stable_SRCS} - ${App_2_Stable_HDRS} -) -TARGET_LINK_LIBRARIES(App_2_Stable - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_2_Stable PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_2_Stable PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_2_Stable PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/main.cpp deleted file mode 100644 index e005c870e..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/main.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/2_stable" - -static bool s_isRunning = true; - -int sceneId = 2; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics.png deleted file mode 100644 index 483e6e806..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.cpp deleted file mode 100644 index 7ed69e9da..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.cpp +++ /dev/null @@ -1,869 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 5000 -#define NUM_JOINTS 5000 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.h deleted file mode 100644 index 0aa7e07de..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/premake4.lua deleted file mode 100644 index ab367031b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable/premake4.lua +++ /dev/null @@ -1,22 +0,0 @@ - project "2_stable" - - kind "WindowedApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util", - "opengl32" - } - - flags {"WinMain"} - - files { - "main.cpp", - "physics_func.cpp", - "../common/ctrl_func.win32.cpp", - "../common/perf_func.win32.cpp", - "../common/render_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/main.cpp deleted file mode 100644 index e005c870e..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/main.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/2_stable" - -static bool s_isRunning = true; - -int sceneId = 2; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.cpp deleted file mode 100644 index eaf49033f..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.cpp +++ /dev/null @@ -1,968 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 5000 -#define NUM_JOINTS 5000 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ??????? -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J ?? -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J ????????????????? -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J ????? -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J ???? -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ????? -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ?? -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J ????? -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J ?????? -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J ???????????????? -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -// ARA begin insert new code -//E task manager for parallel demo -#define NUM_THREADS 1 -PfxTaskManager *taskManager = NULL; -//E need enough bytes for NUM_THREADS PfxTaskArg objects, with the space rounded up to fill a 16-bit aligned space -#define TASK_MANAGER_POOL_BYTES 1024 -unsigned char SCE_PFX_ALIGNED(16) taskPoolBuff[TASK_MANAGER_POOL_BYTES]; -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J ????????????????? - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ??????????????? - //E Create broadpahse proxies - { - for(int i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - } - - //J ???????????? - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); - -// ARA begin insert new code -#ifdef USE_PTHREADS - if (!taskManager) - { - taskManager = PfxCreateTaskManagerPthreads(NUM_THREADS, NUM_THREADS, taskPoolBuff, TASK_MANAGER_POOL_BYTES); - taskManager->initialize(); - } -#endif -// ARA end -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -// ARA begin insert new code - if (taskManager) - taskManager->finalize(); -// ARA end -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.h deleted file mode 100644 index 0a6d2fe78..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/2_stable_parallel/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J ???????? -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ????? -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J ???????? -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/3_sleep.windows.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/3_sleep.windows.vcproj deleted file mode 100644 index d3c7857a3..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/3_sleep.windows.vcproj +++ /dev/null @@ -1,713 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/CMakeLists.txt deleted file mode 100644 index d54bb9a3b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_3_Sleep) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_3_Sleep_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_3_Sleep_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_3_Sleep WIN32 - ${App_3_Sleep_SRCS} - ${App_3_Sleep_HDRS} -) -TARGET_LINK_LIBRARIES(App_3_Sleep - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_3_Sleep PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_3_Sleep PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_3_Sleep PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/main.cpp deleted file mode 100644 index 6c25d5c95..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/main.cpp +++ /dev/null @@ -1,512 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/3_sleep" - -#define ENABLE_DEBUG_DRAW - -#ifdef ENABLE_DEBUG_DRAW - //#define ENABLE_DEBUG_DRAW_CONTACT - //#define ENABLE_DEBUG_DRAW_AABB - #define ENABLE_DEBUG_DRAW_ISLAND -#endif - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - const PfxVector3 colorWhite(1.0f); - const PfxVector3 colorGray(0.7f); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics.png deleted file mode 100644 index 7230a6617..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.cpp deleted file mode 100644 index f549d739c..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.cpp +++ /dev/null @@ -1,1016 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J シミュレーションアイランド -//E Island generation -PfxIsland *island=NULL; -PfxUInt8 SCE_PFX_ALIGNED(16) islandBuff[32*NUM_RIGIDBODIES]; // Island buffer should be 32 * the number of rigid bodies. - -//J スリープ制御 -//E Sleep control -/* - A sleeping object wakes up, when - * a new pair related to this rigid body is created - * a pair releated to this rigid body is removed - * a rigid body's velocity or position are updated - */ - -//J スリープã«å…¥ã‚‹ã‚«ã‚¦ãƒ³ãƒˆ -//E Count to enter sleeping -const PfxUInt32 sleepCount = 180; - -//J 速度ãŒé–¾å€¤ä»¥ä¸‹ãªã‚‰ã°ã‚¹ãƒªãƒ¼ãƒ—カウントãŒå¢—加 -//E If velocity is under the following value, sleep count is increased. -const PfxFloat sleepVelocity = 0.1f; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - - //J å¯ã¦ã‚‹å‰›ä½“ã‚’èµ·ã“ã™ - //E Wake up sleeping rigid bodies - PfxRigidState &stateA = states[pfxGetObjectIdA(outNewPairs[i])]; - PfxRigidState &stateB = states[pfxGetObjectIdB(outNewPairs[i])]; - if(stateA.isAsleep()) { - stateA.wakeup(); - SCE_PFX_PRINTF("wakeup %u\n",stateA.getRigidBodyId()); - } - if(stateB.isAsleep()) { - stateB.wakeup(); - SCE_PFX_PRINTF("wakeup %u\n",stateB.getRigidBodyId()); - } - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i sleepCount) { - numCanSleep++; - } - } - } - } - - // Deactivate Island - if(numCanSleep > 0 && numCanSleep == numActive + numSleep) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].sleep(); - } - } - - // Activate Island - else if(numSleep > 0 && numActive > 0) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].wakeup(); - } - } - } - } -} - -void integrate() -{ - PfxUpdateRigidStatesParam param; - param.states = states; - param.bodies = bodies; - param.numRigidBodies = numRigidBodies; - param.timeStep = timeStep; - - pfxUpdateRigidStates(param); -} - -void physics_simulate() -{ - PfxPerfCounter pc; - - for(int i=1;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - island = NULL; - frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} - -const PfxIsland* physics_get_islands() -{ - return island; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.h deleted file mode 100644 index bde418949..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/physics_func.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -// Get contact information -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -// Get simulation island -const PfxIsland* physics_get_islands(); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/premake4.lua deleted file mode 100644 index c59b51b3f..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/3_sleep/premake4.lua +++ /dev/null @@ -1,22 +0,0 @@ - project "3_sleep" - - kind "WindowedApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util", - "opengl32" - } - - flags {"WinMain"} - - files { - "main.cpp", - "physics_func.cpp", - "../common/ctrl_func.win32.cpp", - "../common/perf_func.win32.cpp", - "../common/render_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/4_motion_type.windows.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/4_motion_type.windows.vcproj deleted file mode 100644 index f6d81a282..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/4_motion_type.windows.vcproj +++ /dev/null @@ -1,721 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/CMakeLists.txt deleted file mode 100644 index bb31f7b58..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/CMakeLists.txt +++ /dev/null @@ -1,75 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_4_MotionType) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_3_Sleep_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_3_Sleep_HDRS - physics_func.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_4_MotionType WIN32 - ${App_3_Sleep_SRCS} - ${App_3_Sleep_HDRS} -) -TARGET_LINK_LIBRARIES(App_4_MotionType - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_4_MotionType PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_4_MotionType PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_4_MotionType PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/main.cpp deleted file mode 100644 index 62a53106a..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/main.cpp +++ /dev/null @@ -1,481 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/4_motion_type" - -//#define ENABLE_DEBUG_DRAW - -#ifdef ENABLE_DEBUG_DRAW - #define ENABLE_DEBUG_DRAW_CONTACT - #define ENABLE_DEBUG_DRAW_AABB - #define ENABLE_DEBUG_DRAW_ISLAND -#endif - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -void render(void) -{ - render_begin(); - - const PfxVector3 colorWhite(1.0f); - const PfxVector3 colorGray(0.7f); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics.png deleted file mode 100644 index c1da418b4..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.cpp deleted file mode 100644 index 405c95f2a..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.cpp +++ /dev/null @@ -1,822 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J シミュレーションアイランド -//E Island generation -PfxIsland *island=NULL; -PfxUInt8 SCE_PFX_ALIGNED(16) islandBuff[32*NUM_RIGIDBODIES]; // Island buffer should be 32 * the number of rigid bodies. - -//J スリープ制御 -//E Sleep control -/* - A sleeping object wakes up, when - * a new pair related to this rigid body is created - * a pair releated to this rigid body is removed - * a rigid body's velocity or position are updated - */ - -//J スリープã«å…¥ã‚‹ã‚«ã‚¦ãƒ³ãƒˆ -//E Count to enter sleeping -const PfxUInt32 sleepCount = 180; - -//J 速度ãŒé–¾å€¤ä»¥ä¸‹ãªã‚‰ã°ã‚¹ãƒªãƒ¼ãƒ—カウントãŒå¢—加 -//E If velocity is under the following value, sleep count is increased. -const PfxFloat sleepVelocity = 0.1f; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -// Keyframe -void updateKeyframe(); -int keyframeId; - -// Trigger -void updateTrigger(); -int triggerId; - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - - //J å¯ã¦ã‚‹å‰›ä½“ã‚’èµ·ã“ã™ - //E Wake up sleeping rigid bodies - PfxRigidState &stateA = states[pfxGetObjectIdA(outNewPairs[i])]; - PfxRigidState &stateB = states[pfxGetObjectIdB(outNewPairs[i])]; - if(stateA.isAsleep()) { - stateA.wakeup(); - } - if(stateB.isAsleep()) { - stateB.wakeup(); - } - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i sleepCount) { - numCanSleep++; - } - } - } - } - - // Deactivate Island - if(numCanSleep > 0 && numCanSleep == numActive + numSleep) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].sleep(); - } - } - - // Activate Island - else if(numSleep > 0 && numActive > 0) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].wakeup(); - } - } - } - } -} - -void integrate() -{ - PfxUpdateRigidStatesParam param; - param.states = states; - param.bodies = bodies; - param.numRigidBodies = numRigidBodies; - param.timeStep = timeStep; - - pfxUpdateRigidStates(param); -} - -void physics_simulate() -{ - PfxPerfCounter pc; - - for(int i=1;i=0) updateKeyframe(); - if(triggerId>=0) updateTrigger(); -} - -/////////////////////////////////////////////////////////////////////////////// -// Create Scene - -int createBrick(int id,const PfxVector3 &pos,const PfxQuat &rot,const PfxVector3 &boxSize,PfxFloat mass) -{ - PfxBox box(boxSize); - PfxShape shape; - shape.reset(); - shape.setBox(box); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - bodies[id].setRestitution(0.0f); - bodies[id].setMass(mass); - bodies[id].setInertia(pfxCalcInertiaBox(boxSize,mass)); - states[id].reset(); - states[id].setPosition(pos); - states[id].setOrientation(rot); - states[id].setMotionType(kPfxMotionTypeActive); - states[id].setUseSleep(1); // sleep mode ON - states[id].setRigidBodyId(id); - - return id; -} - -void createWall(const PfxVector3 &offsetPosition,int stackSize,const PfxVector3 &boxSize) -{ - PfxFloat bodyMass = 0.5f; - - PfxFloat diffX = boxSize[0] * 1.02f; - PfxFloat diffY = boxSize[1] * 1.02f; - PfxFloat diffZ = boxSize[2] * 1.02f; - - PfxFloat offset = -stackSize * (diffZ * 2.0f) * 0.5f; - PfxVector3 pos(0.0f, diffY, 0.0f); - - while(stackSize) { - for(int i=0;i 0) { - SCE_PFX_PRINTF("Find Contact %u\n",pfxGetObjectIdB(pair)); - } - } - if(pfxGetObjectIdB(pair) == triggerId) { - if(contact.getNumContacts() > 0) { - SCE_PFX_PRINTF("Find Contact %u\n",pfxGetObjectIdA(pair)); - } - } - } -} - -void createSceneBoxGround() -{ - int id = numRigidBodies++; - PfxBox box(150.0f,2.5f,150.0f); - PfxShape shape; - shape.reset(); - shape.setBox(box); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-2.5f,0.0f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 3; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - island = NULL; - frame = 0; - - keyframeId = -1; - triggerId = -1; - - switch(sid) { - case 0: - createSceneBoxGround(); - createSceneKeyframe(); - createWall(PfxVector3(0.0f,1.0f,0.0f),5,PfxVector3(0.5f)); - break; - - case 1: - createSceneBoxGround(); - createSceneOneWay(); - break; - - case 2: - createSceneBoxGround(); - createSceneTrigger(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ -} - -void physics_pick_end() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} - -const PfxIsland* physics_get_islands() -{ - return island; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.h deleted file mode 100644 index bde418949..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/physics_func.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -// Get contact information -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -// Get simulation island -const PfxIsland* physics_get_islands(); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/premake4.lua deleted file mode 100644 index dc194545b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/4_motion_type/premake4.lua +++ /dev/null @@ -1,22 +0,0 @@ - project "4_motion_type" - - kind "WindowedApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util", - "opengl32" - } - - flags {"WinMain"} - - files { - "main.cpp", - "physics_func.cpp", - "../common/ctrl_func.win32.cpp", - "../common/perf_func.win32.cpp", - "../common/render_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/5_raycast.windows.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/5_raycast.windows.vcproj deleted file mode 100644 index c92d9152c..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/5_raycast.windows.vcproj +++ /dev/null @@ -1,721 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/CMakeLists.txt deleted file mode 100644 index f8687f7c0..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_5_Raycast) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_5_Raycast_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_5_Raycast_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_5_Raycast WIN32 - ${App_5_Raycast_SRCS} - ${App_5_Raycast_HDRS} -) -TARGET_LINK_LIBRARIES(App_5_Raycast - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/main.cpp deleted file mode 100644 index 9ec4e5ec6..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/main.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" -#include "barrel.h" -#include "landscape.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/5_raycast" - -//#define ENABLE_DEBUG_DRAW - -#ifdef ENABLE_DEBUG_DRAW - #define ENABLE_DEBUG_DRAW_CONTACT - #define ENABLE_DEBUG_DRAW_AABB - #define ENABLE_DEBUG_DRAW_ISLAND -#endif - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -void render(void) -{ - render_begin(); - - const PfxVector3 colorWhite(1.0f); - const PfxVector3 colorGray(0.7f); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics.png deleted file mode 100644 index ffe16ab6d..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics_func.cpp deleted file mode 100644 index e317df572..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/5_raycast/physics_func.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 -#define NUM_RAYS 100 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[6][NUM_RIGIDBODIES]; // shared by simulation and raycast - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J シミュレーションアイランド -//E Island generation -PfxIsland *island=NULL; -PfxUInt8 SCE_PFX_ALIGNED(16) islandBuff[32*NUM_RIGIDBODIES]; // Island buffer should be 32 * the number of rigid bodies. - -//J スリープ制御 -//E Sleep control -/* - A sleeping object wakes up, when - * a new pair related to this rigid body is created - * a pair releated to this rigid body is removed - * a rigid body's velocity or position are updated - */ - -//J スリープã«å…¥ã‚‹ã‚«ã‚¦ãƒ³ãƒˆ -//E Count to enter sleeping -const PfxUInt32 sleepCount = 180; - -//J 速度ãŒé–¾å€¤ä»¥ä¸‹ãªã‚‰ã°ã‚¹ãƒªãƒ¼ãƒ—カウントãŒå¢—加 -//E If velocity is under the following value, sleep count is increased. -const PfxFloat sleepVelocity = 0.1f; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -//J レイ -//E Ray -PfxRayInput SCE_PFX_ALIGNED(128) rayInputs[NUM_RAYS]; -PfxRayOutput SCE_PFX_ALIGNED(128) rayOutputs[NUM_RAYS]; -int numRays; - -/* - doAreaRaycastãŒtrueã®å ´åˆã€æŒ‡å®šã•れãŸé ˜åŸŸå†…ã®å‰›ä½“ã®ã¿åˆ¤å®šå¯¾è±¡ã¨ã™ã‚‹ -*/ -bool doAreaRaycast; -PfxVector3 areaCenter(0.0f); -PfxVector3 areaExtent(5.0f); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - //J レイキャストã¨å…±ç”¨ã™ã‚‹ãŸã‚ã€å…¨ã¦ã®è»¸ã«å¯¾ã™ã‚‹ãƒ—ロキシé…列を作æˆã™ã‚‹ - //E To share with ray casting, create proxy arrays for all axis - - PfxUpdateBroadphaseProxiesParam param; - param.workBytes = pfxGetWorkBytesOfUpdateBroadphaseProxies(numRigidBodies); - param.workBuff = pool.allocate(param.workBytes,128); - param.numRigidBodies = numRigidBodies; - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.worldCenter = worldCenter; - param.worldExtent = worldExtent; - - PfxUpdateBroadphaseProxiesResult result; - - int ret = pfxUpdateBroadphaseProxies(param,result); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxUpdateBroadphaseProxies failed %d\n",ret); - - pool.deallocate(param.workBuff); - } - - //J 交差ペア探索 - //E Find overlapped pairs - { - PfxFindPairsParam findPairsParam; - findPairsParam.pairBytes = pfxGetPairBytesOfFindPairs(NUM_CONTACTS); - findPairsParam.pairBuff = pool.allocate(findPairsParam.pairBytes); - findPairsParam.workBytes = pfxGetWorkBytesOfFindPairs(NUM_CONTACTS); - findPairsParam.workBuff = pool.allocate(findPairsParam.workBytes); - findPairsParam.proxies = proxies[axis]; - findPairsParam.numProxies = numRigidBodies; - findPairsParam.maxPairs = NUM_CONTACTS; - findPairsParam.axis = axis; - - PfxFindPairsResult findPairsResult; - - int ret = pfxFindPairs(findPairsParam,findPairsResult); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxFindPairs failed %d\n",ret); - - pool.deallocate(findPairsParam.workBuff); - - //J äº¤å·®ãƒšã‚¢åˆæˆ - //E Decompose overlapped pairs into 3 arrays - PfxDecomposePairsParam decomposePairsParam; - decomposePairsParam.pairBytes = pfxGetPairBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.pairBuff = pool.allocate(decomposePairsParam.pairBytes); - decomposePairsParam.workBytes = pfxGetWorkBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.workBuff = pool.allocate(decomposePairsParam.workBytes); - decomposePairsParam.previousPairs = previousPairs; - decomposePairsParam.numPreviousPairs = numPreviousPairs; - decomposePairsParam.currentPairs = findPairsResult.pairs; // Set pairs from pfxFindPairs() - decomposePairsParam.numCurrentPairs = findPairsResult.numPairs; // Set the number of pairs from pfxFindPairs() - - PfxDecomposePairsResult decomposePairsResult; - - ret = pfxDecomposePairs(decomposePairsParam,decomposePairsResult); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxDecomposePairs failed %d\n",ret); - - pool.deallocate(decomposePairsParam.workBuff); - - PfxBroadphasePair *outNewPairs = decomposePairsResult.outNewPairs; - PfxBroadphasePair *outKeepPairs = decomposePairsResult.outKeepPairs; - PfxBroadphasePair *outRemovePairs = decomposePairsResult.outRemovePairs; - PfxUInt32 numOutNewPairs = decomposePairsResult.numOutNewPairs; - PfxUInt32 numOutKeepPairs = decomposePairsResult.numOutKeepPairs; - PfxUInt32 numOutRemovePairs = decomposePairsResult.numOutRemovePairs; - - //J 廃棄ペアã®ã‚³ãƒ³ã‚¿ã‚¯ãƒˆã‚’ãƒ—ãƒ¼ãƒ«ã«æˆ»ã™ - //E Put removed contacts into the contact pool - for(PfxUInt32 i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - - //J å¯ã¦ã‚‹å‰›ä½“ã‚’èµ·ã“ã™ - //E Wake up sleeping rigid bodies - PfxRigidState &stateA = states[pfxGetObjectIdA(outNewPairs[i])]; - PfxRigidState &stateB = states[pfxGetObjectIdB(outNewPairs[i])]; - if(stateA.isAsleep()) { - stateA.wakeup(); - } - if(stateB.isAsleep()) { - stateB.wakeup(); - } - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i sleepCount) { - numCanSleep++; - } - } - } - } - - // Deactivate Island - if(numCanSleep > 0 && numCanSleep == numActive + numSleep) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].sleep(); - } - } - - // Activate Island - else if(numSleep > 0 && numActive > 0) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].wakeup(); - } - } - } - } -} - -void integrate() -{ - PfxUpdateRigidStatesParam param; - param.states = states; - param.bodies = bodies; - param.numRigidBodies = numRigidBodies; - param.timeStep = timeStep; - - pfxUpdateRigidStates(param); -} - -int gatherBroadphaseProxiesInArea(const PfxVector3 ¢er,const PfxVector3 &extent) -{ - PfxUpdateBroadphaseProxiesParam param; - param.workBytes = pfxGetWorkBytesOfUpdateBroadphaseProxies(numRigidBodies); - param.workBuff = pool.allocate(param.workBytes,128); - param.numRigidBodies = numRigidBodies; - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.worldCenter = center; - param.worldExtent = extent; - param.outOfWorldBehavior = SCE_PFX_OUT_OF_WORLD_BEHAVIOR_REMOVE_PROXY; - - PfxUpdateBroadphaseProxiesResult result; - - int ret = pfxUpdateBroadphaseProxies(param,result); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxUpdateBroadphaseProxies failed %d\n",ret); - - pool.deallocate(param.workBuff); - - return numRigidBodies - result.numOutOfWorldProxies; -} - -void castRays() -{ - PfxRayCastParam param; - - if(doAreaRaycast) { - static PfxFloat deltaRotY = 0.0f; - PfxQuat rotY = PfxQuat::rotationY(deltaRotY); - areaCenter = rotate(rotY,PfxVector3(15.0f,0.0f,0.0f)); - deltaRotY += 0.02f; - - int num = gatherBroadphaseProxiesInArea(areaCenter,areaExtent); - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.numProxies = num; - param.rangeCenter = areaCenter; - param.rangeExtent = areaExtent; - } - else { - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.numProxies = numRigidBodies; - param.rangeCenter = worldCenter; - param.rangeExtent = worldExtent; - } - - pfxCastRays(rayInputs,rayOutputs,numRays,param); -} - -void physics_simulate() -{ - PfxPerfCounter pc; - - for(int i=1;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,0.0f,0.0f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void initRays(const PfxVector3 &p1,const PfxVector3 &p2) -{ - numRays = NUM_RAYS; - PfxQuat rot = PfxQuat::rotationY(2.0f*SCE_PFX_PI/(float)numRays); - PfxVector3 startPosition = p1; - PfxVector3 targetPosition = p2; - - for(int i=0;i - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/CMakeLists.txt deleted file mode 100644 index 41459419b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_6_Joint) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_6_Joint_SRCS - main.cpp - physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp -) - - -SET(App_6_Joint_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h -) - - -INCLUDE_DIRECTORIES( - ${PHYSICS_EFFECTS_SOURCE_DIR}/include -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_6_Joint WIN32 - ${App_6_Joint_SRCS} - ${App_6_Joint_HDRS} -) -TARGET_LINK_LIBRARIES(App_6_Joint - PfxBaseLevel - PfxLowLevel - PfxUtil - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_6_Joint PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_6_Joint PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_6_Joint PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/barrel.h deleted file mode 100644 index 6574fa862..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/landscape.h b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/landscape.h deleted file mode 100644 index 00f6cffd2..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/landscape.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define LargeMeshVtxCount 81 -#define LargeMeshIdxCount 384 - -static float LargeMeshVtx[] = { --25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f, --25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f, --18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f, --18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f, --12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f, --12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f, --6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f, --6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f, -0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f, -0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f, -6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f, -6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f, -12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f, -12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f, -18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f, -18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f, -25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f, -25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f, --25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f, --18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f, --12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f, --6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f, -0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f, -6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f, -12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f, -18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f, -25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f, --25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f, --18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f, --12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f, --6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f, -0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f, -6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f, -12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f, -18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f, -25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f, --25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f, --18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f, --12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f, --6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f, -0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f, -6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f, -12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f, -18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f, -25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f, --25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f, --18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f, --12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f, --6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f, -0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f, -6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f, -12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f, -18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f, -25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f, --25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f, --18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f, --12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f, --6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f, -0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f, -6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f, -12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f, -18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f, -25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f, --25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f, --18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f, --12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f, --6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f, -0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f, -6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f, -12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f, -18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f, -25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f, --25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f, --18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f, --12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f, --6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f, -0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f, -6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f, -12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f, -18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f, -25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f, -}; - -static float LargeMeshTex[] = { -0.125f,0.0f, -0.0f,0.0f, -0.125f,0.125f, -0.0f,0.125f, -0.125f,0.25f, -0.0f,0.25f, -0.125f,0.375f, -0.0f,0.375f, -0.125f,0.5f, -0.0f,0.5f, -0.125f,0.625f, -0.0f,0.625f, -0.125f,0.75f, -0.0f,0.75f, -0.125f,0.875f, -0.0f,0.875f, -0.125f,1.0f, -0.0f,1.0f, -0.25f,0.0f, -0.25f,0.125f, -0.25f,0.25f, -0.25f,0.375f, -0.25f,0.5f, -0.25f,0.625f, -0.25f,0.75f, -0.25f,0.875f, -0.25f,1.0f, -0.375f,0.0f, -0.375f,0.125f, -0.375f,0.25f, -0.375f,0.375f, -0.375f,0.5f, -0.375f,0.625f, -0.375f,0.75f, -0.375f,0.875f, -0.375f,1.0f, -0.5f,0.0f, -0.5f,0.125f, -0.5f,0.25f, -0.5f,0.375f, -0.5f,0.5f, -0.5f,0.625f, -0.5f,0.75f, -0.5f,0.875f, -0.5f,1.0f, -0.625f,0.0f, -0.625f,0.125f, -0.625f,0.25f, -0.625f,0.375f, -0.625f,0.5f, -0.625f,0.625f, -0.625f,0.75f, -0.625f,0.875f, -0.625f,1.0f, -0.75f,0.0f, -0.75f,0.125f, -0.75f,0.25f, -0.75f,0.375f, -0.75f,0.5f, -0.75f,0.625f, -0.75f,0.75f, -0.75f,0.875f, -0.75f,1.0f, -0.875f,0.0f, -0.875f,0.125f, -0.875f,0.25f, -0.875f,0.375f, -0.875f,0.5f, -0.875f,0.625f, -0.875f,0.75f, -0.875f,0.875f, -0.875f,1.0f, -1.0f,0.0f, -1.0f,0.125f, -1.0f,0.25f, -1.0f,0.375f, -1.0f,0.5f, -1.0f,0.625f, -1.0f,0.75f, -1.0f,0.875f, -1.0f,1.0f, -}; - -static unsigned short LargeMeshIdx[] = { -0,1,2, -3,2,1, -2,3,4, -5,4,3, -4,5,6, -7,6,5, -6,7,8, -9,8,7, -8,9,10, -11,10,9, -10,11,12, -13,12,11, -12,13,14, -15,14,13, -14,15,16, -17,16,15, -18,0,19, -2,19,0, -19,2,20, -4,20,2, -20,4,21, -6,21,4, -21,6,22, -8,22,6, -22,8,23, -10,23,8, -23,10,24, -12,24,10, -24,12,25, -14,25,12, -25,14,26, -16,26,14, -27,18,28, -19,28,18, -28,19,29, -20,29,19, -29,20,30, -21,30,20, -30,21,31, -22,31,21, -31,22,32, -23,32,22, -32,23,33, -24,33,23, -33,24,34, -25,34,24, -34,25,35, -26,35,25, -36,27,37, -28,37,27, -37,28,38, -29,38,28, -38,29,39, -30,39,29, -39,30,40, -31,40,30, -40,31,41, -32,41,31, -41,32,42, -33,42,32, -42,33,43, -34,43,33, -43,34,44, -35,44,34, -45,36,46, -37,46,36, -46,37,47, -38,47,37, -47,38,48, -39,48,38, -48,39,49, -40,49,39, -49,40,50, -41,50,40, -50,41,51, -42,51,41, -51,42,52, -43,52,42, -52,43,53, -44,53,43, -54,45,55, -46,55,45, -55,46,56, -47,56,46, -56,47,57, -48,57,47, -57,48,58, -49,58,48, -58,49,59, -50,59,49, -59,50,60, -51,60,50, -60,51,61, -52,61,51, -61,52,62, -53,62,52, -63,54,64, -55,64,54, -64,55,65, -56,65,55, -65,56,66, -57,66,56, -66,57,67, -58,67,57, -67,58,68, -59,68,58, -68,59,69, -60,69,59, -69,60,70, -61,70,60, -70,61,71, -62,71,61, -72,63,73, -64,73,63, -73,64,74, -65,74,64, -74,65,75, -66,75,65, -75,66,76, -67,76,66, -76,67,77, -68,77,67, -77,68,78, -69,78,68, -78,69,79, -70,79,69, -79,70,80, -71,80,70, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/main.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/main.cpp deleted file mode 100644 index e78f4fa25..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/main.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../common/common.h" -#include "../common/ctrl_func.h" -#include "../common/render_func.h" -#include "../common/perf_func.h" -#include "physics_func.h" - -#ifdef _WIN32 - #include - #include -#endif - -// ARA begin insert new code -#ifdef __ANDROID__ - #include - #include -#endif -// ARA end - -#define SAMPLE_NAME "api_physics_effects/6_joint" - -//#define ENABLE_DEBUG_DRAW - -#ifdef ENABLE_DEBUG_DRAW - #define ENABLE_DEBUG_DRAW_CONTACT - #define ENABLE_DEBUG_DRAW_AABB - #define ENABLE_DEBUG_DRAW_ISLAND -#endif - -static bool s_isRunning = true; - -int sceneId = 0; -bool simulating = false; - -void render(void) -{ - render_begin(); - - const PfxVector3 colorWhite(1.0f); - const PfxVector3 colorGray(0.7f); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - int w,h; - render_get_screent_size(w,h); - ctrl_set_screen_size(w,h); - - static PfxVector3 pickPos(0.0f); - - if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_DOWN) { - int sx,sy; - ctrl_get_cursor_position(sx,sy); - PfxVector3 wp1((float)sx,(float)sy,0.0f); - PfxVector3 wp2((float)sx,(float)sy,1.0f); - wp1 = render_get_world_position(wp1); - wp2 = render_get_world_position(wp2); - pickPos = physics_pick_start(wp1,wp2); - } - else if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_KEEP) { - int sx,sy; - ctrl_get_cursor_position(sx,sy); - PfxVector3 sp = render_get_screen_position(pickPos); - PfxVector3 wp((float)sx,(float)sy,sp[2]); - wp = render_get_world_position(wp); - physics_pick_update(wp); - } - else if(ctrl_button_pressed(BTN_PICK) == BTN_STAT_UP) { - physics_pick_end(); - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef _WIN32 - -// ARA begin insert new code -#ifdef __ANDROID__ - -/////////////////////////////////////////////////////////////////////////////// -// sceneChange -// -/// This function is used to change the physics scene on Android devices -/////////////////////////////////////////////////////////////////////////////// -void sceneChange() -{ - physics_create_scene(sceneId++); -} - -#else // __ANDROID__ -// ARA end - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -// ARA begin insert new code -#endif // __ANDROID__ -// ARA end - -#else // _WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics.png b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics.png deleted file mode 100644 index d4813595d..000000000 Binary files a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics.png and /dev/null differ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.cpp deleted file mode 100644 index 520571092..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.cpp +++ /dev/null @@ -1,1641 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 500 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 4000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 8; - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[6][NUM_RIGIDBODIES]; // shared by simulation and raycast - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int pairSwap; -unsigned int numPairs[2]; -PfxBroadphasePair pairsBuff[2][NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -PfxUInt32 contactIdPool[NUM_CONTACTS]; -int numContactIdPool; - -//J シミュレーションアイランド -//E Island generation -PfxIsland *island=NULL; -PfxUInt8 SCE_PFX_ALIGNED(16) islandBuff[32*NUM_RIGIDBODIES]; // Island buffer should be 32 * the number of rigid bodies. - -//J スリープ制御 -//E Sleep control -/* - A sleeping object wakes up, when - * a new pair related to this rigid body is created - * a pair releated to this rigid body is removed - * a rigid body's velocity or position are updated - */ - -//J スリープã«å…¥ã‚‹ã‚«ã‚¦ãƒ³ãƒˆ -//E Count to enter sleeping -const PfxUInt32 sleepCount = 180; - -//J 速度ãŒé–¾å€¤ä»¥ä¸‹ãªã‚‰ã°ã‚¹ãƒªãƒ¼ãƒ—カウントãŒå¢—加 -//E If velocity is under the following value, sleep count is increased. -const PfxFloat sleepVelocity = 0.3f; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char SCE_PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - pairSwap = 1-pairSwap; - - unsigned int &numPreviousPairs = numPairs[1-pairSwap]; - unsigned int &numCurrentPairs = numPairs[pairSwap]; - PfxBroadphasePair *previousPairs = pairsBuff[1-pairSwap]; - PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; - - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - //J レイキャストã¨å…±ç”¨ã™ã‚‹ãŸã‚ã€å…¨ã¦ã®è»¸ã«å¯¾ã™ã‚‹ãƒ—ロキシé…列を作æˆã™ã‚‹ - //E To share with ray casting, create proxy arrays for all axis - - PfxUpdateBroadphaseProxiesParam param; - param.workBytes = pfxGetWorkBytesOfUpdateBroadphaseProxies(numRigidBodies); - param.workBuff = pool.allocate(param.workBytes,128); - param.numRigidBodies = numRigidBodies; - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.worldCenter = worldCenter; - param.worldExtent = worldExtent; - - PfxUpdateBroadphaseProxiesResult result; - - int ret = pfxUpdateBroadphaseProxies(param,result); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxUpdateBroadphaseProxies failed %d\n",ret); - - pool.deallocate(param.workBuff); - } - - //J 交差ペア探索 - //E Find overlapped pairs - { - PfxFindPairsParam findPairsParam; - findPairsParam.pairBytes = pfxGetPairBytesOfFindPairs(NUM_CONTACTS); - findPairsParam.pairBuff = pool.allocate(findPairsParam.pairBytes); - findPairsParam.workBytes = pfxGetWorkBytesOfFindPairs(NUM_CONTACTS); - findPairsParam.workBuff = pool.allocate(findPairsParam.workBytes); - findPairsParam.proxies = proxies[axis]; - findPairsParam.numProxies = numRigidBodies; - findPairsParam.maxPairs = NUM_CONTACTS; - findPairsParam.axis = axis; - - PfxFindPairsResult findPairsResult; - - int ret = pfxFindPairs(findPairsParam,findPairsResult); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxFindPairs failed %d\n",ret); - - pool.deallocate(findPairsParam.workBuff); - - //J äº¤å·®ãƒšã‚¢åˆæˆ - //E Decompose overlapped pairs into 3 arrays - PfxDecomposePairsParam decomposePairsParam; - decomposePairsParam.pairBytes = pfxGetPairBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.pairBuff = pool.allocate(decomposePairsParam.pairBytes); - decomposePairsParam.workBytes = pfxGetWorkBytesOfDecomposePairs(numPreviousPairs,findPairsResult.numPairs); - decomposePairsParam.workBuff = pool.allocate(decomposePairsParam.workBytes); - decomposePairsParam.previousPairs = previousPairs; - decomposePairsParam.numPreviousPairs = numPreviousPairs; - decomposePairsParam.currentPairs = findPairsResult.pairs; // Set pairs from pfxFindPairs() - decomposePairsParam.numCurrentPairs = findPairsResult.numPairs; // Set the number of pairs from pfxFindPairs() - - PfxDecomposePairsResult decomposePairsResult; - - ret = pfxDecomposePairs(decomposePairsParam,decomposePairsResult); - if(ret != SCE_PFX_OK) SCE_PFX_PRINTF("pfxDecomposePairs failed %d\n",ret); - - pool.deallocate(decomposePairsParam.workBuff); - - PfxBroadphasePair *outNewPairs = decomposePairsResult.outNewPairs; - PfxBroadphasePair *outKeepPairs = decomposePairsResult.outKeepPairs; - PfxBroadphasePair *outRemovePairs = decomposePairsResult.outRemovePairs; - PfxUInt32 numOutNewPairs = decomposePairsResult.numOutNewPairs; - PfxUInt32 numOutKeepPairs = decomposePairsResult.numOutKeepPairs; - PfxUInt32 numOutRemovePairs = decomposePairsResult.numOutRemovePairs; - - //J 廃棄ペアã®ã‚³ãƒ³ã‚¿ã‚¯ãƒˆã‚’ãƒ—ãƒ¼ãƒ«ã«æˆ»ã™ - //E Put removed contacts into the contact pool - for(PfxUInt32 i=0;i 0) { - cId = contactIdPool[--numContactIdPool]; - } - else { - cId = numContacts++; - } - if(cId >= NUM_CONTACTS) { - cId = 0; - } - SCE_PFX_ASSERT(cId < NUM_CONTACTS); - pfxSetContactId(outNewPairs[i],cId); - PfxContactManifold &contact = contacts[cId]; - contact.reset(pfxGetObjectIdA(outNewPairs[i]),pfxGetObjectIdB(outNewPairs[i])); - - //J å¯ã¦ã‚‹å‰›ä½“ã‚’èµ·ã“ã™ - //E Wake up sleeping rigid bodies - PfxRigidState &stateA = states[pfxGetObjectIdA(outNewPairs[i])]; - PfxRigidState &stateB = states[pfxGetObjectIdB(outNewPairs[i])]; - if(stateA.isAsleep()) { - stateA.wakeup(); - SCE_PFX_PRINTF("wakeup %u\n",stateA.getRigidBodyId()); - } - if(stateB.isAsleep()) { - stateB.wakeup(); - SCE_PFX_PRINTF("wakeup %u\n",stateB.getRigidBodyId()); - } - } - - //J æ–°è¦ãƒšã‚¢ã¨ç¶­æŒãƒšã‚¢ã‚’åˆæˆ - //E Merge 'new' and 'keep' pairs - numCurrentPairs = 0; - for(PfxUInt32 i=0;i sleepCount) { - numCanSleep++; - } - } - } - } - - // Deactivate Island - if(numCanSleep > 0 && numCanSleep == numActive + numSleep) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].sleep(); - } - } - - // Activate Island - else if(numSleep > 0 && numActive > 0) { - PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,(PfxUInt32)i); - for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) { - if(!(SCE_PFX_MOTION_MASK_CAN_SLEEP(states[pfxGetUnitId(islandUnit)].getMotionType()))) continue; - states[pfxGetUnitId(islandUnit)].wakeup(); - } - } - } - } -} - -void integrate() -{ - PfxUpdateRigidStatesParam param; - param.states = states; - param.bodies = bodies; - param.numRigidBodies = numRigidBodies; - param.timeStep = timeStep; - - pfxUpdateRigidStates(param); -} - -void physics_simulate() -{ - PfxPerfCounter pc; - - for(int i=1;i0) { - PfxRigidState &stateA = states[id-1]; - PfxRigidState &stateB = states[id]; - int jointId = numJoints++; - PfxSwingTwistJointInitParam jparam; - jparam.twistLowerAngle = -0.5f; - jparam.twistUpperAngle = 0.5f; - jparam.anchorPoint = (stateA.getPosition() + stateB.getPosition())*0.5f; - jparam.twistAxis = PfxVector3(1.0f,0.0f,0.0f); - pfxInitializeSwingTwistJoint(joints[jointId],stateA,stateB,jparam); - pfxUpdateJointPairs(jointPairs[jointId],jointId,joints[jointId],stateA,stateB); - - joints[jointId].m_constraints[3].m_damping = 0.1f; - } - - if(i==0) { - firstRope = id; - } - else if(i==numRopes-1) { - lastRope = id; - } - } - } - - const PfxFloat sphereRad = 2.0f; - - { - PfxShape shapeSphere; - shapeSphere.reset(); - shapeSphere.setSphere(PfxSphere(sphereRad)); - - { - PfxVector3 pos = states[firstRope].getPosition() - PfxVector3(ropeLen+sphereRad,0.0f,0.0f); - - int id2 = numRigidBodies++; - collidables[id2].reset(); - collidables[id2].addShape(shapeSphere); - collidables[id2].finish(); - bodies[id2].reset(); - bodies[id2].setMass(10.0f); - bodies[id2].setInertia(pfxCalcInertiaSphere(sphereRad,15.0f)); - states[id2].reset(); - states[id2].setPosition(pos); - states[id2].setMotionType(kPfxMotionTypeActive); - states[id2].setUseSleep(1); - states[id2].setRigidBodyId(id2); - states[id2].setContactFilterSelf(0x00000001); - states[id2].setContactFilterTarget(0xfffffffe); - - int jointId = numJoints++; - PfxBallJointInitParam jparam; - jparam.anchorPoint = states[firstRope].getPosition() - PfxVector3(ropeLen,0.0f,0.0f); - pfxInitializeBallJoint(joints[jointId],states[id2],states[firstRope],jparam); - pfxUpdateJointPairs(jointPairs[jointId],jointId,joints[jointId],states[id2],states[firstRope]); - } - - { - PfxVector3 pos = states[lastRope].getPosition() + PfxVector3(ropeLen+sphereRad,0.0f,0.0f); - - int id2 = numRigidBodies++; - collidables[id2].reset(); - collidables[id2].addShape(shapeSphere); - collidables[id2].finish(); - bodies[id2].reset(); - bodies[id2].setMass(2.0f); - bodies[id2].setInertia(pfxCalcInertiaSphere(sphereRad,5.0f)); - states[id2].reset(); - states[id2].setPosition(pos); - states[id2].setMotionType(kPfxMotionTypeActive); - states[id2].setUseSleep(1); - states[id2].setRigidBodyId(id2); - states[id2].setContactFilterSelf(0x00000001); - states[id2].setContactFilterTarget(0xfffffffe); - - int jointId = numJoints++; - PfxBallJointInitParam jparam; - jparam.anchorPoint = states[lastRope].getPosition() + PfxVector3(ropeLen,0.0f,0.0f); - pfxInitializeBallJoint(joints[jointId],states[id2],states[lastRope],jparam); - pfxUpdateJointPairs(jointPairs[jointId],jointId,joints[jointId],states[id2],states[lastRope]); - } - } -} - -void createSceneBoxGround() -{ - int id = numRigidBodies++; - PfxBox box(150.0f,2.5f,150.0f); - PfxShape shape; - shape.reset(); - shape.setBox(box); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-2.5f,0.0f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 3; - int sid = sceneId % numScenes; - - numRigidBodies= 0; - pairSwap = 0; - numPairs[0] = 0; - numPairs[1] = 0; - numContacts = 0; - numContactIdPool = 0; - numJoints = 0; - island = NULL; - frame = 0; - - //E Keep a first joint as a pick joint - //J 最åˆã®ã‚¸ãƒ§ã‚¤ãƒ³ãƒˆã‚’ピッキング用ã«ã‚­ãƒ¼ãƒ— - numJoints = 1; - joints[0].m_active = 0; - pfxSetActive(jointPairs[0],false); - - switch(sid) { - case 0: // basic joints - createSceneBoxGround(); - createSceneBasicJoints(); - break; - - case 1: // ragdolls - createSceneBoxGround(); - createSceneRagdolls(); - break; - - case 2: // complex machine - createSceneBoxGround(); - createSceneComplexMachine(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -/////////////////////////////////////////////////////////////////////////////// -// Initialize / Finalize Engine - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - -/////////////////////////////////////////////////////////////////////////////// -// Pick - -inline PfxVector3 calcLocalCoord(const PfxRigidState &state,const PfxVector3 &coord) -{ - return rotate(conj(state.getOrientation()),(coord - state.getPosition())); -} - -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2) -{ - PfxJoint &pickJoint = joints[0]; - - PfxRayCastParam param; - param.offsetRigidStates = states; - param.offsetCollidables = collidables; - param.proxiesX = proxies[0]; - param.proxiesY = proxies[1]; - param.proxiesZ = proxies[2]; - param.proxiesXb = proxies[3]; - param.proxiesYb = proxies[4]; - param.proxiesZb = proxies[5]; - param.numProxies = numRigidBodies; - param.rangeCenter = worldCenter; - param.rangeExtent = worldExtent; - - PfxRayInput pickRay; - PfxRayOutput pickOut; - - pickRay.m_contactFilterSelf = pickRay.m_contactFilterTarget = 0xffffffff; - pickRay.m_startPosition = p1; - pickRay.m_direction = p2-p1; - pickRay.m_facetMode = SCE_PFX_RAY_FACET_MODE_FRONT_ONLY; - pfxCastSingleRay(pickRay,pickOut,param); - - if(pickOut.m_contactFlag) { - PfxRigidState &stateA = states[0]; - PfxRigidState &stateB = states[pickOut.m_objectId]; - PfxRigidBody &bodyB = bodies[pickOut.m_objectId]; - - /* Connect a picked rigid body and the ground with a ball joint. - * Weaken pick power by adjusting a m_maxImpulse parameter so that impulse doesn't exceeds m_maxImpulse. - * It is needed, because constraint power is too strong. - */ - - PfxBallJointInitParam jparam; - jparam.anchorPoint = pickOut.m_contactPoint; - - pfxInitializeBallJoint(pickJoint,stateA,stateB,jparam); - pickJoint.m_constraints[0].m_maxImpulse = bodyB.getMass() * 2.0f; - pickJoint.m_constraints[1].m_maxImpulse = bodyB.getMass() * 2.0f; - pickJoint.m_constraints[2].m_maxImpulse = bodyB.getMass() * 2.0f; - - pfxUpdateJointPairs(jointPairs[0],0,pickJoint,stateA,stateB); - - SCE_PFX_PRINTF("pick objId %d ",pickOut.m_objectId); - if(pickOut.m_subData.m_type == PfxSubData::MESH_INFO) { - SCE_PFX_PRINTF("mesh islandId %d facetId %d",pickOut.m_subData.getIslandId(),pickOut.m_subData.getFacetId()); - } - SCE_PFX_PRINTF("\n"); - - return pickOut.m_contactPoint; - } - - return PfxVector3(0.0f); -} - -void physics_pick_update(const PfxVector3 &p) -{ - PfxJoint &pickJoint = joints[0]; - - if(pickJoint.m_active>0) { - pickJoint.m_anchorA = calcLocalCoord(states[pickJoint.m_rigidBodyIdA],p); - if(states[pickJoint.m_rigidBodyIdB].isAsleep()) { - states[pickJoint.m_rigidBodyIdB].wakeup(); - } - } -} - -void physics_pick_end() -{ - PfxJoint &pickJoint = joints[0]; - - if(pickJoint.m_active>0) { - pickJoint.m_active = 0; - } -} - -/////////////////////////////////////////////////////////////////////////////// -// Get Information - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - -int physics_get_num_contacts() -{ - return numPairs[pairSwap]; -} - -const PfxContactManifold &physics_get_contact(int id) -{ - return contacts[pfxGetConstraintId(pairsBuff[pairSwap][id])]; -} - -const PfxIsland* physics_get_islands() -{ - return island; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.h deleted file mode 100644 index bde418949..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/physics_func.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -// Get contact information -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -// Get simulation island -const PfxIsland* physics_get_islands(); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/premake4.lua b/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/premake4.lua deleted file mode 100644 index 80dad3187..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/6_joint/premake4.lua +++ /dev/null @@ -1,22 +0,0 @@ - project "5_joint" - - kind "WindowedApp" - targetdir "../../../bin" - includedirs {"../../../include"} - - links { - "physicseffects2_lowlevel", - "physicseffects2_baselevel", - "physicseffects2_util", - "opengl32" - } - - flags {"WinMain"} - - files { - "main.cpp", - "physics_func.cpp", - "../common/ctrl_func.win32.cpp", - "../common/perf_func.win32.cpp", - "../common/render_func.win32.cpp" - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/99_BulletPhysicsEffects.vcproj b/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/99_BulletPhysicsEffects.vcproj deleted file mode 100644 index c1903deb3..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/99_BulletPhysicsEffects.vcproj +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/CMakeLists.txt deleted file mode 100644 index 4d210b93c..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/CMakeLists.txt +++ /dev/null @@ -1,89 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - - -#this line has to appear before 'PROJECT' in order to be able to disable incremental linking -SET(MSVC_INCREMENTAL_DEFAULT ON) - -PROJECT(App_99_BulletPhysicsEffects) - - -IF (NOT CMAKE_BUILD_TYPE) -# SET(CMAKE_BUILD_TYPE "Debug") - SET(CMAKE_BUILD_TYPE "Release") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON) -OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF) - - -IF(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -ENDIF(COMMAND cmake_policy) - - -SET(App_99_BulletPhysicsEffects_SRCS - main.cpp - bullet_physics_func.cpp - ../common/ctrl_func.win32.cpp - ../common/perf_func.win32.cpp - ../common/render_func.win32.cpp - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.cpp - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.cpp - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.cpp - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelBroadphase.cpp - -) - - -SET(App_99_BulletPhysicsEffects_HDRS - physics_func.h - landscape.h - barrel.h - ../common/render_func.h - ../common/common.h - ../common/ctrl_func.h - ../common/perf_func.h - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.h - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.h - ${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelBroadphase.h -) - - -INCLUDE_DIRECTORIES( - ../../../../../src -# ${VECTOR_MATH_INCLUDE} -) - -#LINK_DIRECTORIES( -# -#) - -#ADD_DEFINITIONS(-DUNICODE) -#ADD_DEFINITIONS(-D_UNICODE) - -ADD_EXECUTABLE(App_99_BulletPhysicsEffects WIN32 - ${App_99_BulletPhysicsEffects_SRCS} - ${App_99_BulletPhysicsEffects_HDRS} -) -TARGET_LINK_LIBRARIES(App_99_BulletPhysicsEffects - PfxBaseLevel - PfxLowLevel - PfxUtil - BulletDynamics - BulletCollision - LinearMath - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} -) - -IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) - SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES DEBUG_POSTFIX "_Debug") - SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") - SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF() - - - - \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/barrel.h b/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/barrel.h deleted file mode 100644 index ade7bb5b1..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/barrel.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define BarrelVtxCount 57 -#define BarrelIdxCount 180 - -static float BarrelVtx[] = { -0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f, --0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f, --0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, --0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f, -0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f, -0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f, --0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f, --0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, --0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f, -0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f, -0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f, -0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f, -0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f, -0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, -0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f, --0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f, -0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f, --0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f, --0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f, --0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f, --0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f, --0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f, --0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f, --0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f, --0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f, --0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f, -0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f, -0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f, -0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f, -0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f, -0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f, -0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f, -0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f, --0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f, --0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f, --0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f, --0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f, -0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f, -0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f, -}; - -static float BarrelTex[] = { -0.0f,0.5f, -0.0f,0.85f, -0.0f,0.75f, -0.0f,0.95f, -0.0f,0.05f, -0.0f,-0.05f, -0.0f,0.15f, -0.0f,0.25f, -0.0f,0.35f, -0.0f,0.45f, -0.0f,0.55f, -0.0f,0.65f, -1.0f,0.5f, -1.0f,0.75f, -1.0f,0.85f, -1.0f,0.95f, -1.0f,-0.05f, -1.0f,0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -0.0f,0.75f, -0.5f,0.85f, -0.5f,0.75f, -0.0f,0.85f, -0.5f,0.95f, -0.0f,0.95f, -0.0f,-0.05f, -0.5f,0.05f, -0.5f,-0.05f, -0.0f,0.05f, -0.5f,0.15f, -0.0f,0.15f, -0.5f,0.25f, -0.0f,0.25f, -0.5f,0.35f, -0.0f,0.35f, -0.5f,0.45f, -0.0f,0.45f, -0.5f,0.55f, -0.0f,0.55f, -0.5f,0.65f, -0.0f,0.65f, -1.0f,0.85f, -1.0f,0.75f, -1.0f,0.95f, -1.0f,0.05f, -1.0f,-0.05f, -1.0f,0.15f, -1.0f,0.25f, -1.0f,0.35f, -1.0f,0.45f, -1.0f,0.55f, -1.0f,0.65f, -}; - -static unsigned short BarrelIdx[] = { -0,1,2, -0,3,1, -0,4,5, -0,6,4, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,2,11, -12,13,14, -12,14,15, -12,16,17, -12,17,18, -12,18,19, -12,19,20, -12,20,21, -12,21,22, -12,22,23, -12,23,13, -24,25,26, -24,27,25, -27,28,25, -27,29,28, -30,31,32, -30,33,31, -33,34,31, -33,35,34, -35,36,34, -35,37,36, -37,38,36, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -43,44,42, -43,45,44, -45,26,44, -45,24,26, -26,46,47, -26,25,46, -25,48,46, -25,28,48, -32,49,50, -32,31,49, -31,51,49, -31,34,51, -34,52,51, -34,36,52, -36,53,52, -36,38,53, -38,54,53, -38,40,54, -40,55,54, -40,42,55, -42,56,55, -42,44,56, -44,47,56, -44,26,47, -}; - diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/bullet_physics_func.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/bullet_physics_func.cpp deleted file mode 100644 index e342e2af0..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/bullet_physics_func.cpp +++ /dev/null @@ -1,1241 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "physics_func.h" -#include "../common/perf_func.h" - -#include "BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h" -#include "BulletPhysicsEffects/btLowLevelBroadphase.h" -#include "BulletPhysicsEffects/btLowLevelCollisionDispatcher.h" -#include "BulletPhysicsEffects/btLowLevelData.h" -#include "BulletPhysicsEffects/btLowLevelConstraintSolver.h" -#include "BulletPhysicsEffects/btLowLevelConstraintSolver2.h" - - -#include "LinearMath/btIDebugDraw.h" -#include "BulletMultiThreaded/vectormath2bullet.h" -#include "../common/render_func.h" -#if 0 -#ifdef _WIN32 -#include "BulletMultiThreaded/Win32ThreadSupport.h" -#endif - -btThreadSupportInterface* createSolverThreadSupport(int maxNumThreads) -{ -#define SEQUENTIAL -#ifdef SEQUENTIAL - SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc); - SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); - threadSupport->startSPU(); -#else - -#ifdef _WIN32 - Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("solverThreads",SolverThreadFunc,SolverlsMemoryFunc,maxNumThreads); - Win32ThreadSupport* threadSupport = new Win32ThreadSupport(threadConstructionInfo); - threadSupport->startSPU(); -#elif defined (USE_PTHREADS) - PosixThreadSupport::ThreadConstructionInfo solverConstructionInfo("solver", SolverThreadFunc, - SolverlsMemoryFunc, maxNumThreads); - - PosixThreadSupport* threadSupport = new PosixThreadSupport(solverConstructionInfo); - -#else - SequentialThreadSupport::SequentialThreadConstructionInfo tci("solverThreads",SolverThreadFunc,SolverlsMemoryFunc); - SequentialThreadSupport* threadSupport = new SequentialThreadSupport(tci); - threadSupport->startSPU(); -#endif - -#endif - - return threadSupport; -} -#endif - - -class PEDebugDrawer : public btIDebugDraw -{ - int m_debugMode; - -public: - - PEDebugDrawer() - :m_debugMode(0) - { - } - virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& clr) - { - PfxVector3 position1 = getVmVector3(from); - PfxVector3 position2 = getVmVector3(to); - PfxVector3 color = getVmVector3(clr); - render_debug_line(position1,position2,color); - } - virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) - { - - } - - virtual void reportErrorWarning(const char* warningString) - { - SCE_PFX_PRINTF(warningString); - } - - virtual void draw3dText(const btVector3& location,const char* textString) - { - } - - virtual void setDebugMode(int debugMode) - { - m_debugMode = debugMode; - } - - virtual int getDebugMode() const - { - return m_debugMode; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Data - -#define NUM_RIGIDBODIES 5000 -#define NUM_JOINTS 500 -#define NUM_CONTACTS 20000 - -const float timeStep = 0.016f; -const float separateBias = 0.1f; -int iteration = 5; - - -//J ワールドサイズ -//E World size -PfxVector3 worldCenter(0.0f); -PfxVector3 worldExtent(500.0f); - -//J 剛体 -//E Rigid body -PfxRigidState states[NUM_RIGIDBODIES]; -PfxRigidBody bodies[NUM_RIGIDBODIES]; -PfxCollidable collidables[NUM_RIGIDBODIES]; -PfxSolverBody solverBodies[NUM_RIGIDBODIES]; -int numRigidBodies = 0; -//PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J 地形を表ç¾ã™ã‚‹ãŸã‚ã®ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ -//E Large mesh for representing a landscape -#include "landscape.h" -PfxLargeTriMesh gLargeMesh; - -//J 凸メッシュ -//E Convex Mesh -#include "barrel.h" -PfxConvexMesh gConvex; - - - -int physics_get_num_rigidbodies() -{ - return numRigidBodies; -} - -const PfxRigidState& physics_get_state(int id) -{ - return states[id]; -} - -const PfxRigidBody& physics_get_body(int id) -{ - return bodies[id]; -} - -const PfxCollidable& physics_get_collidable(int id) -{ - return collidables[id]; -} - - - - - -/////////////////////////////////////////////////////////////////////////////// -// Create Scene - -void createBrick(int id,const PfxVector3 &pos,const PfxQuat &rot,const PfxVector3 &boxSize,PfxFloat mass) -{ - PfxBox box(boxSize); - PfxShape shape; - shape.reset(); - shape.setBox(box); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - bodies[id].setRestitution(0.0f); - bodies[id].setMass(mass); - bodies[id].setInertia(pfxCalcInertiaBox(boxSize,mass)); - states[id].reset(); - states[id].setPosition(pos); - states[id].setOrientation(rot); - states[id].setMotionType(kPfxMotionTypeActive); - states[id].setRigidBodyId(id); -} - -void createWall(const PfxVector3 &offsetPosition,int stackSize,const PfxVector3 &boxSize) -{ - PfxFloat bodyMass = 0.5f; - - PfxFloat diffX = boxSize[0] * 1.02f; - PfxFloat diffY = boxSize[1] * 1.02f; - PfxFloat diffZ = boxSize[2] * 1.02f; - - PfxFloat offset = -stackSize * (diffZ * 2.0f) * 0.5f; - PfxVector3 pos(0.0f, diffY, 0.0f); - - while(stackSize) { - for(int i=0;i 0) { - pfxReleaseLargeTriMesh(gLargeMesh); - } - - PfxInt32 ret = pfxCreateLargeTriMesh(gLargeMesh,param); - if(ret != SCE_PFX_OK) { - SCE_PFX_PRINTF("Can't create large mesh.\n"); - } - - int id = numRigidBodies++; - PfxShape shape; - shape.reset(); - shape.setLargeTriMesh(&gLargeMesh); - collidables[id].reset(); - collidables[id].addShape(shape); - collidables[id].finish(); - bodies[id].reset(); - states[id].reset(); - states[id].setPosition(PfxVector3(0.0f,-5.0f,0.0f)); - states[id].setOrientation(PfxQuat::rotationX(0.5f)*PfxQuat::rotationY(0.7f)); - states[id].setMotionType(kPfxMotionTypeFixed); - states[id].setRigidBodyId(id); -} - -#include -#include "BulletMultiThreaded/vectormath2bullet.h" - -btDefaultCollisionConfiguration* m_config=0; -btCollisionDispatcher* m_dispatcher=0; -btBroadphaseInterface* m_broadphase=0; -btConstraintSolver* m_solver=0; -btDiscreteDynamicsWorld* m_dynamicsWorld=0; -btThreadSupportInterface* sThreadSupport=0; - -void debugRenderPhysics() -{ - if (m_dynamicsWorld) - m_dynamicsWorld->debugDrawWorld(); -} - -static void cleanupBullet(void) -{ - if (m_dynamicsWorld) - { - delete m_dynamicsWorld; - delete m_solver; -// delete sThreadSupport; - delete m_broadphase; - delete m_dispatcher; - delete m_config; - } -} - -void physics_simulate() -{ - //run the simulation - - static btClock clock; - static bool first = true; - if (first) - { - first=false; - clock.reset(); - } - btScalar dt = (btScalar)clock.getTimeMicroseconds(); - clock.reset(); - - - - m_dynamicsWorld->stepSimulation(dt/1000000.f); - - int i; - for (i=0;igetNumCollisionObjects();i++) - { - btRigidBody* body = btRigidBody::upcast(m_dynamicsWorld->getCollisionObjectArray()[i]); - if (body) - { - - PfxRigidState* state = (PfxRigidState*) body->getUserPointer(); - - PfxVector3 pe_pos = getVmVector3(body->getWorldTransform().getOrigin()); - PfxQuat pe_orn = getVmQuat(body->getWorldTransform().getRotation()); - PfxVector3 pe_lvel = getVmVector3(body->getLinearVelocity()); - PfxVector3 pe_avel = getVmVector3(body->getAngularVelocity()); - - state->setPosition(pe_pos); - state->setOrientation(pe_orn); - state->setLinearVelocity(pe_lvel); - state->setAngularVelocity(pe_avel); - } - } - - -} - -btRigidBody* addRigidBody(btCollisionShape* shape, btScalar mass, const btTransform& startTransform) -{ - btVector3 localInertia; - localInertia.setZero(); - - if (mass) - shape->calculateLocalInertia(mass,localInertia); - - btRigidBody* body = new btRigidBody(mass,0,shape,localInertia); - body->setWorldTransform(startTransform); - body->setActivationState(DISABLE_DEACTIVATION); - //body->setFriction(2); - m_dynamicsWorld->addRigidBody(body); - return body; -} - -static void convertToBullet(void) -{ - - cleanupBullet(); - - m_config = new btDefaultCollisionConfiguration(); - - btHashedOverlappingPairCache* pairCache = new btHashedOverlappingPairCache(); - //m_broadphase = new btDbvtBroadphase(); - btLowLevelData* lowLevelData = new btLowLevelData; - - lowLevelData->m_maxContacts = NUM_CONTACTS;//8024; - lowLevelData->m_contactIdPool = (int*) btAlignedAlloc(sizeof(int)*lowLevelData->m_maxContacts ,16); - lowLevelData->m_contacts = (PfxContactManifold*) btAlignedAlloc(sizeof(PfxContactManifold)*lowLevelData->m_maxContacts,16); - lowLevelData->m_maxPairs = lowLevelData->m_maxContacts;//?? - lowLevelData->m_pairsBuff[0] = (PfxBroadphasePair*) btAlignedAlloc(sizeof(PfxBroadphasePair)*lowLevelData->m_maxPairs,16); - lowLevelData->m_pairsBuff[1] = (PfxBroadphasePair*) btAlignedAlloc(sizeof(PfxBroadphasePair)*lowLevelData->m_maxPairs,16); - -#define USE_LL_BP -#ifdef USE_LL_BP - btLowLevelBroadphase* llbp = new btLowLevelBroadphase(lowLevelData,pairCache); - m_broadphase = llbp; -#else //USE_LL_BP - m_broadphase = new btDbvtBroadphase(); -#endif //USE_LL_BP - - //m_dispatcher = new btCollisionDispatcher(m_config); - m_dispatcher = new btLowLevelCollisionDispatcher(lowLevelData,m_config,NUM_CONTACTS); - -//#ifdef USE_PARALLEL_SOLVER -// m_solver = new btSequentialImpulseConstraintSolver(); -//#else - //sThreadSupport = createSolverThreadSupport(4); - //m_solver = new btLowLevelConstraintSolver(sThreadSupport); - m_solver = new btLowLevelConstraintSolver2(lowLevelData); -//#endif //USE_PARALLEL_SOLVER - - //m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_config); - m_dynamicsWorld = new btBulletPhysicsEffectsWorld(lowLevelData, m_dispatcher,llbp,m_solver,m_config,0); - PEDebugDrawer* drawer = new PEDebugDrawer(); - drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawAabb); - - m_dynamicsWorld->setDebugDrawer(drawer); - - m_dynamicsWorld ->getSolverInfo().m_splitImpulse = true; - - for(int i=0;i shapes; - btAlignedObjectArray childTtransforms; - - PfxRigidState &state = states[i];//physics_get_state(i); - state.setUserData(0); - - - const PfxCollidable &coll = physics_get_collidable(i); - - PfxTransform3 rbT(state.getOrientation(), state.getPosition()); - - PfxShapeIterator itrShape(coll); - for(int j=0;jm_verts[0]; - btConvexHullShape* convexHull = new btConvexHullShape(vertices,convex->m_numVerts, sizeof(PfxVector3)); - shapes.push_back(convexHull); - } - break; - - case kPfxShapeLargeTriMesh: - { - const PfxLargeTriMesh* mesh = shape.getLargeTriMesh(); - btTriangleIndexVertexArray* meshInterface = new btTriangleIndexVertexArray(); - int i; - for (i= 0; i < mesh->m_numIslands;i++) - { - PfxTriMesh* island = &mesh->m_islands[i]; - - //mesh->m_islands - //mesh->m_numIslands - btIndexedMesh indexedMesh; - indexedMesh.m_indexType = PHY_UCHAR; - indexedMesh.m_numTriangles = island->m_numFacets; - indexedMesh.m_triangleIndexBase = &island->m_facets[0].m_vertIds[0]; - indexedMesh.m_triangleIndexStride = sizeof(PfxFacet); - indexedMesh.m_vertexBase = (const unsigned char*) &island->m_verts[0]; - indexedMesh.m_numVertices = island->m_numVerts;//unused - indexedMesh.m_vertexStride = sizeof(PfxVector3); - meshInterface->addIndexedMesh(indexedMesh,PHY_UCHAR); - } - - btBvhTriangleMeshShape* trimesh = new btBvhTriangleMeshShape(meshInterface,true); - shapes.push_back(trimesh); - } - - break; - - default: - { - printf("unknown\n"); - } - break; - } - } - - if(shapes.size()>0) - { - printf("shapes!\n"); - btCollisionShape* colShape = 0; - if (shapes.size()==1 && childTtransforms[0].getOrigin().fuzzyZero()) -//todo: also check orientation - { - colShape = shapes[0]; - } - else - { - btCompoundShape* compound = new btCompoundShape(); - for (int i=0;iaddChildShape(childTtransforms[i],shapes[i]); - } - colShape = compound; - - } - - btTransform worldTransform; - worldTransform.setIdentity(); - worldTransform.setOrigin(getBtVector3(rbT.getTranslation())); - PfxQuat quat(rbT.getUpper3x3()); - worldTransform.setBasis(btMatrix3x3(getBtQuat(quat))); - - btScalar mass = physics_get_body(i).getMass(); - btRigidBody* body = addRigidBody(colShape,mass,worldTransform); - void* ptr = (void*)&state; - body->setUserPointer(ptr); - state.setUserData(body); - } - - } - - //very basic joint conversion (only limits of PFX_JOINT_SWINGTWIST joint) - for (int i=0;isetLimit(i,0,0); - break; - } - case SCE_PFX_JOINT_LOCK_FREE: - { - dof6->setLimit(i,1,0); - break; - } - case SCE_PFX_JOINT_LOCK_LIMIT: - { - //deal with the case where angular limits of Y-axis are free and/or beyond -PI/2 and PI/2 - if ((i==4) && ((joint.m_constraints[i].m_movableLowerLimit<-SIMD_PI/2)||(joint.m_constraints[i].m_movableUpperLimit>SIMD_PI/2))) - { - printf("error with joint limits, forcing DOF to fixed\n"); - dof6->setLimit(i,0,0); - } else - { - dof6->setLimit(i,joint.m_constraints[i].m_movableLowerLimit,joint.m_constraints[i].m_movableUpperLimit); - } - - break; - } - default: - { - printf("unknown joint lock state\n"); - } - } - - } - - m_dynamicsWorld->addConstraint(dof6,true); - - } else - { - printf("error: missing bodies during joint conversion\n"); - } - break; - }; - case kPfxJointBall: - case kPfxJointHinge: - case kPfxJointSlider: - case kPfxJointFix: - case kPfxJointUniversal: - case kPfxJointAnimation: - default: - { - printf("unknown joint\n"); - } - } - } - - //create a large enough buffer. There is no method to pre-calculate the buffer size yet. - int maxSerializeBufferSize = 1024*1024*5; - - btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize); - m_dynamicsWorld->serialize(serializer); - - FILE* file = fopen("testFile.bullet","wb"); - fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file); - fclose(file); - -} - -void physics_create_scene(int sceneId) -{ - const int numScenes = 4; - int sid = sceneId % numScenes; - - numRigidBodies= 0; -// numPairs = 0; -// numContacts = 0; - numJoints = 0; -// //frame = 0; - - switch(sid) { - case 0: // simple primitives - createSceneBoxGround(); - createScenePrimitives(); - break; - - case 1: // joints - createSceneBoxGround(); - createSceneJoints(); - break; - - case 2: // stacking - createSceneBoxGround(); - createSceneStacking(); - break; - - case 3: // landscape - createSceneLandscape(); - createScenePrimitives(); - break; - } - - SCE_PFX_PRINTF("----- Size of rigid body buffer ------\n"); - SCE_PFX_PRINTF(" size * num = total\n"); - SCE_PFX_PRINTF("PfxRigidState %5d * %5d = %5d bytes\n",sizeof(PfxRigidState),numRigidBodies,sizeof(PfxRigidState)*numRigidBodies); - SCE_PFX_PRINTF("PfxRigidBody %5d * %5d = %5d bytes\n",sizeof(PfxRigidBody),numRigidBodies,sizeof(PfxRigidBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxCollidable %5d * %5d = %5d bytes\n",sizeof(PfxCollidable),numRigidBodies,sizeof(PfxCollidable)*numRigidBodies); - //SCE_PFX_PRINTF("PfxJoint %5d * %5d = %5d bytes\n",sizeof(PfxJoint),numJoints,sizeof(PfxJoint)*numJoints); - SCE_PFX_PRINTF("PfxSolverBody %5d * %5d = %5d bytes\n",sizeof(PfxSolverBody),numRigidBodies,sizeof(PfxSolverBody)*numRigidBodies); - SCE_PFX_PRINTF("PfxBroadphaseProxy %5d * %5d = %5d bytes\n",sizeof(PfxBroadphaseProxy),numRigidBodies,sizeof(PfxBroadphaseProxy)*numRigidBodies); - SCE_PFX_PRINTF("PfxContactManifold %5d * %5d = %5d bytes\n",sizeof(PfxContactManifold),NUM_CONTACTS,sizeof(PfxContactManifold)*NUM_CONTACTS); - SCE_PFX_PRINTF("PfxBroadphasePair %5d * %5d = %5d bytes\n",sizeof(PfxBroadphasePair),NUM_CONTACTS,sizeof(PfxBroadphasePair)*NUM_CONTACTS); - - int totalBytes = - (sizeof(PfxRigidState) + sizeof(PfxRigidBody) + sizeof(PfxCollidable) + sizeof(PfxSolverBody) + sizeof(PfxBroadphaseProxy)) * numRigidBodies + - (sizeof(PfxContactManifold) + sizeof(PfxBroadphasePair)) * NUM_CONTACTS; - - //convert to Bullet - convertToBullet(); - - - SCE_PFX_PRINTF("----------------------------------------------------------\n"); - SCE_PFX_PRINTF("Total %5d bytes\n",totalBytes); -} - -bool physics_init() -{ - return true; -} - -void physics_release() -{ -} - - -#if 0 - -//J プロキシ -//E Proxies -PfxBroadphaseProxy proxies[NUM_RIGIDBODIES]; - -//J ジョイント -//E Joint -PfxConstraintPair jointPairs[NUM_JOINTS]; -PfxJoint joints[NUM_JOINTS]; -int numJoints = 0; - -//J ペア -//E Pairs -unsigned int numPairs; -PfxBroadphasePair pairs[NUM_CONTACTS]; - -//J コンタクト -//E Contacts -PfxContactManifold contacts[NUM_CONTACTS]; -int numContacts; - -//J 一時ãƒãƒƒãƒ•ã‚¡ -//E Temporary buffers -#define POOL_BYTES (5*1024*1024) -unsigned char PFX_ALIGNED(128) poolBuff[POOL_BYTES]; - -//J 一時ãƒãƒƒãƒ•ァ用スタックアロケータ -//E Stack allocator for temporary buffers -PfxHeapManager pool(poolBuff,POOL_BYTES); - -/////////////////////////////////////////////////////////////////////////////// -// Simulation Function - -int frame = 0; - -void broadphase() -{ - //J å‰›ä½“ãŒæœ€ã‚‚分散ã—ã¦ã„る軸を見ã¤ã‘ã‚‹ - //E Find the axis along which all rigid bodies are most widely positioned - int axis = 0; - { - PfxVector3 s(0.0f),s2(0.0f); - for(int i=0;i v[0]) axis = 1; - if(v[2] > v[axis]) axis = 2; - } - - //J ãƒ–ãƒ­ãƒ¼ãƒ‰ãƒ•ã‚§ãƒ¼ã‚ºãƒ—ãƒ­ã‚­ã‚·ã®æ›´æ–° - //E Create broadpahse proxies - { - for(int i=0;i - #include -#endif - -#define SAMPLE_NAME "api_physics_effects/1_simple" - -static bool s_isRunning = true; - -int sceneId = 2; -bool simulating = false; - -int landscapeMeshId; -int convexMeshId; - -/* - kPfxShapeSphere = 0, - kPfxShapeBox, - kPfxShapeCapsule, - kPfxShapeCylinder, - kPfxShapeConvexMesh, - kPfxShapeLargeTriMesh, - kPfxShapeReserved0, - kPfxShapeReserved1, - kPfxShapeReserved2, - kPfxShapeUser0, - kPfxShapeUser1, - kPfxShapeUser2, - kPfxShapeCount // =12 - */ - -extern void debugRenderPhysics(); - -static void render(void) -{ - - render_begin(); - - for(int i=0;i -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_DOWN)) { - angX += 0.05f*dt; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - } - - if(ctrl_button_pressed(BTN_LEFT)) { - angY -= 0.05f*dt; - } - - if(ctrl_button_pressed(BTN_RIGHT)) { - angY += 0.05f*dt; - } - - if(ctrl_button_pressed(BTN_ZOOM_OUT)) { - r *= (1.f+0.2*dt); - if(r > 500.0f) r = 500.0f; - } - - if(ctrl_button_pressed(BTN_ZOOM_IN)) { - r *= (1.f-0.2*dt); - if(r < 1.0f) r = 1.0f; - } - - if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) { - physics_create_scene(sceneId); - } - - if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) { - physics_create_scene(++sceneId); - } - - if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) { - simulating = !simulating; - } - - if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) { - simulating = true; - } - else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) { - simulating = false; - } - - render_set_view_angle(angX,angY,r); -} - -#ifndef WIN32 - -/////////////////////////////////////////////////////////////////////////////// -// Main - -int main(void) -{ - init(); - - physics_create_scene(sceneId); - - printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - while (s_isRunning) { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - - shutdown(); - - printf("## %s: FINISHED ##\n", SAMPLE_NAME); - - return 0; -} - -#else - - -#include -#include - -static jmp_buf buf; - -void second(void) { - printf("second\n"); // prints - longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1 -} - -void first(void) { - second(); - printf("first\n"); // does not print -} - -int main2() { - if ( ! setjmp(buf) ) { - first(); // when executed, setjmp returns 0 - } else { // when longjmp jumps back, setjmp returns 1 - printf("main\n"); // prints - } - - return 0; -} - - -/////////////////////////////////////////////////////////////////////////////// -// WinMain - -extern HDC hDC; -extern HGLRC hRC; -HWND hWnd; -HINSTANCE hInstance; - -void releaseWindow() -{ - if(hRC) { - wglMakeCurrent(0,0); - wglDeleteContext(hRC); - } - - if(hDC) ReleaseDC(hWnd,hDC); - if(hWnd) DestroyWindow(hWnd); - - UnregisterClass(SAMPLE_NAME,hInstance); -} - -LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) -{ - switch(uMsg) { - case WM_SYSCOMMAND: - { - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - return 0; - } - break; - } - - case WM_CLOSE: - PostQuitMessage(0); - return 0; - - case WM_SIZE: - render_resize(LOWORD(lParam),HIWORD(lParam)); - return 0; - } - - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -bool createWindow(char* title, int width, int height) -{ - WNDCLASS wc; - RECT rect; - rect.left=0; - rect.right=width; - rect.top=0; - rect.bottom=height; - - hInstance = GetModuleHandle(NULL); - wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC) WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = SAMPLE_NAME; - - if(!RegisterClass(&wc)) { - return false; - } - - AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE); - - if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title, - WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN, - 0,0,rect.right-rect.left,rect.bottom-rect.top, - NULL,NULL,hInstance,NULL))) { - releaseWindow(); - return false; - } - - static PIXELFORMATDESCRIPTOR pfd = { - sizeof(PIXELFORMATDESCRIPTOR), - 1, - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, - 32, - 0, 0, - 0, 0, - 0, 0, - 0, 0, - 0, - 0, 0, 0, 0, - 32, - 0, - 0, - PFD_MAIN_PLANE, - 0, - 0, 0, 0 - }; - - if(!(hDC=GetDC(hWnd))) - { - releaseWindow(); - OutputDebugString(""); - return FALSE; - } - - int pixelformat; - - if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){ - OutputDebugString("ChoosePixelFormat Failed...."); - return FALSE; - } - - if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){ - OutputDebugString("SetPixelFormat Failed...."); - return FALSE; - } - - if (!(hRC=wglCreateContext(hDC))){ - OutputDebugString("Creating HGLRC Failed...."); - return FALSE; - } - - // Set Vsync - //BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL; - - //if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) { - //} - //else { - //wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT"); - //if(wglSwapIntervalEXT) wglSwapIntervalEXT(1); - //} - - wglMakeCurrent(hDC,hRC); - - ShowWindow(hWnd,SW_SHOW); - SetForegroundWindow(hWnd); - SetFocus(hWnd); - - render_resize(width, height); - - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClearDepth(1.0f); - - return TRUE; -} - -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -{ - main2(); - - if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) { - MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION); - return 0; - } - - init(); - - physics_create_scene(sceneId); - - SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME); - - MSG msg; - while(s_isRunning) { - if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { - if(msg.message==WM_QUIT) { - s_isRunning = false; - } - else { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - else { - update(); - if(simulating) physics_simulate(); - render(); - - perf_sync(); - } - } - - shutdown(); - - SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME); - - releaseWindow(); - return (msg.wParam); -} - -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/physics_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/physics_func.h deleted file mode 100644 index 898ce2ce1..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/99_bullet_highlevel/physics_func.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PHYSICS_FUNC_H__ -#define __PHYSICS_FUNC_H__ - -#define SCE_PFX_USE_PERFCOUNTER - -#include "physics_effects.h" - -using namespace sce::PhysicsEffects; - -//E Simulation -//J シミュレーション -bool physics_init(); -void physics_release(); -void physics_create_scene(int sceneId); -void physics_simulate(); - -//E Picking -//J ピッキング -PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2); -void physics_pick_update(const PfxVector3 &p); -void physics_pick_end(); - -//E Change parameters -//J パラメータã®å–å¾— -int physics_get_num_rigidbodies(); -const PfxRigidState& physics_get_state(int id); -const PfxRigidBody& physics_get_body(int id); -const PfxCollidable& physics_get_collidable(int id); - -int physics_get_num_contacts(); -const PfxContactManifold &physics_get_contact(int id); - -#endif /* __PHYSICS_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/CMakeLists.txt b/Extras/PhysicsEffects/sample/api_physics_effects/CMakeLists.txt deleted file mode 100644 index 543922336..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -SUBDIRS( - 0_console -) - -IF (WIN32) - SUBDIRS( - 1_simple - 2_stable - 3_sleep - 4_motion_type - 5_raycast - 6_joint - 99_bullet_highlevel -# common - ) -ENDIF() \ No newline at end of file diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/api_physics_effects.windows.sln b/Extras/PhysicsEffects/sample/api_physics_effects/api_physics_effects.windows.sln deleted file mode 100644 index f337433cc..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/api_physics_effects.windows.sln +++ /dev/null @@ -1,164 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "1_simple.windows", "1_simple\1_simple.windows.vcproj", "{C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2_stable.windows", "2_stable\2_stable.winsows.vcproj", "{4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "3_sleep.windows", "3_sleep\3_sleep.windows.vcproj", "{97E051D8-9233-410D-8123-E5ED749D6640}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4_motion_type.windows", "4_motion_type\4_motion_type.windows.vcproj", "{B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "5_raycast.windows", "5_raycast\5_raycast.windows.vcproj", "{96B87A78-C8E3-43C5-B0E4-9A30999B2712}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "6_joint.windows", "6_joint\6_joint.windows.vcproj", "{A296A166-9E6A-44DE-BF58-30131687A117}" - ProjectSection(ProjectDependencies) = postProject - {4908A1B7-06F4-4517-936A-D81D140004F7} = {4908A1B7-06F4-4517-936A-D81D140004F7} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "physics_effects_lib.oss", "..\..\project\physics_effects_lib.oss.vcproj", "{4908A1B7-06F4-4517-936A-D81D140004F7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win32 Debug|Win32 = Win32 Debug|Win32 - Win32 Debug|x64 = Win32 Debug|x64 - Win32 Release|Win32 = Win32 Release|Win32 - Win32 Release|x64 = Win32 Release|x64 - Win64 Debug|Win32 = Win64 Debug|Win32 - Win64 Debug|x64 = Win64 Debug|x64 - Win64 Release|Win32 = Win64 Release|Win32 - Win64 Release|x64 = Win64 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {C74B57DB-C7EF-4718-8BD9-9F6AE6478FAC}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {4CEE7D0E-6C26-4E94-9682-6ECB73091DF7}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {97E051D8-9233-410D-8123-E5ED749D6640}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {B4B4695B-055A-48F5-B9AC-A49F6BCAFCE2}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {96B87A78-C8E3-43C5-B0E4-9A30999B2712}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Debug|Win32.Build.0 = Win64 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {A296A166-9E6A-44DE-BF58-30131687A117}.Win64 Release|x64.Build.0 = Win64 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|Win32.ActiveCfg = Win32 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|Win32.Build.0 = Win32 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|x64.ActiveCfg = Win32 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Debug|x64.Build.0 = Win32 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|Win32.ActiveCfg = Win32 Release|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|Win32.Build.0 = Win32 Release|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|x64.ActiveCfg = Win32 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win32 Release|x64.Build.0 = Win32 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|Win32.ActiveCfg = Win64 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|Win32.Build.0 = Win64 Debug|Win32 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|x64.ActiveCfg = Win64 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Debug|x64.Build.0 = Win64 Debug|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|Win32.ActiveCfg = Win64 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|Win32.Build.0 = Win64 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|x64.ActiveCfg = Win64 Release|x64 - {4908A1B7-06F4-4517-936A-D81D140004F7}.Win64 Release|x64.Build.0 = Win64 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/box.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/box.h deleted file mode 100644 index 716ee8e1b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/box.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define NUM_BOX_VTX 36 -#define NUM_BOX_IDX 36 -const float box_vtx[] = { - -0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - -0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - 0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - -0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - 0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - 0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f, - -0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f, - 0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f, - 0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f, - -0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f, - 0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f, - -0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f, - -0.500000f,-0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,-0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,-0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f, - -0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - 0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - 0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - -0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - 0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - -0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f, - -0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f, - -0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f, - 0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f, - -0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f, - 0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f, - 0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f, - 0.500000f,-0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f, - 0.500000f,0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f, - 0.500000f,0.500000f,0.500000f,1.000000f,0.000000f,0.000000f, - 0.500000f,-0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f, - 0.500000f,0.500000f,0.500000f,1.000000f,0.000000f,0.000000f, - 0.500000f,-0.500000f,0.500000f,1.000000f,0.000000f,0.000000f, -}; -const unsigned short box_idx[] = { - 0,1,2, - 3,4,5, - 6,7,8, - 9,10,11, - 12,13,14, - 15,16,17, - 18,19,20, - 21,22,23, - 24,25,26, - 27,28,29, - 30,31,32, - 33,34,35, -}; diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/common.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/common.h deleted file mode 100644 index a1bdea2f4..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/common.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#include -#include -#include -#include -#include - -// Platform specific -#ifdef _WIN32 - #include -#endif - -#endif /* __COMMON_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.android.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.android.cpp deleted file mode 100644 index aa56a3ae4..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.android.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "common.h" -#include "ctrl_func.h" - -int keyState[2][BTN_NUM] = {0}; -int keySw = 0; - -void ctrl_init() -{ - keySw = 0; -} - -void ctrl_release() -{ -} - -void ctrl_update() -{ -} - -ButtonStatus ctrl_button_pressed(ButtonID btnId) -{ - if(keyState[1-keySw][btnId] && !keyState[keySw][btnId]) { - return BTN_STAT_DOWN; - } - else if(keyState[1-keySw][btnId] && keyState[keySw][btnId]) { - return BTN_STAT_KEEP; - } - else if(!keyState[1-keySw][btnId] && keyState[keySw][btnId]) { - return BTN_STAT_UP; - } - - return BTN_STAT_NONE; -} - -void ctrl_set_screen_size(int w,int h) -{ -} - -void ctrl_get_cursor_position(int &cursorX,int &cursorY) -{ -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.h deleted file mode 100644 index 2cf2fb772..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __CTRL_FUNC_H__ -#define __CTRL_FUNC_H__ - -enum ButtonID { - BTN_SCENE_RESET=0, - BTN_SCENE_NEXT, - BTN_SIMULATION, - BTN_STEP, - BTN_UP, - BTN_DOWN, - BTN_LEFT, - BTN_RIGHT, - BTN_ZOOM_IN, - BTN_ZOOM_OUT, - BTN_PICK, - BTN_NUM -}; - -enum ButtonStatus { - BTN_STAT_NONE = 0, - BTN_STAT_DOWN, - BTN_STAT_UP, - BTN_STAT_KEEP -}; - -void ctrl_init(); -void ctrl_release(); -void ctrl_update(); - -void ctrl_set_screen_size(int w,int h); -void ctrl_get_cursor_position(int &cursorX,int &cursorY); - -ButtonStatus ctrl_button_pressed(ButtonID btnId); - -#endif /* __CTRL_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.win32.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.win32.cpp deleted file mode 100644 index ce3109888..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/ctrl_func.win32.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "common.h" -#include "ctrl_func.h" - -int keyState[2][BTN_NUM] = {0}; -int keySw = 0; - -void ctrl_init() -{ - keySw = 0; -} - -void ctrl_release() -{ -} - -void ctrl_update() -{ - keyState[keySw][BTN_SCENE_RESET] = GetAsyncKeyState(VK_F1); - keyState[keySw][BTN_SCENE_NEXT] = GetAsyncKeyState(VK_F2); - keyState[keySw][BTN_SIMULATION] = GetAsyncKeyState(VK_F3); - keyState[keySw][BTN_STEP] = GetAsyncKeyState(VK_F4); - keyState[keySw][BTN_UP] = GetAsyncKeyState(VK_UP); - keyState[keySw][BTN_DOWN] = GetAsyncKeyState(VK_DOWN); - keyState[keySw][BTN_LEFT] = GetAsyncKeyState(VK_LEFT); - keyState[keySw][BTN_RIGHT] = GetAsyncKeyState(VK_RIGHT); - keyState[keySw][BTN_ZOOM_IN] = GetAsyncKeyState(VK_INSERT); - keyState[keySw][BTN_ZOOM_OUT] = GetAsyncKeyState(VK_DELETE); - keyState[keySw][BTN_PICK] = GetAsyncKeyState(VK_LBUTTON); - keySw = 1-keySw; -} - -ButtonStatus ctrl_button_pressed(ButtonID btnId) -{ - if(keyState[1-keySw][btnId] && !keyState[keySw][btnId]) { - return BTN_STAT_DOWN; - } - else if(keyState[1-keySw][btnId] && keyState[keySw][btnId]) { - return BTN_STAT_KEEP; - } - else if(!keyState[1-keySw][btnId] && keyState[keySw][btnId]) { - return BTN_STAT_UP; - } - - return BTN_STAT_NONE; -} - -void ctrl_set_screen_size(int w,int h) -{ -} - -void ctrl_get_cursor_position(int &cursorX,int &cursorY) -{ - HWND hWnd = ::GetActiveWindow(); - - POINT pnt; - RECT rect; - ::GetCursorPos(&pnt); - ::ScreenToClient(hWnd,&pnt); - ::GetClientRect(hWnd,&rect); - cursorX = pnt.x - (rect.right - rect.left) / 2; - cursorY = (rect.bottom-rect.top) / 2 - pnt.y; -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/cylinder.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/cylinder.h deleted file mode 100644 index bba5d2a47..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/cylinder.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#define NUM_CYLINDER_VTX 68 -#define NUM_CYLINDER_IDX 192 -const float cylinder_vtx[] = { --1.0f,0.0f,0.0f, -1.0f,0.0f,0.0f, --1.0f,-0.923879f,-0.382683f, -1.0f,0.0f,0.0f, --1.0f,-1.0f,1.62921e-007f, -1.0f,0.0f,0.0f, --1.0f,-0.707107f,-0.707107f, -1.0f,0.0f,0.0f, --1.0f,-0.382683f,-0.923879f, -1.0f,0.0f,0.0f, --1.0f,0.0f,-1.0f, -1.0f,0.0f,0.0f, --1.0f,0.382684f,-0.923879f, -1.0f,0.0f,0.0f, --1.0f,0.707107f,-0.707107f, -1.0f,0.0f,0.0f, --1.0f,0.92388f,-0.382683f, -1.0f,0.0f,0.0f, --1.0f,1.0f,-1.62921e-007f, -1.0f,0.0f,0.0f, --1.0f,0.92388f,0.382683f, -1.0f,0.0f,0.0f, --1.0f,0.707107f,0.707107f, -1.0f,0.0f,0.0f, --1.0f,0.382684f,0.92388f, -1.0f,0.0f,0.0f, --1.0f,1.50996e-007f,1.0f, -1.0f,0.0f,0.0f, --1.0f,-0.382683f,0.92388f, -1.0f,0.0f,0.0f, --1.0f,-0.707107f,0.707107f, -1.0f,0.0f,0.0f, --1.0f,-0.92388f,0.382683f, -1.0f,0.0f,0.0f, -1.0f,0.0f,0.0f, 1.0f,0.0f,0.0f, -1.0f,-1.0f,0.0f, 1.0f,0.0f,0.0f, -1.0f,-0.92388f,-0.382683f, 1.0f,0.0f,0.0f, -1.0f,-0.707107f,-0.707107f, 1.0f,0.0f,0.0f, -1.0f,-0.382684f,-0.92388f, 1.0f,0.0f,0.0f, -1.0f,-1.19209e-007f,-1.0f, 1.0f,0.0f,0.0f, -1.0f,0.382683f,-0.92388f, 1.0f,0.0f,0.0f, -1.0f,0.707107f,-0.707107f, 1.0f,0.0f,0.0f, -1.0f,0.923879f,-0.382684f, 1.0f,0.0f,0.0f, -1.0f,1.0f,-3.13917e-007f, 1.0f,0.0f,0.0f, -1.0f,0.92388f,0.382683f, 1.0f,0.0f,0.0f, -1.0f,0.707107f,0.707106f, 1.0f,0.0f,0.0f, -1.0f,0.382684f,0.923879f, 1.0f,0.0f,0.0f, -1.0f,0.0f,1.0f, 1.0f,0.0f,0.0f, -1.0f,-0.382684f,0.923879f, 1.0f,0.0f,0.0f, -1.0f,-0.707107f,0.707107f, 1.0f,0.0f,0.0f, -1.0f,-0.92388f,0.382683f, 1.0f,0.0f,0.0f, --1.0f,-1.0f,1.62921e-007f, 0.0f,-1.0f,0.0f, -1.0f,-0.92388f,-0.382683f, 0.0f,-0.92388f,-0.382683f, -1.0f,-1.0f,0.0f, 0.0f,-1.0f,0.0f, --1.0f,-0.923879f,-0.382683f, 0.0f,-0.92388f,-0.382683f, -1.0f,-0.707107f,-0.707107f, 0.0f,-0.707107f,-0.707107f, --1.0f,-0.707107f,-0.707107f, 0.0f,-0.707107f,-0.707107f, -1.0f,-0.382684f,-0.92388f, 0.0f,-0.382684f,-0.92388f, --1.0f,-0.382683f,-0.923879f, 0.0f,-0.382683f,-0.92388f, -1.0f,-1.19209e-007f,-1.0f, 0.0f,0.0f,-1.0f, --1.0f,0.0f,-1.0f, 0.0f,0.0f,-1.0f, --1.0f,0.0f,-1.0f, 0.0f,0.0f,-1.0f, -1.0f,0.382683f,-0.92388f, 0.0f,0.382683f,-0.92388f, -1.0f,-1.19209e-007f,-1.0f, 0.0f,0.0f,-1.0f, --1.0f,0.382684f,-0.923879f, 0.0f,0.382683f,-0.92388f, -1.0f,0.707107f,-0.707107f, 0.0f,0.707107f,-0.707107f, --1.0f,0.707107f,-0.707107f, 0.0f,0.707107f,-0.707107f, -1.0f,0.923879f,-0.382684f, 0.0f,0.923879f,-0.382684f, --1.0f,0.92388f,-0.382683f, 0.0f,0.923879f,-0.382684f, -1.0f,1.0f,-3.13917e-007f, 0.0f,1.0f,-2.03489e-007f, --1.0f,1.0f,-1.62921e-007f, 0.0f,1.0f,-2.13162e-007f, -1.0f,0.92388f,0.382683f, 0.0f,0.92388f,0.382683f, --1.0f,0.92388f,0.382683f, 0.0f,0.92388f,0.382683f, -1.0f,0.707107f,0.707106f, 0.0f,0.707107f,0.707107f, --1.0f,0.707107f,0.707107f, 0.0f,0.707107f,0.707107f, -1.0f,0.382684f,0.923879f, 0.0f,0.382684f,0.923879f, --1.0f,0.382684f,0.92388f, 0.0f,0.382684f,0.923879f, -1.0f,0.0f,1.0f, 0.0f,0.0f,1.0f, --1.0f,1.50996e-007f,1.0f, 0.0f,0.0f,1.0f, -1.0f,-0.382684f,0.923879f, 0.0f,-0.382684f,0.92388f, --1.0f,-0.382683f,0.92388f, 0.0f,-0.382683f,0.92388f, -1.0f,-0.707107f,0.707107f, 0.0f,-0.707107f,0.707107f, --1.0f,-0.707107f,0.707107f, 0.0f,-0.707107f,0.707107f, -1.0f,-0.92388f,0.382683f, 0.0f,-0.92388f,0.382683f, --1.0f,-0.92388f,0.382683f, 0.0f,-0.92388f,0.382683f, -}; -const unsigned short cylinder_idx[] = { -0,1,2, -0,3,1, -0,4,3, -0,5,4, -0,6,5, -0,7,6, -0,8,7, -0,9,8, -0,10,9, -0,11,10, -0,12,11, -0,13,12, -0,14,13, -0,15,14, -0,16,15, -0,2,16, -17,18,19, -17,19,20, -17,20,21, -17,21,22, -17,22,23, -17,23,24, -17,24,25, -17,25,26, -17,26,27, -17,27,28, -17,28,29, -17,29,30, -17,30,31, -17,31,32, -17,32,33, -17,33,18, -34,35,36, -34,37,35, -37,38,35, -37,39,38, -39,40,38, -39,41,40, -41,42,40, -41,43,42, -44,45,46, -44,47,45, -47,48,45, -47,49,48, -49,50,48, -49,51,50, -51,52,50, -51,53,52, -53,54,52, -53,55,54, -55,56,54, -55,57,56, -57,58,56, -57,59,58, -59,60,58, -59,61,60, -61,62,60, -61,63,62, -63,64,62, -63,65,64, -65,66,64, -65,67,66, -67,36,66, -67,34,36, -}; diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.cpp deleted file mode 100644 index 9a42ad392..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include -#include "physicseffects-android.h" -#include "../render_func.h" -#include "../perf_func.h" - -#ifdef __cplusplus -extern "C" { -#endif - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit -// -/// Implementation of JNI function to initilize the simulation and start the -/// first scene. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit( JNIEnv* env ) -{ - init(); - sceneChange(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsSimulate -// -/// Implementation of JNI function to update the simulation and view parameters, -/// perform one simulation step, and redraw the scene. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsSimulate( JNIEnv* env ) -{ - update(); - physics_simulate(); - render(); - perf_sync(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsUpdate -// -/// Implementation of JNI function to update the camera view and simulation -/// parameters. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsUpdate( JNIEnv* env ) -{ - update(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsPhysStep -// -/// Implementation of JNI function to perform one simulation step. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsPhysStep( JNIEnv* env ) -{ - physics_simulate(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsRender -// -/// Implementation of JNI function to render the scene. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsRender( JNIEnv* env ) -{ - render(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange -// -/// Implementation of JNI function to change to the next scene. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange( JNIEnv* env ) -{ - sceneChange(); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraUp -// -/// Implementation of JNI function to tilt the camera up -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraUp( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - angX -= 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - - render_set_view_angle(angX, angY, r); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraDown -// -/// Implementation of JNI function to tilt the camera down -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraDown( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - angX += 0.05f; - if(angX < -1.4f) angX = -1.4f; - if(angX > -0.01f) angX = -0.01f; - - render_set_view_angle(angX, angY, r); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraLeft -// -/// Implementation of JNI function to tilt the camera left -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraLeft( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - angY -= 0.05f; - - render_set_view_angle(angX, angY, r); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraRight -// -/// Implementation of JNI function to tilt the camera right -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraRight( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - angY += 0.05f; - - render_set_view_angle(angX, angY, r); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomOut -// -/// Implementation of JNI function to dolly the camera away from scene, -/// effectively zooming out. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomOut( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - r *= 1.1f; - if(r > 500.0f) r = 500.0f; - - render_set_view_angle(angX, angY, r); -} - -//---------------------------------------------------------------------------- -// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomIn -// -/// Implementation of JNI function to dolly the camera towards scene, -/// effectively zooming in. -/// -/// @param env Pointer to JNI environment -//---------------------------------------------------------------------------- -void -Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomIn( JNIEnv* env ) -{ - float angX, angY, r; - render_get_view_angle(angX, angY, r); - - r *= 0.9f; - if(r < 1.0f) r = 1.0f; - - render_set_view_angle(angX, angY, r); -} - -#ifdef __cplusplus -} -#endif diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.h deleted file mode 100644 index 1229cdf94..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/jni/physicseffects-android.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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 PHYSICSEFFECTS_ANDROID_H -#define PHYSICSEFFECTS_ANDROID_H - -// The following C++ functions must be provided by the -// sample application. -extern int init(); -extern void render(void); -extern void sceneChange(); -extern void update(void); -extern void physics_simulate(); - -#endif // !PHYSICSEFFECTS_ANDROID_H diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.android.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.android.cpp deleted file mode 100644 index 2b3d5656b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.android.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "common.h" -#include "perf_func.h" - -void perf_init() -{ -} - -void perf_release() -{ -} - -void perf_push_marker(char *str) -{ -} - -void perf_pop_marker() -{ -} - -void perf_sync() -{ -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.h b/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.h deleted file mode 100644 index 2868fe2dd..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef __PERF_FUNC_H__ -#define __PERF_FUNC_H__ - -void perf_init(); -void perf_release(); -void perf_push_marker(char *str); -void perf_pop_marker(); -void perf_sync(); - -#endif /* __PERF_FUNC_H__ */ diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.win32.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.win32.cpp deleted file mode 100644 index 2b3d5656b..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/perf_func.win32.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "common.h" -#include "perf_func.h" - -void perf_init() -{ -} - -void perf_release() -{ -} - -void perf_push_marker(char *str) -{ -} - -void perf_pop_marker() -{ -} - -void perf_sync() -{ -} diff --git a/Extras/PhysicsEffects/sample/api_physics_effects/common/render_func.android.cpp b/Extras/PhysicsEffects/sample/api_physics_effects/common/render_func.android.cpp deleted file mode 100644 index cadc8097f..000000000 --- a/Extras/PhysicsEffects/sample/api_physics_effects/common/render_func.android.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "render_func.h" - -#include "box.h" -#include "sphere.h" -#include "cylinder.h" - -#include -#include - -// local variables -static int screen_width,screen_height; -static PfxMatrix4 g_pMat,g_vMat; -static PfxVector3 g_viewPos,g_lightPos,g_viewTgt; -static float lightRadius,lightRadX,lightRadY; -static float viewRadius,viewRadX,viewRadY,viewHeight; - -static unsigned short *box_wire_idx; -static unsigned short *sphere_wire_idx; -static unsigned short *cylinder_wire_idx; - -#define MAX_MESH 5 - -static struct MeshBuff { - float *vtx; - float *nml; - int numVtx; - unsigned short *idx; - unsigned short *wire_idx; - int numIdx; -} meshBuff[MAX_MESH]; -int numMesh; - -void render_init() -{ - screen_width = DISPLAY_WIDTH; - screen_height = DISPLAY_HEIGHT; - - // initalize matrix - g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)screen_width/(float)screen_height,0.1f, 1000.0f); - - // initalize parameters - lightRadius = 40.0f; - lightRadX = -0.6f; - lightRadY = 0.6f; - viewRadius = 40.0f; - viewRadX = -0.01f; - viewRadY = 0.0f; - viewHeight = 1.0f; - - g_viewTgt = PfxVector3(0.0f,viewHeight,0.0f); - - box_wire_idx = new unsigned short [NUM_BOX_IDX*2]; - sphere_wire_idx = new unsigned short [NUM_SPHERE_IDX*2]; - cylinder_wire_idx = new unsigned short [NUM_CYLINDER_IDX*2]; - - for(int i=0;i 0) { - for(int i=0;i=0&&meshId - -#include "box.h" -#include "sphere.h" -#include "cylinder.h" - -// context -HDC hDC; -HGLRC hRC; - -// local variables -static int screen_width,screen_height; -static PfxMatrix4 g_pMat,g_vMat; -static PfxVector3 g_viewPos,g_lightPos,g_viewTgt; -static float lightRadius,lightRadX,lightRadY; -static float viewRadius,viewRadX,viewRadY,viewHeight; - -static unsigned short *box_wire_idx; -static unsigned short *sphere_wire_idx; -static unsigned short *cylinder_wire_idx; - -#define MAX_MESH 5 - -static struct MeshBuff { - float *vtx; - float *nml; - int numVtx; - unsigned short *idx; - unsigned short *wire_idx; - int numIdx; -} meshBuff[MAX_MESH]; -int numMesh; - -void render_init() -{ - screen_width = DISPLAY_WIDTH; - screen_height = DISPLAY_HEIGHT; - - // initalize matrix - g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)screen_width/(float)screen_height,0.1f, 1000.0f); - - // initalize parameters - lightRadius = 40.0f; - lightRadX = -0.6f; - lightRadY = 0.6f; - viewRadius = 40.0f; - viewRadX = -0.01f; - viewRadY = 0.0f; - viewHeight = 1.0f; - - g_viewTgt = PfxVector3(0.0f,viewHeight,0.0f); - - box_wire_idx = new unsigned short [NUM_BOX_IDX*2]; - sphere_wire_idx = new unsigned short [NUM_SPHERE_IDX*2]; - cylinder_wire_idx = new unsigned short [NUM_CYLINDER_IDX*2]; - - for(int i=0;i 0) { - for(int i=0;i=0&&meshId = d18,d19 - vld1.32 {d16,d17}, [r0] @ input = d16,d17 -@ rearrange inputs into convenient order - vtrn.32 d18,d19 @ q9 = = d18,d19 - vrev64.32 d16,d16 @ q8 = = d16,d17 - vrev64.32 d18,d18 @ q9 = = d18,d19 - vtrn.32 d16,d17 @ q8 = = d16,d17 -@ perform first half of cross product using rearranged inputs - vmul.f32 q10, q8, q9 @ q10 = -@ rearrange inputs again - vtrn.32 d18,d19 @ q9 = = d18,d19 - vrev64.32 d16,d16 @ q8 = = d16,d17 - vrev64.32 d18,d18 @ q9 = = d18,d19 - vtrn.32 d16,d17 @ q8 = = d16,d17 -@ perform last half of cross product using rearranged inputs - vmls.f32 q10, q8, q9 @ q10 = -@ and store the result - vst1.32 {q10}, [r2] - bx lr - .fnend - -@ cross product, result stored directly to memory, version 2 - - .global CrossProductNeonResultInMemoryAssembly2 - .thumb_func -CrossProductNeonResultInMemoryAssembly2: - .fnstart - vld1.32 {d18[1]}, [r1]! - vld1.32 {d19[0]}, [r1]! - vld1.32 {d18[0]}, [r1]! - vld1.32 {d19[1]}, [r1] @ q9 = = d18,d19 - vld1.32 {d17[0]}, [r0]! - vld1.32 {d16}, [r0]! - vld1.32 {d17[1]}, [r0] @ q8 = = d16,d17 -@ perform first half of cross product using rearranged inputs - vmul.f32 q10, q8, q9 @ q10 = -@ rearrange inputs for second half - vtrn.32 d18,d19 @ q9 = = d18,d19 - vrev64.32 d16,d16 @ q8 = = d16,d17 - vrev64.32 d18,d18 @ q9 = = d18,d19 - vtrn.32 d16,d17 @ q8 = = d16,d17 -@ perform last half of cross product using rearranged inputs - vmls.f32 q10, q8, q9 @ q10 = -@ and store the result - vst1.32 {q10}, [r2] - bx lr - .fnend - - .global CrossProductNeonResultInMemoryAssembly3 - .thumb_func -CrossProductNeonResultInMemoryAssembly3: - .fnstart - vld1.32 {d18[1]}, [r1]! - vld1.32 {d19[0]}, [r1]! - vld1.32 {d18[0]}, [r1]! - vld1.32 {d19[1]}, [r1]! @ q9 = = d18,d19 - vld1.32 {d17[0]}, [r0]! - vld1.32 {d16}, [r0]! - vld1.32 {d17[1]}, [r0]! @ q8 = = d16,d17 -@ perform first half of cross product using rearranged inputs - vmul.f32 q10, q8, q9 @ q10 = - vld1.32 {d18[1]}, [r0]! - vld1.32 {d19[0]}, [r0]! - vld1.32 {d18[0]}, [r0]! - vld1.32 {d19[1]}, [r0]! @ q9 = = d18,d19 - vld1.32 {d17[0]}, [r1]! - vld1.32 {d16}, [r1]! - vld1.32 {d17[1]}, [r1]! @ q8 = = d16,d17 -@ perform last half of cross product using rearranged inputs - vmls.f32 q10, q8, q9 @ q10 = -@ and store the result - vst1.32 {q10}, [r2] - bx lr - .fnend - -@ cross product, result stored directly to memory, version 3 - -@ .global CrossProductNeonResultInMemoryAssembly3 -@ .thumb_func -@CrossProductNeonResultInMemoryAssembly3: -@ .fnstart -@ ldr r3, table -@ vld1.32 {d18,d19}, [r1] @ input = d18,d19 -@ vld1.32 {d16,d17}, [r0] @ input = d16,d17 -@ rearrange inputs into convenient order -@ vld1.32 {q10}, [r3]! -@ vld1.32 {q11}, [r3] -@ vtbl.8 q12, {d18,d19}, q10 -@ vtbl.8 q13, {d16,d17}, q11 -@ perform first half of cross product using rearranged inputs -@ vmul.f32 q14, q12, q13 -@ rearrange inputs again -@ vtbl.8 q12, {d18,d19}, q11 -@ vtbl.8 q13, {d16,d17}, q10 -@ perform last half of cross product using rearranged inputs -@ vmls.f32 q14, q12, q13 -@ and store the result -@ vst1.32 {q14}, [r2] -@ bx lr -@ .fnend - -@table: -@z2,x2,y2,w2 -@ dcb 08,09,10,11,00,01,02,03,04,05,06,07,00,00,00,00 -@y1,z1,x1,w1 -@ dcb 04,05,06,07,08,09,10,11,00,01,02,03,00,00,00,00 diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_dot_product.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_dot_product.S deleted file mode 100644 index 56aedfcaf..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_dot_product.S +++ /dev/null @@ -1,98 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ dot product, result returned in register - - .global DotProductNeonResultInRegisterAssembly - .thumb_func -DotProductNeonResultInRegisterAssembly: - .fnstart - vld1.32 {d16,d17}, [r0] @ input - vld1.32 {d18,d19}, [r1] @ input - vmul.f32 d14, d16, d18 @ d14= - vmla.f32 d14, d17, d19 @ d14=d14+= - vpadd.f32 d14, d14, d14 @ add the two halves of d14 together, result in each lane - vmov.f32 r0, s28 @ s28 aliases the first lane of d14 - bx lr - .fnend - -@ dot product, result stored directly to memory - - .global DotProductNeonResultInMemoryAssembly - .thumb_func -DotProductNeonResultInMemoryAssembly: - .fnstart - vld1.32 {d16,d17}, [r0] @ input - vld1.32 {d18,d19}, [r1] @ input - vmul.f32 d14, d16, d18 @ d14= -@ non-fused multiple accumulate - vmla.f32 d14, d17, d19 @ d14=d14+= -@ fused multiple accumulate - not recognized by GNU assembler -@@ vfma.f32 {d14}, d17, d19 @ d14=d14+= - vpadd.f32 d14, d14, d14 @ add the two halves of d14 together, same result in each lane - vst1.32 {d14}, [r2] - bx lr - .fnend - -@ dot product, result stored directly to memory, all inputs are contiguous in memory - - .global DotProductNeonResultInMemoryAssembly2 - .thumb_func -DotProductNeonResultInMemoryAssembly2: - .fnstart - vld1.32 {d16-d19}, [r0] @ input q8=, q9= - vmul.f32 d14, d16, d18 @ d14= -@ non-fused multiple accumulate - vmla.f32 d14, d17, d19 @ d14=d14+= -@ fused multiple accumulate - not recognized by GNU assembler -@@ vfma.f32 d14, d17, d19 @ d14=d14+= - vpadd.f32 d14, d14, d14 @ add the two halves of d14 together, same result in each lane - vst1.32 {d14}, [r1] - bx lr - .fnend - -@ same as DotProductNeonResultInMemoryAssembly2, but alternate methodology to compute result - - .global DotProductNeonResultInMemoryAssembly2b - .thumb_func -DotProductNeonResultInMemoryAssembly2b: - .fnstart - vld1.32 {d14-d17}, [r0] @ input q7=, q8= - vmul.f32 q7, q7, q8 @ q7 = = d14,d15 = s28,s29,s30,s31 - vpadd.f32 d14,d14,d14 @ add elements of d14 together= - vpadd.f32 d15,d15,d15 @ add elements of d14 together= - vadd.f32 d14,d14,d15 @ add d14 and d15 together, final result in both lanes - vst1.32 {d14}, [r1] - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix3_operator_multiply.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix3_operator_multiply.S deleted file mode 100644 index 2c4470e73..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix3_operator_multiply.S +++ /dev/null @@ -1,62 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ matrix3 operator *, result stored directly to memory - - .global Matrix3OperatorMultiplyNeon - .thumb_func -Matrix3OperatorMultiplyNeon: - .fnstart - vld1.32 {d16-d19}, [r0]! @ load first eight elements of matrix 0 - vld1.32 {d20-d21}, [r0] @ load second eight elements of matrix 0 - vld1.32 {d0-d3}, [r1]! @ load first eight elements of matrix 1 - vld1.32 {d4-d5}, [r1] @ load second eight elements of matrix 1 - - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmul.f32 q13, q8, d2[0] @ rslt col1 = (mat0 col0) * (mat1 col1 elt0) - vmul.f32 q14, q8, d4[0] @ rslt col2 = (mat0 col0) * (mat1 col2 elt0) - - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q13, q9, d2[1] @ rslt col1 += (mat0 col1) * (mat1 col1 elt1) - vmla.f32 q14, q9, d4[1] @ rslt col2 += (mat0 col1) * (mat1 col2 elt1) - - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vmla.f32 q13, q10, d3[0] @ rslt col1 += (mat0 col2) * (mat1 col1 elt2) - vmla.f32 q14, q10, d5[0] @ rslt col2 += (mat0 col2) * (mat1 col2 elt2) - - vst1.32 {d24-d27}, [r2]! @ store first eight elements of result - vst1.32 {d28-d29}, [r2] @ store second eight elements of result - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix4_operator_multiply.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix4_operator_multiply.S deleted file mode 100644 index 848e998b7..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_matrix4_operator_multiply.S +++ /dev/null @@ -1,71 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ matrix4 operator *, result stored directly to memory - - .global Matrix4OperatorMultiplyNeon - .thumb_func -Matrix4OperatorMultiplyNeon: - .fnstart - - vld1.32 {d16-d19}, [r0]! @ load first eight elements of matrix 0 - vld1.32 {d20-d23}, [r0] @ load second eight elements of matrix 0 - vld1.32 {d0-d3}, [r1]! @ load first eight elements of matrix 1 - vld1.32 {d4-d7}, [r1] @ load second eight elements of matrix 1 - - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmul.f32 q13, q8, d2[0] @ rslt col1 = (mat0 col0) * (mat1 col1 elt0) - vmul.f32 q14, q8, d4[0] @ rslt col2 = (mat0 col0) * (mat1 col2 elt0) - vmul.f32 q15, q8, d6[0] @ rslt col3 = (mat0 col0) * (mat1 col3 elt0) - - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q13, q9, d2[1] @ rslt col1 += (mat0 col1) * (mat1 col1 elt1) - vmla.f32 q14, q9, d4[1] @ rslt col2 += (mat0 col1) * (mat1 col2 elt1) - vmla.f32 q15, q9, d6[1] @ rslt col3 += (mat0 col1) * (mat1 col3 elt1) - - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vmla.f32 q13, q10, d3[0] @ rslt col1 += (mat0 col2) * (mat1 col1 elt2) - vmla.f32 q14, q10, d5[0] @ rslt col2 += (mat0 col2) * (mat1 col2 elt2) - vmla.f32 q15, q10, d7[0] @ rslt col3 += (mat0 col2) * (mat1 col2 elt2) - - vmla.f32 q12, q11, d1[1] @ rslt col0 += (mat0 col3) * (mat1 col0 elt3) - vmla.f32 q13, q11, d3[1] @ rslt col1 += (mat0 col3) * (mat1 col1 elt3) - vmla.f32 q14, q11, d5[1] @ rslt col2 += (mat0 col3) * (mat1 col2 elt3) - vmla.f32 q15, q11, d7[1] @ rslt col3 += (mat0 col3) * (mat1 col3 elt3) - - vst1.32 {d24-d27}, [r2]! @ store first eight elements of result - vst1.32 {d28-d31}, [r2] @ store second eight elements of result - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_orthoInverse_transform3.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_orthoInverse_transform3.S deleted file mode 100644 index 161fde629..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_orthoInverse_transform3.S +++ /dev/null @@ -1,81 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ orthoInverse of a transform3, result stored directly to memory - - .global OrthoInverseTransform3Neon - .thumb_func -OrthoInverseTransform3Neon: - .fnstart -@way 1 -@ vld1.f32 {d0-d3}, [r0]! @ load first eight elements of result -@ vld1.f32 {d4-d7}, [r0] @ load second eight elements of result - -@ vzip.f32 d0, d2 -@ vzip.f32 d1, d3 -@ vswp.f32 d1, d4 -@ vzip.f32 d1, d3 - -@way 2 (faster) -@ -@ -@ NOTE NOTE! This is broken! It does not use the last column of the input! Please see -@ implementation of pfxTransform3OrthoInverseNEON in vectormath_neon_assembly_implementations.S, in -@ include/vecmath/neon, for a correct implementation! -@ - vld1.f32 d0[0], [r0]! - vld1.f32 d2[0], [r0]! - vld1.f32 d4[0], [r0]! - vld1.f32 d1[1], [r0]! - - vld1.f32 d0[1], [r0]! - vld1.f32 d2[1], [r0]! - vld1.f32 d4[1], [r0]! - vld1.f32 d3[1], [r0]! - - vld1.f32 d1[0], [r0]! - vld1.f32 d3[0], [r0]! - vld1.f32 d5[0], [r0]! - vld1.f32 d5[1], [r0] - - vmul.f32 q3, q0, d1[0] - vmla.f32 q3, q1, d3[0] - vmla.f32 q3, q2, d5[0] - vneg.f32 q3, q3 - - vst1.f32 {d0-d3}, [r1]! @ store first eight elements of result - vst1.f32 {d4-d7}, [r1] @ store second eight elements of result - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transform3_operator_multiply.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transform3_operator_multiply.S deleted file mode 100644 index 09c655e3b..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transform3_operator_multiply.S +++ /dev/null @@ -1,51 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ transform3 operator *, result stored directly to memory - - .global Transform3OperatorMultiplyNeon - .thumb_func -Transform3OperatorMultiplyNeon: - .fnstart - - vld1.32 {d16-d19}, [r0]! @ load first eight elements of transform matrix - vld1.32 {d20-d21}, [r0] @ load second eight elements of transform matrix - vld1.32 {d0-d1}, [r1] @ load the four elements of vector3 - vmul.f32 q12, q8, d0[0] @ rslt col0 = (mat0 col0) * (mat1 col0 elt0) - vmla.f32 q12, q9, d0[1] @ rslt col0 += (mat0 col1) * (mat1 col0 elt1) - vmla.f32 q12, q10, d1[0] @ rslt col0 += (mat0 col2) * (mat1 col0 elt2) - vst1.32 {d24-d25}, [r2] @ store first eight elements of result - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transpose_matrix3.S b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transpose_matrix3.S deleted file mode 100644 index 3d586bbd2..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/neon_transpose_matrix3.S +++ /dev/null @@ -1,81 +0,0 @@ -@ -@ Applied Research Associates Inc. (c)2011 -@ -@ 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 Applied Research Associates 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. -@ - .syntax unified - .arch armv7-a - .fpu neon - .thumb - .text - .align 2 - -@ transpose a matrix3, result stored directly to memory - - .global TransposeMatrix3Neon - .thumb_func -TransposeMatrix3Neon: - .fnstart - -@way1 -@ vld1.f32 d0[0], [r0]! -@ vld1.f32 d2[0], [r0]! -@ vld1.f32 d4[0], [r0]! -@ vld1.f32 d1[1], [r0]! - -@ vld1.f32 d0[1], [r0]! -@ vld1.f32 d2[1], [r0]! -@ vld1.f32 d4[1], [r0]! -@ vld1.f32 d3[1], [r0]! - -@ vld1.f32 d1[0], [r0]! -@ vld1.f32 d3[0], [r0]! -@ vld1.f32 d5[0], [r0]! -@ vld1.f32 d5[1], [r0] - -@way2 -@ vld2.f32 {d0-d1}, [r0]! -@ vld2.f32 {d2-d3}, [r0]! -@ vld2.f32 {d4-d5}, [r0] - -@ vzip.f32 q0, q1 -@ vswp.f32 d1, d4 -@ vswp.f32 d3, d5 -@ vzip.f32 d1, d5 - -@way3 (Fastest) - vld1.f32 {d0-d3}, [r0]! @ store first eight elements of result - vld1.f32 {d4-d5}, [r0] @ store second eight elements of result - - vzip.f32 d0, d2 - vzip.f32 d1, d3 - vswp.f32 d1, d4 - vzip.f32 d1, d3 - - vst1.f32 {d0-d3}, [r1]! @ store first eight elements of result - vst1.f32 {d4-d5}, [r1] @ store second eight elements of result - - bx lr - .fnend diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon.h b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon.h deleted file mode 100644 index 04f059e9c..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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 TEST_NEON_H -#define TEST_NEON_H - -//Neon functions to test -void TestNeonDotProduct(); -void TestNeonCrossProduct(); -void TestNeonMatrix3OperatorMultiply(); -void TestNeonMatrix4OperatorMultiply(); -void TestNeonOrthoInverseTransform3(); -void TestNeonTransform3OperatorMultiply(); -void TestNeonTransposeMatrix3(); -void TestNeonSolveLinearConstraintRow(); - -#endif // TEST_NEON_H diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_cross_product.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_cross_product.cpp deleted file mode 100644 index 1350e2743..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_cross_product.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -//#define PRINT_COMPUTED_VECTOR_RESULTS - -// assembly implementations -extern "C" -{ - void CrossProductNeonResultInMemoryAssembly(float *a, float *b, float *pfResult); - void CrossProductNeonResultInMemoryAssembly2(float *a, float *b, float *pfResult); - void CrossProductNeonResultInMemoryAssembly3(float *a, float *b, float *pfResult); -} - -//---------------------------------------------------------------------------- -// CrossProductNeonResultInMemory -// -/// Performs a Vector3 style cross product using NEON intrinsics, storing the -/// result directly into system memory. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// @param pfResult [in] must point to an array of at least *4* -/// float values. [out] The result of the cross -/// product is contained in the first 3 lanes. -/// -/// NOTE: The parameter types here are floats, not float32_t's. gcc -/// sometimes doesn't interpret float32_t's correctly. In particular, -/// if the type of pfResult is set to float32_t*, gcc will throw an -/// internal compiler error (ICE) for this code. In memory, float32_t -/// and float are equivalent, so can cast between them explicitly. -//---------------------------------------------------------------------------- -void CrossProductNeonResultInMemory(float *a, float *b, float *pfResult) -{ - float32x4_t v1 = {a[1],a[2],a[0], 0.0f}; - float32x4_t v2 = {b[2],b[0],b[1], 0.0f}; - float32x4_t v3 = {a[2],a[0],a[1], 0.0f}; - float32x4_t v4 = {b[1],b[2],b[0], 0.0f}; - v1 = vmulq_f32(v1, v2); - v1 = vmlsq_f32(v1, v3, v4); - vst1q_f32((float32_t*)pfResult, v1); -} - -void CrossProductNeonResultInMemoryCPPAssembly(float *a, float *b, float *result) { - asm volatile( - "vld1.32 {d18[1]}, [r1]! \n\t" - "vld1.32 {d19[0]}, [r1]! \n\t" - "vld1.32 {d18[0]}, [r1]! \n\t" - "vld1.32 {d19[1]}, [r1] \n\t" - "vld1.32 {d17[0]}, [r0]! \n\t" - "vld1.32 {d16}, [r0]! \n\t" - "vld1.32 {d17[1]}, [r0] \n\t" - "vmul.f32 q10, q8, q9 \n\t" - "vtrn.32 d18,d19 \n\t" - "vrev64.32 d16,d16 \n\t" - "vrev64.32 d18,d18 \n\t" - "vtrn.32 d16,d17 \n\t" - "vmls.f32 q10, q8, q9 \n\t" - "vst1.32 {q10}, [r2] \n\t" - ); -} - -//---------------------------------------------------------------------------- -// CrossProductScalarResultInMemory -// -/// Performs a Vector3 style cross product using scalar math, storing the -/// result directly into system memory. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// @param pfResult [in] pointer to a float. [out] Contains the -/// result, dotproduct(a,b) -//---------------------------------------------------------------------------- -void CrossProductScalarResultInMemory(float *a, float *b, float *pfResult) -{ - pfResult[0] = a[1]*b[2] - a[2]*b[1]; - pfResult[1] = a[2]*b[0] - a[0]*b[2]; - pfResult[2] = a[0]*b[1] - a[1]*b[0]; -} - -//---------------------------------------------------------------------------- -// TestFastNeonCrossProduct -// -/// Run timing study of the cross product functions above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonCrossProduct() -{ - float SET_ALIGNMENT(64) data[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - - float *a = &data[0]; - float *b = &data[4]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Cross product test inputs A=<%f,%f,%f>, B=<%f,%f,%f>", - a[0], a[1], a[2], b[0], b[1], b[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - float SET_ALIGNMENT(64) fResult[4]; - - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - - sce::PhysicsEffects::PfxPerfCounter pc; - -// profile scalar cross product with direct memory return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - CrossProductScalarResultInMemory(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for CrossProductScalarResultInMemory: %f secs, speedup: %5.2f, result value=<%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - -// profile NEON assembly volatile cross product with direct memory return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - CrossProductNeonResultInMemoryCPPAssembly(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for CrossProductNeonResultInMemoryFast: %f secs, speedup: %5.2f, result value=<%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - -// profile NEON cross product with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - CrossProductNeonResultInMemoryAssembly(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for CrossProductNeonResultInMemoryAssembly: %f secs, speedup: %5.2f, result value=<%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - -// profile NEON cross product with direct memory return, assembly version 2 - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - CrossProductNeonResultInMemoryAssembly2(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - - sprintf(szMsg, "Time to do %i calls for CrossProductNeonResultInMemoryAssembly2: %f secs, speedup: %5.2f, result value=<%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - -// profile NEON cross product with direct memory return, assembly version 3 - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - CrossProductNeonResultInMemoryAssembly3(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - - sprintf(szMsg, "Time to do %i calls for CrossProductNeonResultInMemoryAssembly3: %f secs, speedup: %5.2f, result value=<%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_dot_product.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_dot_product.cpp deleted file mode 100644 index e1f5c1ff2..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_dot_product.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -//#define PRINT_COMPUTED_VECTOR_RESULTS - -// assembly implementations -extern "C" -{ - float32_t DotProductNeonResultInRegisterAssembly(float *a, float *b); - void DotProductNeonResultInMemoryAssembly(float *a, float *b, float *pfResult); - void DotProductNeonResultInMemoryAssembly2(float *data, float *pfResult); - void DotProductNeonResultInMemoryAssembly2b(float *data, float *pfResult); -} - -//---------------------------------------------------------------------------- -// DotProductNeonResultInRegister -// -/// Performs a Vector4 style dot product using NEON intrinsics, returning -/// the result in an ARM register. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// -/// @return dotproduct(a,b) -//---------------------------------------------------------------------------- -float32_t DotProductNeonResultInRegister(float *a, float *b) -{ - float32_t result[2]; - float32x2_t v1a = vld1_f32((float32_t*)a); - float32x2_t v1b = vld1_f32((float32_t*)(a + 2)); - float32x2_t v2a = vld1_f32((float32_t*)b); - float32x2_t v2b = vld1_f32((float32_t*)(b + 2)); - v1a = vmul_f32(v1a, v2a); - v1a = vmla_f32(v1a, v1b, v2b); - v1a = vpadd_f32(v1a, v1a); - vst1_f32(result, v1a); - return(result[0]); -} - -// pfResult must point to memory large enough to store *two* -// float32_t values -//---------------------------------------------------------------------------- -// DotProductNeonResultInMemory -// -/// Performs a Vector4 style dot product using NEON intrinsics, storing the -/// result directly into system memory. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// @param pfResult [in] must point to an array of at least *2* -/// float values. [out] The result of the dot -/// product is contained in both slots of the array. -/// Recommended to use the first one though they -/// have the same value -/// -/// NOTE: The parameter types here are floats, not float32_t's. gcc -/// sometimes doesn't interpret float32_t's correctly. In particular, -/// if the type of pfResult is set to float32_t*, gcc will throw an -/// internal compiler error (ICE) for this code. In memory, float32_t -/// and float are equivalent, so can cast between them explicitly. -//---------------------------------------------------------------------------- -void DotProductNeonResultInMemory(float *a, float *b, float *pfResult) -{ - float32x2_t v1a = vld1_f32((float32_t*)a); - float32x2_t v1b = vld1_f32((float32_t*)(a + 2)); - float32x2_t v2a = vld1_f32((float32_t*)b); - float32x2_t v2b = vld1_f32((float32_t*)(b + 2)); - v1a = vmul_f32(v1a, v2a); - v1a = vmla_f32(v1a, v1b, v2b); - v1a = vpadd_f32(v1a, v1a); - vst1_f32((float32_t*)pfResult, v1a); -} - -//---------------------------------------------------------------------------- -// DotProductScalarResultInRegister -// -/// Performs a Vector4 style dot product using scalar math, and returning -/// the result in an ARM register. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// -/// @return dotproduct(a,b) -//---------------------------------------------------------------------------- -float DotProductScalarResultInRegister(float *a, float *b) -{ - return(a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]); -} - -//---------------------------------------------------------------------------- -// DotProductScalarResultInMemory -// -/// Performs a Vector4 style dot product using scalar math, storing the -/// result directly into system memory. -/// -/// @param a Input vector 1. Must point to 4 float values -/// @param b Input vector 2. Must point to 4 float values -/// @param pfResult [in] pointer to a float. [out] Contains the -/// result, dotproduct(a,b) -//---------------------------------------------------------------------------- -void DotProductScalarResultInMemory(float *a, float *b, float *pfResult) -{ - *pfResult = a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]; -} - -//---------------------------------------------------------------------------- -// TestFastNeonDotProduct -// -/// Run timing study of the four dot product functions above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonDotProduct() -{ - float SET_ALIGNMENT(64) data[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX)}; - - float *a = &data[0]; - float *b = &data[4]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Dot product test inputs A=<%f,%f,%f>, B=<%f,%f,%f>", - a[0], a[1], a[2], b[0], b[1], b[2]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -#endif - - float SET_ALIGNMENT(64) fResult[2]; - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan; - unsigned int uiNumTries = 10000000; - unsigned int i; - - // profile scalar dot product with register return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - fResult[0] = DotProductScalarResultInRegister(a, b); // C++ - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to scalar dot product return in register: %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, "Sclr C++ Dot Product Register Return: %10.7f secs, REF TIME", dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with register return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - fResult[0] = DotProductNeonResultInRegister(a, b); // C++ - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in register: %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, "Neon C++ Dot Product Register Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with register return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - fResult[0] = DotProductNeonResultInRegisterAssembly(a, b); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in register (assembly version): %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, "Neon Asm Dot Product Register Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile scalar dot product with direct memory return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - DotProductScalarResultInMemory(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - - dRefTimeSpan = dTimeSpan; -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to scalar dot product return in memory: %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, " Sclr C++ Dot Product Memory Return: %10.7f secs, REF TIME", dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with direct memory return - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - DotProductNeonResultInMemory(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in memory: %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, " Neon C++ Dot Product Memory Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - DotProductNeonResultInMemoryAssembly(a, b, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in memory (assembly version): %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, " Neon Asm Dot Product Memory Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with direct memory return, assembly version with both - // inputs in contiguous memory block (array of structures) - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - DotProductNeonResultInMemoryAssembly2(data, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in memory (assembly version - array of structures): %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, " Neon Asm2 Dot Product Memory Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - // profile NEON dot product with direct memory return, assembly version with both - // inputs in contiguous memory block (array of structures), alternate methodology - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - DotProductNeonResultInMemoryAssembly2b(data, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - -#ifdef PRINT_COMPUTED_VECTOR_RESULTS - sprintf(szMsg, "Time to do %i calls to NEON dot product return in memory (assembly version - alternate methodology): %f, result value=%f", - uiNumTries, dTimeSpan, fResult[0]); -#else - sprintf(szMsg, " Neon Asm3 Dot Product Memory Return: %10.7f secs, speedup: %5.2f", dTimeSpan, dRefTimeSpan/dTimeSpan); -#endif - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix3_operator_multiply.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix3_operator_multiply.cpp deleted file mode 100644 index 58d558993..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix3_operator_multiply.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -// assembly implementations -extern "C" -{ - void Matrix3OperatorMultiplyNeon(float *mCol, float *mat, float *pfResult); -} - -//---------------------------------------------------------------------------- -// Matrix3OperatorMultiplyScalar -// -/// Performs a Matrix3 Vector3 multiply using scalar math, storing the -/// result directly into system memory. -/// -/// @param mCol Matrix3 Columns. Must point to 3x 4 float values -/// @param mat Matrix3 Columns. Must point to 3x 4 float values -/// @param pfResult [in] pointer to a float(matrix 3). [out] Contains the result -//---------------------------------------------------------------------------- -//inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -//{ -// return Vector3( -// ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), -// ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), -// ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) -// ); -//} -// -//inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -//{ -// return Matrix3( -// ( *this * mat.mCol0 ), -// ( *this * mat.mCol1 ), -// ( *this * mat.mCol2 ) -// ); -//} -void Matrix3OperatorMultiplyScalar(float *mCol, float *mat, float *pfResult) -{ - pfResult[0] = ( ( ( mCol[0] * mat[0] ) + ( mCol[4] * mat[1] ) ) + ( mCol[8] * mat[2] ) ); - pfResult[1] = ( ( ( mCol[1] * mat[0] ) + ( mCol[5] * mat[1] ) ) + ( mCol[9] * mat[2] ) ); - pfResult[2] = ( ( ( mCol[2] * mat[0] ) + ( mCol[6] * mat[1] ) ) + ( mCol[10] * mat[2] ) ); - pfResult[3] = 0.0f; - - pfResult[4] = ( ( ( mCol[0] * mat[4] ) + ( mCol[4] * mat[5] ) ) + ( mCol[8] * mat[6] ) ); - pfResult[5] = ( ( ( mCol[1] * mat[4] ) + ( mCol[5] * mat[5] ) ) + ( mCol[9] * mat[6] ) ); - pfResult[6] = ( ( ( mCol[2] * mat[4] ) + ( mCol[6] * mat[5] ) ) + ( mCol[10] * mat[6] ) ); - pfResult[7] = 0.0f; - - pfResult[8] = ( ( ( mCol[0] * mat[8] ) + ( mCol[4] * mat[9] ) ) + ( mCol[8] * mat[10] ) ); - pfResult[9] = ( ( ( mCol[1] * mat[8] ) + ( mCol[5] * mat[9] ) ) + ( mCol[9] * mat[10] ) ); - pfResult[10] = ( ( ( mCol[2] * mat[8] ) + ( mCol[6] * mat[9] ) ) + ( mCol[10] * mat[10] ) ); - pfResult[11] = 0.0f; -} - -//---------------------------------------------------------------------------- -// TestNeonMatrix3OperatorMultiply -// -/// Run timing study of the NeonMatrix3OperatorMultiply product functions above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonMatrix3OperatorMultiply() -{ - float SET_ALIGNMENT(64) data1[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - float SET_ALIGNMENT(64) data2[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - float *mCol = &data1[0]; - float *mat = &data2[0]; - float SET_ALIGNMENT(64) fResult[12]; - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonMatrix3OperatorMultiply Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input mCol: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - mCol[0], mCol[1], mCol[2], mCol[3], - mCol[4], mCol[5], mCol[6], mCol[7], - mCol[8], mCol[9], mCol[10], mCol[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input mat: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - mat[0], mat[1], mat[2], mat[3], - mat[4], mat[5], mat[6], mat[7], - mat[8], mat[9], mat[10], mat[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - -// profile scalar NeonMatrix3OperatorMultiplyScalar with direct memory return, c++ version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Matrix3OperatorMultiplyScalar(mCol, mat, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for Matrix3OperatorMultiplyScalar: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON Matrix3OperatorMultiplyNeon with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Matrix3OperatorMultiplyNeon(mCol, mat, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for Matrix3OperatorMultiplyNeon: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sprintf(szMsg,"TestNeonMatrix3OperatorMultiply End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix4_operator_multiply.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix4_operator_multiply.cpp deleted file mode 100644 index 9c88e805a..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_matrix4_operator_multiply.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -// assembly implementations -extern "C" -{ - void Matrix4OperatorMultiplyNeon(float *mCol, float *mat, float *pfResult); -} - -//---------------------------------------------------------------------------- -// Matrix4OperatorMultiplyScalar -// -/// Performs a Matrix4 vector3 multiply using scalar math, storing the -/// result directly into system memory. -/// -/// @param mCol Input matrix 1. Must point to 4x 4 float values -/// @param mat Input matrix 2. Must point to 4x 4 float values -/// @param pfResult [in] pointer to a float(matrix). [out] Contains the result -//---------------------------------------------------------------------------- -//inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -//{ -// return Vector4( -// ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), -// ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), -// ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), -// ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) -// ); -//} -//inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -//{ -// return Matrix4( -// ( *this * mat.mCol0 ), -// ( *this * mat.mCol1 ), -// ( *this * mat.mCol2 ), -// ( *this * mat.mCol3 ) -// ); -//} -void Matrix4OperatorMultiplyScalar(float *mCol, float *mat, float *pfResult) -{ - pfResult[0] = ( ( ( mCol[0] * mat[0] ) + ( mCol[4] * mat[1] ) ) + ( mCol[8] * mat[2] ) + ( mCol[12] * mat[3] ) ); - pfResult[1] = ( ( ( mCol[1] * mat[0] ) + ( mCol[5] * mat[1] ) ) + ( mCol[9] * mat[2] ) + ( mCol[13] * mat[3] ) ); - pfResult[2] = ( ( ( mCol[2] * mat[0] ) + ( mCol[6] * mat[1] ) ) + ( mCol[10] * mat[2] ) + ( mCol[14] * mat[3] ) ); - pfResult[3] = ( ( ( mCol[3] * mat[0] ) + ( mCol[7] * mat[1] ) ) + ( mCol[11] * mat[2] ) + ( mCol[15] * mat[3] ) ); - - pfResult[4] = ( ( ( mCol[0] * mat[4] ) + ( mCol[4] * mat[5] ) ) + ( mCol[8] * mat[6] ) + ( mCol[12] * mat[7] ) ); - pfResult[5] = ( ( ( mCol[1] * mat[4] ) + ( mCol[5] * mat[5] ) ) + ( mCol[9] * mat[6] ) + ( mCol[13] * mat[7] ) ); - pfResult[6] = ( ( ( mCol[2] * mat[4] ) + ( mCol[6] * mat[5] ) ) + ( mCol[10] * mat[6] ) + ( mCol[14] * mat[7] ) ); - pfResult[7] = ( ( ( mCol[3] * mat[4] ) + ( mCol[7] * mat[5] ) ) + ( mCol[11] * mat[6] ) + ( mCol[15] * mat[7] ) ); - - pfResult[8] = ( ( ( mCol[0] * mat[8] ) + ( mCol[4] * mat[9] ) ) + ( mCol[8] * mat[10] ) + ( mCol[12] * mat[11] ) ); - pfResult[9] = ( ( ( mCol[1] * mat[8] ) + ( mCol[5] * mat[9] ) ) + ( mCol[9] * mat[10] ) + ( mCol[13] * mat[11] ) ); - pfResult[10] = ( ( ( mCol[2] * mat[8] ) + ( mCol[6] * mat[9] ) ) + ( mCol[10] * mat[10] ) + ( mCol[14] * mat[11] ) ); - pfResult[11] = ( ( ( mCol[3] * mat[8] ) + ( mCol[7] * mat[9] ) ) + ( mCol[11] * mat[10] ) + ( mCol[15] * mat[11] ) ); - - pfResult[12] = ( ( ( mCol[0] * mat[12] ) + ( mCol[4] * mat[13] ) ) + ( mCol[8] * mat[14] ) + ( mCol[12] * mat[15] ) ); - pfResult[13] = ( ( ( mCol[1] * mat[12] ) + ( mCol[5] * mat[13] ) ) + ( mCol[9] * mat[14] ) + ( mCol[13] * mat[15] ) ); - pfResult[14] = ( ( ( mCol[2] * mat[12] ) + ( mCol[6] * mat[13] ) ) + ( mCol[10] * mat[14] ) + ( mCol[14] * mat[15] ) ); - pfResult[15] = ( ( ( mCol[3] * mat[12] ) + ( mCol[7] * mat[13] ) ) + ( mCol[11] * mat[14] ) + ( mCol[15] * mat[15] ) ); -} - -//---------------------------------------------------------------------------- -// TestNeonMatrix4OperatorMultiply -// -/// Run timing study of the matrix4 vector3 multiply operator from above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonMatrix4OperatorMultiply() -{ - float SET_ALIGNMENT(64) data1[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX)}; - float SET_ALIGNMENT(64) data2[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX), - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX)}; - float *mCol = &data1[0]; - float *mat = &data2[0]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonMatrix4OperatorMultiply Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input mCol: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - mCol[0], mCol[1], mCol[2], mCol[3], - mCol[4], mCol[5], mCol[6], mCol[7], - mCol[8], mCol[9], mCol[10], mCol[11], - mCol[12], mCol[13], mCol[14], mCol[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input mat: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - mat[0], mat[1], mat[2], mat[3], - mat[4], mat[5], mat[6], mat[7], - mat[8], mat[9], mat[10], mat[11], - mCol[12], mCol[13], mCol[14], mCol[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - float SET_ALIGNMENT(64) fResult[16]; - - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - -// profile scalar Matrix4OperatorMultiplyScalar with direct memory return, c++ version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Matrix4OperatorMultiplyScalar(mCol, mat, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for Matrix4OperatorMultiplyScalar: %f secs, speedup: %5.2f", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "result value: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11], - fResult[12], fResult[13], fResult[14], fResult[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON Matrix4OperatorMultiplyNeon with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Matrix4OperatorMultiplyNeon(mCol, mat, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for Matrix4OperatorMultiplyNeon: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11], - fResult[12], fResult[13], fResult[14], fResult[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sprintf(szMsg,"TestNeonMatrix4OperatorMultiply End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_orthoInverse_transform3.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_orthoInverse_transform3.cpp deleted file mode 100644 index 216b350c2..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_orthoInverse_transform3.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -// assembly implementations -extern "C" -{ - void OrthoInverseTransform3Neon(float *trfm, float *pfResult); -} - -//---------------------------------------------------------------------------- -// OrthoInverseTransform3Scalar -// -/// Performs a ortho inverse of a transform3 using scalar math, storing the -/// result directly into system memory. -/// -/// @param trfm Input transform3. Must point to 4x 4 float values -/// @param pfResult [in] pointer to a float(tranform3). [out] Contains the result -//---------------------------------------------------------------------------- -//inline const Transform3 orthoInverse( const Transform3 & tfrm ) -//{ -// Vector3 inv0, inv1, inv2; -// inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); -// inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); -// inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); -// return Transform3( -// inv0, -// inv1, -// inv2, -// Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) -// ); -//} -void OrthoInverseTransform3Scalar(float *trfm, float *pfResult) -{ - pfResult[0] = trfm[0]; - pfResult[1] = trfm[4]; - pfResult[2] = trfm[8]; - pfResult[3] = 0.0f; - - pfResult[4] = trfm[1]; - pfResult[5] = trfm[5]; - pfResult[6] = trfm[9]; - pfResult[7] = 0.0f; - - pfResult[8] = trfm[2]; - pfResult[9] = trfm[6]; - pfResult[10] = trfm[10]; - pfResult[11] = 0.0f; - - pfResult[12] = ( -( ( trfm[0] * trfm[8]) + ( ( trfm[1] * trfm[9]) + ( trfm[2] * trfm[10]) ) ) ); - pfResult[13] = ( -( ( trfm[4] * trfm[8]) + ( ( trfm[5] * trfm[9]) + ( trfm[6] * trfm[10]) ) ) ); - pfResult[14] = ( -( ( trfm[8] * trfm[8]) + ( ( trfm[9] * trfm[9]) + ( trfm[10] * trfm[10]) ) ) ); - pfResult[15] = 0.0f; -} - -//---------------------------------------------------------------------------- -// TestNeonOrthoInverseTransform3 -// -/// Run timing study of the orthoinverse on transform3 functions above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonOrthoInverseTransform3() -{ - float SET_ALIGNMENT(64) data1[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - float *trfm = &data1[0]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonOrthoInverseTransform3 Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input trfm: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>>", - trfm[0], trfm[1], trfm[2], trfm[3], - trfm[4], trfm[5], trfm[6], trfm[7], - trfm[8], trfm[9], trfm[10], trfm[11], - trfm[12], trfm[13], trfm[14], trfm[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - float SET_ALIGNMENT(64) fResult[16]; - - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - -// profile scalar OrthoInverseTransform3Scalar with direct memory return, c++ version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - OrthoInverseTransform3Scalar(trfm, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for OrthoInverseTransform3Scalar: %f secs, speedup: %5.2f", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11], - fResult[12], fResult[13], fResult[14], fResult[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON OrthoInverseTransform3Neon with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - OrthoInverseTransform3Neon(trfm, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for OrthoInverseTransform3Neon: %f secs, speedup: %5.2f", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11], - fResult[12], fResult[13], fResult[14], fResult[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - sprintf(szMsg,"TestNeonOrthoInverseTransform3 End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_solve_linear_constraint_row.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_solve_linear_constraint_row.cpp deleted file mode 100644 index a98d8f993..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_solve_linear_constraint_row.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -//---------------------------------------------------------------------------- -// pfxSolveLinearConstraintRowScalar -// -/// Performs -/// -/// @param Input -//---------------------------------------------------------------------------- -void pfxSolveLinearConstraintRowScalar(float *constraint, // 8 floats - float *deltaLinearVelocityA, // 4 floats - float *deltaAngularVelocityA, // 4 floats - float massInvA, // 1 floats - float *inertiaInvA, // 12 floats - float *rA, // 4 floats - float *deltaLinearVelocityB, // 4 floats - float *deltaAngularVelocityB, // 4 floats - float massInvB, // 1 floats - float *inertiaInvB, // 12 floats - float *rB) // 4 floats -{ -//const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); //fourth element is not zero and it need to be in assembly - float SET_ALIGNMENT(64) normalRead[] = {constraint[0],constraint[1],constraint[2],0.0f}; - float *normal = &normalRead[0]; -//PfxFloat deltaImpulse = constraint.m_rhs; - float deltaImpulse = constraint[4]; -//PfxVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); - float SET_ALIGNMENT(64) dVARead[] = {deltaLinearVelocityA[0] + (deltaAngularVelocityA[1]*rA[2] - deltaAngularVelocityA[2]*rA[1]), - deltaLinearVelocityA[1] + (deltaAngularVelocityA[2]*rA[0] - deltaAngularVelocityA[0]*rA[2]), - deltaLinearVelocityA[2] + (deltaAngularVelocityA[0]*rA[1] - deltaAngularVelocityA[1]*rA[0]), - 0.0f}; - float *dVA = &dVARead[0]; -//PfxVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); - float SET_ALIGNMENT(64) dVBRead[] = {deltaLinearVelocityB[0] + (deltaAngularVelocityB[1]*rB[2] - deltaAngularVelocityB[2]*rB[1]), - deltaLinearVelocityB[1] + (deltaAngularVelocityB[2]*rB[0] - deltaAngularVelocityB[0]*rB[2]), - deltaLinearVelocityB[2] + (deltaAngularVelocityB[0]*rB[1] - deltaAngularVelocityB[1]*rB[0]), - 0.0f}; - float *dVB = &dVBRead[0]; -//deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); - deltaImpulse -= constraint[4] * (normal[0]*(dVA[0]-dVB[0]) + normal[1]*(dVA[1]-dVB[1]) + normal[2]*(dVA[2]-dVB[2])); -//PfxFloat oldImpulse = constraint.m_accumImpulse; - float oldImpulse = constraint[7]; -//constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); - if((oldImpulse + deltaImpulse) > constraint[6]){ - if(constraint[6] > constraint[5]){ - constraint[7] = constraint[6]; - }else { - constraint[7] = constraint[5]; - } - } else { - if(oldImpulse + deltaImpulse > constraint[5]){ - constraint[7] = oldImpulse + deltaImpulse; - }else { - constraint[7] = constraint[5]; - } - } -//deltaImpulse = constraint.m_accumImpulse - oldImpulse; - deltaImpulse = constraint[7] - oldImpulse; -//deltaLinearVelocityA += deltaImpulse * massInvA * normal; - deltaLinearVelocityA[0] += deltaImpulse * massInvA * normal[0]; - deltaLinearVelocityA[1] += deltaImpulse * massInvA * normal[1]; - deltaLinearVelocityA[2] += deltaImpulse * massInvA * normal[2]; - deltaLinearVelocityA[3] += deltaImpulse * massInvA * normal[3]; - -//deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); - deltaAngularVelocityA[0] += deltaImpulse * ((inertiaInvA[0] * (rA[1]*normal[2] - rA[2]*normal[1])) + - (inertiaInvA[4] * (rA[2]*normal[0] - rA[0]*normal[2])) +// - (inertiaInvA[8] * (rA[0]*normal[1] - rA[1]*normal[0]))); - deltaAngularVelocityA[1] += deltaImpulse * ((inertiaInvA[1] * (rA[1]*normal[2] - rA[2]*normal[1])) + - (inertiaInvA[5] * (rA[2]*normal[0] - rA[0]*normal[2])) + - (inertiaInvA[9] * (rA[0]*normal[1] - rA[1]*normal[0]))); - deltaAngularVelocityA[2] += deltaImpulse * ((inertiaInvA[2] * (rA[1]*normal[2] - rA[2]*normal[1])) + - (inertiaInvA[6] * (rA[2]*normal[0] - rA[0]*normal[2])) + - (inertiaInvA[10] * (rA[0]*normal[1] - rA[1]*normal[0]))); - deltaAngularVelocityA[3] += deltaImpulse * ((inertiaInvA[3] * (rA[1]*normal[2] - rA[2]*normal[1])) + - (inertiaInvA[7] * (rA[2]*normal[0] - rA[0]*normal[2])) + - (inertiaInvA[11] * (rA[0]*normal[1] - rA[1]*normal[0]))); -//deltaLinearVelocityB -= deltaImpulse * massInvB * normal; - deltaLinearVelocityB[0] -= deltaImpulse * massInvB * normal[0]; - deltaLinearVelocityB[1] -= deltaImpulse * massInvB * normal[1]; - deltaLinearVelocityB[2] -= deltaImpulse * massInvB * normal[2]; - deltaLinearVelocityB[3] -= deltaImpulse * massInvB * normal[3]; - -//deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); - deltaAngularVelocityB[0] -= deltaImpulse * ((inertiaInvB[0] * (rB[1]*normal[2] - rB[2]*normal[1])) + - (inertiaInvB[4] * (rB[2]*normal[0] - rB[0]*normal[2])) + - (inertiaInvB[8] * (rB[0]*normal[1] - rB[1]*normal[0]))); - deltaAngularVelocityB[1] -= deltaImpulse * ((inertiaInvB[1] * (rB[1]*normal[2] - rB[2]*normal[1])) + - (inertiaInvB[5] * (rB[2]*normal[0] - rB[0]*normal[2])) + - (inertiaInvB[9] * (rB[0]*normal[1] - rB[1]*normal[0]))); - deltaAngularVelocityB[2] -= deltaImpulse * ((inertiaInvB[2] * (rB[1]*normal[2] - rB[2]*normal[1])) + - (inertiaInvB[6] * (rB[2]*normal[0] - rB[0]*normal[2])) + - (inertiaInvB[10] * (rB[0]*normal[1] - rB[1]*normal[0]))); - deltaAngularVelocityB[3] -= deltaImpulse * ((inertiaInvB[3] * (rB[1]*normal[2] - rB[2]*normal[1])) + - (inertiaInvB[7] * (rB[2]*normal[0] - rB[0]*normal[2])) + - (inertiaInvB[11] * (rB[0]*normal[1] - rB[1]*normal[0]))); -} - -/*//////////////////////////////////////Source Code/////////////////////////////////////// -void pfxSolveLinearConstraintRow( - PfxConstraintRow &constraint, // 8 floats - PfxVector3 &deltaLinearVelocityA, // 4 floats - PfxVector3 &deltaAngularVelocityA, // 4 floats - PfxFloat massInvA, // 1 float -const PfxMatrix3 &inertiaInvA, // 12 floats -const PfxVector3 &rA, // 4 floats - PfxVector3 &deltaLinearVelocityB, // 4 floats - PfxVector3 &deltaAngularVelocityB, // 4 floats - PfxFloat massInvB, // 1 float -const PfxMatrix3 &inertiaInvB, // 12 floats -const PfxVector3 &rB) // 4 floats -{ - // PfxConstraintRow structure: - // PfxFloat m_normal[3]; - // PfxFloat m_rhs; - // PfxFloat m_jacDiagInv; - // PfxFloat m_lowerLimit; - // PfxFloat m_upperLimit; - // PfxFloat m_accumImpulse; -const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); -PfxFloat deltaImpulse = constraint.m_rhs; -PfxVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); -PfxVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); -deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); -PfxFloat oldImpulse = constraint.m_accumImpulse; -constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); -deltaImpulse = constraint.m_accumImpulse - oldImpulse; -deltaLinearVelocityA += deltaImpulse * massInvA * normal; -deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); -deltaLinearVelocityB -= deltaImpulse * massInvB * normal; -deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); -} -*/ - -void pfxSolveLinearConstraintRowNeonInline(float *constraint, // 8 floats - float *deltaLinearVelocityA, // 4 floats - float *deltaAngularVelocityA, // 4 floats - float *massInvA, // 1 floats - float *inertiaInvA, // 12 floats - float *rA, // 4 floats - float *deltaLinearVelocityB, // 4 floats - float *deltaAngularVelocityB, // 4 floats - float *massInvB, // 1 floats - float *inertiaInvB, // 12 floats - float *rB) // 4 floats -{ -// "r" (constraint), //%0 -// "r" (deltaLinearVelocityA), //%1 -// "r" (deltaAngularVelocityA), //%2 -// "r" (massInvA), //%3 -// "r" (inertiaInvA), //%4 -// "r" (rA), //%5 -// "r" (deltaLinearVelocityB), //%6 -// "r" (deltaAngularVelocityB), //%7 -// "r" (massInvB), //%8 -// "r" (inertiaInvB), //%9 -// "r" (rB) //%10 - asm volatile - ( - //Loads beforehand so the normal vector will be able to have zero in the 4th element - "vld1.32 {q0}, [%1] \n\t" //LOAD => deltaLinearVelocityA ----------------> q0 - "vld1.32 {q1}, [%2] \n\t" //LOAD => deltaAngularVelocityA ---------------> q1 - "vld1.32 {q2}, [%6] \n\t" //LOAD => deltaLinearVelocityB ----------------> q2 - "vld1.32 {q3}, [%7] \n\t" //LOAD => deltaAngularVelocityB ---------------> q3 - //const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); - "vld1.32 {q4}, [%0]! \n\t" //LOAD => constraint normal--------------------> q4 - "vdup.32 d10, d1[1] \n\t" //set 4th element on normal vector to zero - "vtrn.32 d9, d10 \n\t" //LOAD => deltaImpulse ------------------------> q5 (d10[0] only) - //PfxFloat deltaImpulse = constraint.m_rhs; - "vld1.32 {d12}, [%0]! \n\t" //LOAD => constraint variables ----------------> q6 - "vld1.32 {d13[0]}, [%0]! \n\t" //constraint variables - "vld1.32 {d13[1]}, [%0] \n\t" //constraint load of remaining variables loaded this way keep pointer to m_accumilate in order to store back in later - //PfxVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); - //PfxVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); - "vld1.32 {d14[1]}, [%5] \n\t" //LOAD => rA for cross product use 1A ---------> q7 (save these for use later) - "vld1.32 {d18[1]}, [%10] \n\t" //LOAD => rB for cross product use 1B ---------> q9 - "vld1.32 {d17[0]}, [%5]! \n\t" //LOAD => rA for cross product use 2A ---------> q8 - "vld1.32 {d21[0]}, [%10]! \n\t" //LOAD => rB for cross product use 2B ---------> q10 - "vld1.32 {d16}, [%5] \n\t" //rA 2 - "vld1.32 {d20}, [%10] \n\t" //rB 2 - "vld1.32 {d15[0]}, [%5]! \n\t" //rA 1 - "vld1.32 {d19[0]}, [%10]! \n\t" //rB 1 - "vld1.32 {d14[0]}, [%5]! \n\t" //rA 1 - "vld1.32 {d18[0]}, [%10]! \n\t" //rB 1 - "vld1.32 {d15[1]}, [%5] \n\t" //rA 1 - "vld1.32 {d19[1]}, [%10] \n\t" //rB 1 - "vld1.32 {d17[1]}, [%5]! \n\t" //rA 2 - "vld1.32 {d21[1]}, [%10]! \n\t" //rB 2 - "vdup.32 q12, d1[1] \n\t" //set deltaAngularVelocityB 2 - "vdup.32 q13, d1[1] \n\t" //set deltaAngularVelocityB 1 - "vdup.32 q14, d1[1] \n\t" //set deltaAngularVelocityA 1 - "vdup.32 q15, d1[1] \n\t" //set deltaAngularVelocityA 2 - "vadd.f32 q14, q14, q1 \n\t" - "vadd.f32 q13, q13, q3 \n\t" - "vadd.f32 q15, q15, q1 \n\t" - "vadd.f32 q12, q12, q3 \n\t" - "vrev64.32 d28, d28 \n\t" //set deltaAngularVelocityA 1 - "vrev64.32 d26, d26 \n\t" //set deltaAngularVelocityB 1 - "vtrn.32 d30, d31 \n\t" //set deltaAngularVelocityA 2 - "vtrn.32 d24, d25 \n\t" //set deltaAngularVelocityB 2 - "vtrn.32 d28, d29 \n\t" //set deltaAngularVelocityA 1 - "vtrn.32 d26, d27 \n\t" //set deltaAngularVelocityB 1 - "vrev64.32 d30, d30 \n\t" //set deltaAngularVelocityA 2 - "vrev64.32 d24, d24 \n\t" //set deltaAngularVelocityB 2 - "vmul.f32 q14, q7, q14 \n\t" //operation for cross product 1A - "vmul.f32 q13, q9, q13 \n\t" //operation for cross product 1B - "vmls.f32 q14, q8, q15 \n\t" //operation for cross product 2A - "vmls.f32 q13, q10, q12 \n\t" //operation for cross product 2B - "vadd.f32 q14, q14, q0 \n\t" //operation for adding cross to linearVelocityA - "vadd.f32 q13, q13, q2 \n\t" //operation for adding cross to linearVelocityB - //LOAD => dVA --------------------------------> q14 - //LOAD => dVB --------------------------------> q13 - //FREE q11, q12, q15, d11 - //deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); - "vsub.f32 q11, q14, q13 \n\t" //TEMP q11 => dVA-dVB for dot product - /*find*/ "vmul.f32 q11, q11, q4 \n\t" //operation for dot product - /*fastest*/ "vpadd.f32 d22, d22, d22 \n\t" //operation for dot product - /*dot*/ "vpadd.f32 d23, d23, d23 \n\t" //operation for dot product - "vadd.f32 d22, d22, d23 \n\t" //operation for dot product - "vmul.f32 d22, d22, d12[0] \n\t" //m_jacDiagInv times dot product result - "vsub.f32 d10, d10, d22 \n\t" //subtract result from deltaImpule - //PfxFloat oldImpulse = constraint.m_accumImpulse; - "vdup.32 d11, d13[1] \n\t" //LOAD => oldImpulse -------------------------> q5 (d11 only) - //constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); - "vdup.32 d23, d13[0] \n\t" //TEMP q11 => m_upperLimit (d23 only) - "vdup.32 d24, d12[1] \n\t" //TEMP q12 => m_lowerLimit (d34 only) - "vadd.f32 d25, d10, d11 \n\t" //TEMP q12 => deltaImpulse + oldImplues (d25 only) - "vmin.f32 d25, d25, d23 \n\t" //operation MIN(v,b) - "vmax.f32 d22, d25, d24 \n\t" //operation MAX(a,MIN(v,b) - "vst1.32 {d22[0]}, [%0] \n\t" //store m_accumImpulse (incremented so that it can be reloaded for cross product later) - //deltaImpulse = constraint.m_accumImpulse - oldImpulse; - "vsub.f32 d10, d22, d11 \n\t" //operation to calculate new deltaImpule - //FREE q6, q11, q12, q13, q14, q15, d11 - //deltaLinearVelocityB -= deltaImpulse * massInvB * normal; - //deltaLinearVelocityA += deltaImpulse * massInvA * normal; - "vld1.32 {d11[0]}, [%3] \n\t" //LOAD => massInvA ---------------------------> q5 (d11[0] only) - "vld1.32 {d11[1]}, [%8] \n\t" //LOAD => massInvB ---------------------------> q5 (d11[1] only) - "vmul.f32 q11, q4, d11[0] \n\t" //TEMP q11 => operation normal times massInvA A - "vmul.f32 q12, q4, d11[1] \n\t" //TEMP q12 => operation normal times massInvB B - "vmul.f32 q11, q11, d10[0] \n\t" //TEMP q11 => operation result times DeltaImpulse A - "vmul.f32 q12, q12, d10[0] \n\t" //TEMP q12 => operation result times DeltaImpulse B - "vadd.f32 q0, q0, q11 \n\t" //operation create new deltaLinearVelocityA A - "vsub.f32 q2, q2, q12 \n\t" //operation create new deltaLinearVelocityB B - "vst1.32 {q0}, [%1] \n\t" //store the new deltaLinearVelocityA A - "vst1.32 {q2}, [%6] \n\t" //store the new deltaLinearVelocityB B - //FREE q0, q2, q6, q11, q12, q13, q14, q15, d11 - //deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); - //deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); - "vdup.32 q14, d1[1] \n\t" //set normal cross load - "vdup.32 q15, d1[1] \n\t" // - "vadd.f32 q14, q14, q4 \n\t" // - "vadd.f32 q15, q15, q4 \n\t" // - "vrev64.32 d28, d28 \n\t" // - "vtrn.32 d30, d31 \n\t" // - "vtrn.32 d28, d29 \n\t" // - "vrev64.32 d30, d30 \n\t" // - "vmul.f32 q0, q8, q15 \n\t" //operation for cross product A - "vmul.f32 q2, q10, q15 \n\t" //operation for cross product B - "vmls.f32 q0, q14, q7 \n\t" //operation for cross product A - "vmls.f32 q2, q14, q9 \n\t" //operation for cross product B - //LOAD => cross product result A ------------> q0 - //LOAD => cross product result B ------------> q2 - //FREE q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, d11 - - "vld1.32 {q13-q14}, [%4]! \n\t" //LOAD => inertiaInvA col0, col1 A ----------> q13, q14 - "vld1.32 {q9-q10}, [%9]! \n\t" //LOAD => inertiaInvB col0, col1 B -----------> q9, q10 - "vld1.32 {q15}, [%4] \n\t" //LOAD => inertiaInvA col2 A ----------------> q5 - "vld1.32 {q11}, [%9] \n\t" //LOAD => inertiaInvB col2 B -----------------> q11 - "vmul.f32 q13, q13, d0[0] \n\t" //operation inertiaInvA col0 = (col0) * (crossA elem0) A - "vmul.f32 q9, q9, d4[0] \n\t" //operation inertiaInvB col0 = (col0) * (crossB elem0) B - "vmla.f32 q13, q14, d0[1] \n\t" //operation inertiaInvA col1 = (col1) * (crossA elem1) A - "vmla.f32 q9, q10, d4[1] \n\t" //operation inertiaInvB col1 = (col1) * (crossB elem1) B - "vmla.f32 q13, q15, d1[0] \n\t" //operation inertiaInvA col2 = (col2) * (crossA elem2) A - "vmla.f32 q9, q11, d5[0] \n\t" //operation inertiaInvB col2 = (col2) * (crossB elem2) B - "vmul.f32 q13, q13, d10[0] \n\t" //operation inertiaInvA times deltaImpulse A - "vmul.f32 q9, q9, d10[0] \n\t" //operation inertiaInvB times deltaImpulse B - "vadd.f32 q1, q1, q13 \n\t" //operation accumulate the deltaAngularVelocityA A - "vsub.f32 q3, q3, q9 \n\t" //operation accumulate the deltaAngularVelocityB B - "vst1.32 {q1}, [%2] \n\t" //store deltaAngularVelocityA A - "vst1.32 {q3}, [%7] \n\t" //store deltaAngularVelocityB B - : // NO outputs! It is important to *not* put anything here. (Putting something here forces use of r0, which wreak havok - : "r" (constraint), "r" (deltaLinearVelocityA), "r" (deltaAngularVelocityA), "r" (massInvA), "r" (inertiaInvA), "r" (rA), "r" (deltaLinearVelocityB), "r" (deltaAngularVelocityB), "r" (massInvB), "r" (inertiaInvB), "r" (rB) //inputs - : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15" // clobbers - ); -} - -//---------------------------------------------------------------------------- -// TestNeonSolveLinearConstraintRow -// -/// Run timing study of the Linear Constraint Row Solver from above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonSolveLinearConstraintRow() -{ - //Scalar - float SET_ALIGNMENT(64) constraintDataScalar[] = {0.0f,1.0f,2.0f,3.0f,1.0f,2.0f,3.0f,4.0f}; - float SET_ALIGNMENT(64) deltaLinearVelocityADataScalar[] = {1.0f,2.0f,3.0f,0.0f}; - float SET_ALIGNMENT(64) deltaAngularVelocityADataScalar[] = {2.0f,3.0f,4.0f,0.0f}; - float SET_ALIGNMENT(64) inertiaInvADataScalar[] = {4.0f,5.0f,6.0f,0.0f,5.0f,6.0f,7.0f,0.0f,6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) rADataScalar[] = {5.0f,6.0f,7.0f,0.0f}; - float SET_ALIGNMENT(64) deltaLinearVelocityBDataScalar[] = {6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) deltaAngularVelocityBDataScalar[] = {9.0f,8.0f,7.0f,0.0f}; - float SET_ALIGNMENT(64) inertiaInvBDataScalar[] = {7.0f,6.0f,5.0f,0.0f,9.0f,8.0f,7.0f,0.0f,6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) rBDataScalar[] = {6.0f,5.0f,4.0f,0.0f}; - - float *constraintScalar = &constraintDataScalar[0]; - float *deltaLinearVelocityAScalar = &deltaLinearVelocityADataScalar[0]; - float *deltaAngularVelocityAScalar = &deltaAngularVelocityADataScalar[0]; - float massInvAScalar = 3.0f; - float *inertiaInvAScalar = &inertiaInvADataScalar[0]; - float *rAScalar = &rADataScalar[0]; - float *deltaLinearVelocityBScalar = &deltaLinearVelocityBDataScalar[0]; - float *deltaAngularVelocityBScalar = &deltaAngularVelocityBDataScalar[0]; - float massInvBScalar = 8.0f; - float *inertiaInvBScalar = &inertiaInvBDataScalar[0]; - float *rBScalar = &rBDataScalar[0]; - - //Neon - float SET_ALIGNMENT(64) constraintDataNeon[] = {0.0f,1.0f,2.0f,3.0f,1.0f,2.0f,3.0f,4.0f}; - float SET_ALIGNMENT(64) deltaLinearVelocityADataNeon[] = {1.0f,2.0f,3.0f,0.0f}; - float SET_ALIGNMENT(64) deltaAngularVelocityADataNeon[] = {2.0f,3.0f,4.0f,0.0f}; - float SET_ALIGNMENT(64) massInvADataNeon[] = {3.0f}; - float SET_ALIGNMENT(64) inertiaInvADataNeon[] = {4.0f,5.0f,6.0f,0.0f,5.0f,6.0f,7.0f,0.0f,6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) rADataNeon[] = {5.0f,6.0f,7.0f,0.0f}; - float SET_ALIGNMENT(64) deltaLinearVelocityBDataNeon[] = {6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) deltaAngularVelocityBDataNeon[] = {9.0f,8.0f,7.0f,0.0f}; - float SET_ALIGNMENT(64) massInvBDataNeon[] = {8.0f}; - float SET_ALIGNMENT(64) inertiaInvBDataNeon[] = {7.0f,6.0f,5.0f,0.0f,9.0f,8.0f,7.0f,0.0f,6.0f,7.0f,8.0f,0.0f}; - float SET_ALIGNMENT(64) rBDataNeon[] = {6.0f,5.0f,4.0f,0.0f}; - - float *constraintNeon = &constraintDataNeon[0]; - float *deltaLinearVelocityANeon = &deltaLinearVelocityADataNeon[0]; - float *deltaAngularVelocityANeon = &deltaAngularVelocityADataNeon[0]; - float *massInvANeon = &massInvADataNeon[0]; - float *inertiaInvANeon = &inertiaInvADataNeon[0]; - float *rANeon = &rADataNeon[0]; - float *deltaLinearVelocityBNeon = &deltaLinearVelocityBDataNeon[0]; - float *deltaAngularVelocityBNeon = &deltaAngularVelocityBDataNeon[0]; - float *massInvBNeon = &massInvBDataNeon[0]; - float *inertiaInvBNeon = &inertiaInvBDataNeon[0]; - float *rBNeon = &rBDataNeon[0]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonSolveLinearConstraintRow Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - -// profile pfxSolveLinearConstraintRowScalar with direct memory return, c++ version - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - pfxSolveLinearConstraintRowScalar( - constraintScalar, - deltaLinearVelocityAScalar, - deltaAngularVelocityAScalar, - massInvAScalar, - inertiaInvAScalar, - rAScalar, - deltaLinearVelocityBScalar, - deltaAngularVelocityBScalar, - massInvBScalar, - inertiaInvBScalar, - rBScalar - ); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for pfxSolveLinearConstraintRowScalar: %f secs, speedup: %5.2f", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "constraint.m_accumImpulse = <%f>", constraintScalar[7]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaLinearVelocityA = <%f,%f,%f,%f>", - deltaLinearVelocityAScalar[0], deltaLinearVelocityAScalar[1], deltaLinearVelocityAScalar[2], deltaLinearVelocityAScalar[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaAngularVelocityA = <%f,%f,%f,%f>", - deltaAngularVelocityAScalar[0], deltaAngularVelocityAScalar[1], deltaAngularVelocityAScalar[2], deltaAngularVelocityAScalar[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaLinearVelocityB = <%f,%f,%f,%f>", - deltaLinearVelocityBScalar[0], deltaLinearVelocityBScalar[1], deltaLinearVelocityBScalar[2], deltaLinearVelocityBScalar[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaAngularVelocityB = <%f,%f,%f,%f>", - deltaAngularVelocityBScalar[0], deltaAngularVelocityBScalar[1], deltaAngularVelocityBScalar[2], deltaAngularVelocityBScalar[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON pfxSolveLinearConstraintRowNeonInline with direct memory return, inline assembly version - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - pfxSolveLinearConstraintRowNeonInline(constraintNeon, - deltaLinearVelocityANeon, - deltaAngularVelocityANeon, - massInvANeon, - inertiaInvANeon, - rANeon, - deltaLinearVelocityBNeon, - deltaAngularVelocityBNeon, - massInvBNeon, - inertiaInvBNeon, - rBNeon); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for pfxSolveLinearConstraintRowNeon: %f secs, speedup: %5.2f", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "constraint.m_accumImpulse = <%f>", constraintNeon[7]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaLinearVelocityA = <%f,%f,%f,%f>", - deltaLinearVelocityANeon[0], deltaLinearVelocityANeon[1], deltaLinearVelocityANeon[2], deltaLinearVelocityANeon[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaAngularVelocityA = <%f,%f,%f,%f>", - deltaAngularVelocityANeon[0], deltaAngularVelocityANeon[1], deltaAngularVelocityANeon[2], deltaAngularVelocityANeon[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaLinearVelocityB = <%f,%f,%f,%f>", - deltaLinearVelocityBNeon[0], deltaLinearVelocityBNeon[1], deltaLinearVelocityBNeon[2], deltaLinearVelocityBNeon[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "deltaAngularVelocityB = <%f,%f,%f,%f>", - deltaAngularVelocityBNeon[0], deltaAngularVelocityBNeon[1], deltaAngularVelocityBNeon[2], deltaAngularVelocityBNeon[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sprintf(szMsg,"TestNeonSolveLinearConstraintRow End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transform3_operator_multiply.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transform3_operator_multiply.cpp deleted file mode 100644 index fc3d1785d..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transform3_operator_multiply.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -// assembly implementations -extern "C" -{ - void Transform3OperatorMultiplyNeon(float *trfm, float *vec3, float *pfResult); -} - -//---------------------------------------------------------------------------- -// Transform3OperatorMultiplyScalar -// -/// Performs a multiply operation on a tranform3 using scalar math, storing the -/// result directly into system memory. -/// -/// @param trfm Input transform. Must point to 4x 4 float values -/// @param vec3 Input vector3. Must point to 4 float values -/// @param pfResult [in] pointer to a float(vector3). [out] Contains the result -//---------------------------------------------------------------------------- -//inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -//{ -// return Vector3( -// ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), -// ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), -// ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) -// ); -//} -void Transform3OperatorMultiplyScalar(float *trfm, float *vec3, float *pfResult) -{ - pfResult[0] = ( ( ( trfm[0] * vec3[0] ) + ( trfm[4] * vec3[1] ) ) + ( trfm[8] * vec3[2] ) ); - pfResult[1] = ( ( ( trfm[1] * vec3[0] ) + ( trfm[5] * vec3[1] ) ) + ( trfm[9] * vec3[2] ) ); - pfResult[2] = ( ( ( trfm[2] * vec3[0] ) + ( trfm[6] * vec3[1] ) ) + ( trfm[10] * vec3[2] ) ); - pfResult[3] = 0.0f; -} - -//---------------------------------------------------------------------------- -// TestNeonTransform3OperatorMultiply -// -/// Run timing study of the Tranform3 multiply operator from above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonTransform3OperatorMultiply() -{ - float SET_ALIGNMENT(64) data1[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - float SET_ALIGNMENT(64) data2[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - - float *trfm = &data1[0]; - float *vec3 = &data2[0]; - - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonTransform3OperatorMultiply Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input vec3: <%f,%f,%f,%f>", - vec3[0], vec3[1], vec3[2], vec3[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input trfm: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>>", - trfm[0], trfm[1], trfm[2], trfm[3], - trfm[4], trfm[5], trfm[6], trfm[7], - trfm[8], trfm[9], trfm[10], trfm[11], - trfm[12], trfm[13], trfm[14], trfm[15]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - float SET_ALIGNMENT(64) fResult[4]; - - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - -// profile scalar Transform3OperatorMultiplyScalar with direct memory return, c++ version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Transform3OperatorMultiplyScalar(trfm, vec3, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for Transform3OperatorMultiplyScalar: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON Transform3OperatorMultiplyNeon with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - Transform3OperatorMultiplyNeon(trfm, vec3, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for Transform3OperatorMultiplyNeon: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sprintf(szMsg,"TestNeonTransform3OperatorMultiply End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transpose_matrix3.cpp b/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transpose_matrix3.cpp deleted file mode 100644 index bfadd8336..000000000 --- a/Extras/PhysicsEffects/sample/test_ARM_NEON_performance/test_neon_transpose_matrix3.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#include "test_neon.h" -#define SCE_PFX_USE_PERFCOUNTER -#include "physics_effects.h" -#include -#include -#include -#include -#include - -// This works with gcc -#define SET_ALIGNMENT(alignment) __attribute__((__aligned__((alignment)))) - -// assembly implementations -extern "C" -{ - void TransposeMatrix3Neon(float *mCol, float *pfResult); -} - -//---------------------------------------------------------------------------- -// TransposeMatrix3Scalar -// -/// Performs a transpose on a matrix3 using scalar math, storing the -/// result directly into system memory. -/// -/// @param mCol Input matrix. Must point to 3x 4 float values -/// @param pfResult [in] pointer to a float(matrix3). [out] Contains the result -//---------------------------------------------------------------------------- -//inline const Matrix3 transpose( const Matrix3 & mat ) -//{ -// return Matrix3( -// Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), -// Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), -// Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) -// ); -//} -void TransposeMatrix3Scalar(float *mCol, float *pfResult) -{ - pfResult[0] = mCol[0]; - pfResult[1] = mCol[4]; - pfResult[2] = mCol[8]; - pfResult[3] = 0.0f; - - pfResult[4] = mCol[1]; - pfResult[5] = mCol[5]; - pfResult[6] = mCol[9]; - pfResult[7] = 0.0f; - - pfResult[8] = mCol[2]; - pfResult[9] = mCol[6]; - pfResult[10] = mCol[10]; - pfResult[11] = 0.0f; -} - -//---------------------------------------------------------------------------- -// TestNeonTransposeMatrix3 -// -/// Run timing study of the matrix3 transpose functions above, writing the -/// results to the Android verbose log. -//---------------------------------------------------------------------------- -void TestNeonTransposeMatrix3() -{ - float SET_ALIGNMENT(64) data[] = {float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f, - float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),float(rand())/float(RAND_MAX),0.0f}; - float *mCol = &data[0]; - - char szMsg[256]; - - sprintf(szMsg, ""); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"---------------------------------------"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg,"TestNeonTransposeMatrix3 Start"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - sprintf(szMsg, "Test input mCol: <%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - mCol[0], mCol[1], mCol[2], mCol[3], - mCol[4], mCol[5], mCol[6], mCol[7], - mCol[8], mCol[9], mCol[10], mCol[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - float SET_ALIGNMENT(64) fResult[12]; - - - sce::PhysicsEffects::PfxPerfCounter pc; - double dTimeSpan, dRefTimeSpan;; - unsigned int uiNumTries = 10000000; - unsigned int i; - -// profile scalar TransposeMatrix3Scalar with direct memory return, c++ version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - TransposeMatrix3Scalar(mCol, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - dRefTimeSpan = dTimeSpan; - sprintf(szMsg, "Time to do %i calls for TransposeMatrix3Scalar: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - -// profile NEON TransposeMatrix3Neon with direct memory return, assembly version - fResult[0] = 0.0f; - pc.countBegin(""); - for(i = 0; i < uiNumTries; i++) - { - TransposeMatrix3Neon(mCol, fResult); - } - pc.countEnd(); - dTimeSpan = pc.getCountTime(0); - pc.resetCount(); - sprintf(szMsg, "Time to do %i calls for TransposeMatrix3Neon: %f secs, speedup: %5.2f, result value=<%f,%f,%f,%f> <%f,%f,%f,%f> <%f,%f,%f,%f>", - uiNumTries, dTimeSpan, dRefTimeSpan/dTimeSpan, fResult[0], fResult[1], fResult[2], fResult[3], - fResult[4], fResult[5], fResult[6], fResult[7], - fResult[8], fResult[9], fResult[10], fResult[11]); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); - - - sprintf(szMsg,"TestNeonTransposeMatrix3 End"); - __android_log_write(ANDROID_LOG_VERBOSE,"PHYSICS TIMING STUDY", szMsg); -} diff --git a/Extras/PhysicsEffects/src/CMakeLists.txt b/Extras/PhysicsEffects/src/CMakeLists.txt deleted file mode 100644 index 4f73bd4d9..000000000 --- a/Extras/PhysicsEffects/src/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -SUBDIRS( - base_level - low_level - util -) - -SUBDIRS( - ../../../src/BulletDynamics - ../../../src/BulletCollision - ../../../src/LinearMath -) \ No newline at end of file diff --git a/Extras/PhysicsEffects/src/base_level/CMakeLists.txt b/Extras/PhysicsEffects/src/base_level/CMakeLists.txt deleted file mode 100644 index 433b3ad09..000000000 --- a/Extras/PhysicsEffects/src/base_level/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -INCLUDE_DIRECTORIES( ${PHYSICS_EFFECTS_SOURCE_DIR}/include ) - -SET(PfxBaseLevel_SRCS - broadphase/pfx_update_broadphase_proxy.cpp - collision/pfx_collidable.cpp - collision/pfx_contact_box_box.cpp - collision/pfx_contact_box_capsule.cpp - collision/pfx_contact_box_sphere.cpp - collision/pfx_contact_cache.cpp - collision/pfx_contact_capsule_capsule.cpp - collision/pfx_contact_capsule_sphere.cpp - collision/pfx_contact_large_tri_mesh.cpp - collision/pfx_contact_manifold.cpp - collision/pfx_contact_sphere_sphere.cpp - collision/pfx_contact_tri_mesh_box.cpp - collision/pfx_contact_tri_mesh_capsule.cpp - collision/pfx_contact_tri_mesh_convex.cpp - collision/pfx_contact_tri_mesh_cylinder.cpp - collision/pfx_contact_tri_mesh_sphere.cpp - collision/pfx_gjk_solver.cpp - collision/pfx_gjk_support_func.cpp - collision/pfx_intersect_ray_box.cpp - collision/pfx_intersect_ray_capsule.cpp - collision/pfx_intersect_ray_convex.cpp - collision/pfx_intersect_ray_cylinder.cpp - collision/pfx_intersect_ray_large_tri_mesh.cpp - collision/pfx_intersect_ray_sphere.cpp - collision/pfx_shape.cpp - collision/pfx_simplex_solver.cpp - solver/pfx_contact_constraint.cpp - solver/pfx_joint_ball.cpp - solver/pfx_joint_fix.cpp - solver/pfx_joint_hinge.cpp - solver/pfx_joint_slider.cpp - solver/pfx_joint_swing_twist.cpp - solver/pfx_joint_universal.cpp - sort/pfx_sort.cpp - -) - -SET(PfxBaseLevel_HDRS - broadphase/pfx_check_collidable.h - collision/pfx_contact_box_box.h - collision/pfx_contact_box_capsule.h - collision/pfx_contact_box_sphere.h - collision/pfx_contact_cache.h - collision/pfx_contact_capsule_capsule.h - collision/pfx_contact_capsule_sphere.h - collision/pfx_contact_large_tri_mesh.h - collision/pfx_contact_sphere_sphere.h - collision/pfx_contact_tri_mesh_box.h - collision/pfx_contact_tri_mesh_capsule.h - collision/pfx_contact_tri_mesh_convex.h - collision/pfx_contact_tri_mesh_cylinder.h - collision/pfx_contact_tri_mesh_sphere.h - collision/pfx_gjk_solver.h - collision/pfx_gjk_support_func.h - collision/pfx_intersect_common.h - collision/pfx_intersect_ray_box.h - collision/pfx_intersect_ray_capsule.h - collision/pfx_intersect_ray_convex.h - collision/pfx_intersect_ray_cylinder.h - collision/pfx_intersect_ray_large_tri_mesh.h - collision/pfx_intersect_ray_sphere.h - collision/pfx_mesh_common.h - collision/pfx_simplex_solver.h - solver/pfx_check_solver.h - solver/pfx_constraint_row_solver.h -) - - - - -ADD_LIBRARY(PfxBaseLevel ${PfxBaseLevel_SRCS} ${PfxBaseLevel_HDRS}) - -SET_TARGET_PROPERTIES(PfxBaseLevel PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(PfxBaseLevel PROPERTIES SOVERSION ${BULLET_VERSION}) diff --git a/Extras/PhysicsEffects/src/base_level/broadphase/pfx_check_collidable.h b/Extras/PhysicsEffects/src/base_level/broadphase/pfx_check_collidable.h deleted file mode 100644 index 9a69bb211..000000000 --- a/Extras/PhysicsEffects/src/base_level/broadphase/pfx_check_collidable.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CHECK_COLLIDABLE_H -#define _SCE_PFX_CHECK_COLLIDABLE_H - -#include "../../../include/physics_effects/base_level/rigidbody/pfx_rigid_state.h" -#include "../../../include/physics_effects/base_level/collision/pfx_aabb.h" -#include "../../../include/physics_effects/base_level/broadphase/pfx_broadphase_proxy.h" -#include "../../../include/physics_effects/base_level/broadphase/pfx_broadphase_pair.h" - -namespace sce { -namespace PhysicsEffects { - -// Collidable check table -/* - -----------------MotionTypeA - |0 1 0 1 1 - |1 1 1 1 1 - |0 1 0 1 1 - |1 1 1 0 1 - |1 1 1 1 0 -MotionTypeB - */ - -static SCE_PFX_FORCE_INLINE -PfxBool pfxCheckCollidableTable(ePfxMotionType i,ePfxMotionType j) -{ - const PfxUInt32 collidableTable = 0x00bfafbe; - - SCE_PFX_ASSERT(i < kPfxMotionTypeCount); - SCE_PFX_ASSERT(j < kPfxMotionTypeCount); - - PfxUInt32 idx = j * kPfxMotionTypeCount + i; - PfxUInt32 mask = 1 << (kPfxMotionTypeCount*kPfxMotionTypeCount-1-idx); - - return (collidableTable & mask) != 0; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxCheckCollidableInBroadphase(const PfxBroadphaseProxy &proxyA, const PfxBroadphaseProxy &proxyB) -{ - ePfxMotionType motionA = (ePfxMotionType)(pfxGetMotionMask(proxyA)&SCE_PFX_MOTION_MASK_TYPE); - ePfxMotionType motionB = (ePfxMotionType)(pfxGetMotionMask(proxyB)&SCE_PFX_MOTION_MASK_TYPE); - - return - pfxCheckCollidableTable(motionA,motionB) && // モーションタイプ別è¡çªåˆ¤å®šãƒ†ãƒ¼ãƒ–ル - ((pfxGetSelf(proxyA)&pfxGetTarget(proxyB)) && (pfxGetTarget(proxyA)&pfxGetSelf(proxyB))) && // è¡çªãƒ•ィルター - pfxTestAabb(proxyA,proxyB); // AABB交差判定 -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxCheckCollidableInCollision(const PfxBroadphasePair &pair) -{ - PfxUInt32 motionA = pfxGetMotionMaskA(pair)&SCE_PFX_MOTION_MASK_TYPE; - PfxUInt32 motionB = pfxGetMotionMaskB(pair)&SCE_PFX_MOTION_MASK_TYPE; - PfxUInt32 sleepA = pfxGetMotionMaskA(pair)&SCE_PFX_MOTION_MASK_SLEEPING; - PfxUInt32 sleepB = pfxGetMotionMaskB(pair)&SCE_PFX_MOTION_MASK_SLEEPING; - - return - pfxCheckCollidableTable((ePfxMotionType)motionA,(ePfxMotionType)motionB) && // モーションタイプ別è¡çªåˆ¤å®šãƒ†ãƒ¼ãƒ–ル - !((sleepA != 0 && sleepB != 0) || (sleepA != 0 && motionB == kPfxMotionTypeFixed) || (sleepB != 0 && motionA == kPfxMotionTypeFixed)); // スリープ時ã®ãƒã‚§ãƒƒã‚¯ -} -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CHECK_COLLIDABLE_H diff --git a/Extras/PhysicsEffects/src/base_level/broadphase/pfx_update_broadphase_proxy.cpp b/Extras/PhysicsEffects/src/base_level/broadphase/pfx_update_broadphase_proxy.cpp deleted file mode 100644 index 9de1d91ad..000000000 --- a/Extras/PhysicsEffects/src/base_level/broadphase/pfx_update_broadphase_proxy.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/collision/pfx_aabb.h" -#include "../../../include/physics_effects/base_level/broadphase/pfx_update_broadphase_proxy.h" - -namespace sce { -namespace PhysicsEffects { - -static SCE_PFX_FORCE_INLINE -PfxBool operator < (const PfxVector3 &v1,const PfxVector3 &v2) -{ - return maxElem(v2-v1) > 0.0f; -} - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxy, - const PfxRigidState &state, - const PfxCollidable &coll, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent, - PfxUInt32 axis) -{ - SCE_PFX_ALWAYS_ASSERT(axis<3); - - PfxInt32 ret = SCE_PFX_OK; - - PfxVector3 center = state.getPosition() + coll.getCenter(); - PfxVector3 half = absPerElem(PfxMatrix3(state.getOrientation())) * coll.getHalf(); - - PfxVector3 minRig = center - half; - PfxVector3 maxRig = center + half; - - PfxVector3 minWld = worldCenter - worldExtent; - PfxVector3 maxWld = worldCenter + worldExtent; - - if(maxWld < minRig || maxRig < minWld) { - ret = SCE_PFX_ERR_OUT_OF_WORLD; - } - - PfxVecInt3 aabbMin,aabbMax; - pfxConvertCoordWorldToLocal(worldCenter,worldExtent,minRig,maxRig,aabbMin,aabbMax); - - pfxSetXMin(proxy,aabbMin.getX()); - pfxSetXMax(proxy,aabbMax.getX()); - pfxSetYMin(proxy,aabbMin.getY()); - pfxSetYMax(proxy,aabbMax.getY()); - pfxSetZMin(proxy,aabbMin.getZ()); - pfxSetZMax(proxy,aabbMax.getZ()); - pfxSetKey(proxy,aabbMin.get(axis)); - pfxSetObjectId(proxy,state.getRigidBodyId()); - pfxSetMotionMask(proxy,state.getMotionMask()); - pfxSetSelf(proxy,state.getContactFilterSelf()); - pfxSetTarget(proxy,state.getContactFilterTarget()); - - return ret; -} - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxy, - const PfxRigidState &state, - const PfxVector3 &objectCenter, - const PfxVector3 &objectHalf, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent, - PfxUInt32 axis) -{ - SCE_PFX_ALWAYS_ASSERT(axis<3); - - PfxInt32 ret = SCE_PFX_OK; - - PfxVector3 minRig = objectCenter - objectHalf; - PfxVector3 maxRig = objectCenter + objectHalf; - - PfxVector3 minWld = worldCenter - worldExtent; - PfxVector3 maxWld = worldCenter + worldExtent; - - if(maxWld < minRig || maxRig < minWld) { - ret = SCE_PFX_ERR_OUT_OF_WORLD; - } - - PfxVecInt3 aabbMin,aabbMax; - pfxConvertCoordWorldToLocal(worldCenter,worldExtent,minRig,maxRig,aabbMin,aabbMax); - - pfxSetXMin(proxy,aabbMin.getX()); - pfxSetXMax(proxy,aabbMax.getX()); - pfxSetYMin(proxy,aabbMin.getY()); - pfxSetYMax(proxy,aabbMax.getY()); - pfxSetZMin(proxy,aabbMin.getZ()); - pfxSetZMax(proxy,aabbMax.getZ()); - pfxSetKey(proxy,aabbMin.get(axis)); - pfxSetObjectId(proxy,state.getRigidBodyId()); - pfxSetMotionMask(proxy,state.getMotionMask()); - pfxSetSelf(proxy,state.getContactFilterSelf()); - pfxSetTarget(proxy,state.getContactFilterTarget()); - - return ret; -} - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxyX, - PfxBroadphaseProxy &proxyY, - PfxBroadphaseProxy &proxyZ, - PfxBroadphaseProxy &proxyXb, - PfxBroadphaseProxy &proxyYb, - PfxBroadphaseProxy &proxyZb, - const PfxRigidState &state, - const PfxCollidable &coll, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent) -{ - PfxInt32 ret = SCE_PFX_OK; - - PfxVector3 center = state.getPosition() + coll.getCenter(); - PfxVector3 half = absPerElem(PfxMatrix3(state.getOrientation())) * coll.getHalf(); - - PfxVector3 minRig = center - half; - PfxVector3 maxRig = center + half; - - PfxVector3 minWld = worldCenter - worldExtent; - PfxVector3 maxWld = worldCenter + worldExtent; - - if(maxWld < minRig || maxRig < minWld) { - ret = SCE_PFX_ERR_OUT_OF_WORLD; - } - - PfxVecInt3 aabbMin,aabbMax; - pfxConvertCoordWorldToLocal(worldCenter,worldExtent,minRig,maxRig,aabbMin,aabbMax); - - PfxBroadphaseProxy proxy; - - pfxSetXMin(proxy,aabbMin.getX()); - pfxSetXMax(proxy,aabbMax.getX()); - pfxSetYMin(proxy,aabbMin.getY()); - pfxSetYMax(proxy,aabbMax.getY()); - pfxSetZMin(proxy,aabbMin.getZ()); - pfxSetZMax(proxy,aabbMax.getZ()); - pfxSetObjectId(proxy,state.getRigidBodyId()); - pfxSetMotionMask(proxy,state.getMotionMask()); - pfxSetSelf(proxy,state.getContactFilterSelf()); - pfxSetTarget(proxy,state.getContactFilterTarget()); - - proxyX = proxy; - proxyXb = proxy; - proxyY = proxy; - proxyYb = proxy; - proxyZ = proxy; - proxyZb = proxy; - - pfxSetKey(proxyX ,aabbMin.getX()); - pfxSetKey(proxyXb,aabbMax.getX()); - pfxSetKey(proxyY ,aabbMin.getY()); - pfxSetKey(proxyYb,aabbMax.getY()); - pfxSetKey(proxyZ ,aabbMin.getZ()); - pfxSetKey(proxyZb,aabbMax.getZ()); - - return ret; -} - -PfxInt32 pfxUpdateBroadphaseProxy( - PfxBroadphaseProxy &proxyX, - PfxBroadphaseProxy &proxyY, - PfxBroadphaseProxy &proxyZ, - PfxBroadphaseProxy &proxyXb, - PfxBroadphaseProxy &proxyYb, - PfxBroadphaseProxy &proxyZb, - const PfxRigidState &state, - const PfxVector3 &objectCenter, - const PfxVector3 &objectHalf, - const PfxVector3 &worldCenter, - const PfxVector3 &worldExtent) -{ - PfxInt32 ret = SCE_PFX_OK; - - PfxVector3 minRig = objectCenter - objectHalf; - PfxVector3 maxRig = objectCenter + objectHalf; - - PfxVector3 minWld = worldCenter - worldExtent; - PfxVector3 maxWld = worldCenter + worldExtent; - - if(maxWld < minRig || maxRig < minWld) { - ret = SCE_PFX_ERR_OUT_OF_WORLD; - } - - PfxVecInt3 aabbMin,aabbMax; - pfxConvertCoordWorldToLocal(worldCenter,worldExtent,minRig,maxRig,aabbMin,aabbMax); - - PfxBroadphaseProxy proxy; - - pfxSetXMin(proxy,aabbMin.getX()); - pfxSetXMax(proxy,aabbMax.getX()); - pfxSetYMin(proxy,aabbMin.getY()); - pfxSetYMax(proxy,aabbMax.getY()); - pfxSetZMin(proxy,aabbMin.getZ()); - pfxSetZMax(proxy,aabbMax.getZ()); - pfxSetObjectId(proxy,state.getRigidBodyId()); - pfxSetMotionMask(proxy,state.getMotionMask()); - pfxSetSelf(proxy,state.getContactFilterSelf()); - pfxSetTarget(proxy,state.getContactFilterTarget()); - - proxyX = proxy; - proxyXb = proxy; - proxyY = proxy; - proxyYb = proxy; - proxyZ = proxy; - proxyZb = proxy; - - pfxSetKey(proxyX ,aabbMin.getX()); - pfxSetKey(proxyXb,aabbMax.getX()); - pfxSetKey(proxyY ,aabbMin.getY()); - pfxSetKey(proxyYb,aabbMax.getY()); - pfxSetKey(proxyZ ,aabbMin.getZ()); - pfxSetKey(proxyZb,aabbMax.getZ()); - - return ret; -} - -} // namespace PhysicsEffects -} // namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_collidable.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_collidable.cpp deleted file mode 100644 index 9a8f596f5..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_collidable.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_collidable.h" - -namespace sce { -namespace PhysicsEffects { - -void PfxCollidable::addShape(const PfxShape &shape) -{ - if(m_numShapes distanceThreshold ) return gap; \ - axisType = A_AXIS; \ - faceDimA = dim; \ - axisA = ident[dim]; \ - } \ - else \ - { \ - gap = gapsA.get##letter(); \ - if ( gap > distanceThreshold ) return gap; \ - else if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = A_AXIS; \ - faceDimA = dim; \ - axisA = ident[dim]; \ - } \ - } \ -} - - -#define BaxisTest( dim, letter ) \ -{ \ - gap = gapsB.get##letter(); \ - if ( gap > distanceThreshold ) return gap; \ - else if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = B_AXIS; \ - faceDimB = dim; \ - axisB = ident[dim]; \ - } \ -} - -#define CrossAxisTest( dima, dimb, letterb ) \ -{ \ - const PfxFloat lsqr_tolerance = 1.0e-30f; \ - PfxFloat lsqr; \ - \ - lsqr = lsqrs.getCol##dima().get##letterb(); \ - \ - if ( lsqr > lsqr_tolerance ) \ - { \ - PfxFloat l_recip = 1.0f / sqrtf( lsqr ); \ - gap = PfxFloat(gapsAxB.getCol##dima().get##letterb()) * l_recip; \ - \ - if ( gap > distanceThreshold ) \ - { \ - return gap; \ - } \ - \ - if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = CROSS_AXIS; \ - edgeDimA = dima; \ - edgeDimB = dimb; \ - axisA = cross(ident[dima],matrixAB.getCol##dimb()) * l_recip; \ - } \ - } \ -} - -//------------------------------------------------------------------------------------------------- -// tests whether a vertex of box B and a face of box A are the closest features -//------------------------------------------------------------------------------------------------- - -inline -PfxFloat -VertexBFaceATest( - PfxBool & inVoronoi, - PfxFloat & t0, - PfxFloat & t1, - const PfxVector3 & hA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB ) -{ - // compute a corner of box B in A's coordinate system - - PfxVector3 corner = - PfxVector3( faceOffsetAB + matrixAB.getCol0() * scalesB.getX() + matrixAB.getCol1() * scalesB.getY() ); - - // compute the parameters of the point on A, closest to this corner - - t0 = corner[0]; - t1 = corner[1]; - - if ( t0 > hA[0] ) - t0 = hA[0]; - else if ( t0 < -hA[0] ) - t0 = -hA[0]; - if ( t1 > hA[1] ) - t1 = hA[1]; - else if ( t1 < -hA[1] ) - t1 = -hA[1]; - - // do the Voronoi test: already know the point on B is in the Voronoi region of the - // point on A, check the reverse. - - PfxVector3 facePointB = - PfxVector3( mulPerElem( faceOffsetBA + matrixBA.getCol0() * t0 + matrixBA.getCol1() * t1 - scalesB, signsB ) ); - - inVoronoi = ( ( facePointB[0] >= voronoiTol * facePointB[2] ) && - ( facePointB[1] >= voronoiTol * facePointB[0] ) && - ( facePointB[2] >= voronoiTol * facePointB[1] ) ); - - return (SCE_PFX_SQR( corner[0] - t0 ) + SCE_PFX_SQR( corner[1] - t1 ) + SCE_PFX_SQR( corner[2] )); -} - -#define VertexBFaceA_SetNewMin() \ -{ \ - minDistSqr = distSqr; \ - localPointA.setX(t0); \ - localPointA.setY(t1); \ - localPointB.setX( scalesB.getX() ); \ - localPointB.setY( scalesB.getY() ); \ -} - -void -VertexBFaceATests( - PfxBool & done, - PfxFloat & minDistSqr, - PfxPoint3 & localPointA, - PfxPoint3 & localPointB, - const PfxVector3 & hA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB, - PfxBool first ) -{ - PfxFloat t0, t1; - PfxFloat distSqr; - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( first ) { - VertexBFaceA_SetNewMin(); - } else { - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = VertexBFaceATest( done, t0, t1, hA, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsB, scalesB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } -} - -//------------------------------------------------------------------------------------------------- -// VertexAFaceBTest: tests whether a vertex of box A and a face of box B are the closest features -//------------------------------------------------------------------------------------------------- - -inline -PfxFloat -VertexAFaceBTest( - PfxBool & inVoronoi, - PfxFloat & t0, - PfxFloat & t1, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA ) -{ - PfxVector3 corner = - PfxVector3( faceOffsetBA + matrixBA.getCol0() * scalesA.getX() + matrixBA.getCol1() * scalesA.getY() ); - - t0 = corner[0]; - t1 = corner[1]; - - if ( t0 > hB[0] ) - t0 = hB[0]; - else if ( t0 < -hB[0] ) - t0 = -hB[0]; - if ( t1 > hB[1] ) - t1 = hB[1]; - else if ( t1 < -hB[1] ) - t1 = -hB[1]; - - PfxVector3 facePointA = - PfxVector3( mulPerElem( faceOffsetAB + matrixAB.getCol0() * t0 + matrixAB.getCol1() * t1 - scalesA, signsA ) ); - - inVoronoi = ( ( facePointA[0] >= voronoiTol * facePointA[2] ) && - ( facePointA[1] >= voronoiTol * facePointA[0] ) && - ( facePointA[2] >= voronoiTol * facePointA[1] ) ); - - return (SCE_PFX_SQR( corner[0] - t0 ) + SCE_PFX_SQR( corner[1] - t1 ) + SCE_PFX_SQR( corner[2] )); -} - -#define VertexAFaceB_SetNewMin() \ -{ \ - minDistSqr = distSqr; \ - localPointB.setX(t0); \ - localPointB.setY(t1); \ - localPointA.setX( scalesA.getX() ); \ - localPointA.setY( scalesA.getY() ); \ -} - -void -VertexAFaceBTests( - PfxBool & done, - PfxFloat & minDistSqr, - PfxPoint3 & localPointA, - PfxPoint3 & localPointB, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxBool first ) -{ - PfxFloat t0, t1; - PfxFloat distSqr; - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( first ) { - VertexAFaceB_SetNewMin(); - } else { - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = VertexAFaceBTest( done, t0, t1, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - VertexAFaceB_SetNewMin(); - } -} - -//------------------------------------------------------------------------------------------------- -// EdgeEdgeTest: -// -// tests whether a pair of edges are the closest features -// -// note on the shorthand: -// 'a' & 'b' refer to the edges. -// 'c' is the dimension of the axis that points from the face center to the edge Center -// 'd' is the dimension of the edge Direction -// the dimension of the face normal is 2 -//------------------------------------------------------------------------------------------------- - -#define EdgeEdgeTest( ac, ac_letter, ad, ad_letter, bc, bc_letter, bd, bd_letter ) \ -{ \ - PfxVector3 edgeOffsetAB; \ - PfxVector3 edgeOffsetBA; \ - \ - edgeOffsetAB = faceOffsetAB + matrixAB.getCol##bc() * scalesB.get##bc_letter(); \ - edgeOffsetAB.set##ac_letter( edgeOffsetAB.get##ac_letter() - scalesA.get##ac_letter() ); \ - \ - edgeOffsetBA = faceOffsetBA + matrixBA.getCol##ac() * scalesA.get##ac_letter(); \ - edgeOffsetBA.set##bc_letter( edgeOffsetBA.get##bc_letter() - scalesB.get##bc_letter() ); \ - \ - PfxFloat dirDot = matrixAB.getCol##bd().get##ad_letter(); \ - PfxFloat denom = 1.0f - dirDot*dirDot; \ - PfxFloat edgeOffsetAB_ad = edgeOffsetAB.get##ad_letter(); \ - PfxFloat edgeOffsetBA_bd = edgeOffsetBA.get##bd_letter(); \ - \ - if ( denom == 0.0f ) \ - { \ - tA = 0.0f; \ - } \ - else \ - { \ - tA = ( edgeOffsetAB_ad + edgeOffsetBA_bd * dirDot ) / denom; \ - } \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - \ - tB = tA * dirDot + edgeOffsetBA_bd; \ - \ - if ( tB < -hB[bd] ) \ - { \ - tB = -hB[bd]; \ - tA = tB * dirDot + edgeOffsetAB_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - else if ( tB > hB[bd] ) \ - { \ - tB = hB[bd]; \ - tA = tB * dirDot + edgeOffsetAB_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - \ - PfxVector3 edgeOffAB = PfxVector3( mulPerElem( edgeOffsetAB + matrixAB.getCol##bd() * tB, signsA ) );\ - PfxVector3 edgeOffBA = PfxVector3( mulPerElem( edgeOffsetBA + matrixBA.getCol##ad() * tA, signsB ) );\ - \ - inVoronoi = ( edgeOffAB[ac] >= voronoiTol * edgeOffAB[2] ) && \ - ( edgeOffAB[2] >= voronoiTol * edgeOffAB[ac] ) && \ - ( edgeOffBA[bc] >= voronoiTol * edgeOffBA[2] ) && \ - ( edgeOffBA[2] >= voronoiTol * edgeOffBA[bc] ); \ - \ - edgeOffAB[ad] -= tA; \ - edgeOffBA[bd] -= tB; \ - \ - return dot(edgeOffAB,edgeOffAB); \ -} - -PfxFloat -EdgeEdgeTest_0101( - PfxBool & inVoronoi, - PfxFloat & tA, - PfxFloat & tB, - const PfxVector3 & hA, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB ) -{ - EdgeEdgeTest( 0, X, 1, Y, 0, X, 1, Y ); -} - -PfxFloat -EdgeEdgeTest_0110( - PfxBool & inVoronoi, - PfxFloat & tA, - PfxFloat & tB, - const PfxVector3 & hA, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB ) -{ - EdgeEdgeTest( 0, X, 1, Y, 1, Y, 0, X ); -} - -PfxFloat -EdgeEdgeTest_1001( - PfxBool & inVoronoi, - PfxFloat & tA, - PfxFloat & tB, - const PfxVector3 & hA, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB ) -{ - EdgeEdgeTest( 1, Y, 0, X, 0, X, 1, Y ); -} - -PfxFloat -EdgeEdgeTest_1010( - PfxBool & inVoronoi, - PfxFloat & tA, - PfxFloat & tB, - const PfxVector3 & hA, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB ) -{ - EdgeEdgeTest( 1, Y, 0, X, 1, Y, 0, X ); -} - -#define EdgeEdge_SetNewMin( ac_letter, ad_letter, bc_letter, bd_letter ) \ -{ \ - minDistSqr = distSqr; \ - localPointA.set##ac_letter(scalesA.get##ac_letter()); \ - localPointA.set##ad_letter(tA); \ - localPointB.set##bc_letter(scalesB.get##bc_letter()); \ - localPointB.set##bd_letter(tB); \ - otherFaceDimA = testOtherFaceDimA; \ - otherFaceDimB = testOtherFaceDimB; \ -} - -void -EdgeEdgeTests( - PfxBool & done, - PfxFloat & minDistSqr, - PfxPoint3 & localPointA, - PfxPoint3 & localPointB, - int & otherFaceDimA, - int & otherFaceDimB, - const PfxVector3 & hA, - const PfxVector3 & hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG faceOffsetBA, - const PfxMatrix3 & matrixAB, - const PfxMatrix3 & matrixBA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesB, - PfxBool first ) -{ - PfxFloat distSqr; - PfxFloat tA, tB; - - int testOtherFaceDimA, testOtherFaceDimB; - - testOtherFaceDimA = 0; - testOtherFaceDimB = 0; - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( first ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } else { - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0101( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, X, Y ); - } - - if ( done ) - return; - - testOtherFaceDimA = 1; - testOtherFaceDimB = 0; - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1001( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, X, Y ); - } - - if ( done ) - return; - - testOtherFaceDimA = 0; - testOtherFaceDimB = 1; - signsB.setX( -signsB.getX() ); - scalesB.setX( -scalesB.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_0110( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y, Y, X ); - } - - if ( done ) - return; - - testOtherFaceDimA = 1; - testOtherFaceDimB = 1; - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsB.setY( -signsB.getY() ); - scalesB.setY( -scalesB.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_1010( done, tA, tB, hA, hB, faceOffsetAB, faceOffsetBA, - matrixAB, matrixBA, signsA, signsB, scalesA, scalesB ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X, Y, X ); - } -} - -PfxFloat pfxContactBoxBox( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxBox &boxA = *((PfxBox*)shapeA); - PfxBox &boxB = *((PfxBox*)shapeB); - - PfxVector3 ident[3] = { - PfxVector3(1.0,0.0,0.0), - PfxVector3(0.0,1.0,0.0), - PfxVector3(0.0,0.0,1.0), - }; - - // get relative transformations - - PfxTransform3 transformAB, transformBA; - PfxMatrix3 matrixAB, matrixBA; - PfxVector3 offsetAB, offsetBA; - - transformAB = orthoInverse(transformA) * transformB; - transformBA = orthoInverse(transformAB); - - matrixAB = transformAB.getUpper3x3(); - offsetAB = transformAB.getTranslation(); - matrixBA = transformBA.getUpper3x3(); - offsetBA = transformBA.getTranslation(); - - PfxMatrix3 absMatrixAB = absPerElem(matrixAB); - PfxMatrix3 absMatrixBA = absPerElem(matrixBA); - - // find separating axis with largest gap between projections - - BoxSepAxisType axisType; - PfxVector3 axisA(0.0f), axisB(0.0f); - PfxFloat gap, maxGap; - int faceDimA = 0, faceDimB = 0, edgeDimA = 0, edgeDimB = 0; - - // face axes - - PfxVector3 gapsA = absPerElem(offsetAB) - boxA.m_half - absMatrixAB * boxB.m_half; - - AaxisTest(0,X,true); - AaxisTest(1,Y,false); - AaxisTest(2,Z,false); - - PfxVector3 gapsB = absPerElem(offsetBA) - boxB.m_half - absMatrixBA * boxA.m_half; - - BaxisTest(0,X); - BaxisTest(1,Y); - BaxisTest(2,Z); - - // cross product axes - - // 外ç©ãŒï¼ã®ã¨ãã®å¯¾ç­– - absMatrixAB += PfxMatrix3(1.0e-5f); - absMatrixBA += PfxMatrix3(1.0e-5f); - - PfxMatrix3 lsqrs, projOffset, projAhalf, projBhalf; - - lsqrs.setCol0( mulPerElem( matrixBA.getCol2(), matrixBA.getCol2() ) + - mulPerElem( matrixBA.getCol1(), matrixBA.getCol1() ) ); - lsqrs.setCol1( mulPerElem( matrixBA.getCol2(), matrixBA.getCol2() ) + - mulPerElem( matrixBA.getCol0(), matrixBA.getCol0() ) ); - lsqrs.setCol2( mulPerElem( matrixBA.getCol1(), matrixBA.getCol1() ) + - mulPerElem( matrixBA.getCol0(), matrixBA.getCol0() ) ); - - projOffset.setCol0(matrixBA.getCol1() * offsetAB.getZ() - matrixBA.getCol2() * offsetAB.getY()); - projOffset.setCol1(matrixBA.getCol2() * offsetAB.getX() - matrixBA.getCol0() * offsetAB.getZ()); - projOffset.setCol2(matrixBA.getCol0() * offsetAB.getY() - matrixBA.getCol1() * offsetAB.getX()); - - projAhalf.setCol0(absMatrixBA.getCol1() * boxA.m_half.getZ() + absMatrixBA.getCol2() * boxA.m_half.getY()); - projAhalf.setCol1(absMatrixBA.getCol2() * boxA.m_half.getX() + absMatrixBA.getCol0() * boxA.m_half.getZ()); - projAhalf.setCol2(absMatrixBA.getCol0() * boxA.m_half.getY() + absMatrixBA.getCol1() * boxA.m_half.getX()); - - projBhalf.setCol0(absMatrixAB.getCol1() * boxB.m_half.getZ() + absMatrixAB.getCol2() * boxB.m_half.getY()); - projBhalf.setCol1(absMatrixAB.getCol2() * boxB.m_half.getX() + absMatrixAB.getCol0() * boxB.m_half.getZ()); - projBhalf.setCol2(absMatrixAB.getCol0() * boxB.m_half.getY() + absMatrixAB.getCol1() * boxB.m_half.getX()); - - PfxMatrix3 gapsAxB = absPerElem(projOffset) - projAhalf - transpose(projBhalf); - - CrossAxisTest(0,0,X); - CrossAxisTest(0,1,Y); - CrossAxisTest(0,2,Z); - CrossAxisTest(1,0,X); - CrossAxisTest(1,1,Y); - CrossAxisTest(1,2,Z); - CrossAxisTest(2,0,X); - CrossAxisTest(2,1,Y); - CrossAxisTest(2,2,Z); - - // need to pick the face on each box whose normal best matches the separating axis. - // will transform vectors to be in the coordinate system of this face to simplify things later. - // for this, a permutation matrix can be used, which the next section computes. - - int dimA[3], dimB[3]; - - if ( axisType == A_AXIS ) { - if ( dot(axisA,offsetAB) < 0.0f ) - axisA = -axisA; - axisB = matrixBA * -axisA; - - PfxVector3 absAxisB = PfxVector3(absPerElem(axisB)); - - if ( ( absAxisB[0] > absAxisB[1] ) && ( absAxisB[0] > absAxisB[2] ) ) - faceDimB = 0; - else if ( absAxisB[1] > absAxisB[2] ) - faceDimB = 1; - else - faceDimB = 2; - } else if ( axisType == B_AXIS ) { - if ( dot(axisB,offsetBA) < 0.0f ) - axisB = -axisB; - axisA = matrixAB * -axisB; - - PfxVector3 absAxisA = PfxVector3(absPerElem(axisA)); - - if ( ( absAxisA[0] > absAxisA[1] ) && ( absAxisA[0] > absAxisA[2] ) ) - faceDimA = 0; - else if ( absAxisA[1] > absAxisA[2] ) - faceDimA = 1; - else - faceDimA = 2; - } - - if ( axisType == CROSS_AXIS ) { - if ( dot(axisA,offsetAB) < 0.0f ) - axisA = -axisA; - axisB = matrixBA * -axisA; - - PfxVector3 absAxisA = PfxVector3(absPerElem(axisA)); - PfxVector3 absAxisB = PfxVector3(absPerElem(axisB)); - - dimA[1] = edgeDimA; - dimB[1] = edgeDimB; - - if ( edgeDimA == 0 ) { - if ( absAxisA[1] > absAxisA[2] ) { - dimA[0] = 2; - dimA[2] = 1; - } else { - dimA[0] = 1; - dimA[2] = 2; - } - } else if ( edgeDimA == 1 ) { - if ( absAxisA[2] > absAxisA[0] ) { - dimA[0] = 0; - dimA[2] = 2; - } else { - dimA[0] = 2; - dimA[2] = 0; - } - } else { - if ( absAxisA[0] > absAxisA[1] ) { - dimA[0] = 1; - dimA[2] = 0; - } else { - dimA[0] = 0; - dimA[2] = 1; - } - } - - if ( edgeDimB == 0 ) { - if ( absAxisB[1] > absAxisB[2] ) { - dimB[0] = 2; - dimB[2] = 1; - } else { - dimB[0] = 1; - dimB[2] = 2; - } - } else if ( edgeDimB == 1 ) { - if ( absAxisB[2] > absAxisB[0] ) { - dimB[0] = 0; - dimB[2] = 2; - } else { - dimB[0] = 2; - dimB[2] = 0; - } - } else { - if ( absAxisB[0] > absAxisB[1] ) { - dimB[0] = 1; - dimB[2] = 0; - } else { - dimB[0] = 0; - dimB[2] = 1; - } - } - } else { - dimA[2] = faceDimA; - dimA[0] = (faceDimA+1)%3; - dimA[1] = (faceDimA+2)%3; - dimB[2] = faceDimB; - dimB[0] = (faceDimB+1)%3; - dimB[1] = (faceDimB+2)%3; - } - - PfxMatrix3 aperm_col, bperm_col; - - aperm_col.setCol0(ident[dimA[0]]); - aperm_col.setCol1(ident[dimA[1]]); - aperm_col.setCol2(ident[dimA[2]]); - - bperm_col.setCol0(ident[dimB[0]]); - bperm_col.setCol1(ident[dimB[1]]); - bperm_col.setCol2(ident[dimB[2]]); - - PfxMatrix3 aperm_row, bperm_row; - - aperm_row = transpose(aperm_col); - bperm_row = transpose(bperm_col); - - // permute all box parameters to be in the face coordinate systems - - PfxMatrix3 matrixAB_perm = aperm_row * matrixAB * bperm_col; - PfxMatrix3 matrixBA_perm = transpose(matrixAB_perm); - - PfxVector3 offsetAB_perm, offsetBA_perm; - - offsetAB_perm = aperm_row * offsetAB; - offsetBA_perm = bperm_row * offsetBA; - - PfxVector3 halfA_perm, halfB_perm; - - halfA_perm = aperm_row * boxA.m_half; - halfB_perm = bperm_row * boxB.m_half; - - // compute the vector between the centers of each face, in each face's coordinate frame - - PfxVector3 signsA_perm, signsB_perm, scalesA_perm, scalesB_perm, faceOffsetAB_perm, faceOffsetBA_perm; - - signsA_perm = copySignPerElem(PfxVector3(1.0f),aperm_row * axisA); - signsB_perm = copySignPerElem(PfxVector3(1.0f),bperm_row * axisB); - scalesA_perm = mulPerElem( signsA_perm, halfA_perm ); - scalesB_perm = mulPerElem( signsB_perm, halfB_perm ); - - faceOffsetAB_perm = offsetAB_perm + matrixAB_perm.getCol2() * scalesB_perm.getZ(); - faceOffsetAB_perm.setZ( faceOffsetAB_perm.getZ() - scalesA_perm.getZ() ); - - faceOffsetBA_perm = offsetBA_perm + matrixBA_perm.getCol2() * scalesA_perm.getZ(); - faceOffsetBA_perm.setZ( faceOffsetBA_perm.getZ() - scalesB_perm.getZ() ); - - if ( maxGap < 0.0f ) { - // if boxes overlap, this will separate the faces for finding points of penetration. - - faceOffsetAB_perm -= aperm_row * axisA * maxGap * 1.01f; - faceOffsetBA_perm -= bperm_row * axisB * maxGap * 1.01f; - } - - // for each vertex/face or edge/edge pair of the two faces, find the closest points. - // - // these points each have an associated box feature (vertex, edge, or face). if each - // point is in the external Voronoi region of the other's feature, they are the - // closest points of the boxes, and the algorithm can exit. - // - // the feature pairs are arranged so that in the general case, the first test will - // succeed. degenerate cases (parallel faces) may require up to all tests in the - // worst case. - // - // if for some reason no case passes the Voronoi test, the features with the minimum - // distance are returned. - - PfxPoint3 localPointA_perm, localPointB_perm; - PfxFloat minDistSqr; - PfxBool done; - - PfxVector3 hA_perm( halfA_perm ), hB_perm( halfB_perm ); - - localPointA_perm.setZ( scalesA_perm.getZ() ); - localPointB_perm.setZ( scalesB_perm.getZ() ); - scalesA_perm.setZ(0.0f); - scalesB_perm.setZ(0.0f); - - int otherFaceDimA, otherFaceDimB; - - if ( axisType == CROSS_AXIS ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, true ); - - if ( !done ) { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, false ); - - if ( !done ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, false ); - } - } - } else if ( axisType == B_AXIS ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, true ); - - if ( !done ) { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, false ); - - if ( !done ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, false ); - } - } - } else { - VertexBFaceATests( done, minDistSqr, localPointA_perm, localPointB_perm, - hA_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsB_perm, scalesB_perm, true ); - - if ( !done ) { - VertexAFaceBTests( done, minDistSqr, localPointA_perm, localPointB_perm, - hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, scalesA_perm, false ); - - if ( !done ) { - EdgeEdgeTests( done, minDistSqr, localPointA_perm, localPointB_perm, - otherFaceDimA, otherFaceDimB, - hA_perm, hB_perm, faceOffsetAB_perm, faceOffsetBA_perm, - matrixAB_perm, matrixBA_perm, signsA_perm, signsB_perm, - scalesA_perm, scalesB_perm, false ); - } - } - } - - // convert local points from face-local to box-local coordinate system - - pointA = PfxPoint3( aperm_col * PfxVector3( localPointA_perm ) ); - pointB = PfxPoint3( bperm_col * PfxVector3( localPointB_perm ) ); - - normal = transformA * axisA; - - //SCE_PFX_PRINTF("minDistSqr %f maxGap %f\n",minDistSqr,maxGap); - //SCE_PFX_PRINTF("normal %f %f %f\n",normal[0],normal[1],normal[2]); - //SCE_PFX_PRINTF("pointA %f %f %f\n",pointA[0],pointA[1],pointA[2]); - //SCE_PFX_PRINTF("pointB %f %f %f\n",pointB[0],pointB[1],pointB[2]); - - if ( maxGap < 0.0f ) { - return (maxGap); - } else { - return (sqrtf( minDistSqr )); - } -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_box.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_box.h deleted file mode 100644 index 69ff53018..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_box.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_BOX_BOX_H -#define _SCE_PFX_CONTACT_BOX_BOX_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactBoxBox( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_BOX_BOX_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.cpp deleted file mode 100644 index 350953326..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_box.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" -#include "pfx_contact_box_capsule.h" - -namespace sce { -namespace PhysicsEffects { - -enum BoxCapsSepAxisType -{ - BOX_AXIS, CROSS_AXIS -}; - -//------------------------------------------------------------------------------------------------- -// voronoiTol: bevels Voronoi planes slightly which helps when features are parallel. -//------------------------------------------------------------------------------------------------- - -static const PfxFloat voronoiTol = -1.0e-5f; - -//------------------------------------------------------------------------------------------------- -// lenSqrTol: minimum square of length for safe normalize. -//------------------------------------------------------------------------------------------------- - -static const PfxFloat lenSqrTol = 1.0e-30f; - -//------------------------------------------------------------------------------------------------- -// separating axis tests: gaps along each axis are computed, and the axis with the maximum -// gap is stored. cross product axes are normalized. -//------------------------------------------------------------------------------------------------- - -#define AaxisTest( dim, letter, first ) \ -{ \ - if ( first ) \ - { \ - maxGap = gapsA.get##letter(); \ - if ( maxGap - capsuleB.m_radius > distanceThreshold ) return maxGap - capsuleB.m_radius; \ - axisType = BOX_AXIS; \ - faceDimA = dim; \ - axisA = ident[dim]; \ - } \ - else \ - { \ - PfxFloat gap = gapsA.get##letter(); \ - if ( gap - capsuleB.m_radius > distanceThreshold ) return gap - capsuleB.m_radius; \ - else if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = BOX_AXIS; \ - faceDimA = dim; \ - axisA = ident[dim]; \ - } \ - } \ -} - -#define CrossAxisTest( dima, lettera ) \ -{ \ - const PfxFloat lsqr_tolerance = 1.0e-30f; \ - PfxFloat lsqr; \ - \ - lsqr = lsqrs.get##lettera(); \ - \ - if ( lsqr > lsqr_tolerance ) \ - { \ - PfxFloat l_recip = 1.0f / sqrtf( lsqr ); \ - PfxFloat gap = PfxFloat(gapsAxB.get##lettera()) * l_recip; \ - \ - if ( gap - capsuleB.m_radius > distanceThreshold ) \ - { \ - return gap - capsuleB.m_radius; \ - } \ - \ - if ( gap > maxGap ) \ - { \ - maxGap = gap; \ - axisType = CROSS_AXIS; \ - edgeDimA = dima; \ - axisA = crossProdMat.getCol##dima() * l_recip; \ - } \ - } \ -} - -//------------------------------------------------------------------------------------------------- -// tests whether a vertex of box B and a face of box A are the closest features -//------------------------------------------------------------------------------------------------- - -inline -PfxFloat -VertexBFaceATest( - PfxBool& inVoronoi, - PfxFloat& t0, - PfxFloat& t1, - PfxVector3& ptsVec, - const PfxVector3& hA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG offsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG capsDirection, - PfxFloat signB, - PfxFloat scaleB ) -{ - // compute endpoint of capsule in box's coordinate system - - PfxVector3 endpoint = PfxVector3( offsetAB + capsDirection * scaleB ); - - // compute the parameters of the point on the box face closest to this corner. - - t0 = endpoint[0]; - t1 = endpoint[1]; - - if ( t0 > hA[0] ) - t0 = hA[0]; - else if ( t0 < -hA[0] ) - t0 = -hA[0]; - if ( t1 > hA[1] ) - t1 = hA[1]; - else if ( t1 < -hA[1] ) - t1 = -hA[1]; - - // get vector from face point to capsule endpoint - - endpoint[0] -= t0; - endpoint[1] -= t1; - ptsVec = PfxVector3(endpoint); - - // do the Voronoi test: already know the point on B is in the Voronoi region of the - // point on A, check the reverse. - - inVoronoi = ( -signB * dot(ptsVec,capsDirection) >= voronoiTol ); - - return (lengthSqr(ptsVec)); -} - -#define VertexBFaceA_SetNewMin() \ -{ \ - minDistSqr = distSqr; \ - closestPtsVec = ptsVec; \ - localPointA.setX(t0); \ - localPointA.setY(t1); \ - segmentParamB = scaleB; \ -} - -void -VertexBFaceATests( - PfxBool& done, - PfxFloat& minDistSqr, - PfxVector3& closestPtsVec, - PfxPoint3& localPointA, - PfxFloat& segmentParamB, - const PfxVector3& hA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG offsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG capsDirection, - PfxFloat signB, PfxFloat scaleB, - PfxBool first ) -{ - PfxVector3 ptsVec; - PfxFloat t0, t1; - PfxFloat distSqr; - - // test endpoint of capsule nearest to face - - distSqr = VertexBFaceATest( done, t0, t1, ptsVec, hA, offsetAB, capsDirection, signB, scaleB ); - - if ( first ) { - VertexBFaceA_SetNewMin(); - } else { - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } - } - - if ( done ) - return; - - signB = -signB; - scaleB = -scaleB; - - // test other endpoint if necessary - - distSqr = VertexBFaceATest( done, t0, t1, ptsVec, hA, offsetAB, capsDirection, signB, scaleB ); - - if ( distSqr < minDistSqr ) { - VertexBFaceA_SetNewMin(); - } -} - -//------------------------------------------------------------------------------------------------- -// EdgeEdgeTest: -// -// tests whether a pair of edges are the closest features -// -// note on the shorthand: -// 'a' & 'b' refer to the edges. -// 'c' is the dimension of the axis that points from the face center to the edge Center -// 'd' is the dimension of the edge Direction -// the dimension of the face normal is 2 -//------------------------------------------------------------------------------------------------- - -#define EdgeEdgeTest( ac, ac_letter, ad, ad_letter ) \ -{ \ - /* get vector between edge centers */ \ - \ - ptsVec = offsetAB; \ - ptsVec.set##ac_letter( ptsVec.get##ac_letter() - scalesA.get##ac_letter() ); \ - \ - /* find parameters of closest points on line segments. */ \ - \ - PfxFloat capsDirection_ad = capsDirection.get##ad_letter(); \ - PfxFloat ptsVec_ad = ptsVec.get##ad_letter(); \ - PfxFloat capsDirDotPtsVec = dot(capsDirection,ptsVec); \ - PfxFloat denom = 1.0f - capsDirection_ad * capsDirection_ad; \ - \ - if ( denom == 0.0f ) \ - { \ - tA = 0.0f; \ - } \ - else \ - { \ - tA = ( ptsVec_ad - capsDirDotPtsVec * capsDirection_ad ) / denom; \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - \ - tB = tA * capsDirection_ad - capsDirDotPtsVec; \ - \ - if ( tB < -hB ) \ - { \ - tB = -hB; \ - tA = tB * capsDirection_ad + ptsVec_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - else if ( tB > hB ) \ - { \ - tB = hB; \ - tA = tB * capsDirection_ad + ptsVec_ad; \ - \ - if ( tA < -hA[ad] ) tA = -hA[ad]; \ - else if ( tA > hA[ad] ) tA = hA[ad]; \ - } \ - \ - /* make vector to point at tB on edge B from the center of edge A. */ \ - /* test that it lies inside edge A's voronoi region. */ \ - \ - ptsVec += capsDirection * tB; \ - \ - PfxVector3 cptsVec( mulPerElem( ptsVec, signsA ) ); \ - \ - inVoronoi = ( cptsVec[ac] >= voronoiTol * cptsVec[2] ) && \ - ( cptsVec[2] >= voronoiTol * cptsVec[ac] ); \ - \ - ptsVec.set##ad_letter( ptsVec.get##ad_letter() - tA ); \ - \ - return lengthSqr(ptsVec); \ -} - -PfxFloat -EdgeEdgeTest_01( - PfxBool& inVoronoi, - PfxFloat& tA, - PfxFloat& tB, - PfxVector3& ptsVec, - const PfxVector3& hA, - PfxFloat hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG offsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG capsDirection, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA ) -{ - EdgeEdgeTest( 0, X, 1, Y ); -} - -PfxFloat -EdgeEdgeTest_10( - PfxBool& inVoronoi, - PfxFloat& tA, - PfxFloat& tB, - PfxVector3& ptsVec, - const PfxVector3& hA, - PfxFloat hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG offsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG capsDirection, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA ) -{ - EdgeEdgeTest( 1, Y, 0, X ); -} - -#define EdgeEdge_SetNewMin( ac_letter, ad_letter ) \ -{ \ - minDistSqr = distSqr; \ - closestPtsVec = ptsVec; \ - localPointA.set##ac_letter(scalesA.get##ac_letter()); \ - localPointA.set##ad_letter(tA); \ - segmentParamB = tB; \ - otherFaceDimA = testOtherFaceDimA; \ -} - -void -EdgeEdgeTests( - PfxBool& done, - PfxFloat& minDistSqr, - PfxVector3& closestPtsVec, - PfxPoint3& localPointA, - PfxFloat& segmentParamB, - int & otherFaceDimA, - const PfxVector3& hA, - PfxFloat hB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG offsetAB, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG capsDirection, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG signsA, - PfxVector3 SCE_VECTORMATH_AOS_VECTOR_ARG scalesA, - PfxBool first ) -{ - PfxVector3 ptsVec; - PfxFloat tA, tB; - int testOtherFaceDimA; - - testOtherFaceDimA = 0; - - PfxFloat distSqr = EdgeEdgeTest_01( done, tA, tB, ptsVec, hA, hB, - offsetAB, capsDirection, signsA, scalesA ); - - if ( first ) { - EdgeEdge_SetNewMin( X, Y ); - } else { - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y ); - } - } - - if ( done ) - return; - - signsA.setX( -signsA.getX() ); - scalesA.setX( -scalesA.getX() ); - - distSqr = EdgeEdgeTest_01( done, tA, tB, ptsVec, hA, hB, - offsetAB, capsDirection, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( X, Y ); - } - - if ( done ) - return; - - testOtherFaceDimA = 1; - - distSqr = EdgeEdgeTest_10( done, tA, tB, ptsVec, hA, hB, - offsetAB, capsDirection, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X ); - } - - if ( done ) - return; - - signsA.setY( -signsA.getY() ); - scalesA.setY( -scalesA.getY() ); - - distSqr = EdgeEdgeTest_10( done, tA, tB, ptsVec, hA, hB, - offsetAB, capsDirection, signsA, scalesA ); - - if ( distSqr < minDistSqr ) { - EdgeEdge_SetNewMin( Y, X ); - } -} - -PfxFloat pfxContactBoxCapsule( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxBox boxA = *((PfxBox*)shapeA); - PfxCapsule capsuleB = *((PfxCapsule*)shapeB); - - PfxVector3 ident[3] = { - PfxVector3(1.0,0.0,0.0), - PfxVector3(0.0,1.0,0.0), - PfxVector3(0.0,0.0,1.0), - }; - - // get capsule position and direction in box's coordinate system - - PfxMatrix3 matrixA = transformA.getUpper3x3(); - PfxMatrix3 matrixAinv = transpose(matrixA); - - PfxVector3 directionB = transformB.getUpper3x3().getCol0(); - PfxVector3 translationB = transformB.getTranslation(); - - PfxVector3 capsDirection = matrixAinv * directionB; - PfxVector3 absCapsDirection = absPerElem(capsDirection); - PfxVector3 offsetAB = matrixAinv * (translationB - transformA.getTranslation()); - - // find separating axis with largest gap between projections - - BoxCapsSepAxisType axisType; - PfxVector3 axisA; - PfxFloat maxGap; - int faceDimA = 0, edgeDimA = 0; - - // face axes - - // can compute all the gaps at once with VU0 - - PfxVector3 gapsA = absPerElem(offsetAB) - boxA.m_half - absCapsDirection * capsuleB.m_halfLen; - - AaxisTest( 0, X, true ); - AaxisTest( 1, Y, false ); - AaxisTest( 2, Z, false ); - - // cross product axes - - // compute gaps on all cross product axes using some VU0 math. suppose there's a tradeoff - // between doing this with SIMD all at once or without SIMD in each cross product test, since - // some test might exit early. - - PfxVector3 lsqrs, projOffset, projAhalf; - - PfxMatrix3 crossProdMat = crossMatrix(capsDirection) * PfxMatrix3::identity(); - PfxMatrix3 crossProdMatT = crossMatrix(-capsDirection) * PfxMatrix3::identity(); - - lsqrs = mulPerElem( crossProdMatT.getCol0(), crossProdMatT.getCol0() ) + - mulPerElem( crossProdMatT.getCol1(), crossProdMatT.getCol1() ) + - mulPerElem( crossProdMatT.getCol2(), crossProdMatT.getCol2() ); - - projOffset = crossProdMatT * offsetAB; - projAhalf = absPerElem(crossProdMatT) * boxA.m_half; - - PfxVector3 gapsAxB = absPerElem(projOffset) - projAhalf; - - CrossAxisTest( 0, X ); - CrossAxisTest( 1, Y ); - CrossAxisTest( 2, Z ); - - // make axis point from box center towards capsule center. - - if ( dot(axisA,offsetAB) < 0.0f ) - axisA = -axisA; - - // find the face on box whose normal best matches the separating axis. will use the entire - // face only in degenerate cases. - // - // to make things simpler later, change the coordinate system so that the face normal is the z - // direction. if an edge cross product axis was chosen above, also align the box edge to the y - // axis. this saves the later tests from having to know which face was chosen. changing the - // coordinate system involves permuting vector elements, so construct a permutation matrix. - // I believe this is a faster way to permute a bunch of vectors than using arrays. - - int dimA[3]; - - if ( axisType == CROSS_AXIS ) { - PfxVector3 absAxisA = PfxVector3(absPerElem(axisA)); - - dimA[1] = edgeDimA; - - if ( edgeDimA == 0 ) { - if ( absAxisA[1] > absAxisA[2] ) { - dimA[0] = 2; - dimA[2] = 1; - } else { - dimA[0] = 1; - dimA[2] = 2; - } - } else if ( edgeDimA == 1 ) { - if ( absAxisA[2] > absAxisA[0] ) { - dimA[0] = 0; - dimA[2] = 2; - } else { - dimA[0] = 2; - dimA[2] = 0; - } - } else { - if ( absAxisA[0] > absAxisA[1] ) { - dimA[0] = 1; - dimA[2] = 0; - } else { - dimA[0] = 0; - dimA[2] = 1; - } - } - } else { - dimA[2] = faceDimA; - dimA[0] = (faceDimA+1)%3; - dimA[1] = (faceDimA+2)%3; - } - - PfxMatrix3 aperm_col; - - aperm_col.setCol0(ident[dimA[0]]); - aperm_col.setCol1(ident[dimA[1]]); - aperm_col.setCol2(ident[dimA[2]]); - - PfxMatrix3 aperm_row = transpose(aperm_col); - - // permute vectors to be in face coordinate system. - - PfxVector3 offsetAB_perm = aperm_row * offsetAB; - PfxVector3 halfA_perm = aperm_row * boxA.m_half; - PfxVector3 signsA_perm = copySignPerElem(PfxVector3(1.0f), aperm_row * axisA); - PfxVector3 scalesA_perm = mulPerElem( signsA_perm, halfA_perm ); - PfxVector3 capsDirection_perm = aperm_row * capsDirection; - PfxFloat signB = (-dot(capsDirection,axisA) > 0.0f)? 1.0f : -1.0f; - PfxFloat scaleB = signB * capsuleB.m_halfLen; - - // compute the vector between the center of the box face and the capsule center - - offsetAB_perm.setZ( offsetAB_perm.getZ() - scalesA_perm.getZ() ); - - // if box and capsule overlap, this will separate them for finding points of penetration. - - if ( maxGap < 0.0f ) { - offsetAB_perm -= aperm_row * axisA * maxGap * 1.01f; - } - - // for each vertex/face or edge/edge pair of box face and line segment, find the closest - // points. - // - // these points each have an associated feature (vertex, edge, or face). if each - // point is in the external Voronoi region of the other's feature, they are the - // closest points of the objects, and the algorithm can exit. - // - // the feature pairs are arranged so that in the general case, the first test will - // succeed. degenerate cases (line segment parallel to face) may require up to all tests - // in the worst case. - // - // if for some reason no case passes the Voronoi test, the features with the minimum - // distance are returned. - - PfxVector3 closestPtsVec_perm; - PfxPoint3 localPointA_perm; - PfxFloat minDistSqr; - PfxFloat segmentParamB; - PfxBool done; - - localPointA_perm.setZ( scalesA_perm.getZ() ); - scalesA_perm.setZ(0.0f); - - PfxVector3 hA_perm( halfA_perm ); - - int otherFaceDimA; - - if ( axisType == CROSS_AXIS ) { - EdgeEdgeTests( done, minDistSqr, closestPtsVec_perm, localPointA_perm, segmentParamB, - otherFaceDimA, - hA_perm, capsuleB.m_halfLen, offsetAB_perm, capsDirection_perm, signsA_perm, - scalesA_perm, true ); - - if ( !done ) { - VertexBFaceATests( done, minDistSqr, closestPtsVec_perm, localPointA_perm, segmentParamB, - hA_perm, offsetAB_perm, capsDirection_perm, signB, scaleB, false ); - } - } else { - VertexBFaceATests( done, minDistSqr, closestPtsVec_perm, localPointA_perm, segmentParamB, - hA_perm, offsetAB_perm, capsDirection_perm, signB, scaleB, true ); - - if ( !done ) { - EdgeEdgeTests( done, minDistSqr, closestPtsVec_perm, localPointA_perm, segmentParamB, - otherFaceDimA, - hA_perm, capsuleB.m_halfLen, offsetAB_perm, capsDirection_perm, signsA_perm, - scalesA_perm, false ); - } - } - - // compute normal - - PfxBool centerInside = ( signsA_perm.getZ() * closestPtsVec_perm.getZ() < 0.0f ); - - if ( centerInside || ( minDistSqr < lenSqrTol ) ) { - normal = matrixA * axisA; - } else { - PfxVector3 closestPtsVec = aperm_col * closestPtsVec_perm; - normal = matrixA * ( closestPtsVec * (1.0f/sqrtf( minDistSqr )) ); - } - - // compute box point - - pointA = PfxPoint3( aperm_col * PfxVector3( localPointA_perm ) ); - - // compute capsule point - - pointB = PfxPoint3( transpose(transformB.getUpper3x3()) * ( directionB * segmentParamB - normal * capsuleB.m_radius ) ); - - if ( centerInside ) { - return (-sqrtf( minDistSqr ) - capsuleB.m_radius); - } else { - return (sqrtf( minDistSqr ) - capsuleB.m_radius); - } -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.h deleted file mode 100644 index 72e8aa7fd..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_capsule.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_BOX_CAPSULE_H -#define _SCE_PFX_CONTACT_BOX_CAPSULE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactBoxCapsule( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_BOX_CAPSULE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.cpp deleted file mode 100644 index 82a015e02..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_box.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" -#include "pfx_contact_box_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -static const PfxFloat lenSqrTol = 1.0e-30f; - -inline -PfxFloat -VertexBFaceATest( - PfxVector3& ptsVec, - PfxFloat& t0, - PfxFloat& t1, - const PfxVector3& hA, - const PfxVector3 &offsetAB ) -{ - // compute center of sphere in box's coordinate system - - PfxVector3 cptsVec = PfxVector3(offsetAB); - - // compute the parameters of the point on the face - - t0 = cptsVec[0]; - t1 = cptsVec[1]; - - if ( t0 > hA[0] ) - t0 = hA[0]; - else if ( t0 < -hA[0] ) - t0 = -hA[0]; - if ( t1 > hA[1] ) - t1 = hA[1]; - else if ( t1 < -hA[1] ) - t1 = -hA[1]; - - cptsVec[0] -= t0; - cptsVec[1] -= t1; - - ptsVec = PfxVector3( cptsVec ); - - return dot(ptsVec,ptsVec); -} - -PfxFloat pfxContactBoxSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxBox &boxA = *((PfxBox*)shapeA); - PfxSphere &sphereB = *((PfxSphere*)shapeB); - - PfxVector3 ident[3] = { - PfxVector3(1.0,0.0,0.0), - PfxVector3(0.0,1.0,0.0), - PfxVector3(0.0,0.0,1.0), - }; - - //{ - // PfxMatrix3 identity = PfxMatrix3::identity(); - // ident[0] = identity.getCol0(); - // ident[1] = identity.getCol1(); - // ident[2] = identity.getCol2(); - //} - - // offsetAB is vector from A's center to B's center, in A's coordinate system - - PfxVector3 translationB = transformB.getTranslation(); - PfxVector3 offsetAB = transpose(transformA.getUpper3x3()) * ( translationB - - transformA.getTranslation() ); - - // find separating axis with largest gap between objects - - PfxVector3 axisA; - int faceDimA; - PfxFloat maxGap; - - PfxVector3 gapsA = absPerElem(offsetAB) - boxA.m_half - PfxVector3(sphereB.m_radius); - PfxVector3 signsA = copySignPerElem(PfxVector3(1.0f),offsetAB); - - { - PfxFloat gap = gapsA[0]; - - if( gap > distanceThreshold ) { - return gap; - } - - maxGap = gap; - faceDimA = 0; - axisA = mulPerElem( ident[0], signsA ); - - if( gap > maxGap ) { - maxGap = gap; - faceDimA = 0; - axisA = mulPerElem( ident[0], signsA ); - } - - gap = gapsA[1]; - - if( gap > distanceThreshold ) { - return gap; - } - - if( gap > maxGap ) { - maxGap = gap; - faceDimA = 1; - axisA = mulPerElem( ident[1], signsA ); - } - - gap = gapsA[2]; - - if( gap > distanceThreshold ) { - return gap; - } - - if( gap > maxGap ) { - maxGap = gap; - faceDimA = 2; - axisA = mulPerElem( ident[2], signsA ); - } - } - - // choose face in this direction, and make a new coordinate system which the z axis = face - // normal, x and y axes tangent to the face. to transform vectors into this coordinate - // system, will use a permutation matrix. - - int dimA[3]; - - dimA[2] = faceDimA; - dimA[0] = (faceDimA+1)%3; - dimA[1] = (faceDimA+2)%3; - - PfxMatrix3 apermCol; - - apermCol.setCol0(ident[dimA[0]]); - apermCol.setCol1(ident[dimA[1]]); - apermCol.setCol2(ident[dimA[2]]); - - PfxMatrix3 apermRow = transpose(apermCol); - - // permute vectors - - PfxVector3 halfA_perm = apermRow * boxA.m_half; - PfxVector3 offsetAB_perm = apermRow * offsetAB; - PfxVector3 signsA_perm = apermRow * signsA; - - // compute the vector between the center of the box face and the sphere center - - PfxFloat signA2 = signsA_perm.getZ(); - PfxFloat scaleA2 = halfA_perm.getZ() * signA2; - offsetAB_perm.setZ( offsetAB_perm.getZ() - scaleA2 ); - - // find point on face closest to sphere center - - PfxFloat t0, t1; - PfxFloat minDistSqr; - PfxVector3 closestPtsVec_perm; - PfxPoint3 localPointA_perm; - - minDistSqr = VertexBFaceATest( closestPtsVec_perm, t0, t1, PfxVector3( halfA_perm ), offsetAB_perm ); - - //SCE_PFX_PRINTF("faceDimA %d dimA %d %d %d\n",faceDimA,dimA[0],dimA[1],dimA[2]); - //SCE_PFX_PRINTF("boxA.m_half %f %f %f\n",boxA.m_half[0],boxA.m_half[1],boxA.m_half[2]); - //SCE_PFX_PRINTF("ident %f %f %f | %f %f %f | %f %f %f\n", - // ident[0][0],ident[0][1],ident[0][2], - // ident[1][0],ident[1][1],ident[1][2], - // ident[2][0],ident[2][1],ident[2][2]); - //SCE_PFX_PRINTF("apermCol %f %f %f | %f %f %f | %f %f %f\n", - // apermCol[0][0],apermCol[0][1],apermCol[0][2], - // apermCol[1][0],apermCol[1][1],apermCol[1][2], - // apermCol[2][0],apermCol[2][1],apermCol[2][2]); - //SCE_PFX_PRINTF("apermRow %f %f %f | %f %f %f | %f %f %f\n", - // apermRow[0][0],apermRow[0][1],apermRow[0][2], - // apermRow[1][0],apermRow[1][1],apermRow[1][2], - // apermRow[2][0],apermRow[2][1],apermRow[2][2]); - - //SCE_PFX_PRINTF("closestPtsVec_perm %f %f %f\n",closestPtsVec_perm[0],closestPtsVec_perm[1],closestPtsVec_perm[2]); - //SCE_PFX_PRINTF("halfA_perm %f %f %f\n",halfA_perm[0],halfA_perm[1],halfA_perm[2]); - //SCE_PFX_PRINTF("offsetAB_perm %f %f %f\n",offsetAB_perm[0],offsetAB_perm[1],offsetAB_perm[2]); - //SCE_PFX_PRINTF("t0 %f t1 %f scaleA2 %f\n",t0,t1,scaleA2); - - //SCE_PFX_PRINTF("minDistSqr %f sphereB.m_radius %f\n",minDistSqr,sphereB.m_radius); - - localPointA_perm = PfxPoint3( t0, t1, scaleA2 ); - - // compute normal - - bool centerInside = ( signA2 * closestPtsVec_perm.getZ() < 0.0f ); - - if ( centerInside || ( minDistSqr < lenSqrTol ) ) { - normal = transformA * axisA; - } else { - PfxVector3 closestPtsVec = apermCol * closestPtsVec_perm; - normal = transformA * ( closestPtsVec * ( 1.0f / sqrtf( minDistSqr ) ) ); - } - - // compute box point - - pointA = PfxPoint3( apermCol * PfxVector3( localPointA_perm ) ); - - // compute sphere point - - pointB = PfxPoint3( transpose(transformB.getUpper3x3()) * ( -normal * sphereB.m_radius ) ); - - // return distance - - //SCE_PFX_PRINTF("normal %f %f %f\n",(float)normal[0],(float)normal[1],(float)normal[2]); - //SCE_PFX_PRINTF("pointA %f %f %f\n",(float)pointA[0],(float)pointA[1],(float)pointA[2]); - //SCE_PFX_PRINTF("pointB %f %f %f\n",(float)pointB[0],(float)pointB[1],(float)pointB[2]); - - if ( centerInside ) { - return -sqrtf( minDistSqr ) - sphereB.m_radius; - } else { - return sqrtf( minDistSqr ) - sphereB.m_radius; - } -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.h deleted file mode 100644 index 24279d14a..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_box_sphere.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_BOX_SPHERE_H -#define _SCE_PFX_CONTACT_BOX_SPHERE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactBoxSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_BOXSPHERE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.cpp deleted file mode 100644 index 24e945e73..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_CONTACT_SAME_POINT 0.01f - -int PfxContactCache::findNearestContactPoint(const PfxPoint3 &newPoint,const PfxVector3 &newNormal) -{ - int nearestIdx = -1; - PfxFloat minDiff = SCE_PFX_CONTACT_SAME_POINT; - for(PfxUInt32 i=0;i 0.99f) { - minDiff = diff; - nearestIdx = i; - } - } - return nearestIdx; -} - -int PfxContactCache::sort4ContactPoints(const PfxPoint3 &newCP,PfxFloat newDistance) -{ - int maxPenetrationIndex = -1; - PfxFloat maxPenetration = newDistance; - - // 最も深ã„è¡çªç‚¹ã¯æŽ’除対象ã‹ã‚‰ã¯ãšã™ - for(int i=0;i maxVal) { - maxIndex = 1; - maxVal = res[1]; - } - - if (res[2] > maxVal) { - maxIndex = 2; - maxVal = res[2]; - } - - if (res[3] > maxVal) { - maxIndex = 3; - maxVal = res[3]; - } - - return maxIndex; -} - -void PfxContactCache::addContactPoint( - PfxFloat newDistance, - const PfxVector3 &newNormal, // world coords - const PfxPoint3 &newPointA, // local to the objectA - const PfxPoint3 &newPointB, // local to the objectB - PfxSubData subData) -{ - int id = findNearestContactPoint(newPointA,newNormal); - - if(id < 0 && m_numContacts < SCE_PFX_MAX_CACHED_CONTACT_POINTS) { - // è¡çªç‚¹ã‚’æ–°è¦è¿½åŠ  - id = m_numContacts++; - m_cachedContactPoints[id].reset(); - } - else if(id < 0){ - // ソート - id = sort4ContactPoints(newPointA,newDistance); - m_cachedContactPoints[id].reset(); - } - - m_cachedContactPoints[id].m_distance = newDistance; - m_cachedContactPoints[id].m_subData = subData; - m_cachedContactPoints[id].m_normal = newNormal; - m_cachedContactPoints[id].m_localPointA = newPointA; - m_cachedContactPoints[id].m_localPointB = newPointB; -} - -void PfxContactCache::addContactPoint(const PfxCachedContactPoint &cp) -{ - PfxPoint3 pA = cp.m_localPointA; - - int id = findNearestContactPoint(pA,cp.m_normal); - - if(id >= 0) { - if(m_cachedContactPoints[id].m_distance > cp.m_distance) { - // åŒä¸€ç‚¹ã‚’発見ã€è¡çªç‚¹æƒ…報を更新 - m_cachedContactPoints[id].m_distance = cp.m_distance; - m_cachedContactPoints[id].m_normal = cp.m_normal; - m_cachedContactPoints[id].m_localPointA = cp.m_localPointA; - m_cachedContactPoints[id].m_localPointB = cp.m_localPointB; - } - } - else if(m_numContacts < SCE_PFX_MAX_CACHED_CONTACT_POINTS) { - // è¡çªç‚¹ã‚’æ–°è¦è¿½åŠ  - m_cachedContactPoints[m_numContacts++] = cp; - } - else { - // ソート - id = sort4ContactPoints(pA,cp.m_distance); - - // コンタクトãƒã‚¤ãƒ³ãƒˆå…¥ã‚Œæ›¿ãˆ - m_cachedContactPoints[id] = cp; - } -} - -} //namespace PhysicsEffects -} //namespace sce - diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.h deleted file mode 100644 index 5093b7974..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_cache.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_CACHE_H -#define _SCE_PFX_CONTACT_CACHE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sub_data.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_MAX_CACHED_CONTACT_POINTS 4 - -/* - 内部ã®è¡çªåˆ¤å®šã«ä½¿ã†è»½é‡ãªã‚³ãƒ³ã‚¿ã‚¯ãƒˆã‚­ãƒ£ãƒƒã‚·ãƒ¥ -*/ - -/////////////////////////////////////////////////////////////////////////////// -// Contact Point - -struct PfxCachedContactPoint -{ - PfxSubData m_subData; - PfxUInt8 m_shapeIdA; - PfxUInt8 m_shapeIdB; - SCE_PFX_PADDING(1,2) - PfxFloat m_distance; - PfxVector3 m_normal; - PfxPoint3 m_localPointA; - PfxPoint3 m_localPointB; - - void reset() - { - m_shapeIdA = m_shapeIdB = 0; - m_subData = PfxSubData(); - m_distance = SCE_PFX_FLT_MAX; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// Contact Point - -class PfxContactCache -{ -private: - PfxUInt32 m_numContacts; - SCE_PFX_PADDING(1,12) - PfxCachedContactPoint m_cachedContactPoints[SCE_PFX_MAX_CACHED_CONTACT_POINTS]; - - int findNearestContactPoint(const PfxPoint3 &newPoint,const PfxVector3 &newNormal); - int sort4ContactPoints(const PfxPoint3 &newPoint,PfxFloat newDistance); - -public: - PfxContactCache() : m_numContacts(0) {} - - void addContactPoint( - PfxFloat newDistance, - const PfxVector3 &newNormal, // world normal vector - const PfxPoint3 &newPointA, // local contact point to the objectA - const PfxPoint3 &newPointB, // local contact point to the objectB - PfxSubData m_subData); - - void addContactPoint(const PfxCachedContactPoint &cp); - - int getNumContacts() const {return (int)m_numContacts;} - - PfxCachedContactPoint &getContactPoint(int i) {return m_cachedContactPoints[i];} - - const PfxCachedContactPoint &getContactPoint(int i) const {return m_cachedContactPoints[i];} - - PfxFloat getDistance(int i) {return m_cachedContactPoints[i].m_distance;} - - const PfxVector3 &getNormal(int i) const {return m_cachedContactPoints[i].m_normal;} - - const PfxPoint3 &getLocalPointA(int i) const {return m_cachedContactPoints[i].m_localPointA;} - - const PfxPoint3 &getLocalPointB(int i) const {return m_cachedContactPoints[i].m_localPointB;} - - const PfxSubData &getSubData(int i) const {return m_cachedContactPoints[i].m_subData;} -}; - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_CACHE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.cpp deleted file mode 100644 index e4e07eedb..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" -#include "pfx_contact_capsule_capsule.h" - -namespace sce { -namespace PhysicsEffects { - -inline -void -segmentsClosestPoints( - PfxVector3& ptsVector, - PfxVector3& offsetA, - PfxVector3& offsetB, - PfxFloat& tA, PfxFloat& tB, - const PfxVector3 &translation, - const PfxVector3 &dirA, PfxFloat hlenA, - const PfxVector3 &dirB, PfxFloat hlenB ) -{ - // compute the parameters of the closest points on each line segment - - PfxFloat dirA_dot_dirB = dot(dirA,dirB); - PfxFloat dirA_dot_trans = dot(dirA,translation); - PfxFloat dirB_dot_trans = dot(dirB,translation); - - PfxFloat denom = 1.0f - dirA_dot_dirB * dirA_dot_dirB; - - if ( denom == 0.0f ) { - tA = 0.0f; - } else { - tA = ( dirA_dot_trans - dirB_dot_trans * dirA_dot_dirB ) / denom; - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } - - tB = tA * dirA_dot_dirB - dirB_dot_trans; - - if ( tB < -hlenB ) { - tB = -hlenB; - tA = tB * dirA_dot_dirB + dirA_dot_trans; - - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } else if ( tB > hlenB ) { - tB = hlenB; - tA = tB * dirA_dot_dirB + dirA_dot_trans; - - if ( tA < -hlenA ) - tA = -hlenA; - else if ( tA > hlenA ) - tA = hlenA; - } - - // compute the closest points relative to segment centers. - - offsetA = dirA * tA; - offsetB = dirB * tB; - - ptsVector = translation - offsetA + offsetB; -} - -inline -void -segmentsNormal( PfxVector3& normal, const PfxVector3 &ptsVector ) -{ - // compute the unit direction vector between the closest points. - // with convex objects, you want the unit direction providing the largest gap between the - // objects when they're projected onto it. So, if you have a few candidates covering different - // configurations of the objects, you can compute them all, test the gaps and pick best axis - // based on this. Some directions might be degenerate, and the normalized() function tests for - // degeneracy and returns an arbitrary unit vector in that case. - - PfxVector3 testDir; - - // closest points vector - - normal = pfxSafeNormalize(ptsVector); -} - -PfxFloat pfxContactCapsuleCapsule( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxCapsule &capsuleA = *((PfxCapsule*)shapeA); - PfxCapsule &capsuleB = *((PfxCapsule*)shapeB); - - PfxVector3 directionA = transformA.getUpper3x3().getCol0(); - PfxVector3 translationA = transformA.getTranslation(); - PfxVector3 directionB = transformB.getUpper3x3().getCol0(); - PfxVector3 translationB = transformB.getTranslation(); - - // translation between centers - - PfxVector3 translation = translationB - translationA; - - // compute the closest points of the capsule line segments - - PfxVector3 ptsVector; // the vector between the closest points - PfxVector3 offsetA, offsetB; // offsets from segment centers to their closest points - PfxFloat tA, tB; // parameters on line segment - - segmentsClosestPoints( ptsVector, offsetA, offsetB, tA, tB, translation, - directionA, capsuleA.m_halfLen, directionB, capsuleB.m_halfLen ); - - PfxFloat distance = length(ptsVector) - capsuleA.m_radius - capsuleB.m_radius; - - if ( distance > distanceThreshold ) - return distance; - - // compute the contact normal - - segmentsNormal( normal, ptsVector ); - - // compute points on capsules - - pointA = PfxPoint3( transpose(transformA.getUpper3x3()) * ( offsetA + normal * capsuleA.m_radius ) ); - pointB = PfxPoint3( transpose(transformB.getUpper3x3()) * ( offsetB - normal * capsuleB.m_radius ) ); - - return distance; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.h deleted file mode 100644 index 744e7a014..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_capsule.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_CAPSULE_CAPSULE_H -#define _SCE_PFX_CONTACT_CAPSULE_CAPSULE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactCapsuleCapsule( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_CAPSULE_CAPSULE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.cpp deleted file mode 100644 index 7102ac0dd..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" -#include "pfx_contact_capsule_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -inline -void -segmentPointClosestPoints( - PfxVector3& ptsVector, - PfxVector3& offsetA, - PfxFloat& tA, - const PfxVector3 &translation, - const PfxVector3 &dirA, PfxFloat hLenA ) -{ - // compute the parameters of the closest points on each line segment - - tA = dot(dirA,translation); - - if ( tA < -hLenA ) - tA = -hLenA; - else if ( tA > hLenA ) - tA = hLenA; - - // compute the closest point on segment relative to its center. - - offsetA = dirA * tA; - ptsVector = translation - offsetA; -} - -inline -void -segmentPointNormal( PfxVector3& normal, const PfxVector3 &ptsVector ) -{ - // compute the unit direction vector between the closest points. - // with convex objects, you want the unit direction providing the largest gap between the - // objects when they're projected onto it. So, if you have a few candidates covering different - // configurations of the objects, you can compute them all, test the gaps and pick best axis - // based on this. Some directions might be degenerate, and the normalized() function tests for - // degeneracy and returns an arbitrary unit vector in that case. - - // closest points vector - - normal = pfxSafeNormalize(ptsVector); -} - -PfxFloat pfxContactCapsuleSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxCapsule &capsuleA = *((PfxCapsule*)shapeA); - PfxSphere &sphereB = *((PfxSphere*)shapeB); - - PfxVector3 directionA = transformA.getUpper3x3().getCol0(); - PfxVector3 translationA = transformA.getTranslation(); - PfxVector3 translationB = transformB.getTranslation(); - - // translation between centers of capsule and sphere - - PfxVector3 translation = translationB - translationA; - - // compute the closest point on the capsule line segment to the sphere center - - PfxVector3 ptsVector; - PfxVector3 offsetA; - PfxFloat tA; - - segmentPointClosestPoints( ptsVector, offsetA, tA, translation, directionA, capsuleA.m_halfLen ); - - PfxFloat distance = length(ptsVector) - capsuleA.m_radius - sphereB.m_radius; - - if ( distance > distanceThreshold ) - return distance; - - // compute the contact normal - - segmentPointNormal( normal, ptsVector ); - - // compute points on capsule and sphere - - pointA = PfxPoint3( transpose(transformA.getUpper3x3()) * ( offsetA + normal * capsuleA.m_radius ) ); - pointB = PfxPoint3( transpose(transformB.getUpper3x3()) * ( -normal * sphereB.m_radius ) ); - - return distance; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.h deleted file mode 100644 index 653a8e4fa..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_capsule_sphere.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_CAPSULE_SPHERE_H -#define _SCE_PFX_CONTACT_CAPSULE_SPHERE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactCapsuleSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_CAPSULE_SPHERE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_large_tri_mesh.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_large_tri_mesh.cpp deleted file mode 100644 index 764a738d3..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_large_tri_mesh.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_sphere.h" -#include "pfx_contact_tri_mesh_box.h" -#include "pfx_contact_tri_mesh_capsule.h" -#include "pfx_contact_tri_mesh_cylinder.h" -#include "pfx_contact_tri_mesh_convex.h" -#include "pfx_contact_large_tri_mesh.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" - - -namespace sce { -namespace PhysicsEffects { - - -PfxInt32 pfxContactLargeTriMesh( - PfxContactCache &contacts, - const PfxLargeTriMesh *lmeshA, - const PfxTransform3 &transformA, - const PfxShape &shapeB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxTransform3 transformAB; - PfxMatrix3 matrixAB; - PfxVector3 offsetAB; - - // Bローカル→Aローカルã¸ã®å¤‰æ› - transformAB = orthoInverse(transformA) * transformB; - matrixAB = transformAB.getUpper3x3(); - offsetAB = transformAB.getTranslation(); - - // ----------------------------------------------------- - // LargeTriMeshã«å«ã¾ã‚Œã‚‹TriMeshã®AABBã¨å‡¸ä½“ã®AABBを判定ã—〠- // 交差ã™ã‚‹ã‚‚ã®ã‚’個別ã«è¡çªåˆ¤å®šã™ã‚‹ã€‚※LargeMesh座標系 - - PfxVector3 shapeHalf(0.0f); - PfxVector3 shapeCenter = offsetAB; - - - switch(shapeB.getType()) { - case kPfxShapeSphere: - shapeHalf = PfxVector3(shapeB.getSphere().m_radius); - break; - - case kPfxShapeCapsule: - { - PfxCapsule capsule = shapeB.getCapsule(); - shapeHalf = absPerElem(matrixAB) * PfxVector3(capsule.m_halfLen+capsule.m_radius,capsule.m_radius,capsule.m_radius); - } - break; - - case kPfxShapeCylinder: - { - PfxCylinder cylinder = shapeB.getCylinder(); - shapeHalf = absPerElem(matrixAB) * PfxVector3(cylinder.m_halfLen,cylinder.m_radius,cylinder.m_radius); - } - break; - - case kPfxShapeBox: - shapeHalf = absPerElem(matrixAB) * shapeB.getBox().m_half; - break; - - case kPfxShapeConvexMesh: - shapeHalf = absPerElem(matrixAB) * shapeB.getConvexMesh()->m_half; - break; - - default: - break; - } - - // ----------------------------------------------------- - // アイランドã¨ã®è¡çªåˆ¤å®š - - PfxVecInt3 aabbMinL,aabbMaxL; - lmeshA->getLocalPosition((shapeCenter-shapeHalf),(shapeCenter+shapeHalf),aabbMinL,aabbMaxL); - - PfxUInt32 numIslands = lmeshA->m_numIslands; - - { - for(PfxUInt32 i=0;im_aabbList[i]; - if(aabbMaxL.getX() < pfxGetXMin(aabbB) || aabbMinL.getX() > pfxGetXMax(aabbB)) continue; - if(aabbMaxL.getY() < pfxGetYMin(aabbB) || aabbMinL.getY() > pfxGetYMax(aabbB)) continue; - if(aabbMaxL.getZ() < pfxGetZMin(aabbB) || aabbMinL.getZ() > pfxGetZMax(aabbB)) continue; - - PfxTriMesh *island = &lmeshA->m_islands[i]; - - // è¡çªåˆ¤å®š - PfxContactCache localContacts; - switch(shapeB.getType()) { - case kPfxShapeSphere: - pfxContactTriMeshSphere(localContacts,island,transformA,shapeB.getSphere(),transformB,distanceThreshold); - break; - - case kPfxShapeCapsule: - pfxContactTriMeshCapsule(localContacts,island,transformA,shapeB.getCapsule(),transformB,distanceThreshold); - break; - - case kPfxShapeBox: - pfxContactTriMeshBox(localContacts,island,transformA,shapeB.getBox(),transformB,distanceThreshold); - break; - - case kPfxShapeCylinder: - pfxContactTriMeshCylinder(localContacts,island,transformA,shapeB.getCylinder(),transformB,distanceThreshold); - break; - - case kPfxShapeConvexMesh: - pfxContactTriMeshConvex(localContacts,island,transformA,*shapeB.getConvexMesh(),transformB,distanceThreshold); - break; - - default: - break; - } - - - // è¡çªç‚¹ã‚’追加 - for(int j=0;j 0.99f) { - minDiff = diff; - nearestIdx = i; - } - } - return nearestIdx; -} - -int PfxContactManifold::sort4ContactPoints(const PfxPoint3 &newCP,PfxFloat newDistance) -{ - int maxPenetrationIndex = -1; - PfxFloat maxPenetration = newDistance; - - // 最も深ã„è¡çªç‚¹ã¯æŽ’除対象ã‹ã‚‰ã¯ãšã™ - for(int i=0;i maxVal) { - maxIndex = 1; - maxVal = res[1]; - } - - if (res[2] > maxVal) { - maxIndex = 2; - maxVal = res[2]; - } - - if (res[3] > maxVal) { - maxIndex = 3; - maxVal = res[3]; - } - - return maxIndex; -} - -void PfxContactManifold::addContactPoint( - PfxFloat newDistance, - const PfxVector3 &newNormal, // world coords - const PfxPoint3 &newPointA, // local to the objectA - const PfxPoint3 &newPointB, // local to the objectB - PfxSubData subData) -{ - int id = findNearestContactPoint(newPointA,newNormal); - - if(id < 0 && m_numContacts < SCE_PFX_NUMCONTACTS_PER_BODIES) { - // è¡çªç‚¹ã‚’æ–°è¦è¿½åŠ  - id = m_numContacts++; - m_contactPoints[id].reset(); - } - else if(id < 0){ - // ソート - id = sort4ContactPoints(newPointA,newDistance); - m_contactPoints[id].reset(); - } - - m_contactPoints[id].m_distance = newDistance; - m_contactPoints[id].m_subData = subData; - pfxStorePoint3(newPointA,m_contactPoints[id].m_localPointA); - pfxStorePoint3(newPointB,m_contactPoints[id].m_localPointB); - pfxStoreVector3(newNormal,m_contactPoints[id].m_constraintRow[0].m_normal); -} - -void PfxContactManifold::addContactPoint(const PfxContactPoint &cp) -{ - PfxPoint3 pA = pfxReadPoint3(cp.m_localPointA); - - int id = findNearestContactPoint(pA,pfxReadVector3(cp.m_constraintRow[0].m_normal)); - - if(id >= 0) { -#if 1 - PfxVector3 nml1(pfxReadVector3(m_contactPoints[id].m_constraintRow[0].m_normal)); - PfxVector3 nml2(pfxReadVector3(cp.m_constraintRow[0].m_normal)); - if(fabsf(dot(nml1,nml2)) > 0.99f ) { - // åŒä¸€ç‚¹ã‚’発見ã€è“„ç©ã•ã‚ŒãŸæƒ…報を継続 - m_contactPoints[id].m_distance = cp.m_distance; - m_contactPoints[id].m_localPointA[0] = cp.m_localPointA[0]; - m_contactPoints[id].m_localPointA[1] = cp.m_localPointA[1]; - m_contactPoints[id].m_localPointA[2] = cp.m_localPointA[2]; - m_contactPoints[id].m_localPointB[0] = cp.m_localPointB[0]; - m_contactPoints[id].m_localPointB[1] = cp.m_localPointB[1]; - m_contactPoints[id].m_localPointB[2] = cp.m_localPointB[2]; - m_contactPoints[id].m_constraintRow[0].m_normal[0] = cp.m_constraintRow[0].m_normal[0]; - m_contactPoints[id].m_constraintRow[0].m_normal[1] = cp.m_constraintRow[0].m_normal[1]; - m_contactPoints[id].m_constraintRow[0].m_normal[2] = cp.m_constraintRow[0].m_normal[2]; - } - else { - // åŒä¸€ç‚¹ã§ã¯ã‚ã‚‹ãŒæ³•ç·šãŒé•ã†ãŸã‚æ›´æ–° - m_contactPoints[id] = cp; - } -#else - if(m_contactPoints[id].m_distance > cp.m_distance) { - // åŒä¸€ç‚¹ã‚’発見ã€è¡çªç‚¹æƒ…報を更新 - m_contactPoints[id].m_distance = cp.m_distance; - m_contactPoints[id].m_localPointA[0] = cp.m_localPointA[0]; - m_contactPoints[id].m_localPointA[1] = cp.m_localPointA[1]; - m_contactPoints[id].m_localPointA[2] = cp.m_localPointA[2]; - m_contactPoints[id].m_localPointB[0] = cp.m_localPointB[0]; - m_contactPoints[id].m_localPointB[1] = cp.m_localPointB[1]; - m_contactPoints[id].m_localPointB[2] = cp.m_localPointB[2]; - m_contactPoints[id].m_constraintRow[0].m_normal[0] = cp.m_constraintRow[0].m_normal[0]; - m_contactPoints[id].m_constraintRow[0].m_normal[1] = cp.m_constraintRow[0].m_normal[1]; - m_contactPoints[id].m_constraintRow[0].m_normal[2] = cp.m_constraintRow[0].m_normal[2]; - } -#endif - } - else if(m_numContacts < SCE_PFX_NUMCONTACTS_PER_BODIES) { - // è¡çªç‚¹ã‚’æ–°è¦è¿½åŠ  - m_contactPoints[m_numContacts++] = cp; - } - else { - // ソート - id = sort4ContactPoints(pA,cp.m_distance); - - // コンタクトãƒã‚¤ãƒ³ãƒˆå…¥ã‚Œæ›¿ãˆ - m_contactPoints[id] = cp; - } -} - -void PfxContactManifold::merge(const PfxContactManifold &contact) -{ - SCE_PFX_ALWAYS_ASSERT(m_rigidBodyIdA == contact.getRigidBodyIdA()); - SCE_PFX_ALWAYS_ASSERT(m_rigidBodyIdB == contact.getRigidBodyIdB()); - - for(int i=0;i 0) { - PfxVector3 normal = pfxReadVector3(m_contactPoints[i].m_constraintRow[0].m_normal); - PfxVector3 cpA = pA + rotate(qA,pfxReadVector3(m_contactPoints[i].m_localPointA)); - PfxVector3 cpB = pB + rotate(qB,pfxReadVector3(m_contactPoints[i].m_localPointB)); - - // 貫通深度ãŒãƒ—ラスã«è»¢ã˜ãŸã‹ã©ã†ã‹ã‚’ãƒã‚§ãƒƒã‚¯ - PfxFloat distance = dot(normal,(cpA - cpB)); - if(distance > SCE_PFX_CONTACT_THRESHOLD_NORMAL) { - removeContactPoint(i); - i--; - continue; - } - m_contactPoints[i].m_distance = distance; - - // 深度方å‘を除去ã—ã¦ä¸¡ç‚¹ã®è·é›¢ã‚’ãƒã‚§ãƒƒã‚¯ - cpA = cpA - m_contactPoints[i].m_distance * normal; - PfxFloat distanceAB = lengthSqr(cpA - cpB); - if(distanceAB > SCE_PFX_CONTACT_THRESHOLD_TANGENT) { - removeContactPoint(i); - i--; - continue; - } - } - if(m_contactPoints[i].m_duration < 255) m_contactPoints[i].m_duration++; - } - if(m_numContacts > 0 && m_duration < 65535) m_duration++; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.cpp deleted file mode 100644 index f55f09660..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" -#include "pfx_contact_sphere_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -const PfxFloat lenSqrTol = 1.0e-30f; - -PfxFloat pfxContactSphereSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - PfxSphere &sphereA = *((PfxSphere*)shapeA); - PfxSphere &sphereB = *((PfxSphere*)shapeB); - - PfxVector3 direction(0.0f); - - PfxVector3 translationA = transformA.getTranslation(); - PfxVector3 translationB = transformB.getTranslation(); - - // get the offset vector between sphere centers - - PfxVector3 offsetAB; - - offsetAB = translationB - translationA; - - // normalize the offset to compute the direction vector - - PfxFloat distSqr = dot(offsetAB,offsetAB); - PfxFloat dist = sqrtf(distSqr); - PfxFloat sphereDist = dist - sphereA.m_radius - sphereB.m_radius; - - if ( sphereDist > distanceThreshold ) { - return sphereDist; - } - - if ( distSqr > lenSqrTol ) { - PfxFloat distInv = 1.0f / dist; - - direction = offsetAB * distInv; - } else { - direction = PfxVector3(0.0f, 0.0f, 1.0f); - } - - normal = direction; - - // compute the points on the spheres, in world space - - pointA = PfxPoint3( transpose(transformA.getUpper3x3()) * ( direction * sphereA.m_radius ) ); - pointB = PfxPoint3( transpose(transformB.getUpper3x3()) * ( -direction * sphereB.m_radius ) ); - - // return the distance between the spheres - - return sphereDist; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.h deleted file mode 100644 index 03def3598..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_sphere_sphere.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_SPHERE_SPHERE_H -#define _SCE_PFX_CONTACT_SPHERE_SPHERE_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -namespace sce { -namespace PhysicsEffects { - -PfxFloat pfxContactSphereSphere( - PfxVector3 &normal,PfxPoint3 &pointA,PfxPoint3 &pointB, - void *shapeA,const PfxTransform3 &transformA, - void *shapeB,const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_SPHERE_SPHERE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.cpp deleted file mode 100644 index 199d762ea..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_box.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" - -namespace sce { -namespace PhysicsEffects { - -static SCE_PFX_FORCE_INLINE -bool checkSAT(const PfxVector3 &axis,PfxFloat AMin,PfxFloat AMax,PfxFloat BMin,PfxFloat BMax,PfxFloat &distMin,PfxVector3 &axisMin) -{ - // â–  éžæŽ¥è§¦. - - // A: +----+ - // B:+----+ - if(BMax <= AMin) { - return true; - } - - // A:+----+ - // B: +----+ - else if(AMax <= BMin) { - return true; - } - - // â–  内包 - - //A: +--+ - //B: +------+ - if(BMin < AMin && AMax < BMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - //A: +------+ - //B: +--+ - else if(AMin < BMin && BMax < AMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - // â–  接触 - - // A: +----+ - // B:+----+ - else if(BMin < AMin && AMin < BMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - // A: +----+ - // B: +----+ - else if(AMin < BMin && BMin < AMax) { - PfxFloat d = BMin-AMax; - if(distMin < d) { - distMin = d; - axisMin = -axis; - } - } - - return false; -} - -static SCE_PFX_FORCE_INLINE -bool pfxContactTriangleBox(PfxContactCache &contacts,PfxUInt32 facetId, - const PfxVector3 &normal,const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2, - const PfxFloat thickness,const PfxFloat angle0,const PfxFloat angle1,const PfxFloat angle2, - PfxUInt32 edgeChk, - const PfxVector3 &boxHalf) -{ - const PfxFloat epsilon = 0.00001f; - - // 最も浅ã„貫通深度ã¨ãã®ã¨ãã®åˆ†é›¢è»¸ - PfxFloat distMin = -SCE_PFX_FLT_MAX; - PfxVector3 axisMin(0.0f); - - //------------------------------------------- - // 1.分離軸判定 - { - PfxVector3 facetPnts[6] = { - p0,p1,p2,p0-thickness*normal,p1-thickness*normal,p2-thickness*normal - }; - - PfxVector3 sideNml[3] = { - normalize(cross((facetPnts[1] - facetPnts[0]),normal)), - normalize(cross((facetPnts[2] - facetPnts[1]),normal)), - normalize(cross((facetPnts[0] - facetPnts[2]),normal)), - }; - - - // Trianglesã®é¢ -> Box - { - // 分離軸 - const PfxVector3 sepAxis = normal; - - // åˆ†é›¢å¹³é¢ - PfxPlane planeA(sepAxis,p0); - - // Boxã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat r = dot(boxHalf,absPerElem(sepAxis)); - PfxFloat boxOffset = planeA.onPlane(PfxVector3(0.0f)); - PfxFloat boxMax = boxOffset + r; - PfxFloat boxMin = boxOffset - r; - - // 判定 - if(boxMin > 0.0f || boxMax < -thickness) { - return false; - } - - if(distMin < boxMin) { - distMin = boxMin; - axisMin = -sepAxis; - } - } - - // Box -> Triangles - for(int bf=0;bf<3;bf++) { - // 分離軸 - PfxVector3 sepAxis(0.0f); - sepAxis[bf] = 1.0f; - - // åˆ†é›¢è»¸ã®æ–¹å‘ã‚’ãƒã‚§ãƒƒã‚¯ - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Trianglesã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat triMin,triMax; - pfxGetProjAxisPnts6(facetPnts,sepAxis,triMin,triMax); - - // Boxã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat boxMin = -boxHalf[bf]; - PfxFloat boxMax = boxHalf[bf]; - - if(checkSAT(sepAxis,triMin,triMax,boxMin,boxMax,distMin,axisMin)) { - return false; - } - } - - // エッジ Trianglesé¢ã®ã‚¨ãƒƒã‚¸(x3)×Boxã®ã‚¨ãƒƒã‚¸(x3) - for(int e=0;e<3;e++) { - PfxVector3 dir = normalize(facetPnts[(e+1)%3] - facetPnts[e]); - - for(int i=0;i<3;i++) { - PfxVector3 boxEdge(0.0f); - boxEdge[i] = 1.0f; - - // エッジãŒå¹³è¡Œã§ã‚れã°åˆ¤å®šã—ãªã„ - if(pfxIsSameDirection(dir,boxEdge)) continue; - - PfxVector3 sepAxis = normalize(cross(dir,boxEdge)); - - // åˆ†é›¢è»¸ã®æ–¹å‘ã‚’ãƒã‚§ãƒƒã‚¯ - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Trianglesã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat triMin,triMax; - pfxGetProjAxisPnts6(facetPnts,sepAxis,triMin,triMax); - - // Boxã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat r = dot(boxHalf,absPerElem(sepAxis)); - PfxFloat boxMin = -r; - PfxFloat boxMax = r; - - if(checkSAT(sepAxis,triMin,triMax,boxMin,boxMax,distMin,axisMin)) { - return false; - } - } - } - - // é¢ã«åŽšã¿ãŒã‚ã‚‹å ´åˆã®è£œåŠ©çš„ãªåˆ¤å®šï¼ˆäº¤å·®ã™ã‚‹ã‹ã—ãªã„ã‹ã ã‘を判定) - if(thickness > 0.0f) { - // 厚ã¿å´é¢ã®æ³•ç·š - for(int i=0;i<3;i++) { - // åˆ†é›¢å¹³é¢ - PfxPlane planeA(sideNml[i],facetPnts[i]); - - // Boxã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat r = dot(boxHalf,absPerElem(sideNml[i])); - PfxFloat boxOffset = planeA.onPlane(PfxVector3(0.0f)); - PfxFloat boxMin = boxOffset - r; - - if(boxMin > 0.0f) { - return false; - } - } - - // ï¼’ã¤ã®åŽšã¿å´é¢ã®ãªã™ã‚¨ãƒƒã‚¸3×ボックスã®ã‚¨ãƒƒã‚¸3 - for(int e=0;e<3;e++) { - PfxVector3 edgeVec = normalize(cross(sideNml[(e+1)%3],sideNml[e])); - - for(int i=0;i<3;i++) { - PfxVector3 boxEdge(0.0f); - boxEdge[i] = 1.0f; - - // エッジãŒå¹³è¡Œã§ã‚れã°åˆ¤å®šã—ãªã„ - if(pfxIsSameDirection(edgeVec,boxEdge)) continue; - - PfxVector3 sepAxis = normalize(cross(edgeVec,boxEdge)); - - // Trianglesã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat triMin,triMax; - pfxGetProjAxisPnts3(facetPnts,sepAxis,triMin,triMax); - - // Boxã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat r = dot(boxHalf,absPerElem(sepAxis)); - PfxFloat boxMin = -r; - PfxFloat boxMax = r; - - if(triMax < boxMin || boxMax < triMin) { - return false; - } - } - } - } - } - - //------------------------------------------- - // 2.è¡çªç‚¹ã®æŽ¢ç´¢ - { - // 分離軸方å‘ã«å¼•ã離ã™(最近接を判定ã™ã‚‹ãŸã‚ã€äº¤å·®å›žé¿ã•ã›ã‚‹) - PfxVector3 sepAxis = 1.1f * fabsf(distMin) * axisMin; - - const PfxVector3 facetPnts[3] = { - p0 + sepAxis, - p1 + sepAxis, - p2 + sepAxis, - }; - - const PfxVector3 boxPnts[8] = { - mulPerElem(PfxVector3(-1.0f,-1.0f,-1.0f),boxHalf), - mulPerElem(PfxVector3(-1.0f,-1.0f, 1.0f),boxHalf), - mulPerElem(PfxVector3( 1.0f,-1.0f, 1.0f),boxHalf), - mulPerElem(PfxVector3( 1.0f,-1.0f,-1.0f),boxHalf), - mulPerElem(PfxVector3(-1.0f, 1.0f,-1.0f),boxHalf), - mulPerElem(PfxVector3(-1.0f, 1.0f, 1.0f),boxHalf), - mulPerElem(PfxVector3( 1.0f, 1.0f, 1.0f),boxHalf), - mulPerElem(PfxVector3( 1.0f, 1.0f,-1.0f),boxHalf), - }; - - //-------------------------------------------------------------------- - // è¡çªç‚¹ã®æŽ¢ç´¢ - - PfxClosestPoints cp; - PfxVector3 sA,sB; - - // ã‚¨ãƒƒã‚¸é–“ã®æœ€çŸ­è·é›¢ã¨åº§æ¨™å€¤ã‚’算出 - { - const int boxIds[] = { - 0,1, - 1,2, - 2,3, - 3,0, - 4,5, - 5,6, - 6,7, - 7,4, - 0,4, - 3,7, - 2,6, - 1,5, - }; - - for(int i=0;i<3;i++) { - for(int j=0;j<12;j++) { - pfxClosestTwoLines(facetPnts[i],facetPnts[(i+1)%3],boxPnts[boxIds[j*2]],boxPnts[boxIds[j*2+1]],sA,sB); - cp.add(PfxPoint3(sA),PfxPoint3(sB),lengthSqr(sA-sB)); - } - } - } - - // Triangleã®é ‚点 -> Boxã®é¢ - { -#ifdef SCE_PFX_USE_GEOMETRY - PfxFloatInVec sqrDist; - PfxGeomAabb aabb(PfxPoint3(0.0f),boxHalf); - { - PfxPoint3 closestPoint = sce::Geometry::Aos::closestPoint(PfxPoint3(facetPnts[0]),aabb,&sqrDist); - cp.add(PfxPoint3(facetPnts[0]),closestPoint,sqrDist); - } - { - PfxPoint3 closestPoint = sce::Geometry::Aos::closestPoint(PfxPoint3(facetPnts[1]),aabb,&sqrDist); - cp.add(PfxPoint3(facetPnts[1]),closestPoint,sqrDist); - } - { - PfxPoint3 closestPoint = sce::Geometry::Aos::closestPoint(PfxPoint3(facetPnts[2]),aabb,&sqrDist); - cp.add(PfxPoint3(facetPnts[2]),closestPoint,sqrDist); - } -#else - pfxClosestPointAABB(facetPnts[0],boxHalf,sB); - cp.add(PfxPoint3(facetPnts[0]),PfxPoint3(sB),lengthSqr(sB-facetPnts[0])); - - pfxClosestPointAABB(facetPnts[1],boxHalf,sB); - cp.add(PfxPoint3(facetPnts[1]),PfxPoint3(sB),lengthSqr(sB-facetPnts[1])); - - pfxClosestPointAABB(facetPnts[2],boxHalf,sB); - cp.add(PfxPoint3(facetPnts[2]),PfxPoint3(sB),lengthSqr(sB-facetPnts[2])); -#endif - } - - // Boxã®é ‚点 -> Trianglesã®é¢ - PfxTriangle triangleA(facetPnts[0],facetPnts[1],facetPnts[2]); - for(int i=0;i<8;i++) { - pfxClosestPointTriangle(boxPnts[i],triangleA,sA); - cp.add(PfxPoint3(sA),PfxPoint3(boxPnts[i]),lengthSqr(sA-boxPnts[i])); - } - - for(int i=0;im_facets[selFacets[f]]; - - PfxVector3 facetNormal = matrixBA * pfxReadVector3(facet.m_normal); - - PfxVector3 facetPntsA[3] = { - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[0]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[1]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[2]], - }; - - const PfxEdge *edge[3] = { - &meshA->m_edges[facet.m_edgeIds[0]], - &meshA->m_edges[facet.m_edgeIds[1]], - &meshA->m_edges[facet.m_edgeIds[2]], - }; - - PfxUInt32 edgeChk = - ((edge[0]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x01) | - ((edge[1]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x02) | - ((edge[2]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x04); - - pfxContactTriangleBox(localContacts,selFacets[f], - facetNormal,facetPntsA[0],facetPntsA[1],facetPntsA[2], - facet.m_thickness, - 0.5f*SCE_PFX_PI*(edge[0]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[1]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[2]->m_tilt/255.0f), - edgeChk,boxB.m_half); - } - - for(int i=0;im_facets[subData.getFacetId()]; - - PfxTriangle triangleA( - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]]); - - PfxFloat s=0.0f,t=0.0f; - pfxGetLocalCoords(PfxVector3(localContacts.getLocalPointA(i)),triangleA,s,t); - subData.m_type = PfxSubData::MESH_INFO; - subData.setFacetLocalS(s); - subData.setFacetLocalT(t); - - contacts.addContactPoint( - localContacts.getDistance(i), - transformB.getUpper3x3() * localContacts.getNormal(i), - transformAB * localContacts.getLocalPointA(i), - localContacts.getLocalPointB(i), - subData); - } - - return contacts.getNumContacts(); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.h deleted file mode 100644 index 60584b4ef..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_box.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_TRI_MESH_BOX_H -#define _SCE_PFX_CONTACT_TRI_MESH_BOX_H - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "../../../include/physics_effects/base_level/collision/pfx_box.h" -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxContactTriMeshBox( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxBox &boxB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX ); - -} // namespace PhysicsEffects -} // namespace sce - -#endif // _SCE_PFX_CONTACT_TRI_MESH_BOX_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.cpp deleted file mode 100644 index e5fcb5049..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_capsule.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" - -namespace sce { -namespace PhysicsEffects { - -// 分離軸ãŒè¦‹ã¤ã‹ã£ãŸå ´åˆã¯ã™ãã«å‡¦ç†ã‚’抜ã‘ã‚‹ãŸã‚最短è·é›¢ãŒè¿”ã•れるã‚ã‘ã§ã¯ãªã„ã“ã¨ã«æ³¨æ„ - -/* - â—‹ カプセル分離軸(x19) - 颿³•ç·š - カプセル軸 x エッジ0 - カプセル軸 x エッジ1 - カプセル軸 x エッジ2 - ((カプセル点0-é¢ç‚¹0) x エッジ0) x エッジ0 - ((カプセル点0-é¢ç‚¹1) x エッジ1) x エッジ1 - ((カプセル点0-é¢ç‚¹2) x エッジ2) x エッジ2 - ((カプセル点1-é¢ç‚¹0) x エッジ0) x エッジ0 - ((カプセル点1-é¢ç‚¹1) x エッジ1) x エッジ1 - ((カプセル点1-é¢ç‚¹2) x エッジ2) x エッジ2 - ((é¢ç‚¹0-カプセル点0) x カプセル軸) x カプセル軸 - ((é¢ç‚¹1-カプセル点0) x カプセル軸) x カプセル軸 - ((é¢ç‚¹2-カプセル点0) x カプセル軸) x カプセル軸 - é¢ç‚¹0-カプセル点0 - é¢ç‚¹1-カプセル点0 - é¢ç‚¹2-カプセル点0 - é¢ç‚¹0-カプセル点1 - é¢ç‚¹1-カプセル点1 - é¢ç‚¹2-カプセル点1 - */ - -static SCE_PFX_FORCE_INLINE -bool checkSAT(const PfxVector3 &axis,PfxFloat AMin,PfxFloat AMax,PfxFloat BMin,PfxFloat BMax,PfxFloat &distMin,PfxVector3 &axisMin) -{ - // â–  éžæŽ¥è§¦. - - // A: +----+ - // B:+----+ - if(BMax <= AMin) { - return true; - } - - // A:+----+ - // B: +----+ - else if(AMax <= BMin) { - return true; - } - - // â–  内包 - - //A: +--+ - //B: +------+ - if(BMin < AMin && AMax < BMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - //A: +------+ - //B: +--+ - else if(AMin < BMin && BMax < AMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - // â–  接触 - - // A: +----+ - // B:+----+ - else if(BMin < AMin && AMin < BMax) { - PfxFloat d = AMin-BMax; - if(distMin < d) { - distMin = d; - axisMin = axis; - } - } - - // A: +----+ - // B: +----+ - else if(AMin < BMin && BMin < AMax) { - PfxFloat d = BMin-AMax; - if(distMin < d) { - distMin = d; - axisMin = -axis; - } - } - - return false; -} - -static SCE_PFX_FORCE_INLINE -bool pfxContactTriangleCapsule(PfxContactCache &contacts,PfxUInt32 facetId, - const PfxVector3 &normal,const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2, - const PfxFloat thickness,const PfxFloat angle0,const PfxFloat angle1,const PfxFloat angle2, - PfxUInt32 edgeChk, - PfxFloat capsuleRadius,const PfxVector3 &capP0,const PfxVector3 &capP1) -{ - const PfxFloat epsilon = 0.00001f; - - // 最も浅ã„貫通深度ã¨ãã®ã¨ãã®åˆ†é›¢è»¸ - PfxFloat distMin = -SCE_PFX_FLT_MAX; - PfxVector3 axisMin(0.0f); - - //------------------------------------------- - // 1.分離軸判定 - { - PfxVector3 facetPnts[6] = { - p0,p1,p2,p0-thickness*normal,p1-thickness*normal,p2-thickness*normal - }; - - PfxVector3 sideNml[3] = { - normalize(cross((facetPnts[1] - facetPnts[0]),normal)), - normalize(cross((facetPnts[2] - facetPnts[1]),normal)), - normalize(cross((facetPnts[0] - facetPnts[2]),normal)), - }; - - - const PfxVector3 capPnts[2] = { - capP0,capP1 - }; - - { - const PfxVector3 &sepAxis = normal; - - // åˆ†é›¢å¹³é¢ - PfxPlane plane(sepAxis,facetPnts[0]); - - // Capsule(B)ã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat test1,test2,BMin,BMax; - test1 = plane.onPlane(capP0); - test2 = plane.onPlane(capP1); - BMax = SCE_PFX_MAX(test1,test2) + capsuleRadius; - BMin = SCE_PFX_MIN(test1,test2) - capsuleRadius; - - // 判定 - if(BMin > 0.0f || BMax < -thickness) { - return false; - } - - if(distMin < BMin) { - distMin = BMin; - axisMin = -sepAxis; - } - } - - //------------------------------------------- - // カプセル軸 x é¢ã‚¨ãƒƒã‚¸0,1,2 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 sepAxis = cross(capP1-capP0,facetPnts[(e+1)%3]-facetPnts[e]); - PfxFloat l=length(sepAxis); - if(l < 0.00001f) continue; - sepAxis /= l; - - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - //------------------------------------------- - // ((カプセル点0-é¢ç‚¹0,1,2) x エッジ0,1,2) x エッジ0,1,2 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 edge = facetPnts[(e+1)%3]-facetPnts[e]; - PfxVector3 sepAxis = normalize(cross(cross(capP0-facetPnts[e],edge),edge)); - - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - //------------------------------------------- - // ((カプセル点1-é¢ç‚¹0,1,2) x エッジ0,1,2) x エッジ0,1,2 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 edge = facetPnts[(e+1)%3]-facetPnts[e]; - PfxVector3 sepAxis = normalize(cross(cross(capP1-facetPnts[e],edge),edge)); - - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - //------------------------------------------- - // ((é¢ç‚¹0,1,2-カプセル点0) x カプセル軸) x カプセル軸 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 capdir = capP1-capP0; - PfxVector3 sepAxis = cross(cross(facetPnts[e]-capP0,capdir),capdir); - PfxFloat l=length(sepAxis); - if(l < 0.00001f) continue; - sepAxis /= l; - - if(dot(normal,sepAxis) > 0.0f) - sepAxis = -sepAxis; - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - //------------------------------------------- - // é¢ç‚¹0,1,2-カプセル点0 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 sepAxis = normalize(facetPnts[e]-capP0); - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - //------------------------------------------- - // é¢ç‚¹0,1,2-カプセル点1 - // ※Triangles座標系 (Aローカル) - - { - for(int e=0;e<3;e++) { - PfxVector3 sepAxis = normalize(facetPnts[e]-capP1); - - // Triangleã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat AMin=SCE_PFX_FLT_MAX,AMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts6(facetPnts,sepAxis,AMin,AMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½± - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(checkSAT(sepAxis,AMin,AMax,BMin,BMax,distMin,axisMin)) { - return false; - } - } - } - - // é¢ã«åŽšã¿ãŒã‚ã‚‹å ´åˆã®è£œåŠ©çš„ãªåˆ¤å®šï¼ˆé¢æ³•ç·š x カプセル軸) - // 交差ã™ã‚‹ã‹ã—ãªã„ã‹ã ã‘を判定 - if(thickness > 0.0f) { - // 厚ã¿å´é¢ã®æ³•ç·š - for(int i=0;i<3;i++) { - // åˆ†é›¢å¹³é¢ - PfxPlane plane(sideNml[i],facetPnts[i]); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat test1,test2,BMin; - test1 = plane.onPlane(capP0); - test2 = plane.onPlane(capP1); - BMin = SCE_PFX_MIN(test1,test2) - capsuleRadius; - - if(BMin > 0.0f) { - return false; - } - } - - // ï¼’ã¤ã®åŽšã¿å´é¢ã®ãªã™ã‚¨ãƒƒã‚¸3×カプセル軸 - for(int e=0;e<3;e++) { - PfxVector3 edgeVec = normalize(cross(sideNml[(e+1)%3],sideNml[e])); - PfxVector3 capVec = capP1-capP0; - - // エッジãŒå¹³è¡Œã§ã‚れã°åˆ¤å®šã—ãªã„ - if(pfxIsSameDirection(edgeVec,capVec)) continue; - - PfxVector3 sepAxis = normalize(cross(edgeVec,capVec)); - - // Trianglesã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat triMin,triMax; - pfxGetProjAxisPnts3(facetPnts,sepAxis,triMin,triMax); - - // ã‚«ãƒ—ã‚»ãƒ«ã‚’åˆ†é›¢è»¸ã«æŠ•å½±ã—ã¦ç¯„囲をå–å¾— - PfxFloat BMin=SCE_PFX_FLT_MAX,BMax=-SCE_PFX_FLT_MAX; - pfxGetProjAxisPnts2(capPnts,sepAxis,BMin,BMax); - BMin -= capsuleRadius; - BMax += capsuleRadius; - - if(triMax < BMin || BMax < triMin) { - return false; - } - } - } - } - - //------------------------------------------- - // 2.è¡çªç‚¹ã®æŽ¢ç´¢ - - { - // 分離軸方å‘ã«å¼•ã離ã™(最近接を判定ã™ã‚‹ãŸã‚ã€äº¤å·®å›žé¿ã•ã›ã‚‹) - PfxVector3 sepAxis = 1.1f * fabsf(distMin) * axisMin; - - const PfxVector3 facetPnts[3] = { - p0 + sepAxis, - p1 + sepAxis, - p2 + sepAxis, - }; - - //-------------------------------------------------------------------- - // è¡çªç‚¹ã®æŽ¢ç´¢ - - PfxClosestPoints cp; - PfxVector3 sA,sB; - - //-------------------------------------------------------------------- - //Triangleã®é ‚点 -> Capsule - - // カプセルã®ç·šåˆ†ã¨é¢ã®ã‚¨ãƒƒã‚¸x3ã®æœ€è¿‘接点ã®ç®—出 -#ifdef SCE_PFX_USE_GEOMETRY - PfxGeomSegment segmentC((PfxPoint3)capP0,(PfxPoint3)capP1); - - { - PfxGeomSegment segmentF((PfxPoint3)facetPnts[0],(PfxPoint3)facetPnts[1]); - PfxPoint3 closestPointA,closestPointB; - PfxFloatInVec sqrDist = closestPoints(segmentC,segmentF,closestPointB,closestPointA); - cp.add(closestPointA,closestPointB + normalize(closestPointA-closestPointB)*capsuleRadius,sqrDist); - } - { - PfxGeomSegment segmentF((PfxPoint3)facetPnts[1],(PfxPoint3)facetPnts[2]); - PfxPoint3 closestPointA,closestPointB; - PfxFloatInVec sqrDist = closestPoints(segmentC,segmentF,closestPointB,closestPointA); - cp.add(closestPointA,closestPointB + normalize(closestPointA-closestPointB)*capsuleRadius,sqrDist); - } - { - PfxGeomSegment segmentF((PfxPoint3)facetPnts[2],(PfxPoint3)facetPnts[0]); - PfxPoint3 closestPointA,closestPointB; - PfxFloatInVec sqrDist = closestPoints(segmentC,segmentF,closestPointB,closestPointA); - cp.add(closestPointA,closestPointB + normalize(closestPointA-closestPointB)*capsuleRadius,sqrDist); - } -#else - pfxClosestTwoLines(capP0,capP1,facetPnts[0],facetPnts[1],sB,sA); - cp.add(PfxPoint3(sA),PfxPoint3(sB + normalize(sA-sB)*capsuleRadius),lengthSqr(sA-sB)); - - pfxClosestTwoLines(capP0,capP1,facetPnts[1],facetPnts[2],sB,sA); - cp.add(PfxPoint3(sA),PfxPoint3(sB + normalize(sA-sB)*capsuleRadius),lengthSqr(sA-sB)); - - pfxClosestTwoLines(capP0,capP1,facetPnts[2],facetPnts[0],sB,sA); - cp.add(PfxPoint3(sA),PfxPoint3(sB + normalize(sA-sB)*capsuleRadius),lengthSqr(sA-sB)); -#endif - - // カプセルã®ç«¯ç‚¹ã¨é¢ã®æœ€è¿‘接点ã®ç®—出 - PfxTriangle triangleA(facetPnts[0],facetPnts[1],facetPnts[2]); - pfxClosestPointTriangle(capP0,triangleA,sA); - cp.add(PfxPoint3(sA),PfxPoint3(capP0+normalize(sA-capP0)*capsuleRadius),lengthSqr(sA-capP0)); - - pfxClosestPointTriangle(capP1,triangleA,sA); - cp.add(PfxPoint3(sA),PfxPoint3(capP1+normalize(sA-capP1)*capsuleRadius),lengthSqr(sA-capP1)); - - for(int i=0;im_facets[selFacets[f]]; - - PfxVector3 facetNormal = matrixBA * pfxReadVector3(facet.m_normal); - - PfxVector3 facetPntsA[3] = { - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[0]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[1]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[2]], - }; - - const PfxEdge *edge[3] = { - &meshA->m_edges[facet.m_edgeIds[0]], - &meshA->m_edges[facet.m_edgeIds[1]], - &meshA->m_edges[facet.m_edgeIds[2]], - }; - - PfxUInt32 edgeChk = - ((edge[0]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x01) | - ((edge[1]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x02) | - ((edge[2]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x04); - - pfxContactTriangleCapsule(localContacts,selFacets[f], - facetNormal,facetPntsA[0],facetPntsA[1],facetPntsA[2], - facet.m_thickness, - 0.5f*SCE_PFX_PI*(edge[0]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[1]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[2]->m_tilt/255.0f), - edgeChk,capsuleB.m_radius,vCapAB[0],vCapAB[1]); - } - - for(int i=0;im_facets[subData.getFacetId()]; - - PfxTriangle triangleA( - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]]); - - PfxFloat s=0.0f,t=0.0f; - pfxGetLocalCoords(PfxVector3(localContacts.getLocalPointA(i)),triangleA,s,t); - subData.m_type = PfxSubData::MESH_INFO; - subData.setFacetLocalS(s); - subData.setFacetLocalT(t); - - contacts.addContactPoint( - localContacts.getDistance(i), - transformB.getUpper3x3() * localContacts.getNormal(i), - transformAB * localContacts.getLocalPointA(i), - localContacts.getLocalPointB(i), - subData); - } - - return contacts.getNumContacts(); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.h deleted file mode 100644 index 9e392ffee..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_capsule.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_TRI_MESH_CAPSULE_H -#define _SCE_PFX_CONTACT_TRI_MESH_CAPSULE_H - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxContactTriMeshCapsule( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxCapsule &capsuleB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX ); - - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_TRI_MESH_CAPSULE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.cpp deleted file mode 100644 index 545186ffe..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_convex.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" -#include "pfx_gjk_solver.h" -#include "pfx_gjk_support_func.h" - -namespace sce { -namespace PhysicsEffects { - - -static SCE_PFX_FORCE_INLINE -bool pfxContactTriangleConvex(PfxContactCache &contacts,PfxUInt32 facetId, - const PfxVector3 &normal,const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2, - const PfxFloat thickness,const PfxFloat angle0,const PfxFloat angle1,const PfxFloat angle2, - PfxUInt32 edgeChk, - const PfxConvexMesh &convex) -{ - PfxVector3 facetPnts[6] = { - p0,p1,p2,p0-thickness*normal,p1-thickness*normal,p2-thickness*normal - }; - - - PfxPoint3 pA(0.0f),pB(0.0f); - PfxVector3 nml(0.0f); - PfxGjkSolver gjk; - - gjk.setup((void*)facetPnts,(void*)&convex,pfxGetSupportVertexTriangleWithThickness,pfxGetSupportVertexConvex); - PfxFloat d = gjk.collide(nml,pA,pB,PfxTransform3::identity(),PfxTransform3::identity(),SCE_PFX_FLT_MAX); - if(d >= 0.0f) return false; - - PfxVector3 pointsOnTriangle = PfxVector3(pA); - PfxVector3 pointsOnConvex = PfxVector3(pB); - PfxVector3 axis = nml; - - // é¢ä¸Šã®æœ€è¿‘接点ãŒå‡¸ã‚¨ãƒƒã‚¸ä¸Šã§ãªã„å ´åˆã¯æ³•線を変ãˆã‚‹ - if( ((edgeChk&0x01)&&pfxPointOnLine(pointsOnTriangle,p0,p1)) || - ((edgeChk&0x02)&&pfxPointOnLine(pointsOnTriangle,p1,p2)) || - ((edgeChk&0x04)&&pfxPointOnLine(pointsOnTriangle,p2,p0)) ) { - axis=-normal; - } - - PfxSubData subData; - subData.setFacetId(facetId); - contacts.addContactPoint(-length(pointsOnTriangle-pointsOnConvex),axis,pA,pB,subData); - - return true; -} - -PfxInt32 pfxContactTriMeshConvex( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxConvexMesh &convexB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - (void) distanceThreshold; - - PfxTransform3 transformAB, transformBA; - PfxMatrix3 matrixBA; - PfxVector3 offsetBA; - - // Bローカル→Aローカルã¸ã®å¤‰æ›. - transformAB = orthoInverse(transformA) * transformB; - - // Aローカル→Bローカルã¸ã®å¤‰æ›. - transformBA = orthoInverse(transformAB); - - matrixBA = transformBA.getUpper3x3(); - offsetBA = transformBA.getTranslation(); - - //------------------------------------------- - // 判定ã™ã‚‹é¢ã‚’絞り込む. - - PfxUInt8 SCE_PFX_ALIGNED(16) selFacets[SCE_PFX_NUMMESHFACETS] = { 0 }; - PfxUInt32 numSelFacets = 0; - - // ※convexB座標系 - PfxVector3 aabbB(convexB.m_half); - numSelFacets = pfxGatherFacets(meshA,(PfxFloat*)&aabbB,offsetBA,matrixBA,selFacets); - - if(numSelFacets == 0) { - return 0; - } - - //------------------------------------------- - // é¢ã”ã¨ã«è¡çªã‚’検出 - - PfxContactCache localContacts; - - for(PfxUInt32 f = 0; f < numSelFacets; f++) { - const PfxFacet &facet = meshA->m_facets[selFacets[f]]; - - PfxVector3 facetNormal = matrixBA * pfxReadVector3(facet.m_normal); - - PfxVector3 facetPntsA[3] = { - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[0]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[1]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[2]], - }; - - const PfxEdge *edge[3] = { - &meshA->m_edges[facet.m_edgeIds[0]], - &meshA->m_edges[facet.m_edgeIds[1]], - &meshA->m_edges[facet.m_edgeIds[2]], - }; - - PfxUInt32 edgeChk = - ((edge[0]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x01) | - ((edge[1]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x02) | - ((edge[2]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x04); - - pfxContactTriangleConvex(localContacts,selFacets[f], - facetNormal,facetPntsA[0],facetPntsA[1],facetPntsA[2], - facet.m_thickness, - 0.5f*SCE_PFX_PI*(edge[0]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[1]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[2]->m_tilt/255.0f), - edgeChk,convexB); - } - - for(int i=0;im_facets[subData.getFacetId()]; - - PfxTriangle triangleA( - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]]); - - PfxFloat s=0.0f,t=0.0f; - pfxGetLocalCoords(PfxVector3(localContacts.getLocalPointA(i)),triangleA,s,t); - subData.m_type = PfxSubData::MESH_INFO; - subData.setFacetLocalS(s); - subData.setFacetLocalT(t); - - contacts.addContactPoint( - localContacts.getDistance(i), - transformB.getUpper3x3() * localContacts.getNormal(i), - transformAB * localContacts.getLocalPointA(i), - localContacts.getLocalPointB(i), - subData); - } - - return contacts.getNumContacts(); -} -} //namespace PhysicsEffects -} //namespace sce - diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.h deleted file mode 100644 index e653670df..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_convex.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_TRI_MESH_CONVEX_H -#define _SCE_PFX_CONTACT_TRI_MESH_CONVEX_H - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxContactTriMeshConvex( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxConvexMesh &convexB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX ); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_TRI_MESH_CONVEX_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.cpp deleted file mode 100644 index 608e99c17..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_cylinder.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" -#include "pfx_gjk_solver.h" -#include "pfx_gjk_support_func.h" - -namespace sce { -namespace PhysicsEffects { - -static SCE_PFX_FORCE_INLINE -bool pfxContactTriangleCylinder(PfxContactCache &contacts,PfxUInt32 facetId, - const PfxVector3 &normal,const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2, - const PfxFloat thickness,const PfxFloat angle0,const PfxFloat angle1,const PfxFloat angle2, - PfxUInt32 edgeChk, - const PfxCylinder &cylinder) -{ - PfxVector3 facetPnts[6] = { - p0,p1,p2,p0-thickness*normal,p1-thickness*normal,p2-thickness*normal - }; - - - PfxPoint3 pA(0.0f),pB(0.0f); - PfxVector3 nml(0.0f); - PfxGjkSolver gjk; - - gjk.setup((void*)facetPnts,(void*)&cylinder,pfxGetSupportVertexTriangleWithThickness,pfxGetSupportVertexCylinder); - PfxFloat d = gjk.collide(nml,pA,pB,PfxTransform3::identity(),PfxTransform3::identity(),SCE_PFX_FLT_MAX); - if(d >= 0.0f) return false; - - PfxVector3 pointsOnTriangle = PfxVector3(pA); - PfxVector3 pointsOnConvex = PfxVector3(pB); - PfxVector3 axis = nml; - - // é¢ä¸Šã®æœ€è¿‘接点ãŒå‡¸ã‚¨ãƒƒã‚¸ä¸Šã§ãªã„å ´åˆã¯æ³•線を変ãˆã‚‹ - if( ((edgeChk&0x01)&&pfxPointOnLine(pointsOnTriangle,p0,p1)) || - ((edgeChk&0x02)&&pfxPointOnLine(pointsOnTriangle,p1,p2)) || - ((edgeChk&0x04)&&pfxPointOnLine(pointsOnTriangle,p2,p0)) ) { - axis=-normal; - } - - PfxSubData subData; - subData.setFacetId(facetId); - contacts.addContactPoint(-length(pointsOnTriangle-pointsOnConvex),axis,pA,pB,subData); - - return true; -} - -PfxInt32 pfxContactTriMeshCylinder( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxCylinder &cylinderB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - (void) distanceThreshold; - - PfxTransform3 transformAB, transformBA; - PfxMatrix3 matrixBA; - PfxVector3 offsetBA; - - // Bローカル→Aローカルã¸ã®å¤‰æ›. - transformAB = orthoInverse(transformA) * transformB; - - // Aローカル→Bローカルã¸ã®å¤‰æ›. - transformBA = orthoInverse(transformAB); - - matrixBA = transformBA.getUpper3x3(); - offsetBA = transformBA.getTranslation(); - - //------------------------------------------- - // 判定ã™ã‚‹é¢ã‚’絞り込む. - - PfxUInt8 SCE_PFX_ALIGNED(16) selFacets[SCE_PFX_NUMMESHFACETS] = { 0 }; - PfxUInt32 numSelFacets = 0; - - // ※cylinderB座標系 - PfxVector3 aabbB(cylinderB.m_halfLen,cylinderB.m_radius,cylinderB.m_radius); - numSelFacets = pfxGatherFacets(meshA,(PfxFloat*)&aabbB,offsetBA,matrixBA,selFacets); - - if(numSelFacets == 0) { - return 0; - } - - //------------------------------------------- - // é¢ã”ã¨ã«è¡çªã‚’検出 - - PfxContactCache localContacts; - - for(PfxUInt32 f = 0; f < numSelFacets; f++) { - const PfxFacet &facet = meshA->m_facets[selFacets[f]]; - - PfxVector3 facetNormal = matrixBA * pfxReadVector3(facet.m_normal); - - PfxVector3 facetPntsA[3] = { - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[0]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[1]], - offsetBA + matrixBA * meshA->m_verts[facet.m_vertIds[2]], - }; - - const PfxEdge *edge[3] = { - &meshA->m_edges[facet.m_edgeIds[0]], - &meshA->m_edges[facet.m_edgeIds[1]], - &meshA->m_edges[facet.m_edgeIds[2]], - }; - - PfxUInt32 edgeChk = - ((edge[0]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x01) | - ((edge[1]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x02) | - ((edge[2]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x04); - - pfxContactTriangleCylinder(localContacts,selFacets[f], - facetNormal,facetPntsA[0],facetPntsA[1],facetPntsA[2], - facet.m_thickness, - 0.5f*SCE_PFX_PI*(edge[0]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[1]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[2]->m_tilt/255.0f), - edgeChk,cylinderB); - } - - for(int i=0;im_facets[subData.getFacetId()]; - - PfxTriangle triangleA( - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]]); - - PfxFloat s=0.0f,t=0.0f; - pfxGetLocalCoords(PfxVector3(localContacts.getLocalPointA(i)),triangleA,s,t); - subData.m_type = PfxSubData::MESH_INFO; - subData.setFacetLocalS(s); - subData.setFacetLocalT(t); - - contacts.addContactPoint( - localContacts.getDistance(i), - transformB.getUpper3x3() * localContacts.getNormal(i), - transformAB * localContacts.getLocalPointA(i), - localContacts.getLocalPointB(i), - subData); - } - - return contacts.getNumContacts(); -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.h deleted file mode 100644 index 5d9c9dbd3..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_cylinder.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_TRI_MESH_CYLINDER_H -#define _SCE_PFX_CONTACT_TRI_MESH_CYLINDER_H - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "../../../include/physics_effects/base_level/collision/pfx_cylinder.h" -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxContactTriMeshCylinder( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxCylinder &cylinderB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX ); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_TRI_MESH_CYLINDER_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.cpp deleted file mode 100644 index 39d248b27..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_contact_tri_mesh_sphere.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" - -namespace sce { -namespace PhysicsEffects { - -static SCE_PFX_FORCE_INLINE -bool pfxContactTriangleSphere(PfxContactCache &contacts,PfxUInt32 facetId, - const PfxVector3 &normal,const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2, - const PfxFloat thickness,const PfxFloat angle0,const PfxFloat angle1,const PfxFloat angle2, - PfxUInt32 edgeChk, - PfxFloat sphereRadius,const PfxVector3 &spherePos) -{ - PfxVector3 facetPnts[3] = { - p0,p1,p2, - }; - - // 早期判定 - { - PfxPlane planeA(normal,p0); - PfxFloat len1 = planeA.onPlane(spherePos); - - if(len1 >= sphereRadius || len1 < -thickness-sphereRadius) return false; - - } - - // çƒã¨é¢ã®æœ€è¿‘接点を計算 - { - PfxTriangle triangleA(p0,p1,p2); - PfxVector3 pntA; - // pfxClosestPointTriangle(spherePos,triangleA,pntA); - bool insideTriangle = false; - while(1) { - PfxVector3 ab = p1 - p0; - PfxVector3 ac = p2 - p0; - PfxVector3 ap = spherePos - p0; - PfxFloat d1 = dot(ab, ap); - PfxFloat d2 = dot(ac, ap); - if(d1 <= 0.0f && d2 <= 0.0f) { - pntA = p0; - break; - } - - PfxVector3 bp = spherePos - p1; - PfxFloat d3 = dot(ab, bp); - PfxFloat d4 = dot(ac, bp); - if (d3 >= 0.0f && d4 <= d3) { - pntA = p1; - break; - } - - PfxFloat vc = d1*d4 - d3*d2; - if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) { - PfxFloat v = d1 / (d1 - d3); - pntA = p0 + v * ab; - break; - } - - PfxVector3 cp = spherePos - p2; - PfxFloat d5 = dot(ab, cp); - PfxFloat d6 = dot(ac, cp); - if (d6 >= 0.0f && d5 <= d6) { - pntA = p2; - break; - } - - PfxFloat vb = d5*d2 - d1*d6; - if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) { - PfxFloat w = d2 / (d2 - d6); - pntA = p0 + w * ac; - break; - } - - PfxFloat va = d3*d6 - d5*d4; - if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) { - PfxFloat w = (d4 - d3) / ((d4 - d3) + (d5 - d6)); - pntA = p1 + w * (p2 - p1); - break; - } - - PfxFloat den = 1.0f / (va + vb + vc); - PfxFloat v = vb * den; - PfxFloat w = vc * den; - pntA = p0 + ab * v + ac * w; - insideTriangle = true; - break; - } - PfxVector3 distVec = pntA - spherePos; - PfxFloat l = length(distVec); - - if(!insideTriangle && l >= sphereRadius) return false; - - // 分離軸 - PfxVector3 sepAxis = (l < 0.00001f || insideTriangle) ? -normal : distVec / l; - - // çƒä¸Šã®è¡çªç‚¹ - PfxVector3 pointsOnSphere = spherePos + sphereRadius * sepAxis; - PfxVector3 pointsOnTriangle = pntA; - - // é¢ä¸Šã®æœ€è¿‘接点ãŒå‡¸ã‚¨ãƒƒã‚¸ä¸Šã§ãªã„å ´åˆã¯æ³•線を変ãˆã‚‹ - if( ((edgeChk&0x01)&&pfxPointOnLine(pointsOnTriangle,p0,p1)) || - ((edgeChk&0x02)&&pfxPointOnLine(pointsOnTriangle,p1,p2)) || - ((edgeChk&0x04)&&pfxPointOnLine(pointsOnTriangle,p2,p0)) ) { - sepAxis=-normal; - } - - PfxSubData subData; - subData.setFacetId(facetId); - contacts.addContactPoint(-length(pointsOnSphere-pointsOnTriangle),sepAxis,PfxPoint3(pointsOnTriangle),PfxPoint3(pointsOnSphere),subData); - } - - return true; -} - -PfxInt32 pfxContactTriMeshSphere( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxSphere &sphereB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold) -{ - (void) distanceThreshold; - - PfxTransform3 transformAB,transformBA; - PfxMatrix3 matrixBA; - PfxVector3 offsetBA; - - // Bローカル→Aローカルã¸ã®å¤‰æ› - transformAB = orthoInverse(transformA) * transformB; - - // Aローカル→Bローカルã¸ã®å¤‰æ› - transformBA = orthoInverse(transformAB); - - matrixBA = transformBA.getUpper3x3(); - offsetBA = transformBA.getTranslation(); - - //------------------------------------------- - // 判定ã™ã‚‹é¢ã‚’絞り込む - - PfxUInt8 SCE_PFX_ALIGNED(16) selFacets[SCE_PFX_NUMMESHFACETS] = {0}; - PfxUInt32 numSelFacets = 0; - - PfxVector3 aabbB(sphereB.m_radius); - numSelFacets = pfxGatherFacets(meshA,(PfxFloat*)&aabbB,offsetBA,matrixBA,selFacets); - - if(numSelFacets == 0) { - return 0; - } - - //----------------------------------------------- - // 判定 - - PfxContactCache localContacts; - - // TriangleMeshã®é¢->sphereã®åˆ¤å®š - // ※TriangleMesh座標系 - { - for(PfxUInt32 f = 0; f < numSelFacets; f++ ) { - const PfxFacet &facet = meshA->m_facets[selFacets[f]]; - - const PfxVector3 facetNormal = pfxReadVector3(facet.m_normal); - - const PfxVector3 facetPnts[3] = { - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]], - }; - - const PfxEdge *edge[3] = { - &meshA->m_edges[facet.m_edgeIds[0]], - &meshA->m_edges[facet.m_edgeIds[1]], - &meshA->m_edges[facet.m_edgeIds[2]], - }; - - PfxVector3 sepAxis,pntA,pntB; - - PfxUInt32 edgeChk = - ((edge[0]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x01) | - ((edge[1]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x02) | - ((edge[2]->m_angleType==SCE_PFX_EDGE_CONVEX)?0x00:0x04); - - pfxContactTriangleSphere(localContacts,selFacets[f], - facetNormal,facetPnts[0],facetPnts[1],facetPnts[2], - facet.m_thickness, - 0.5f*SCE_PFX_PI*(edge[0]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[1]->m_tilt/255.0f), - 0.5f*SCE_PFX_PI*(edge[2]->m_tilt/255.0f), - edgeChk, - sphereB.m_radius,transformAB.getTranslation()); - } - } - - for(int i=0;im_facets[subData.getFacetId()]; - - PfxTriangle triangleA( - meshA->m_verts[facet.m_vertIds[0]], - meshA->m_verts[facet.m_vertIds[1]], - meshA->m_verts[facet.m_vertIds[2]]); - - PfxFloat s=0.0f,t=0.0f; - pfxGetLocalCoords(PfxVector3(localContacts.getLocalPointA(i)),triangleA,s,t); - subData.m_type = PfxSubData::MESH_INFO; - subData.setFacetLocalS(s); - subData.setFacetLocalT(t); - - contacts.addContactPoint( - localContacts.getDistance(i), - transformA.getUpper3x3() * localContacts.getNormal(i), - localContacts.getLocalPointA(i), - transformBA * localContacts.getLocalPointB(i), - subData); - } - - return contacts.getNumContacts(); -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.h deleted file mode 100644 index 5dc3bba50..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_contact_tri_mesh_sphere.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONTACT_TRI_MESH_SPHERE_H -#define _SCE_PFX_CONTACT_TRI_MESH_SPHERE_H - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" -#include "pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxContactTriMeshSphere( - PfxContactCache &contacts, - const PfxTriMesh *meshA, - const PfxTransform3 &transformA, - const PfxSphere &sphereB, - const PfxTransform3 &transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX ); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONTACT_TRI_MESH_SPHERE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.cpp deleted file mode 100644 index e7c4c2403..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.cpp +++ /dev/null @@ -1,485 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_gjk_solver.h" -#include "pfx_intersect_common.h" - - -namespace sce { -namespace PhysicsEffects { - - -template -struct PfxGjkStack { - int cur; - T data[maxData]; - - PfxGjkStack() : cur(0) {} - - void push(const T &d) - { - SCE_PFX_ASSERT(cur gs; - - gs.push(PfxGjkEdge(facet,i)); - - do { - PfxGjkEdge stk = gs.pop(); - PfxGjkFacet *ft = stk.f; - - if(ft->obsolete==0) { - // wã‹ã‚‰è¦‹ãˆã‚‹ã‹ã©ã†ã‹ã‚’判定 - if(dot(ft->normal,w-ft->closest) < 0.0f) { - // 見ãˆãªã„ã®ã§ã‚¨ãƒƒã‚¸ã‚’登録 - SCE_PFX_ASSERT(numEdges<=(int)MAX_FACETS); - edges[numEdges] = stk; - numEdges++; - } - else { - ft->obsolete = 1; - gs.push(PfxGjkEdge(ft->adj[(stk.i+2)%3],ft->j[(stk.i+2)%3])); - gs.push(PfxGjkEdge(ft->adj[(stk.i+1)%3],ft->j[(stk.i+1)%3])); - } - } - } while(SCE_PFX_UNLIKELY(!gs.isEmpty())); -} - -/////////////////////////////////////////////////////////////////////////////// -// Detect Penetration Depth (EPA) - -PfxFloat PfxGjkSolver::detectPenetrationDepth( - const PfxTransform3 &transformA,const PfxTransform3 &transformB, - PfxVector3 &pA,PfxVector3 &pB,PfxVector3 &normal) -{ - PfxMatrix3 invRotA = transpose(transformA.getUpper3x3()); - PfxMatrix3 invRotB = transpose(transformB.getUpper3x3()); - - int epaIterationCount = 0; - PfxFloat distance = SCE_PFX_FLT_MAX; - - numFacets = 0; - numFacetsHead = 0; - - // åˆæœŸçŠ¶æ…‹ã®åˆ¤å®š - if(m_simplex.numVertices <= 1) { - return distance; - } - else if(m_simplex.numVertices == 2) { - PfxVector3 v0 = m_simplex.W[0]; - PfxVector3 v1 = m_simplex.W[1]; - PfxVector3 dir = normalize(v1-v0); - PfxMatrix3 rot = PfxMatrix3::rotation(2.0943951023932f,dir);//120 deg - int axis; - if(dir[0] < dir[1]) { - if(dir[0] < dir[2]) { - axis = 0; - } - else { - axis = 2; - } - } - else { - if(dir[1] < dir[2]) { - axis = 1; - } - else { - axis = 2; - } - } - PfxVector3 vec(0.0f); - vec[axis] = 1.0f; - - PfxVector3 aux[3]; - aux[0] = cross(dir,vec); - aux[1] = rot * aux[0]; - aux[2] = rot * aux[1]; - - PfxVector3 p[3],q[3],w[3]; - - for(int i=0;i<3;i++) { - PfxVector3 pInA,qInB; - getSupportVertexShapeA(shapeA,invRotA * aux[i],pInA); - getSupportVertexShapeB(shapeB,invRotB * (-aux[i]),qInB); - p[i] = transformA.getTranslation() + transformA.getUpper3x3() * pInA; - q[i] = transformB.getTranslation() + transformB.getUpper3x3() * qInB; - w[i] = p[i] - q[i]; - vertsP[i] = p[i]; - vertsQ[i] = q[i]; - vertsW[i] = w[i]; - } - - if(originInTetrahedron(w[0],w[1],w[2],v0)) { - vertsP[3] = m_simplex.P[0]; - vertsQ[3] = m_simplex.Q[0]; - vertsW[3] = m_simplex.W[0]; - numVerts = 4; - } - else if(originInTetrahedron(w[0],w[1],w[2],v1)){ - vertsP[3] = m_simplex.P[1]; - vertsQ[3] = m_simplex.Q[1]; - vertsW[3] = m_simplex.W[1]; - numVerts = 4; - } - else { - return distance; - } - } - else if(m_simplex.numVertices == 3) { - numVerts = 3; - for(int i=0;i 0.0f) { - PfxVector3 vertsP1,vertsQ1,vertsW1; - PfxVector3 vertsP3,vertsQ3,vertsW3; - vertsQ1=vertsQ[1];vertsW1=vertsW[1];vertsP1=vertsP[1]; - vertsQ3=vertsQ[3];vertsW3=vertsW[3];vertsP3=vertsP[3]; - vertsQ[1]=vertsQ3;vertsW[1]=vertsW3;vertsP[1]=vertsP3; - vertsQ[3]=vertsQ1;vertsW[3]=vertsW1;vertsP[3]=vertsP1; - } - - { - PfxGjkFacet *f0 = addFacet(0,1,2); - PfxGjkFacet *f1 = addFacet(0,3,1); - PfxGjkFacet *f2 = addFacet(0,2,3); - PfxGjkFacet *f3 = addFacet(1,3,2); - - if(SCE_PFX_UNLIKELY(!f0 || !f1 || !f2 || !f3)) return distance; - - linkFacets(f0,0,f1,2); - linkFacets(f0,1,f3,2); - linkFacets(f0,2,f2,0); - linkFacets(f1,0,f2,2); - linkFacets(f1,1,f3,0); - linkFacets(f2,1,f3,1); - } - - // 探索 - PfxGjkFacet *facetMin = NULL; - - do { - // 原点ã‹ã‚‰ä¸€ç•ªè¿‘ã„点を算出ã—ã€ãã®ãƒ™ã‚¯ãƒˆãƒ«ã¨æ”¯ç‚¹ã‚’返㙠- int minFacetIdx = 0; - { - PfxFloat minDistSqr = SCE_PFX_FLT_MAX; - for(int i=0;iobsolete==0 && facetsHead[i]->distSqr < minDistSqr) { - minDistSqr = facetsHead[i]->distSqr; - facetMin = facetsHead[i]; - minFacetIdx = i; - } - } - } - - // リストã‹ã‚‰ã¯ãšã™ - facetsHead[minFacetIdx] = facetsHead[--numFacetsHead]; - - PfxVector3 pInA(0.0f),qInB(0.0f); - getSupportVertexShapeA(shapeA,invRotA * facetMin->normal,pInA); - getSupportVertexShapeB(shapeB,invRotB * (-facetMin->normal),qInB); - PfxVector3 p = transformA.getTranslation() + transformA.getUpper3x3() * pInA; - PfxVector3 q = transformB.getTranslation() + transformB.getUpper3x3() * qInB; - PfxVector3 w = p - q; - PfxVector3 v = facetMin->closest; - - // 最近接点ãƒã‚§ãƒƒã‚¯ - PfxFloat l0 = length(v); - PfxFloat l1 = dot(facetMin->normal,w); - - if((l1 - l0) < SCE_PFX_GJK_EPSILON) { - break; - } - - // 求ã‚ãŸç‚¹ã‚’追加ã—ã¦é¢ã‚’分割 - { - SCE_PFX_ASSERT(numVerts<(int)MAX_VERTS); - int vId = numVerts++; - vertsP[vId] = p; - vertsQ[vId] = q; - vertsW[vId] = w; - - facetMin->obsolete = 1; - - numEdges = 0; - - silhouette(facetMin->adj[0],facetMin->j[0],w); - silhouette(facetMin->adj[1],facetMin->j[1],w); - silhouette(facetMin->adj[2],facetMin->j[2],w); - - if(SCE_PFX_UNLIKELY(numEdges == 0)) break; - - bool edgeCheck = true; - PfxGjkFacet *firstFacet,*lastFacet; - { - PfxGjkEdge &edge = edges[0]; - int v0 = edge.f->v[(edge.i+1)%3]; - int v1 = edge.f->v[edge.i]; - firstFacet = addFacet(v0,v1,vId); - if(SCE_PFX_UNLIKELY(!firstFacet)) { - edgeCheck = false; - break; - } - linkFacets(edge.f,edge.i,firstFacet,0); - lastFacet = firstFacet; - } - - if(SCE_PFX_UNLIKELY(!edgeCheck)) break; - - for(int e=1;ev[(edge.i+1)%3]; - int v1 = edge.f->v[edge.i]; - PfxGjkFacet *f = addFacet(v0,v1,vId); - if(SCE_PFX_UNLIKELY(!f)) {edgeCheck=false;break;} - linkFacets(edge.f,edge.i,f,0); - linkFacets(f,2,lastFacet,1); - lastFacet = f; - } - if(SCE_PFX_UNLIKELY(!edgeCheck)) break; - - linkFacets(lastFacet,1,firstFacet,2); - } - - epaIterationCount++; - if(SCE_PFX_UNLIKELY(epaIterationCount > SCE_PFX_EPA_ITERATION_MAX || numFacetsHead == 0)) { - break; - } - } while(1); - - // è¡çªç‚¹è¨ˆç®— - int v1 = facetMin->v[0]; - int v2 = facetMin->v[1]; - int v3 = facetMin->v[2]; - - PfxVector3 p0 = vertsW[v2]-vertsW[v1]; - PfxVector3 p1 = vertsW[v3]-vertsW[v1]; - PfxVector3 p2 = facetMin->closest-vertsW[v1]; - - PfxVector3 v = cross( p0, p1 ); - PfxVector3 crS = cross( v, p0 ); - PfxVector3 crT = cross( v, p1 ); - PfxFloat d0 = dot( crT, p0 ); - PfxFloat d1 = dot( crS, p1 ); - - if(fabsf(d0) < SCE_PFX_GJK_EPSILON || fabsf(d1) < SCE_PFX_GJK_EPSILON) return distance; - - PfxFloat lamda1 = dot( crT, p2 ) / d0; - PfxFloat lamda2 = dot( crS, p2 ) / d1; - - pA = vertsP[v1] + lamda1*(vertsP[v2]-vertsP[v1]) + lamda2*(vertsP[v3]-vertsP[v1]); - pB = vertsQ[v1] + lamda1*(vertsQ[v2]-vertsQ[v1]) + lamda2*(vertsQ[v3]-vertsQ[v1]); - - PfxFloat lenSqr = lengthSqr(pB-pA); - normal = normalize(pB-pA); - - return -sqrtf(lenSqr); -} - -/////////////////////////////////////////////////////////////////////////////// -// Gjk - -PfxFloat PfxGjkSolver::collide( PfxVector3& normal, PfxPoint3 &pointA, PfxPoint3 &pointB, - const PfxTransform3 & transformA, - const PfxTransform3 & transformB, - PfxFloat distanceThreshold) -{ - (void) distanceThreshold; - - int gjkIterationCount = 0; - - m_simplex.reset(); - - PfxTransform3 cTransformA = transformA; - PfxTransform3 cTransformB = transformB; - PfxMatrix3 invRotA = transpose(cTransformA.getUpper3x3()); - PfxMatrix3 invRotB = transpose(cTransformB.getUpper3x3()); - - PfxVector3 offset = (cTransformA.getTranslation() + cTransformB.getTranslation())*0.5f; - cTransformA.setTranslation(cTransformA.getTranslation()-offset); - cTransformB.setTranslation(cTransformB.getTranslation()-offset); - - PfxVector3 separatingAxis(-cTransformA.getTranslation()); - if(lengthSqr(separatingAxis) < 0.000001f) separatingAxis = PfxVector3(1.0,0.0,0.0); - PfxFloat squaredDistance = SCE_PFX_FLT_MAX; - PfxFloat delta = 0.0f; - PfxFloat distance = SCE_PFX_FLT_MAX; - - for(;;) { - // サãƒãƒ¼ãƒˆé ‚点ã®å–å¾— - PfxVector3 pInA,qInB; - - getSupportVertexShapeA(shapeA,invRotA * (-separatingAxis),pInA); - getSupportVertexShapeB(shapeB,invRotB * separatingAxis,qInB); - - PfxVector3 p = cTransformA.getTranslation() + cTransformA.getUpper3x3() * pInA; - PfxVector3 q = cTransformB.getTranslation() + cTransformB.getUpper3x3() * qInB; - PfxVector3 w = p - q; - - delta = dot(separatingAxis,w); - - // 早期終了ãƒã‚§ãƒƒã‚¯ - if(SCE_PFX_UNLIKELY(delta > 0.0f)) { - normal = separatingAxis; - return distance; - } - - if(SCE_PFX_UNLIKELY(m_simplex.inSimplex(w))) { - break; - } - - PfxFloat f0 = squaredDistance - delta; - PfxFloat f1 = squaredDistance * SCE_PFX_GJK_EPSILON; - - if (SCE_PFX_UNLIKELY(f0 <= f1)) { - break; - } - - // 頂点をå˜ä½“ã«è¿½åŠ  - m_simplex.addVertex(w,p,q); - - // 原点ã¨å˜ä½“ã®æœ€è¿‘接点を求ã‚ã€åˆ†é›¢è»¸ã‚’返㙠- if(SCE_PFX_UNLIKELY(!m_simplex.closest(separatingAxis))) { - normal = separatingAxis; - return distance; - } - - squaredDistance = lengthSqr(separatingAxis); - - if(SCE_PFX_UNLIKELY(gjkIterationCount >= SCE_PFX_GJK_ITERATION_MAX || m_simplex.fullSimplex())) { - break; - } - - gjkIterationCount++; - } - - PfxVector3 pA(0.0f),pB(0.0f); - - // ï¼’ã¤ã®Convexã¯äº¤å·®ã—ã¦ã„ã‚‹ã®ã§ã€æŽ¥è§¦ç‚¹ã‚’探索ã™ã‚‹ - PfxFloat dist = detectPenetrationDepth(cTransformA,cTransformB,pA,pB,normal); - - //マージン考慮 - if(dist < 0.0f) { - pA += normal * SCE_PFX_GJK_MARGIN; - pB -= normal * SCE_PFX_GJK_MARGIN; - dist = dot(normal,pA-pB); - pointA = orthoInverse(transformA)*PfxPoint3(pA+offset); - pointB = orthoInverse(transformB)*PfxPoint3(pB+offset); - } - - return dist; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.h deleted file mode 100644 index 9d980a3a7..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_solver.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_GJK_SOLVER_H -#define _SCE_PFX_GJK_SOLVER_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_simplex_solver.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_GJK_EPSILON 1e-04f -#define SCE_PFX_GJK_MARGIN 0.025f -#define SCE_PFX_GJK_ITERATION_MAX 10 -#define SCE_PFX_EPA_ITERATION_MAX 10 - -/////////////////////////////////////////////////////////////////////////////// -// Support Function - -typedef void (*PfxGetSupportVertexFunc)(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); - -/////////////////////////////////////////////////////////////////////////////// -// Gjk -class PfxSimplexSolver; - -class PfxGjkSolver -{ -private: - static const PfxUInt32 MAX_VERTS = 128; - static const PfxUInt32 MAX_EDGES = 128; - static const PfxUInt32 MAX_FACETS = 64; - - PfxSimplexSolver m_simplex; - - // é¢ - struct PfxGjkFacet { - PfxVector3 normal; // é¢ã®æ³•ç·š - PfxVector3 closest; // 原点ã‹ã‚‰ã®æœ€çŸ­ãƒ™ã‚¯ãƒˆãƒ« - PfxUInt32 obsolete; // 廃棄é¢åˆ¤å®š - PfxFloat distSqr; // 原点ã‹ã‚‰ã®è·é›¢ - PfxInt32 v[3]; // 頂点 - PfxInt32 j[3]; // 隣接é¢ã‹ã‚‰è¦‹ãŸIndex - PfxGjkFacet *adj[3]; // éš£æŽ¥é¢ - SCE_PFX_PADDING(1,4) - }; - - // エッジ - struct PfxGjkEdge { - PfxGjkFacet *f; - PfxInt32 i; - PfxGjkEdge() {} - PfxGjkEdge(PfxGjkFacet *f_,PfxInt32 i_) - { - f = f_; - i= i_; - } - }; - - PfxVector3 g_vertsP[MAX_VERTS]; - PfxVector3 g_vertsQ[MAX_VERTS]; - PfxVector3 g_vertsW[MAX_VERTS]; - PfxGjkFacet g_facets[MAX_FACETS]; - PfxGjkFacet *g_facetsHead[MAX_FACETS]; - PfxGjkEdge g_edges[MAX_EDGES]; - - PfxVector3 SCE_PFX_ALIGNED(16) *vertsP; - SCE_PFX_PADDING(1,12) - PfxVector3 SCE_PFX_ALIGNED(16) *vertsQ; - SCE_PFX_PADDING(2,12) - PfxVector3 SCE_PFX_ALIGNED(16) *vertsW; - SCE_PFX_PADDING(3,12) - PfxGjkFacet SCE_PFX_ALIGNED(16) *facets; - SCE_PFX_PADDING(4,12) - PfxGjkFacet SCE_PFX_ALIGNED(16) **facetsHead; - SCE_PFX_PADDING(5,12) - PfxGjkEdge SCE_PFX_ALIGNED(16) *edges; - - int numVerts; - int numEdges; - int numFacets; - int numFacetsHead; - SCE_PFX_PADDING(6,12) - - inline PfxGjkFacet *addFacet(int v1,int v2,int v3); - - inline void linkFacets(PfxGjkFacet *f1,int e1,PfxGjkFacet *f2,int e2); - void silhouette(PfxGjkFacet *facet,int i,PfxVector3 &w); - - inline bool originInTetrahedron(const PfxVector3& p0,const PfxVector3& p1,const PfxVector3& p2,const PfxVector3& p3); - - PfxFloat detectPenetrationDepth( - const PfxTransform3 &transformA,const PfxTransform3 &transformB, - PfxVector3 &pA,PfxVector3 &pB,PfxVector3 &normal); - - void *shapeA; - void *shapeB; - PfxGetSupportVertexFunc getSupportVertexShapeA; - PfxGetSupportVertexFunc getSupportVertexShapeB; - -public: - PfxGjkSolver(); - ~PfxGjkSolver(); - - void setup(void *sA,void *sB,PfxGetSupportVertexFunc fA,PfxGetSupportVertexFunc fB); - - PfxFloat collide( PfxVector3& normal, PfxPoint3 &pointA, PfxPoint3 &pointB, - const PfxTransform3 & transformA, - const PfxTransform3 & transformB, - PfxFloat distanceThreshold = SCE_PFX_FLT_MAX); -}; - -inline -PfxGjkSolver::PfxGjkFacet *PfxGjkSolver::addFacet(int v1,int v2,int v3) -{ - if(SCE_PFX_UNLIKELY(numFacets == (int)MAX_FACETS)) - return NULL; - - PfxGjkFacet &facet = facets[numFacets]; - - PfxVector3 V1 = vertsW[v1]; - PfxVector3 V2 = vertsW[v2]; - PfxVector3 V3 = vertsW[v3]; - facet.obsolete = 0; - facet.v[0] = v1; - facet.v[1] = v2; - facet.v[2] = v3; - - PfxVector3 normal = cross(V3-V1,V2-V1); - - PfxFloat l = lengthSqr(normal); - - if(l < SCE_PFX_GJK_EPSILON * SCE_PFX_GJK_EPSILON) { - return NULL; - } - - normal /= sqrtf(l); - facet.closest = dot(V1,normal)*normal; - facet.normal =normal; - - facet.distSqr = lengthSqr(facet.closest); - - facetsHead[numFacetsHead++] = &facet; - numFacets++; - - return &facet; -} - -inline -void PfxGjkSolver::linkFacets(PfxGjkFacet *f1,int e1,PfxGjkFacet *f2,int e2) -{ - f1->adj[e1] = f2; - f2->adj[e2] = f1; - f1->j[e1] = e2; - f2->j[e2] = e1; -} - -inline -bool PfxGjkSolver::originInTetrahedron(const PfxVector3& p0,const PfxVector3& p1,const PfxVector3& p2,const PfxVector3& p3) -{ - PfxVector3 n0 = cross((p1-p0),(p2-p0)); - PfxVector3 n1 = cross((p2-p1),(p3-p1)); - PfxVector3 n2 = cross((p3-p2),(p0-p2)); - PfxVector3 n3 = cross((p0-p3),(p1-p3)); - - return - dot(n0,p0) * dot(n0,p3-p0) <= 0.0f && - dot(n1,p1) * dot(n1,p0-p1) <= 0.0f && - dot(n2,p2) * dot(n2,p1-p2) <= 0.0f && - dot(n3,p3) * dot(n3,p2-p3) <= 0.0f; -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_GJK_SOLVER_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.cpp deleted file mode 100644 index b252b3f87..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "pfx_gjk_support_func.h" -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "../../../include/physics_effects/base_level/collision/pfx_box.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" -#include "../../../include/physics_effects/base_level/collision/pfx_cylinder.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_GJK_MARGIN 0.025f - -/////////////////////////////////////////////////////////////////////////////// -// Support Function - -void pfxGetSupportVertexTriangle(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxVector3 *vtx = (PfxVector3*)shape; - -PfxFloat d0 = dot(vtx[0],seperatingAxis); -PfxFloat d1 = dot(vtx[1],seperatingAxis); -PfxFloat d2 = dot(vtx[2],seperatingAxis); - -int reti = 2; - -if(d0 > d1 && d0 > d2) { - reti = 0; -} -else if(d1 > d2) { - reti = 1; -} - - supportVertex = vtx[reti] + SCE_PFX_GJK_MARGIN * normalize(seperatingAxis); -} - -void pfxGetSupportVertexTriangleWithThickness(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxVector3 *vtx = (PfxVector3*)shape; - -PfxFloat d[6]; -d[0] = dot(vtx[0],seperatingAxis); -d[1] = dot(vtx[1],seperatingAxis); -d[2] = dot(vtx[2],seperatingAxis); -d[3] = dot(vtx[3],seperatingAxis); -d[4] = dot(vtx[4],seperatingAxis); -d[5] = dot(vtx[5],seperatingAxis); - -int reti = 0; -for(int i=1;i<6;i++) { - if(d[reti] < d[i]) { - reti = i; - } -} - - supportVertex = vtx[reti] + SCE_PFX_GJK_MARGIN * normalize(seperatingAxis); -} - -void pfxGetSupportVertexConvex(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxConvexMesh *mesh = (PfxConvexMesh*)shape; - int reti = 0; -PfxFloat dmax = dot(mesh->m_verts[0],seperatingAxis); -for(int i=1;im_numVerts;i++) { - PfxFloat d = dot(mesh->m_verts[i],seperatingAxis); - if(d > dmax) { - dmax =d; - reti = i; - } -} - supportVertex = mesh->m_verts[reti] + SCE_PFX_GJK_MARGIN * normalize(seperatingAxis); -} - -void pfxGetSupportVertexBox(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxBox *box = (PfxBox*)shape; - PfxVector3 boxHalf = box->m_half + PfxVector3(SCE_PFX_GJK_MARGIN); - supportVertex[0] = seperatingAxis[0]>0.0f?boxHalf[0]:-boxHalf[0]; - supportVertex[1] = seperatingAxis[1]>0.0f?boxHalf[1]:-boxHalf[1]; - supportVertex[2] = seperatingAxis[2]>0.0f?boxHalf[2]:-boxHalf[2]; -} - -void pfxGetSupportVertexCapsule(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxCapsule *capsule = (PfxCapsule*)shape; - PfxVector3 u(1.0f,0.0f,0.0f); - - PfxFloat udotv = dot(seperatingAxis,u); - PfxVector3 dir = u * (udotv > 0.0f ? capsule->m_halfLen : -capsule->m_halfLen); - supportVertex = dir + normalize(seperatingAxis) * (capsule->m_radius + SCE_PFX_GJK_MARGIN); -} - -void pfxGetSupportVertexSphere(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxSphere *sphere = (PfxSphere*)shape; - supportVertex = normalize(seperatingAxis) * (sphere->m_radius + SCE_PFX_GJK_MARGIN); -} - -void pfxGetSupportVertexCylinder(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex) -{ - PfxCylinder *cylinder = (PfxCylinder*)shape; - PfxVector3 u(1.0f,0.0f,0.0f); - - PfxFloat udotv = dot(seperatingAxis,u); - PfxFloat s = seperatingAxis[1]*seperatingAxis[1]+seperatingAxis[2]*seperatingAxis[2]; - if(s < 0.000001f) { - supportVertex = u * (udotv > 0.0f ? cylinder->m_halfLen + SCE_PFX_GJK_MARGIN : -cylinder->m_halfLen-SCE_PFX_GJK_MARGIN); - } - else { - PfxVector3 dir = u * (udotv > 0.0f ? cylinder->m_halfLen : -cylinder->m_halfLen); - PfxVector3 vYZ = seperatingAxis; - vYZ[0] = 0.0f; - vYZ /= sqrtf(s); - supportVertex = dir + vYZ * (cylinder->m_radius) + normalize(seperatingAxis) * SCE_PFX_GJK_MARGIN; - } -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.h deleted file mode 100644 index b7ede87bf..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_gjk_support_func.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_GJK_SUPPORT_FUNC_H -#define _SCE_PFX_GJK_SUPPORT_FUNC_H - -namespace sce { -namespace PhysicsEffects { - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -void pfxGetSupportVertexTriangle(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexTriangleWithThickness(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexConvex(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexBox(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexCapsule(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexSphere(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); -void pfxGetSupportVertexCylinder(void *shape,const PfxVector3 &seperatingAxis,PfxVector3 &supportVertex); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_GJK_SUPPORT_FUNC_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_common.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_common.h deleted file mode 100644 index b7cfd752b..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_common.h +++ /dev/null @@ -1,427 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_COMMON_H -#define _SCE_PFX_INTERSECT_COMMON_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_INTERSECT_COMMON_EPSILON 0.00001f -#define SCE_PFX_RAY_TRIANGLE_EPSILON 0.00001f - -// Internally used intersect functions - -struct PfxTriangle -{ - PfxVector3 points[3]; - - PfxTriangle(const PfxVector3 &p0,const PfxVector3 &p1,const PfxVector3 &p2) - { - points[0] = p0; - points[1] = p1; - points[2] = p2; - } -}; - -struct PfxPlane -{ - PfxVector3 normal; // normal - PfxVector3 point; // point on the plane - - PfxPlane(const PfxVector3 &n,const PfxVector3 &q) - { - normal = n; - point = q; - } - - PfxPlane(const PfxTriangle &triangle) - { - normal = normalize(cross(triangle.points[1]-triangle.points[0],triangle.points[2]-triangle.points[0])); - point = triangle.points[0]; - } - - PfxFloat onPlane(const PfxVector3 &p) const - { - return dot((p-point),normal); - } -}; - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayAABBFast( - const PfxVector3 &rayStartPosition, - const PfxVector3 &rayDirection, - const PfxVector3 &AABBcenter, - const PfxVector3 &AABBhalf, - PfxFloat &variable) -{ - PfxVector3 AABBmin = AABBcenter - AABBhalf; - PfxVector3 AABBmax = AABBcenter + AABBhalf; - - PfxVector3 dir = rayDirection; - PfxVector3 absDir = absPerElem(dir); - PfxVector3 sign = copySignPerElem(PfxVector3(1.0),dir); - -if(absDir[0] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[0] < AABBmin[0] || rayStartPosition[0] > AABBmax[0]) { - return false; - } - dir[0] = sign[0] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - -if(absDir[1] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[1] < AABBmin[1] || rayStartPosition[1] > AABBmax[1]) { - return false; - } - dir[1] = sign[1] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - -if(absDir[2] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[2] < AABBmin[2] || rayStartPosition[2] > AABBmax[2]) { - return false; - } - dir[2] = sign[2] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - - PfxVector3 t1 = divPerElem(AABBmin - rayStartPosition, dir); - PfxVector3 t2 = divPerElem(AABBmax - rayStartPosition, dir); - - PfxVector3 tmin = minPerElem(t1,t2); - PfxVector3 tmax = maxPerElem(t1,t2); - -if(maxElem(tmin) > minElem(tmax)) return false; - -if(tmin[0] > tmin[1]) { - if(tmin[0] > tmin[2]) { - variable = tmin[0]; - } - else { - variable = tmin[2]; - } -} -else { - if(tmin[1] > tmin[2]) { - variable = tmin[1]; - } - else { - variable = tmin[2]; - } -} - - return true; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayAABB( - const PfxVector3 &rayStartPosition, - const PfxVector3 &rayDirection, - const PfxVector3 &AABBcenter, - const PfxVector3 &AABBhalf, - PfxFloat &variable, - PfxVector3 &normal) -{ - PfxVector3 AABBmin = AABBcenter - AABBhalf; - PfxVector3 AABBmax = AABBcenter + AABBhalf; - - PfxVector3 dir = rayDirection; - PfxVector3 absDir = absPerElem(dir); - PfxVector3 sign = copySignPerElem(PfxVector3(1.0),dir); - - // 始点ãŒBoxã®å†…å´ã«ã‚ã‚‹ã‹åˆ¤å®š - if( AABBmin[0] < rayStartPosition[0] && rayStartPosition[0] < AABBmax[0] && - AABBmin[1] < rayStartPosition[1] && rayStartPosition[1] < AABBmax[1] && - AABBmin[2] < rayStartPosition[2] && rayStartPosition[2] < AABBmax[2]) { - return false; - } - -if(absDir[0] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[0] < AABBmin[0] || rayStartPosition[0] > AABBmax[0]) { - return false; - } - dir[0] = sign[0] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - -if(absDir[1] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[1] < AABBmin[1] || rayStartPosition[1] > AABBmax[1]) { - return false; - } - dir[1] = sign[1] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - -if(absDir[2] < SCE_PFX_INTERSECT_COMMON_EPSILON) { - if(rayStartPosition[2] < AABBmin[2] || rayStartPosition[2] > AABBmax[2]) { - return false; - } - dir[2] = sign[2] * SCE_PFX_INTERSECT_COMMON_EPSILON; -} - - PfxVector3 t1 = divPerElem(AABBmin - rayStartPosition, dir); - PfxVector3 t2 = divPerElem(AABBmax - rayStartPosition, dir); - - PfxVector3 tmin = minPerElem(t1,t2); - PfxVector3 tmax = maxPerElem(t1,t2); - - normal = PfxVector3(0); - -if(maxElem(tmin) > minElem(tmax)) return false; - -if(tmin[0] > tmin[1]) { - if(tmin[0] > tmin[2]) { - variable = tmin[0]; - normal[0] = -sign[0]; - } - else { - variable = tmin[2]; - normal[2] = -sign[2]; - } -} -else { - if(tmin[1] > tmin[2]) { - variable = tmin[1]; - normal[1] = -sign[1]; - } - else { - variable = tmin[2]; - normal[2] = -sign[2]; - } -} - - return true; -} - -static SCE_PFX_FORCE_INLINE -void pfxClosestTwoLines( - const PfxVector3 &p1,const PfxVector3 &q1, // line1 - const PfxVector3 &p2,const PfxVector3 &q2, // line2 - PfxVector3 &s1,PfxVector3 &s2) -{ - PfxVector3 v1 = q1-p1; - PfxVector3 v2 = q2-p2; - PfxVector3 r = p1 - p2; - - PfxFloat a = dot(v1,v1); - PfxFloat e = dot(v2,v2); - PfxFloat f = dot(v2,r); - PfxFloat b = dot(v1,v2); - PfxFloat c = dot(v1,r); - PfxFloat den = a*e-b*b; - - PfxFloat s,t; - - if(den != 0.0f) { - s = SCE_PFX_CLAMP((b*f-c*e)/den,0.0f,1.0f); - } - else { - s = 0.0f; - } - - t = (b*s+f)/e; - - if(t < 0.0f) { - t = 0.0f; - s = SCE_PFX_CLAMP(-c/a,0.0f,1.0f); - } - else if(t > 1.0f) { - t = 1.0f; - s = SCE_PFX_CLAMP((b-c)/a,0.0f,1.0f); - } - - s1 = p1 + s * v1; - s2 = p2 + t * v2; -} - -static SCE_PFX_FORCE_INLINE -void pfxClosestPointAABB( - const PfxVector3 &point, - const PfxVector3 &AABBhalf, - PfxVector3 &s) -{ - s = point; - s = maxPerElem(s,-AABBhalf); - s = minPerElem(s,AABBhalf); -} - -static SCE_PFX_FORCE_INLINE -void pfxClosestPointTriangle( - const PfxVector3 &point, - const PfxTriangle &triangle, - PfxVector3 &s) -{ - PfxVector3 a = triangle.points[0]; - PfxVector3 b = triangle.points[1]; - PfxVector3 c = triangle.points[2]; - PfxVector3 ab = b - a; - PfxVector3 ac = c - a; - PfxVector3 ap = point - a; - PfxFloat d1 = dot(ab, ap); - PfxFloat d2 = dot(ac, ap); - if(d1 <= 0.0f && d2 <= 0.0f) { - s = a; - return; - } - - PfxVector3 bp = point - b; - PfxFloat d3 = dot(ab, bp); - PfxFloat d4 = dot(ac, bp); - if (d3 >= 0.0f && d4 <= d3) { - s = b; - return; - } - - PfxFloat vc = d1*d4 - d3*d2; - if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) { - PfxFloat v = d1 / (d1 - d3); - s = a + v * ab; - return; - } - - PfxVector3 cp = point - c; - PfxFloat d5 = dot(ab, cp); - PfxFloat d6 = dot(ac, cp); - if (d6 >= 0.0f && d5 <= d6) { - s = c; - return; - } - - PfxFloat vb = d5*d2 - d1*d6; - if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) { - PfxFloat w = d2 / (d2 - d6); - s = a + w * ac; - return; - } - - PfxFloat va = d3*d6 - d5*d4; - if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) { - PfxFloat w = (d4 - d3) / ((d4 - d3) + (d5 - d6)); - s = b + w * (c - b); - return; - } - - PfxFloat den = 1.0f / (va + vb + vc); - PfxFloat v = vb * den; - PfxFloat w = vc * den; - s = a + ab * v + ac * w; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayTriangle( - const PfxVector3 &rayStartPosition, - const PfxVector3 &rayDirection, - const PfxTriangle &triangle, - PfxFloat &variable) -{ - PfxFloat v,w; - PfxVector3 ab = triangle.points[1] - triangle.points[0]; - PfxVector3 ac = triangle.points[2] - triangle.points[0]; - - PfxVector3 n = cross(ab,ac); - - PfxFloat d = dot(-rayDirection,n); - - if(fabsf(d) < 0.00001f) return false; - - PfxVector3 ap = rayStartPosition - triangle.points[0]; - PfxFloat t = dot(ap,n) / d; - - if(t <= 0.0f || t >= 1.0f) return false; - - variable = t; - - PfxVector3 e = cross(-rayDirection,ap); - v = dot(ac,e) / d; - if(v < -SCE_PFX_RAY_TRIANGLE_EPSILON || v > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - w = -dot(ab,e) / d; - if(w < -SCE_PFX_RAY_TRIANGLE_EPSILON || v+w > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - return true; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayTriangleWithoutFrontFace( - const PfxVector3 &rayStartPosition, - const PfxVector3 &rayDirection, - const PfxTriangle &triangle, - PfxFloat &variable) -{ - PfxFloat v,w; - PfxVector3 ab = triangle.points[1] - triangle.points[0]; - PfxVector3 ac = triangle.points[2] - triangle.points[0]; - - PfxVector3 n = cross(ab,ac); - - PfxFloat d = dot(-rayDirection,n); - - if(d >= 0.0f) return false; - - PfxVector3 ap = rayStartPosition - triangle.points[0]; - PfxFloat t = dot(ap,n) / d; - - if(t <= 0.0f || t >= 1.0f) return false; - - variable = t; - - PfxVector3 e = cross(-rayDirection,ap); - v = dot(ac,e) / d; - if(v < -SCE_PFX_RAY_TRIANGLE_EPSILON || v > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - w = -dot(ab,e) / d; - if(w < -SCE_PFX_RAY_TRIANGLE_EPSILON || v+w > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - return true; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayTriangleWithoutBackFace( - const PfxVector3 &rayStartPosition, - const PfxVector3 &rayDirection, - const PfxTriangle &triangle, - PfxFloat &variable) -{ - PfxFloat v,w; - PfxVector3 ab = triangle.points[1] - triangle.points[0]; - PfxVector3 ac = triangle.points[2] - triangle.points[0]; - - PfxVector3 n = cross(ab,ac); - - PfxFloat d = dot(-rayDirection,n); - - if(d <= 0.0f) return false; - - PfxVector3 ap = rayStartPosition - triangle.points[0]; - PfxFloat t = dot(ap,n) / d; - - if(t <= 0.0f || t >= 1.0f) return false; - - variable = t; - - PfxVector3 e = cross(-rayDirection,ap); - v = dot(ac,e) / d; - if(v < -SCE_PFX_RAY_TRIANGLE_EPSILON || v > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - w = -dot(ab,e) / d; - if(w < -SCE_PFX_RAY_TRIANGLE_EPSILON || v+w > 1.0f+SCE_PFX_RAY_TRIANGLE_EPSILON) return false; - - return true; -} - -} //namespace PhysicsEffects -} //namespace sce - - -#endif // _SCE_PFX_INTERSECT_COMMON_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.cpp deleted file mode 100644 index 9d109f208..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_intersect_common.h" -#include "pfx_intersect_ray_box.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayBox(const PfxRayInput &ray,PfxRayOutput &out,const PfxBox &box,const PfxTransform3 &transform) -{ - // レイをBoxã®ãƒ­ãƒ¼ã‚«ãƒ«åº§æ¨™ã¸å¤‰æ› - PfxTransform3 transformBox = orthoInverse(transform); - PfxVector3 rayStartPosition = transformBox.getUpper3x3() * ray.m_startPosition + transformBox.getTranslation(); - PfxVector3 rayDirection = transformBox.getUpper3x3() * ray.m_direction; - - // 交差判定 - PfxFloat tmpVariable=0.0f; - PfxVector3 tmpNormal(0.0f); - if(pfxIntersectRayAABB(rayStartPosition,rayDirection,PfxVector3(0.0f),box.m_half,tmpVariable,tmpNormal)) { - if(tmpVariable > 0.0f && tmpVariable < out.m_variable) { - out.m_contactFlag = true; - out.m_variable = tmpVariable; - out.m_contactPoint = ray.m_startPosition + tmpVariable * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * tmpNormal; - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } - - return false; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.h deleted file mode 100644 index dfd71417b..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_box.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYBOX_H -#define _SCE_PFX_INTERSECT_RAYBOX_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" -#include "../../../include/physics_effects/base_level/collision/pfx_box.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayBox(const PfxRayInput &ray,PfxRayOutput &out,const PfxBox &box,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYBOX_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.cpp deleted file mode 100644 index 78b8fc407..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_intersect_common.h" -#include "pfx_intersect_ray_capsule.h" - -namespace sce { -namespace PhysicsEffects { -PfxBool pfxIntersectRayCapsule(const PfxRayInput &ray,PfxRayOutput &out,const PfxCapsule &capsule,const PfxTransform3 &transform) -{ - // レイをCapsuleã®ãƒ­ãƒ¼ã‚«ãƒ«åº§æ¨™ã¸å¤‰æ› - PfxTransform3 transformCapsule = orthoInverse(transform); - PfxVector3 startPosL = transformCapsule.getUpper3x3() * ray.m_startPosition + transformCapsule.getTranslation(); - PfxVector3 rayDirL = transformCapsule.getUpper3x3() * ray.m_direction; - - PfxFloat radSqr = capsule.m_radius * capsule.m_radius; - - // 始点ãŒã‚«ãƒ—セルã®å†…å´ã«ã‚ã‚‹ã‹åˆ¤å®š - { - PfxFloat h = fabsf(startPosL[0]); - if(h > capsule.m_halfLen) h = capsule.m_halfLen; - PfxVector3 Px(out.m_variable,0,0); - PfxFloat sqrLen = lengthSqr(startPosL-Px); - if(sqrLen <= radSqr) return false; - } - - // カプセルã®èƒ´ä½“ã¨ã®äº¤å·®åˆ¤å®š - do { - PfxVector3 P(startPosL); - PfxVector3 D(rayDirL); - - P[0] = 0.0f; - D[0] = 0.0f; - - PfxFloat a = dot(D,D); - PfxFloat b = dot(P,D); - PfxFloat c = dot(P,P) - radSqr; - - PfxFloat d = b * b - a * c; - - if(d < 0.0f || fabs(a) < 0.00001f) return false; - - PfxFloat tt = ( -b - sqrtf(d) ) / a; - - if(tt < 0.0f) - break; - else if(tt > 1.0f) - return false; - - if(tt < out.m_variable) { - PfxVector3 cp = startPosL + tt * rayDirL; - - if(fabsf(cp[0]) <= capsule.m_halfLen) { - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = PfxVector3(transform * PfxPoint3(cp)); - out.m_contactNormal = transform.getUpper3x3() * normalize(cp); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } - } while(0); - - // カプセルã®ä¸¡ç«¯ã«ã‚ã‚‹çƒä½“ã¨ã®äº¤å·®åˆ¤å®š - PfxFloat a = dot(rayDirL,rayDirL); - if(fabs(a) < 0.00001f) return false; - - do { - PfxVector3 center(capsule.m_halfLen,0.0f,0.0f); - PfxVector3 v = startPosL - center; - - PfxFloat b = dot(v,rayDirL); - PfxFloat c = dot(v,v) - radSqr; - - PfxFloat d = b * b - a * c; - - if(d < 0.0f) break; - - PfxFloat tt = ( -b - sqrtf(d) ) / a; - - if(tt < 0.0f || tt > 1.0f) break; - - if(tt < out.m_variable) { - PfxVector3 cp = startPosL + tt * rayDirL; - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = ray.m_startPosition + tt * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * normalize(cp-center); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } while(0); - - { - PfxVector3 center(-capsule.m_halfLen,0.0f,0.0f); - PfxVector3 v = startPosL - center; - - PfxFloat b = dot(v,rayDirL); - PfxFloat c = dot(v,v) - radSqr; - - PfxFloat d = b * b - a * c; - - if(d < 0.0f) return false; - - PfxFloat tt = ( -b - sqrtf(d) ) / a; - - if(tt < 0.0f || tt > 1.0f) return false; - - if(tt < out.m_variable) { - PfxVector3 cp = startPosL + out.m_variable * rayDirL; - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = ray.m_startPosition + tt * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * normalize(cp-center); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } - - return false; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.h deleted file mode 100644 index 559ebf5c1..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_capsule.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYCAPSULE_H -#define _SCE_PFX_INTERSECT_RAYCAPSULE_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" -#include "../../../include/physics_effects/base_level/collision/pfx_capsule.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayCapsule(const PfxRayInput &ray,PfxRayOutput &out,const PfxCapsule &capsule,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYCAPSULE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.cpp deleted file mode 100644 index 303ae7395..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" -#include "pfx_intersect_common.h" -#include "pfx_intersect_ray_convex.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayConvex(const PfxRayInput &ray,PfxRayOutput &out,const void *shape,const PfxTransform3 &transform) -{ - const PfxConvexMesh *convex = (const PfxConvexMesh*)shape; - - // レイをConvexã®ãƒ­ãƒ¼ã‚«ãƒ«åº§æ¨™ã¸å¤‰æ› - PfxTransform3 transformConvex = orthoInverse(transform); - PfxVector3 startPosL = transformConvex.getUpper3x3() * ray.m_startPosition + transformConvex.getTranslation(); - PfxVector3 rayDirL = transformConvex.getUpper3x3() * ray.m_direction; - - // レイã¨Convexã®äº¤å·®åˆ¤å®š - PfxFloat tmpVariable(0.0f); - PfxVector3 tmpNormal; - bool ret = false; - for(PfxUInt32 f=0;f<(PfxUInt32)convex->m_numIndices/3;f++) { - PfxTriangle triangle( - convex->m_verts[convex->m_indices[f*3 ]], - convex->m_verts[convex->m_indices[f*3+1]], - convex->m_verts[convex->m_indices[f*3+2]]); - - if(pfxIntersectRayTriangleWithoutBackFace(startPosL,rayDirL,triangle,tmpVariable) && tmpVariable < out.m_variable) { - out.m_contactFlag = true; - out.m_variable = tmpVariable; - out.m_contactPoint = ray.m_startPosition + tmpVariable * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * normalize(cross(triangle.points[2]-triangle.points[1],triangle.points[0]-triangle.points[1])); - out.m_subData.m_type = PfxSubData::NONE; - ret = true; - } - } - - return ret; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.h deleted file mode 100644 index 548290015..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_convex.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYCONVEX_H -#define _SCE_PFX_INTERSECT_RAYCONVEX_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayConvex(const PfxRayInput &ray,PfxRayOutput &out,const void *shape,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYCONVEX_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.cpp deleted file mode 100644 index 8b28dfcfb..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_intersect_common.h" -#include "pfx_intersect_ray_cylinder.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayCylinder(const PfxRayInput &ray,PfxRayOutput &out,const PfxCylinder &cylinder,const PfxTransform3 &transform) -{ - // レイを円柱ã®ãƒ­ãƒ¼ã‚«ãƒ«åº§æ¨™ã¸å¤‰æ› - PfxTransform3 transformCapsule = orthoInverse(transform); - PfxVector3 startPosL = transformCapsule.getUpper3x3() * ray.m_startPosition + transformCapsule.getTranslation(); - PfxVector3 rayDirL = transformCapsule.getUpper3x3() * ray.m_direction; - - PfxFloat radSqr = cylinder.m_radius * cylinder.m_radius; - - // 始点ãŒå††æŸ±ã®å†…å´ã«ã‚ã‚‹ã‹åˆ¤å®š - { - PfxFloat h = fabsf(startPosL[0]); - if(h > cylinder.m_halfLen) h = cylinder.m_halfLen; - PfxVector3 Px(out.m_variable,0,0); - PfxFloat sqrLen = lengthSqr(startPosL-Px); - if(sqrLen <= radSqr) return false; - } - - // 円柱ã®èƒ´ä½“ã¨ã®äº¤å·®åˆ¤å®š - do { - PfxVector3 P(startPosL); - PfxVector3 D(rayDirL); - - P[0] = 0.0f; - D[0] = 0.0f; - - PfxFloat a = dot(D,D); - PfxFloat b = dot(P,D); - PfxFloat c = dot(P,P) - radSqr; - - PfxFloat d = b * b - a * c; - - if(d < 0.0f || fabs(a) < 0.00001f) return false; - - PfxFloat tt = ( -b - sqrtf(d) ) / a; - - if(tt < 0.0f) - break; - else if(tt > 1.0f) - return false; - - if(tt < out.m_variable) { - PfxVector3 cp = startPosL + tt * rayDirL; - - if(fabsf(cp[0]) <= cylinder.m_halfLen) { - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = PfxVector3(transform * PfxPoint3(cp)); - out.m_contactNormal = transform.getUpper3x3() * normalize(cp); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } - } while(0); - - // 円柱ã®ä¸¡ç«¯ã«ã‚ã‚‹å¹³é¢ã¨ã®äº¤å·®åˆ¤å®š - { - if(fabsf(rayDirL[0]) < 0.00001f) return false; - - PfxFloat t1 = ( cylinder.m_halfLen - startPosL[0] ) / rayDirL[0]; - PfxFloat t2 = ( - cylinder.m_halfLen - startPosL[0] ) / rayDirL[0]; - - PfxFloat tt = SCE_PFX_MIN(t1,t2); - - if(tt < 0.0f || tt > 1.0f) return false; - - PfxVector3 p = startPosL + tt * rayDirL; - p[0] = 0.0f; - - if(lengthSqr(p) < radSqr && tt < out.m_variable) { - PfxVector3 cp = startPosL + tt * rayDirL; - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = ray.m_startPosition + tt * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * ((cp[0]>0.0f)?PfxVector3(1.0,0.0,0.0):PfxVector3(-1.0,0.0,0.0)); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - } - - return false; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.h deleted file mode 100644 index ccee5ff0a..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_cylinder.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYCYLINDER_H -#define _SCE_PFX_INTERSECT_RAYCYLINDER_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" -#include "../../../include/physics_effects/base_level/collision/pfx_cylinder.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayCylinder(const PfxRayInput &ray,PfxRayOutput &out,const PfxCylinder &cylinder,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYCYLINDER_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.cpp deleted file mode 100644 index a1e1c9fea..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_large_tri_mesh.h" -#include "pfx_intersect_common.h" -#include "pfx_mesh_common.h" -#include "pfx_intersect_ray_large_tri_mesh.h" - - -namespace sce { -namespace PhysicsEffects { - - -static SCE_PFX_FORCE_INLINE -PfxBool pfxIntersectRayTriMesh(const PfxTriMesh &mesh,const PfxVector3 &rayStart,const PfxVector3 &rayDir, - PfxUInt32 facetMode,PfxFloat &variable,PfxVector3 &normal,PfxSubData &subData) -{ - bool ret = false; - PfxFloat nearest_t = variable; - PfxVector3 nearest_nml(0.0f); - PfxUInt32 nearest_f = 0; - - for(PfxUInt32 f=0;f pfxGetXMax(aabbB)) continue; - if(aabbMaxL.getY() < pfxGetYMin(aabbB) || aabbMinL.getY() > pfxGetYMax(aabbB)) continue; - if(aabbMaxL.getZ() < pfxGetZMin(aabbB) || aabbMinL.getZ() > pfxGetZMax(aabbB)) continue; - // Todo:早期終了ãƒã‚§ãƒƒã‚¯ - - PfxVector3 aabbMin,aabbMax; - aabbMin = largeMesh.getWorldPosition(PfxVecInt3((PfxFloat)pfxGetXMin(aabbB),(PfxFloat)pfxGetYMin(aabbB),(PfxFloat)pfxGetZMin(aabbB))); - aabbMax = largeMesh.getWorldPosition(PfxVecInt3((PfxFloat)pfxGetXMax(aabbB),(PfxFloat)pfxGetYMax(aabbB),(PfxFloat)pfxGetZMax(aabbB))); - - PfxFloat tmpVariable = 1.0f; - PfxVector3 tmpNormal; - - if( !pfxIntersectRayAABBFast( - rayStartPosition,rayDirection, - (aabbMax+aabbMin)*0.5f, - (aabbMax-aabbMin)*0.5f, - tmpVariable) ) - continue; - - if( out.m_variable <= tmpVariable ) continue; - - // アイランドã¨ã®äº¤å·®ãƒã‚§ãƒƒã‚¯ - const PfxTriMesh *island = &largeMesh.m_islands[i]; - - PfxSubData subData; - tmpVariable = out.m_variable; - - if( pfxIntersectRayTriMesh(*island,rayStartPosition,rayDirection,ray.m_facetMode,tmpVariable,tmpNormal,subData) && - tmpVariable < out.m_variable ) { - out.m_contactFlag = true; - out.m_variable = tmpVariable; - out.m_contactPoint = ray.m_startPosition + tmpVariable * ray.m_direction; - out.m_contactNormal = transform.getUpper3x3() * tmpNormal; - subData.setIslandId(i); - out.m_subData = subData; - ret = true; - } - - } - } - - return ret; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.h deleted file mode 100644 index 5bb49703f..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_large_tri_mesh.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYLARGETRIMESH_H -#define _SCE_PFX_INTERSECT_RAYLARGETRIMESH_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRayLargeTriMesh(const PfxRayInput &ray,PfxRayOutput &out,const void *shape,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYLARGETRIMESH_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.cpp deleted file mode 100644 index 6de422b00..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" -#include "pfx_intersect_common.h" -#include "pfx_intersect_ray_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRaySphere(const PfxRayInput &ray,PfxRayOutput &out,const PfxSphere &sphere,const PfxTransform3 &transform) -{ - PfxVector3 v = ray.m_startPosition - transform.getTranslation(); - - PfxFloat a = dot(ray.m_direction,ray.m_direction); - PfxFloat b = dot(v,ray.m_direction); - PfxFloat c = dot(v,v) - sphere.m_radius * sphere.m_radius; - - if(c < 0.0f) return false; - - PfxFloat d = b * b - a * c; - - if(d < 0.0f || fabsf(a) < 0.00001f) return false; - - PfxFloat tt = ( -b - sqrtf(d) ) / a; - - if(tt < 0.0f || tt > 1.0f) return false; - - if(tt < out.m_variable) { - out.m_contactFlag = true; - out.m_variable = tt; - out.m_contactPoint = ray.m_startPosition + tt * ray.m_direction; - out.m_contactNormal = normalize(out.m_contactPoint - transform.getTranslation()); - out.m_subData.m_type = PfxSubData::NONE; - return true; - } - - return false; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.h deleted file mode 100644 index 5df29718e..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_intersect_ray_sphere.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAYSPHERE_H -#define _SCE_PFX_INTERSECT_RAYSPHERE_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" -#include "../../../include/physics_effects/base_level/collision/pfx_sphere.h" - -namespace sce { -namespace PhysicsEffects { - -PfxBool pfxIntersectRaySphere(const PfxRayInput &ray,PfxRayOutput &out,const PfxSphere &sphere,const PfxTransform3 &transform); - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_INTERSECT_RAYSPHERE_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_mesh_common.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_mesh_common.h deleted file mode 100644 index bd2d8ffa1..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_mesh_common.h +++ /dev/null @@ -1,194 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_MESH_COMMON_H -#define _SCE_PFX_MESH_COMMON_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -#include "../../../include/physics_effects/base_level/collision/pfx_tri_mesh.h" - -namespace sce { -namespace PhysicsEffects { - - -struct PfxClosestPoints { - PfxPoint3 pA[4],pB[4]; - PfxFloat distSqr[4]; - PfxFloat closestDistSqr; - int numPoints; - SCE_PFX_PADDING(1,8) - - PfxClosestPoints() - { - numPoints = 0; - closestDistSqr = SCE_PFX_FLT_MAX; - } - - void set(int i,const PfxPoint3 &pointA,const PfxPoint3 &pointB,PfxFloat d) - { - pA[i] = pointA; - pB[i] = pointB; - distSqr[i] = d; - } - - void add(const PfxPoint3 &pointA,const PfxPoint3 &pointB,PfxFloat d) - { - const PfxFloat epsilon = 0.00001f; - if(closestDistSqr < d) return; - - closestDistSqr = d + epsilon; - - int replaceId = -1; - PfxFloat distMax = -SCE_PFX_FLT_MAX; - for(int i=0;im_numFacets;f++) { - const PfxFacet &facet = mesh->m_facets[f]; - - PfxVector3 facetCenter = absPerElem(offsetPos + offsetRot * pfxReadVector3(facet.m_center)); - PfxVector3 halfBA = absOffsetRot * pfxReadVector3(facet.m_half); - - // ConvexBã®AABBã¨ãƒã‚§ãƒƒã‚¯ - if(facetCenter[0] > (halfBA[0]+aabbHalf[0])) continue; - if(facetCenter[1] > (halfBA[1]+aabbHalf[1])) continue; - if(facetCenter[2] > (halfBA[2]+aabbHalf[2])) continue; - - // ã“ã®é¢ã¯åˆ¤å®š - selFacets[numSelFacets++] = (PfxUInt8)f; -} - - return numSelFacets; -} - -static SCE_PFX_FORCE_INLINE -void pfxGetProjAxisPnts6( - const PfxVector3 *verts,const PfxVector3 &axis, - PfxFloat &distMin,PfxFloat &distMax) -{ -PfxFloat p0 = dot(axis, verts[0]); -PfxFloat p1 = dot(axis, verts[1]); -PfxFloat p2 = dot(axis, verts[2]); -PfxFloat p3 = dot(axis, verts[3]); -PfxFloat p4 = dot(axis, verts[4]); -PfxFloat p5 = dot(axis, verts[5]); -distMin = SCE_PFX_MIN(p5,SCE_PFX_MIN(p4,SCE_PFX_MIN(p3,SCE_PFX_MIN(p2,SCE_PFX_MIN(p0,p1))))); -distMax = SCE_PFX_MAX(p5,SCE_PFX_MAX(p4,SCE_PFX_MAX(p3,SCE_PFX_MAX(p2,SCE_PFX_MAX(p0,p1))))); -} - -static SCE_PFX_FORCE_INLINE -void pfxGetProjAxisPnts3( - const PfxVector3 *verts,const PfxVector3 &axis, - PfxFloat &distMin,PfxFloat &distMax) -{ -PfxFloat p0 = dot(axis, verts[0]); -PfxFloat p1 = dot(axis, verts[1]); -PfxFloat p2 = dot(axis, verts[2]); -distMin = SCE_PFX_MIN(p2,SCE_PFX_MIN(p0,p1)); -distMax = SCE_PFX_MAX(p2,SCE_PFX_MAX(p0,p1)); -} - -static SCE_PFX_FORCE_INLINE -void pfxGetProjAxisPnts2( - const PfxVector3 *verts,const PfxVector3 &axis, - PfxFloat &distMin,PfxFloat &distMax) -{ -PfxFloat p0 = dot(axis, verts[0]); -PfxFloat p1 = dot(axis, verts[1]); -distMin = SCE_PFX_MIN(p0,p1); -distMax = SCE_PFX_MAX(p0,p1); -} - -/////////////////////////////////////////////////////////////////////////////// -// ï¼’ã¤ã®ãƒ™ã‚¯ãƒˆãƒ«ã®å‘ãã‚’ãƒã‚§ãƒƒã‚¯ - -static SCE_PFX_FORCE_INLINE -bool pfxIsSameDirection(const PfxVector3 &vecA,const PfxVector3 &vecB) -{ -return fabsf(dot(vecA,vecB)) > 0.9999f; -} - -/////////////////////////////////////////////////////////////////////////////// -// é¢ãƒ­ãƒ¼ã‚«ãƒ«ã®åº§æ¨™ã‚’算出 - -static SCE_PFX_FORCE_INLINE -void pfxGetLocalCoords( - const PfxVector3 &pointOnTriangle, - const PfxTriangle &triangle, - PfxFloat &s,PfxFloat &t) -{ - PfxVector3 v0 = triangle.points[1] - triangle.points[0]; - PfxVector3 v1 = triangle.points[2] - triangle.points[0]; - PfxVector3 dir = pointOnTriangle - triangle.points[0]; - PfxVector3 v = cross( v0, v1 ); - PfxVector3 crS = cross( v, v0 ); - PfxVector3 crT = cross( v, v1 ); - s = dot( crT, dir ) / dot( crT, v0 ); - t = dot( crS, dir ) / dot( crS, v1 ); -} - -// a,bã‹ã‚‰ãªã‚‹ç›´ç·šä¸Šã«ç‚¹pãŒã‚ã‚‹ã‹ã©ã†ã‹ã‚’判定 -static SCE_PFX_FORCE_INLINE -bool pfxPointOnLine(const PfxVector3 &p,const PfxVector3 &a,const PfxVector3 &b) -{ - PfxVector3 ab = normalize(b-a); - PfxVector3 q = a + ab * dot(p-a,ab); - return lengthSqr(p-q) < 0.00001f; -} - -// 線分a,b上ã«ç‚¹pãŒã‚ã‚‹ã‹ã©ã†ã‹ã‚’判定 -static SCE_PFX_FORCE_INLINE -bool pfxPointOnSegment(const PfxVector3 &p,const PfxVector3 &a,const PfxVector3 &b) -{ - PfxVector3 ab = b-a; - PfxVector3 ap = p-a; - PfxFloat denom = dot(ab,ab); - PfxFloat num = dot(ap,ab); - PfxFloat t = num/denom; - if(t < 0.0f || t > 1.0f) return false; - return (dot(ap,ap)-num*t) < 0.00001f; -} - - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_MESH_COMMON_H diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_shape.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_shape.cpp deleted file mode 100644 index 0f9ef88e5..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_shape.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_shape.h" - -namespace sce { -namespace PhysicsEffects { -void pfxGetShapeAabbDummy(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - (void)shape,(void)aabbMin,(void)aabbMax; -} - -void pfxGetShapeAabbSphere(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - aabbMin = shape.getOffsetPosition() - PfxVector3(shape.getSphere().m_radius); - aabbMax = shape.getOffsetPosition() + PfxVector3(shape.getSphere().m_radius); -} - -void pfxGetShapeAabbBox(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - PfxVector3 boxSize = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * shape.getBox().m_half; - aabbMin = shape.getOffsetPosition() - boxSize; - aabbMax = shape.getOffsetPosition() + boxSize; -} - -void pfxGetShapeAabbCapsule(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - PfxVector3 dir = rotate(shape.getOffsetOrientation(),PfxVector3(1.0f,0.0f,0.0f)); - PfxVector3 capSize = absPerElem(dir) * shape.getCapsule().m_halfLen + - PfxVector3(shape.getCapsule().m_radius); - aabbMin = shape.getOffsetPosition() - capSize; - aabbMax = shape.getOffsetPosition() + capSize; -} - -void pfxGetShapeAabbCylinder(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - PfxVector3 capSize = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * - PfxVector3(shape.getCylinder().m_halfLen,shape.getCylinder().m_radius,shape.getCylinder().m_radius); - aabbMin = shape.getOffsetPosition() - capSize; - aabbMax = shape.getOffsetPosition() + capSize; -} - -void pfxGetShapeAabbConvexMesh(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - const PfxConvexMesh *convex = shape.getConvexMesh(); - PfxVector3 half = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * convex->m_half; - aabbMin = shape.getOffsetPosition() - half; - aabbMax = shape.getOffsetPosition() + half; -} - -void pfxGetShapeAabbLargeTriMesh(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax) -{ - const PfxLargeTriMesh *largemesh = shape.getLargeTriMesh(); - PfxVector3 half = absPerElem(PfxMatrix3(shape.getOffsetOrientation())) * largemesh->m_half; - aabbMin = shape.getOffsetPosition() - half; - aabbMax = shape.getOffsetPosition() + half; -} - -typedef void (*PfxFuncGetShapeAabb)(const PfxShape &shape,PfxVector3 &aabbMin,PfxVector3 &aabbMax); - -PfxFuncGetShapeAabb pfxFuncGetShapeAabb[kPfxShapeCount] = { - pfxGetShapeAabbSphere, - pfxGetShapeAabbBox, - pfxGetShapeAabbCapsule, - pfxGetShapeAabbCylinder, - pfxGetShapeAabbConvexMesh, - pfxGetShapeAabbLargeTriMesh, - pfxGetShapeAabbDummy, - pfxGetShapeAabbDummy, - pfxGetShapeAabbDummy, - pfxGetShapeAabbDummy, - pfxGetShapeAabbDummy, - pfxGetShapeAabbDummy, -}; - -void PfxShape::getAabb(PfxVector3 &aabbMin,PfxVector3 &aabbMax) const -{ - return pfxFuncGetShapeAabb[m_type](*this,aabbMin,aabbMax); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.cpp b/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.cpp deleted file mode 100644 index 197555d70..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "pfx_simplex_solver.h" -#include "pfx_gjk_solver.h" - -namespace sce { -namespace PhysicsEffects { -inline static -bool operator ==(const PfxVector3 &a,const PfxVector3 &b) -{ - return lengthSqr(a-b) < (SCE_PFX_GJK_EPSILON * SCE_PFX_GJK_EPSILON); -} - -bool PfxSimplexSolver::closest(PfxVector3& v) -{ - bool ret = false; - - bc.reset(); - - switch(numVertices) { - case 0: - ret = false; - break; - - case 1: - { - PfxVector3 tmpP = P[0]; - PfxVector3 tmpQ = Q[0]; - v = tmpP-tmpQ; - bc.reset(); - bc.setBarycentricCoordinates(1.0f,0.0f,0.0f,0.0f); - ret = bc.isValid(); - } - break; - - case 2: - { - PfxVector3 dir = W[1] - W[0]; - PfxFloat t = dot(-W[0],dir) / dot(dir,dir); - - if(t < 0.0f) t = 0.0f; - if(t > 1.0f) t = 1.0f; - - bc.setBarycentricCoordinates(1-t,t,0.0f,0.0f); - - PfxVector3 tmpP = P[0] + t * (P[1] - P[0]); - PfxVector3 tmpQ = Q[0] + t * (Q[1] - Q[0]); - v = tmpP - tmpQ; - - reduceVertices(); - - ret = bc.isValid(); - break; - } - - case 3: - { - const PfxVector3& a = W[0]; - const PfxVector3& b = W[1]; - const PfxVector3& c = W[2]; - - closestPointTriangleFromOrigin(a,b,c,bc); - - PfxVector3 tmpP = P[0] * bc.barycentricCoords[0] + - P[1] * bc.barycentricCoords[1] + - P[2] * bc.barycentricCoords[2]; - - PfxVector3 tmpQ = Q[0] * bc.barycentricCoords[0] + - Q[1] * bc.barycentricCoords[1] + - Q[2] * bc.barycentricCoords[2]; - - v = tmpP-tmpQ; - - reduceVertices(); - ret = bc.isValid(); - break; - } - - case 4: - { - const PfxVector3& a = W[0]; - const PfxVector3& b = W[1]; - const PfxVector3& c = W[2]; - const PfxVector3& d = W[3]; - - if(closestPointTetrahedronFromOrigin(a,b,c,d,bc)) { - PfxVector3 tmpP = P[0] * bc.barycentricCoords[0] + - P[1] * bc.barycentricCoords[1] + - P[2] * bc.barycentricCoords[2] + - P[3] * bc.barycentricCoords[3]; - - PfxVector3 tmpQ = Q[0] * bc.barycentricCoords[0] + - Q[1] * bc.barycentricCoords[1] + - Q[2] * bc.barycentricCoords[2] + - Q[3] * bc.barycentricCoords[3]; - v = tmpP-tmpQ; - - reduceVertices(); - ret = bc.isValid(); - } else { - // 原点ãŒå†…部ã«å­˜åœ¨â†’交差ã—ã¦ã„ã‚‹ - ret = true; - v = PfxVector3(0.0f); - } - break; - } - }; - - return ret; -} - -bool PfxSimplexSolver::inSimplex(const PfxVector3& w) -{ - for(int i=0;i= 0.0f && d4 <= d3) { - result.closest = b; - result.setBarycentricCoordinates(0.0f,1.0f,0.0f,0.0f); - return true; - } - - PfxFloat vc = d1*d4 - d3*d2; - if(vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) { - PfxFloat v = d1 / (d1 - d3); - result.closest = a + v * ab; - result.setBarycentricCoordinates(1.0f-v,v,0.0f,0.0f); - return true; - } - - PfxVector3 cp = p - c; - PfxFloat d5 = dot(ab,cp); - PfxFloat d6 = dot(ac,cp); - if(d6 >= 0.0f && d5 <= d6) { - result.closest = c; - result.setBarycentricCoordinates(0.0f,0.0f,1.0f,0.0f); - return true; - } - - PfxFloat vb = d5*d2 - d1*d6; - if(vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) { - PfxFloat w = d2 / (d2 - d6); - result.closest = a + w * ac; - result.setBarycentricCoordinates(1.0f-w,0.0f,w,0.0f); - return true; - } - - PfxFloat va = d3*d6 - d5*d4; - if(va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) { - PfxFloat w = (d4 - d3) / ((d4 - d3) + (d5 - d6)); - result.closest = b + w * (c - b); - result.setBarycentricCoordinates(0.0f,1.0f-w,w,0.0f); - return true; - } - - PfxFloat denom = PfxFloat(1.0) / (va + vb + vc); - PfxFloat v = vb * denom; - PfxFloat w = vc * denom; - - result.closest = a + ab * v + ac * w; - result.setBarycentricCoordinates(1.0f-v-w,v,w,0.0f); - - return true; -} - -bool PfxSimplexSolver::closestPointTetrahedronFromOrigin(const PfxVector3 &a,const PfxVector3 &b,const PfxVector3 &c,const PfxVector3 &d,PfxBarycentricCoords& finalResult) -{ - PfxBarycentricCoords tempResult; - PfxVector3 p(0.0f); - - finalResult.closest = p; - finalResult.usedVertices = 0; - - bool pointOutsideABC = originOutsideOfPlane(a, b, c, d); - bool pointOutsideACD = originOutsideOfPlane(a, c, d, b); - bool pointOutsideADB = originOutsideOfPlane(a, d, b, c); - bool pointOutsideBDC = originOutsideOfPlane(b, d, c, a); - - if(!pointOutsideABC && !pointOutsideACD && !pointOutsideADB && !pointOutsideBDC) - return false; - - PfxFloat bestSqDist = SCE_PFX_FLT_MAX; - - if(pointOutsideABC) { - closestPointTriangleFromOrigin(a, b, c,tempResult); - PfxVector3 q = tempResult.closest; - PfxFloat sqDist = dot((q - p),(q - p)); - if(sqDist < bestSqDist) { - bestSqDist = sqDist; - finalResult.closest = q; - finalResult.setBarycentricCoordinates( - tempResult.barycentricCoords[0], - tempResult.barycentricCoords[1], - tempResult.barycentricCoords[2], - 0); - } - } - - if(pointOutsideACD) { - closestPointTriangleFromOrigin(a, c, d,tempResult); - PfxVector3 q = tempResult.closest; - PfxFloat sqDist = dot((q - p),(q - p)); - if(sqDist < bestSqDist) { - bestSqDist = sqDist; - finalResult.closest = q; - finalResult.setBarycentricCoordinates( - tempResult.barycentricCoords[0], - 0, - tempResult.barycentricCoords[1], - tempResult.barycentricCoords[2]); - } - } - - if(pointOutsideADB) { - closestPointTriangleFromOrigin(a, d, b,tempResult); - PfxVector3 q = tempResult.closest; - PfxFloat sqDist = dot((q - p),(q - p)); - if(sqDist < bestSqDist) { - bestSqDist = sqDist; - finalResult.closest = q; - finalResult.setBarycentricCoordinates( - tempResult.barycentricCoords[0], - tempResult.barycentricCoords[2], - 0, - tempResult.barycentricCoords[1]); - } - } - - if(pointOutsideBDC) { - closestPointTriangleFromOrigin(b, d, c,tempResult); - PfxVector3 q = tempResult.closest; - PfxFloat sqDist = dot((q - p),(q - p)); - if(sqDist < bestSqDist) { - bestSqDist = sqDist; - finalResult.closest = q; - finalResult.setBarycentricCoordinates( - 0, - tempResult.barycentricCoords[0], - tempResult.barycentricCoords[2], - tempResult.barycentricCoords[1]); - } - } - - return true; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.h b/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.h deleted file mode 100644 index a8aa1a5c2..000000000 --- a/Extras/PhysicsEffects/src/base_level/collision/pfx_simplex_solver.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_SIMPLEX_SOLVER_H -#define _SCE_PFX_SIMPLEX_SOLVER_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" - -namespace sce { -namespace PhysicsEffects { - - -/////////////////////////////////////////////////////////////////////////////// -// Voronoi Simplex Solver - -struct SCE_PFX_ALIGNED(16) PfxBarycentricCoords { - PfxVector3 closest; -PfxFloat barycentricCoords[4]; - unsigned int usedVertices; - SCE_PFX_PADDING(1,12) - - void reset() - { - barycentricCoords[0] = 0.0f; - barycentricCoords[1] = 0.0f; - barycentricCoords[2] = 0.0f; - barycentricCoords[3] = 0.0f; - usedVertices = 0; - } - - bool isValid() - { - return (barycentricCoords[0] >= 0.0f) && - (barycentricCoords[1] >= 0.0f) && - (barycentricCoords[2] >= 0.0f) && - (barycentricCoords[3] >= 0.0f); - } - -void setBarycentricCoordinates(PfxFloat a,PfxFloat b,PfxFloat c,PfxFloat d) -{ - barycentricCoords[0] = a; - barycentricCoords[1] = b; - barycentricCoords[2] = c; - barycentricCoords[3] = d; - if(a != 0.0f) usedVertices |= 1<<3; - if(b != 0.0f) usedVertices |= 1<<2; - if(c != 0.0f) usedVertices |= 1<<1; - if(d != 0.0f) usedVertices |= 1; -} -}; - -class PfxSimplexSolver { -private: - static const int MAX_VERTS = 4; - -public: - int numVertices; - SCE_PFX_PADDING(1,12) - PfxVector3 W[MAX_VERTS]; - PfxVector3 P[MAX_VERTS]; - PfxVector3 Q[MAX_VERTS]; - - PfxBarycentricCoords bc; - - inline void removeVertex(int index); - inline void reduceVertices (); - - inline bool originOutsideOfPlane(const PfxVector3& a, const PfxVector3& b, const PfxVector3& c, const PfxVector3& d); - bool closestPointTetrahedronFromOrigin(const PfxVector3 &a,const PfxVector3 &b,const PfxVector3 &c,const PfxVector3 &d, PfxBarycentricCoords& result); - bool closestPointTriangleFromOrigin(const PfxVector3 &a,const PfxVector3 &b,const PfxVector3 &c,PfxBarycentricCoords& result); - -public: - void reset() - { - numVertices = 0; - bc.reset(); - } - - inline void addVertex(const PfxVector3& w_, const PfxVector3& p_, const PfxVector3& q_); - - bool closest(PfxVector3& v); - - bool fullSimplex() const - { - return (numVertices == 4); - } - - bool inSimplex(const PfxVector3& w); -}; - -inline -void PfxSimplexSolver::removeVertex(int index) -{ - SCE_PFX_ASSERT(numVertices>0); - numVertices--; - W[index] = W[numVertices]; - P[index] = P[numVertices]; - Q[index] = Q[numVertices]; -} - -inline -void PfxSimplexSolver::reduceVertices () -{ - if ((numVertices >= 4) && (!(bc.usedVertices&0x01))) - removeVertex(3); - - if ((numVertices >= 3) && (!(bc.usedVertices&0x02))) - removeVertex(2); - - if ((numVertices >= 2) && (!(bc.usedVertices&0x04))) - removeVertex(1); - - if ((numVertices >= 1) && (!(bc.usedVertices&0x08))) - removeVertex(0); -} - -inline -void PfxSimplexSolver::addVertex(const PfxVector3& w, const PfxVector3& p, const PfxVector3& q) -{ - W[numVertices] = w; - P[numVertices] = p; - Q[numVertices] = q; - numVertices++; -} - -inline -bool PfxSimplexSolver::originOutsideOfPlane(const PfxVector3& a, const PfxVector3& b, const PfxVector3& c, const PfxVector3& d) -{ - PfxVector3 normal = cross((b-a),(c-a)); - - PfxFloat signp = dot(-a,normal); - PfxFloat signd = dot((d - a),normal); - - return signp * signd < 0.0f; -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_SIMPLEX_SOLVER_H diff --git a/Extras/PhysicsEffects/src/base_level/premake4.lua b/Extras/PhysicsEffects/src/base_level/premake4.lua deleted file mode 100644 index 112a875ce..000000000 --- a/Extras/PhysicsEffects/src/base_level/premake4.lua +++ /dev/null @@ -1,12 +0,0 @@ - project "physicseffects2_baselevel" - - kind "StaticLib" - targetdir "../../build/lib" - includedirs { - ".", - } - files { - "**.cpp", - "../../include/physics_effects/base_level/**.h" - - } \ No newline at end of file diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_check_solver.h b/Extras/PhysicsEffects/src/base_level/solver/pfx_check_solver.h deleted file mode 100644 index 417998b3f..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_check_solver.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CHECK_SOLVER_H_ -#define _SCE_PFX_CHECK_SOLVER_H_ - -#include "../../../include/physics_effects/base_level/rigidbody/pfx_rigid_state.h" -#include "../../../include/physics_effects/base_level/solver/pfx_constraint_pair.h" - -namespace sce { -namespace PhysicsEffects { - -// Solver check table -/* - -----------------MotionTypeA - |0 1 0 1 0 - |1 1 1 1 0 - |0 1 0 1 0 - |1 1 1 0 0 - |0 0 0 0 0 -MotionTypeB - */ - -static SCE_PFX_FORCE_INLINE -PfxBool pfxCheckSolverTable(ePfxMotionType i,ePfxMotionType j) -{ - const PfxUInt32 solverTable = 0x00af2b80; - - SCE_PFX_ASSERT(i < kPfxMotionTypeCount); - SCE_PFX_ASSERT(j < kPfxMotionTypeCount); - - PfxUInt32 idx = j * kPfxMotionTypeCount + i; - PfxUInt32 mask = 1 << (kPfxMotionTypeCount*kPfxMotionTypeCount-1-idx); - return (solverTable & mask) != 0; -} - -static SCE_PFX_FORCE_INLINE -PfxBool pfxCheckSolver(const PfxConstraintPair &pair) -{ - PfxUInt32 motionA = pfxGetMotionMaskA(pair)&SCE_PFX_MOTION_MASK_TYPE; - PfxUInt32 motionB = pfxGetMotionMaskB(pair)&SCE_PFX_MOTION_MASK_TYPE; - PfxUInt32 sleepA = pfxGetMotionMaskA(pair)&SCE_PFX_MOTION_MASK_SLEEPING; - PfxUInt32 sleepB = pfxGetMotionMaskB(pair)&SCE_PFX_MOTION_MASK_SLEEPING; - - return - pfxGetActive(pair) && - pfxCheckSolverTable((ePfxMotionType)motionA,(ePfxMotionType)motionB) && // モーションタイプ別è¡çªåˆ¤å®šãƒ†ãƒ¼ãƒ–ル - !((sleepA != 0 && sleepB != 0) || (sleepA != 0 && motionB == kPfxMotionTypeFixed) || (sleepB != 0 && motionA == kPfxMotionTypeFixed));// スリープ時ã®ãƒã‚§ãƒƒã‚¯ -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_CHECK_SOLVER_H_ */ diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver.h b/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver.h deleted file mode 100644 index 146fc411e..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver.h +++ /dev/null @@ -1,296 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_CONSTRAINT_ROW_SOLVER_H -#define _SCE_PFX_CONSTRAINT_ROW_SOLVER_H - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_constraint_row.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_constraint.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Constraint Row Solver - -// ARA begin insert new code -#ifdef __ARM_NEON__ -// prototype for inline NEON assembly version -void pfxSolveLinearConstraintRowNEON(PfxConstraintRow &constraint, - PfxVector3 &deltaLinearVelocityA,PfxVector3 &deltaAngularVelocityA, - PfxFloat &massInvA,const PfxMatrix3 &inertiaInvA,const PfxVector3 &rA, - PfxVector3 &deltaLinearVelocityB,PfxVector3 &deltaAngularVelocityB, - PfxFloat &massInvB,const PfxMatrix3 &inertiaInvB,const PfxVector3 &rB); -#endif // __ARM_NEON__ -// ARA end - -static SCE_PFX_FORCE_INLINE -void pfxSolveLinearConstraintRow(PfxConstraintRow &constraint, - PfxVector3 &deltaLinearVelocityA,PfxVector3 &deltaAngularVelocityA, - PfxFloat massInvA,const PfxMatrix3 &inertiaInvA,const PfxVector3 &rA, - PfxVector3 &deltaLinearVelocityB,PfxVector3 &deltaAngularVelocityB, - PfxFloat massInvB,const PfxMatrix3 &inertiaInvB,const PfxVector3 &rB) -{ -const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); -PfxFloat deltaImpulse = constraint.m_rhs; -PfxVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); -PfxVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); -deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); -PfxFloat oldImpulse = constraint.m_accumImpulse; -constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); -deltaImpulse = constraint.m_accumImpulse - oldImpulse; -deltaLinearVelocityA += deltaImpulse * massInvA * normal; -deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); -deltaLinearVelocityB -= deltaImpulse * massInvB * normal; -deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); -} - -static SCE_PFX_FORCE_INLINE -void pfxSolveAngularConstraintRow(PfxConstraintRow &constraint, - PfxVector3 &deltaAngularVelocityA, - const PfxMatrix3 &inertiaInvA,const PfxVector3 &rA, - PfxVector3 &deltaAngularVelocityB, - const PfxMatrix3 &inertiaInvB,const PfxVector3 &rB) -{ - (void)rA,(void)rB; -const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); -PfxFloat deltaImpulse = constraint.m_rhs; -deltaImpulse -= constraint.m_jacDiagInv * dot(normal,deltaAngularVelocityA-deltaAngularVelocityB); -PfxFloat oldImpulse = constraint.m_accumImpulse; -constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); -deltaImpulse = constraint.m_accumImpulse - oldImpulse; -deltaAngularVelocityA += deltaImpulse * inertiaInvA * normal; -deltaAngularVelocityB -= deltaImpulse * inertiaInvB * normal; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Calc Joint Angle - -static SCE_PFX_FORCE_INLINE -void pfxCalcJointAngleSwingTwist(PfxMatrix3 &worldFrameA,PfxMatrix3 &worldFrameB,PfxFloat *angle,PfxVector3 *axis) -{ - // フレームA座標系ã¸ã®å¤‰æ›ãƒžãƒˆãƒªã‚¯ã‚¹ - PfxMatrix3 frameBA = transpose(worldFrameA) * worldFrameB; - - // クォータニオン回転をtwistã¨swingã«åˆ†é›¢ - PfxQuat swing,twist,qBA(frameBA); - swing = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),frameBA.getCol0()); - twist = qBA * conj(swing); - - if(dot(twist,PfxQuat::rotationX(0.0f)) < 0.0f) { - twist = -twist; - } - - // ãれãžã‚Œã®å›žè»¢è»¸ã¨å›žè»¢è§’度を算出 - pfxGetRotationAngleAndAxis(normalize(twist),angle[0],axis[0]); - pfxGetRotationAngleAndAxis(normalize(swing),angle[1],axis[1]); - - if(angle[1] < 0.00001f) { - axis[1] = PfxVector3(0.0f,1.0f,0.0f); - } - - // twistã®è»¸æ–¹å‘ã®ãƒã‚§ãƒƒã‚¯ - if(dot(axis[0],frameBA.getCol0()) < 0.0f) { - angle[0] = -angle[0]; - } - - axis[0] = worldFrameB.getCol0(); - axis[1] = worldFrameA * axis[1]; - axis[2] = cross(axis[0],axis[1]); - angle[2] = 0.0f; -} - -static SCE_PFX_FORCE_INLINE -void pfxCalcJointAngleSwing1Swing2Twist(PfxMatrix3 &worldFrameA,PfxMatrix3 &worldFrameB,PfxFloat *angle,PfxVector3 *axis) -{ - // フレームA座標系ã¸ã®å¤‰æ›ãƒžãƒˆãƒªã‚¯ã‚¹ - PfxMatrix3 frameBA = transpose(worldFrameA) * worldFrameB; - - // クォータニオン回転をtwistã¨swingã«åˆ†é›¢ - PfxQuat swing,twist,qBA(frameBA); - swing = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),frameBA.getCol0()); - twist = qBA * conj(swing); - - if(dot(twist,PfxQuat::rotationX(0.0f)) < 0.0f) { - twist = -twist; - } - - PfxQuat swing1,swing2; - - PfxVector3 pXY = frameBA.getCol0();pXY[2] = 0.0f; - PfxVector3 pXZ = frameBA.getCol0();pXZ[1] = 0.0f; - - if(fabsf(frameBA.getCol0()[1]) < fabsf(frameBA.getCol0()[2])) { - swing1 = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),pXZ); - swing2 = swing * conj(swing1); - } - else { - swing2 = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),pXY); - swing1 = conj(swing2) * swing; - } - - // ãれãžã‚Œã®å›žè»¢è»¸ã¨å›žè»¢è§’度を算出 - pfxGetRotationAngleAndAxis(normalize(twist),angle[0],axis[0]); - pfxGetRotationAngleAndAxis(normalize(swing2),angle[1],axis[1]); - pfxGetRotationAngleAndAxis(normalize(swing1),angle[2],axis[2]); - - if(angle[1] < 0.00001f) { - angle[1] = 0.0f; - axis[1] = PfxVector3(0.0f,1.0f,0.0f); - } - - if(angle[2] < 0.00001f) { - angle[2] = 0.0f; - axis[2] = PfxVector3(0.0f,0.0f,1.0f); - } - - // twistã®è»¸æ–¹å‘ã®ãƒã‚§ãƒƒã‚¯ - if(dot(axis[0],frameBA.getCol0()) < 0.0f) { - angle[0] = -angle[0]; - } - - axis[0] = worldFrameB.getCol0(); - axis[1] = worldFrameA * axis[1]; - axis[2] = worldFrameA * axis[2]; -} - -static SCE_PFX_FORCE_INLINE -void pfxCalcJointAngleUniversal(PfxMatrix3 &worldFrameA,PfxMatrix3 &worldFrameB,PfxFloat *angle,PfxVector3 *axis) -{ - // フレームA座標系ã¸ã®å¤‰æ›ãƒžãƒˆãƒªã‚¯ã‚¹ - PfxMatrix3 frameBA = transpose(worldFrameA) * worldFrameB; - - // クォータニオン回転をtwistã¨swingã«åˆ†é›¢ - PfxQuat swing,swing1,swing2,twist,qBA(frameBA); - PfxVector3 Pxy(frameBA.getCol0()); - Pxy[2] = 0.0f; - swing1 = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),normalize(Pxy)); - swing = PfxQuat::rotation(PfxVector3(1.0f,0.0f,0.0f),frameBA.getCol0()); - swing2 = swing * conj(swing1); - twist = conj(swing) * qBA; - - if(dot(twist,PfxQuat::rotationX(0.0f)) < 0.0f) { - twist = -twist; - } - - pfxGetRotationAngleAndAxis(normalize(twist),angle[0],axis[0]); - pfxGetRotationAngleAndAxis(normalize(swing1),angle[1],axis[1]); - pfxGetRotationAngleAndAxis(normalize(swing2),angle[2],axis[2]); - - if(axis[1].getZ() < 0.0f) { - axis[1] = -axis[1]; - angle[1] = -angle[1]; - } - - PfxVector3 chkY = cross(PfxVector3(0.0f,0.0f,1.0f),frameBA.getCol0()); - if(dot(chkY,axis[2]) < 0.0f) { - axis[2] = -axis[2]; - angle[2] = -angle[2]; - } - - // twistã®è»¸æ–¹å‘ã®ãƒã‚§ãƒƒã‚¯ - if(dot(axis[0],frameBA.getCol0()) < 0.0f) { - angle[0] = -angle[0]; - } - - axis[0] = worldFrameB.getCol0(); - axis[1] = worldFrameA * axis[1]; - axis[2] = worldFrameA * axis[2]; -} - -/////////////////////////////////////////////////////////////////////////////// -// Calc Joint Limit - -static SCE_PFX_FORCE_INLINE -void pfxCalcLinearLimit( - const PfxJointConstraint &jointConstraint, - PfxFloat &posErr,PfxFloat &velocityAmp,PfxFloat &lowerLimit,PfxFloat &upperLimit) -{ - switch(jointConstraint.m_lock) { - case SCE_PFX_JOINT_LOCK_FREE: - posErr = 0.0f; - velocityAmp *= jointConstraint.m_damping; - break; - - case SCE_PFX_JOINT_LOCK_LIMIT: - if(posErr >= jointConstraint.m_movableLowerLimit && posErr <= jointConstraint.m_movableUpperLimit) { - posErr = 0.0f; - velocityAmp *= jointConstraint.m_damping; - } - else { - if(posErr < jointConstraint.m_movableLowerLimit) { - posErr = posErr - jointConstraint.m_movableLowerLimit; - posErr = SCE_PFX_MIN(0.0f,posErr+SCE_PFX_JOINT_LINEAR_SLOP); - upperLimit = SCE_PFX_MIN(0.0f,upperLimit); - velocityAmp = 1.0f; - } - else { // posErr > movableUpperLimit - posErr = posErr - jointConstraint.m_movableUpperLimit; - posErr = SCE_PFX_MAX(0.0f,posErr-SCE_PFX_JOINT_LINEAR_SLOP); - lowerLimit = SCE_PFX_MAX(0.0f,lowerLimit); - velocityAmp = 1.0f; - } - } - break; - - default: // SCE_PFX_JOINT_LOCK_FIX - break; - } -} - -static SCE_PFX_FORCE_INLINE -void pfxCalcAngularLimit( - const PfxJointConstraint &jointConstraint, - PfxFloat &posErr,PfxFloat &velocityAmp,PfxFloat &lowerLimit,PfxFloat &upperLimit) -{ - switch(jointConstraint.m_lock) { - case SCE_PFX_JOINT_LOCK_FREE: - posErr = 0.0f; - velocityAmp *= jointConstraint.m_damping; - break; - - case SCE_PFX_JOINT_LOCK_LIMIT: - if(posErr >= jointConstraint.m_movableLowerLimit && posErr <= jointConstraint.m_movableUpperLimit) { - posErr = 0.0f; - velocityAmp *= jointConstraint.m_damping; - } - else { - if(posErr < jointConstraint.m_movableLowerLimit) { - posErr = posErr - jointConstraint.m_movableLowerLimit; - posErr = SCE_PFX_MIN(0.0f,posErr+SCE_PFX_JOINT_ANGULAR_SLOP); - upperLimit = SCE_PFX_MIN(0.0f,upperLimit); - velocityAmp = 1.0f; - } - else { // posErr > movableUpperLimit - posErr = posErr - jointConstraint.m_movableUpperLimit; - posErr = SCE_PFX_MAX(0.0f,posErr-SCE_PFX_JOINT_ANGULAR_SLOP); - lowerLimit = SCE_PFX_MAX(0.0f,lowerLimit); - velocityAmp = 1.0f; - } - } - break; - - default: // SCE_PFX_JOINT_LOCK_FIX - break; - } -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_CONSTRAINT_ROW_SOLVER_H diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver_neon.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver_neon.cpp deleted file mode 100644 index c07a144da..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_constraint_row_solver_neon.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ -#ifdef __ANDROID__ - -#include "../../../include/physics_effects.h" -#include - -namespace sce { -namespace PhysicsEffects { - -//---------------------------------------------------------------------------- -// pfxSolveLinearConstraintRowNEON -// -/// NEON inline assembly implementation of the pfxSolveLinearConstraintRow -/// function. -/// -/// @param constraint Constraint row to be solved -/// @param deltaLinearVelocityA Change in linear velocity for object A -/// @param deltaAngularVelocityA Change in angular velocity for object A -/// @param massInvA Mass inverse for object A -/// @param inertiaInvA Inertia tensor inverse for object A -/// @param rA Position of contact point for object A -/// @param deltaLinearVelocityB Change in linear velocity for object B -/// @param deltaAngularVelocityB Change in angular velocity for object B -/// @param massInvB Mass inverse for object B -/// @param inertiaInvB Inertia tensor inverse for object B -/// @param rB Position of contact point for object B -//---------------------------------------------------------------------------- -//GSR version -void pfxSolveLinearConstraintRowNEON(PfxConstraintRow &constraint, - PfxVector3 &deltaLinearVelocityA,PfxVector3 &deltaAngularVelocityA, - PfxFloat &massInvA,const PfxMatrix3 &inertiaInvA,const PfxVector3 &rA, - PfxVector3 &deltaLinearVelocityB,PfxVector3 &deltaAngularVelocityB, - PfxFloat &massInvB,const PfxMatrix3 &inertiaInvB,const PfxVector3 &rB) -{ - asm volatile - ( - //Loads beforehand so the normal vector will be able to have zero in the 4th element - "vld1.32 {q0}, [%1] \n\t" //LOAD => deltaLinearVelocityA ----------------> q0 - "vld1.32 {q1}, [%2] \n\t" //LOAD => deltaAngularVelocityA ---------------> q1 - "vld1.32 {q2}, [%6] \n\t" //LOAD => deltaLinearVelocityB ----------------> q2 - "vld1.32 {q3}, [%7] \n\t" //LOAD => deltaAngularVelocityB ---------------> q3 - //const PfxVector3 normal(pfxReadVector3(constraint.m_normal)); - "vld1.32 {q4}, [%0]! \n\t" //LOAD => constraint normal--------------------> q4 - "vdup.32 d10, d1[1] \n\t" //set 4th element on normal vector to zero. It is zero since q0 holds a vec3...d1[1] is 4th element and on C++ side we set this to zero - "vtrn.32 d9, d10 \n\t" //LOAD => deltaImpulse ------------------------> q5 (d10[0] only) - //PfxFloat deltaImpulse = constraint.m_rhs; - "vld1.32 {d12}, [%0]! \n\t" //LOAD => constraint variables ----------------> q6 - "vld1.32 {d13[0]}, [%0]! \n\t" //constraint variables - "vld1.32 {d13[1]}, [%0] \n\t" //constraint load of remaining variables loaded this way keep pointer to m_accumulate in order to store back in later - //PfxVector3 dVA = deltaLinearVelocityA + cross(deltaAngularVelocityA,rA); - //PfxVector3 dVB = deltaLinearVelocityB + cross(deltaAngularVelocityB,rB); - "vld1.32 {d14[1]}, [%5] \n\t" //LOAD => rA for cross product use 1A ---------> q7 (save these for use later) - "vld1.32 {d18[1]}, [%10] \n\t" //LOAD => rB for cross product use 1B ---------> q9 - "vld1.32 {d17[0]}, [%5]! \n\t" //LOAD => rA for cross product use 2A ---------> q8 - "vld1.32 {d21[0]}, [%10]! \n\t" //LOAD => rB for cross product use 2B ---------> q10 - "vld1.32 {d16}, [%5] \n\t" //rA 2 - "vld1.32 {d20}, [%10] \n\t" //rB 2 - "vld1.32 {d15[0]}, [%5]! \n\t" //rA 1 - "vld1.32 {d19[0]}, [%10]! \n\t" //rB 1 - "vld1.32 {d14[0]}, [%5]! \n\t" //rA 1 - "vld1.32 {d18[0]}, [%10]! \n\t" //rB 1 - "vld1.32 {d15[1]}, [%5] \n\t" //rA 1 - "vld1.32 {d19[1]}, [%10] \n\t" //rB 1 - "vld1.32 {d17[1]}, [%5]! \n\t" //rA 2 - "vld1.32 {d21[1]}, [%10]! \n\t" //rB 2 - "vmov.f32 q14, q1 \n\t" - "vmov.f32 q13, q3 \n\t" - "vmov.f32 q15, q1 \n\t" - "vmov.f32 q12, q3 \n\t" - "vrev64.32 d28, d28 \n\t" //set deltaAngularVelocityA 1 - "vtrn.32 d28, d29 \n\t" //set deltaAngularVelocityA 1 - "vrev64.32 d26, d26 \n\t" //set deltaAngularVelocityB 1 - "vmul.f32 q14, q7, q14 \n\t" //operation for cross product 1A - "vtrn.32 d26, d27 \n\t" //set deltaAngularVelocityB 1 - "vtrn.32 d30, d31 \n\t" //set deltaAngularVelocityA 2 - "vmul.f32 q13, q9, q13 \n\t" //operation for cross product 1B - "vtrn.32 d24, d25 \n\t" //set deltaAngularVelocityB 2 - "vrev64.32 d30, d30 \n\t" //set deltaAngularVelocityA 2 - "vrev64.32 d24, d24 \n\t" //set deltaAngularVelocityB 2 - "vmls.f32 q14, q8, q15 \n\t" //operation for cross product 2A - "vmls.f32 q13, q10, q12 \n\t" //operation for cross product 2B - "vadd.f32 q14, q14, q0 \n\t" //operation for adding cross to linearVelocityA - "vadd.f32 q13, q13, q2 \n\t" //operation for adding cross to linearVelocityB - //LOAD => dVA --------------------------------> q14 - //LOAD => dVB --------------------------------> q13 - //FREE q11, q12, q15, d11 - //deltaImpulse -= constraint.m_jacDiagInv * dot(normal,dVA-dVB); - "vsub.f32 q11, q14, q13 \n\t" //TEMP q11 => dVA-dVB for dot product - "vmul.f32 q11, q11, q4 \n\t" //operation for dot product - "vpadd.f32 d22, d22, d22 \n\t" //operation for dot product - "vpadd.f32 d23, d23, d23 \n\t" //operation for dot product - "vadd.f32 d22, d22, d23 \n\t" //operation for dot product - "vmul.f32 d22, d22, d12[0] \n\t" //m_jacDiagInv times dot product result - "vsub.f32 d10, d10, d22 \n\t" //subtract result from deltaImpule - //PfxFloat oldImpulse = constraint.m_accumImpulse; - "vdup.32 d11, d13[1] \n\t" //LOAD => oldImpulse -------------------------> q5 (d11 only) - //constraint.m_accumImpulse = SCE_PFX_CLAMP(oldImpulse + deltaImpulse,constraint.m_lowerLimit,constraint.m_upperLimit); - "vdup.32 d23, d13[0] \n\t" //TEMP q11 => m_upperLimit (d23 only) - "vdup.32 d24, d12[1] \n\t" //TEMP q12 => m_lowerLimit (d34 only) - "vadd.f32 d25, d10, d11 \n\t" //TEMP q12 => deltaImpulse + oldImplues (d25 only) - "vmin.f32 d25, d25, d23 \n\t" //operation MIN(v,b) - "vmax.f32 d22, d25, d24 \n\t" //operation MAX(a,MIN(v,b) - "vst1.32 {d22[0]}, [%0] \n\t" //store m_accumImpulse (incremented so that it can be reloaded for cross product later) - //deltaImpulse = constraint.m_accumImpulse - oldImpulse; - "vsub.f32 d10, d22, d11 \n\t" //operation to calculate new deltaImpule - //FREE q6, q11, q12, q13, q14, q15, d11 - //deltaLinearVelocityB -= deltaImpulse * massInvB * normal; - //deltaLinearVelocityA += deltaImpulse * massInvA * normal; - "vld1.32 {d11[0]}, [%3] \n\t" //LOAD => massInvA ---------------------------> q5 (d11[0] only) - "vld1.32 {d11[1]}, [%8] \n\t" //LOAD => massInvB ---------------------------> q5 (d11[1] only) - "vmul.f32 q11, q4, d11[0] \n\t" //TEMP q11 => operation normal times massInvA A - "vmul.f32 q12, q4, d11[1] \n\t" //TEMP q12 => operation normal times massInvB B - "vmul.f32 q11, q11, d10[0] \n\t" //TEMP q11 => operation result times DeltaImpulse A - "vmul.f32 q12, q12, d10[0] \n\t" //TEMP q12 => operation result times DeltaImpulse B - "vadd.f32 q0, q0, q11 \n\t" //operation create new deltaLinearVelocityA A - "vst1.32 {q0}, [%1] \n\t" //store the new deltaLinearVelocityA A - "vsub.f32 q2, q2, q12 \n\t" //operation create new deltaLinearVelocityB B - "vst1.32 {q2}, [%6] \n\t" //store the new deltaLinearVelocityB B - //FREE q0, q2, q6, q11, q12, q13, q14, q15, d11 - //deltaAngularVelocityA += deltaImpulse * inertiaInvA * cross(rA,normal); - //deltaAngularVelocityB -= deltaImpulse * inertiaInvB * cross(rB,normal); - "vmov.f32 q14, q4 \n\t" // - "vmov.f32 q15, q4 \n\t" // - "vtrn.32 d30, d31 \n\t" // - "vrev64.32 d30, d30 \n\t" // - "vmul.f32 q0, q8, q15 \n\t" //operation for cross product A - "vrev64.32 d28, d28 \n\t" // - "vmul.f32 q2, q10, q15 \n\t" //operation for cross product B - "vtrn.32 d28, d29 \n\t" // - "vmls.f32 q0, q14, q7 \n\t" //operation for cross product A - "vmls.f32 q2, q14, q9 \n\t" //operation for cross product B - //LOAD => cross product result A ------------> q0 - //LOAD => cross product result B ------------> q2 - //FREE q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, d11 - - "vld1.32 {q13-q14}, [%4]! \n\t" //LOAD => inertiaInvA col0, col1 A ----------> q13, q14 - "vld1.32 {q9-q10}, [%9]! \n\t" //LOAD => inertiaInvB col0, col1 B -----------> q9, q10 - "vld1.32 {q15}, [%4] \n\t" //LOAD => inertiaInvA col2 A ----------------> q5 - "vld1.32 {q11}, [%9] \n\t" //LOAD => inertiaInvB col2 B -----------------> q11 - "vmul.f32 q13, q13, d0[0] \n\t" //operation inertiaInvA col0 = (col0) * (crossA elem0) A - "vmul.f32 q9, q9, d4[0] \n\t" //operation inertiaInvB col0 = (col0) * (crossB elem0) B - "vmla.f32 q13, q14, d0[1] \n\t" //operation inertiaInvA col1 = (col1) * (crossA elem1) A - "vmla.f32 q9, q10, d4[1] \n\t" //operation inertiaInvB col1 = (col1) * (crossB elem1) B - "vmla.f32 q13, q15, d1[0] \n\t" //operation inertiaInvA col2 = (col2) * (crossA elem2) A - "vmla.f32 q9, q11, d5[0] \n\t" //operation inertiaInvB col2 = (col2) * (crossB elem2) B - "vmul.f32 q13, q13, d10[0] \n\t" //operation inertiaInvA times deltaImpulse A - "vmul.f32 q9, q9, d10[0] \n\t" //operation inertiaInvB times deltaImpulse B - "vadd.f32 q1, q1, q13 \n\t" //operation accumulate the deltaAngularVelocityA A - "vst1.32 {q1}, [%2] \n\t" //store deltaAngularVelocityA A - "vsub.f32 q3, q3, q9 \n\t" //operation accumulate the deltaAngularVelocityB B - "vst1.32 {q3}, [%7] \n\t" //store deltaAngularVelocityB B - : // NO direct outputs! It is important to *not* put anything here. Real output is written directly to memory pointed to by inputs - : "r" (&constraint), "r" (&deltaLinearVelocityA), "r" (&deltaAngularVelocityA), "r" (&massInvA), "r" (&inertiaInvA), "r" (&rA), "r" (&deltaLinearVelocityB), "r" (&deltaAngularVelocityB), "r" (&massInvB), "r" (&inertiaInvB), "r" (&rB) //inputs - : "memory", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15" // clobbers - ); -} - -} //namespace PhysicsEffects -} //namespace sce -#endif //__ANDROID__ diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_contact_constraint.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_contact_constraint.cpp deleted file mode 100644 index 494d97d32..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_contact_constraint.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_contact_constraint.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_CONTACT_SLOP 0.001f - -void pfxSetupContactConstraint( - PfxConstraintRow &constraintResponse, - PfxConstraintRow &constraintFriction1, - PfxConstraintRow &constraintFriction2, - PfxFloat penetrationDepth, - PfxFloat restitution, - PfxFloat friction, - const PfxVector3 &contactNormal, - const PfxVector3 &contactPointA, - const PfxVector3 &contactPointB, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat separateBias, - PfxFloat timeStep - ) -{ - (void)friction; - - PfxVector3 rA = rotate(solverBodyA.m_orientation,contactPointA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,contactPointB); - - PfxFloat massInvA = solverBodyA.m_massInv; - PfxFloat massInvB = solverBodyB.m_massInv; - PfxMatrix3 inertiaInvA = solverBodyA.m_inertiaInv; - PfxMatrix3 inertiaInvB = solverBodyB.m_inertiaInv; - - if(solverBodyA.m_motionType == kPfxMotionTypeOneWay) { - massInvB = 0.0f; - inertiaInvB = PfxMatrix3(0.0f); - } - if(solverBodyB.m_motionType == kPfxMotionTypeOneWay) { - massInvA = 0.0f; - inertiaInvA = PfxMatrix3(0.0f); - } - - PfxMatrix3 K = PfxMatrix3::scale(PfxVector3(massInvA + massInvB)) - - crossMatrix(rA) * inertiaInvA * crossMatrix(rA) - - crossMatrix(rB) * inertiaInvB * crossMatrix(rB); - - PfxVector3 vA = stateA.getLinearVelocity() + cross(stateA.getAngularVelocity(),rA); - PfxVector3 vB = stateB.getLinearVelocity() + cross(stateB.getAngularVelocity(),rB); - PfxVector3 vAB = vA-vB; - - PfxVector3 tangent1,tangent2; - pfxGetPlaneSpace(contactNormal,tangent1,tangent2); - - // Contact Constraint - { - PfxVector3 normal = contactNormal; - - PfxFloat denom = dot(K*normal,normal); - - constraintResponse.m_rhs = -(1.0f+restitution)*dot(vAB,normal); // velocity error - constraintResponse.m_rhs -= (separateBias * SCE_PFX_MIN(0.0f,penetrationDepth+SCE_PFX_CONTACT_SLOP)) / timeStep; // position error - constraintResponse.m_rhs /= denom; - constraintResponse.m_jacDiagInv = 1.0f/denom; - constraintResponse.m_lowerLimit = 0.0f; - constraintResponse.m_upperLimit = SCE_PFX_FLT_MAX; - pfxStoreVector3(normal,constraintResponse.m_normal); - } - - // Friction Constraint 1 - { - PfxVector3 normal = tangent1; - - PfxFloat denom = dot(K*normal,normal); - - constraintFriction1.m_jacDiagInv = 1.0f/denom; - constraintFriction1.m_rhs = -dot(vAB,normal); - constraintFriction1.m_rhs *= constraintFriction1.m_jacDiagInv; - constraintFriction1.m_lowerLimit = 0.0f; - constraintFriction1.m_upperLimit = SCE_PFX_FLT_MAX; - pfxStoreVector3(normal,constraintFriction1.m_normal); - } - - // Friction Constraint 2 - { - PfxVector3 normal = tangent2; - - PfxFloat denom = dot(K*normal,normal); - - constraintFriction2.m_jacDiagInv = 1.0f/denom; - constraintFriction2.m_rhs = -dot(vAB,normal); - constraintFriction2.m_rhs *= constraintFriction2.m_jacDiagInv; - constraintFriction2.m_lowerLimit = 0.0f; - constraintFriction2.m_upperLimit = SCE_PFX_FLT_MAX; - pfxStoreVector3(normal,constraintFriction2.m_normal); - } -} - -void pfxSolveContactConstraint( - PfxConstraintRow &constraintResponse, - PfxConstraintRow &constraintFriction1, - PfxConstraintRow &constraintFriction2, - const PfxVector3 &contactPointA, - const PfxVector3 &contactPointB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat friction - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,contactPointA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,contactPointB); - - PfxFloat massInvA = solverBodyA.m_massInv; - PfxFloat massInvB = solverBodyB.m_massInv; - PfxMatrix3 inertiaInvA = solverBodyA.m_inertiaInv; - PfxMatrix3 inertiaInvB = solverBodyB.m_inertiaInv; - - if(solverBodyA.m_motionType == kPfxMotionTypeOneWay) { - massInvB = 0.0f; - inertiaInvB = PfxMatrix3(0.0f); - } - if(solverBodyB.m_motionType == kPfxMotionTypeOneWay) { - massInvA = 0.0f; - inertiaInvA = PfxMatrix3(0.0f); - } - -// ARA begin insert new code -#ifdef __ARM_NEON__ - pfxSolveLinearConstraintRowNEON(constraintResponse, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); -#else // __ARM_NEON__ -// ARA end - - pfxSolveLinearConstraintRow(constraintResponse, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); - -// ARA begin insert new code -#endif // __ARM_NEON__ -// ARA end - - PfxFloat mf = friction*fabsf(constraintResponse.m_accumImpulse); - constraintFriction1.m_lowerLimit = -mf; - constraintFriction1.m_upperLimit = mf; - constraintFriction2.m_lowerLimit = -mf; - constraintFriction2.m_upperLimit = mf; - -// ARA begin insert new code -#ifdef __ARM_NEON__ - pfxSolveLinearConstraintRowNEON(constraintFriction1, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); - - pfxSolveLinearConstraintRowNEON(constraintFriction2, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); -#else // __ARM_NEON__ -// ARA end - - pfxSolveLinearConstraintRow(constraintFriction1, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); - - pfxSolveLinearConstraintRow(constraintFriction2, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,massInvA,inertiaInvA,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,massInvB,inertiaInvB,rB); - -// ARA begin insert new code -#endif // __ARM_NEON__ -// ARA end -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_ball.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_ball.cpp deleted file mode 100644 index 37ca8678a..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_ball.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_ball.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeBallJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxBallJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 3; - joint.m_userData = NULL; - joint.m_type = kPfxJointBall; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<3;i++) { - joint.m_constraints[i].reset(); - } - - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[1].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[2].m_lock = SCE_PFX_JOINT_LOCK_FIX; - - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - joint.m_frameA = PfxMatrix3::identity(); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -void pfxSetupBallJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - PfxVector3 vA = stateA.getLinearVelocity() + cross(stateA.getAngularVelocity(),rA); - PfxVector3 vB = stateB.getLinearVelocity() + cross(stateB.getAngularVelocity(),rB); - PfxVector3 vAB = vA-vB; - - PfxVector3 distance = (stateA.getPosition() + rA) - (stateB.getPosition() + rB); - - PfxMatrix3 worldFrameA,worldFrameB; - worldFrameA = PfxMatrix3(solverBodyA.m_orientation) * joint.m_frameA; - worldFrameB = PfxMatrix3(solverBodyB.m_orientation) * joint.m_frameB; - - // Linear Constraint - PfxMatrix3 K = PfxMatrix3::scale(PfxVector3(solverBodyA.m_massInv + solverBodyB.m_massInv)) - - crossMatrix(rA) * solverBodyA.m_inertiaInv * crossMatrix(rA) - - crossMatrix(rB) * solverBodyB.m_inertiaInv * crossMatrix(rB); - - for(int c=0;c<3;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - PfxVector3 normal = worldFrameA[c]; - - PfxFloat posErr = dot(distance,-normal); - PfxFloat lowerLimit = -jointConstraint.m_maxImpulse; - PfxFloat upperLimit = jointConstraint.m_maxImpulse; - PfxFloat velocityAmp = 1.0f; - - pfxCalcLinearLimit(jointConstraint,posErr,velocityAmp,lowerLimit,upperLimit); - - PfxFloat denom = dot(K*normal,normal); - - constraint.m_rhs = -velocityAmp*dot(vAB,normal); - constraint.m_rhs -= (jointConstraint.m_bias * (-posErr)) / timeStep; - constraint.m_rhs *= jointConstraint.m_weight/denom; - constraint.m_jacDiagInv = jointConstraint.m_weight*velocityAmp/denom; - constraint.m_lowerLimit = lowerLimit; - constraint.m_upperLimit = upperLimit; - pfxStoreVector3(normal,constraint.m_normal); - } -} - -void pfxWarmStartBallJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - // Linear Constraint - for(int c=0;c<3;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - if(jointConstraint.m_warmStarting == 0) { - constraint.m_accumImpulse = 0.0f; - } - else { - PfxVector3 normal = pfxReadVector3(constraint.m_normal); - PfxFloat deltaImpulse = constraint.m_accumImpulse; - solverBodyA.m_deltaLinearVelocity += deltaImpulse * solverBodyA.m_massInv * normal; - solverBodyA.m_deltaAngularVelocity += deltaImpulse * solverBodyA.m_inertiaInv * cross(rA,normal); - solverBodyB.m_deltaLinearVelocity -= deltaImpulse * solverBodyB.m_massInv * normal; - solverBodyB.m_deltaAngularVelocity -= deltaImpulse * solverBodyB.m_inertiaInv * cross(rB,normal); - } - } -} - -void pfxSolveBallJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - // Linear Constraint -// ARA begin insert new code -#ifdef __ARM_NEON__ - pfxSolveLinearConstraintRowNEON(joint.m_constraints[0].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRowNEON(joint.m_constraints[1].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRowNEON(joint.m_constraints[2].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); -#else // __ARM_NEON__ -// ARA end - - pfxSolveLinearConstraintRow(joint.m_constraints[0].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRow(joint.m_constraints[1].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRow(joint.m_constraints[2].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - -// ARA begin insert new code -#endif // __ARM_NEON__ -// ARA end -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_fix.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_fix.cpp deleted file mode 100644 index bb5509f65..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_fix.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_fix.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeFixJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxFixJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 6; - joint.m_userData = NULL; - joint.m_type = kPfxJointFix; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<6;i++) { - joint.m_constraints[i].reset(); - joint.m_constraints[i].m_lock = SCE_PFX_JOINT_LOCK_FIX; - } - - // Calc joint frame - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - joint.m_frameA = PfxMatrix3::identity(); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_hinge.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_hinge.cpp deleted file mode 100644 index c913a36a3..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_hinge.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_hinge.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeHingeJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxHingeJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 6; - joint.m_userData = NULL; - joint.m_type = kPfxJointHinge; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<6;i++) { - joint.m_constraints[i].reset(); - } - - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[1].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[2].m_lock = SCE_PFX_JOINT_LOCK_FIX; - if(param.lowerAngle == 0.0f && param.upperAngle == 0.0f) { - joint.m_constraints[3].m_lock = SCE_PFX_JOINT_LOCK_FREE; - } - else { - joint.m_constraints[3].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - } - joint.m_constraints[4].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[5].m_lock = SCE_PFX_JOINT_LOCK_FIX; - - // Set twist angle limit - if(param.lowerAngle > param.upperAngle || - !SCE_PFX_RANGE_CHECK(param.lowerAngle,-SCE_PFX_PI,SCE_PFX_PI) || - !SCE_PFX_RANGE_CHECK(param.upperAngle,-SCE_PFX_PI,SCE_PFX_PI)) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - joint.m_constraints[3].m_movableLowerLimit = param.lowerAngle; - joint.m_constraints[3].m_movableUpperLimit = param.upperAngle; - - // Calc joint frame - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - PfxVector3 axisInA = rotA * normalize(param.axis); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - PfxVector3 axis1, axis2; - - pfxGetPlaneSpace(axisInA, axis1, axis2 ); - - joint.m_frameA = PfxMatrix3(axisInA, axis1, axis2); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_slider.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_slider.cpp deleted file mode 100644 index 8b843cc57..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_slider.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_slider.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeSliderJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxSliderJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 6; - joint.m_userData = NULL; - joint.m_type = kPfxJointSlider; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<6;i++) { - joint.m_constraints[i].reset(); - } - - if(param.lowerDistance == 0.0f && param.upperDistance == 0.0f) { - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_FREE; - } - else { - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - } - joint.m_constraints[1].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[2].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[3].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[4].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[5].m_lock = SCE_PFX_JOINT_LOCK_FIX; - - if(param.lowerDistance > param.upperDistance ) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - joint.m_constraints[0].m_movableLowerLimit = param.lowerDistance; - joint.m_constraints[0].m_movableUpperLimit = param.upperDistance; - - // Calc joint frame - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - PfxVector3 axisInA = rotA * normalize(param.direction); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - PfxVector3 axis1, axis2; - - pfxGetPlaneSpace(axisInA, axis1, axis2 ); - - joint.m_frameA = PfxMatrix3(axisInA, axis1, axis2); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_swing_twist.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_swing_twist.cpp deleted file mode 100644 index f19b5c317..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_swing_twist.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_swing_twist.h" -#include "pfx_constraint_row_solver.h" - - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeSwingTwistJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxSwingTwistJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 6; - joint.m_userData = NULL; - joint.m_type = kPfxJointSwingtwist; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<6;i++) { - joint.m_constraints[i].reset(); - } - - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[1].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[2].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[3].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - joint.m_constraints[4].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - joint.m_constraints[5].m_lock = SCE_PFX_JOINT_LOCK_FREE; - - // Set twist angle limit - if(param.twistLowerAngle > param.twistUpperAngle || - !SCE_PFX_RANGE_CHECK(param.twistLowerAngle,-SCE_PFX_PI,SCE_PFX_PI) || - !SCE_PFX_RANGE_CHECK(param.twistUpperAngle,-SCE_PFX_PI,SCE_PFX_PI)) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - joint.m_constraints[3].m_movableLowerLimit = param.twistLowerAngle; - joint.m_constraints[3].m_movableUpperLimit = param.twistUpperAngle; - - // Set swing angle limit - if(param.swingLowerAngle > param.swingUpperAngle || - !SCE_PFX_RANGE_CHECK(param.swingLowerAngle,0.0f,SCE_PFX_PI) || - !SCE_PFX_RANGE_CHECK(param.swingUpperAngle,0.0f,SCE_PFX_PI)) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - joint.m_constraints[4].m_movableLowerLimit = param.swingLowerAngle; - joint.m_constraints[4].m_movableUpperLimit = param.swingUpperAngle; - - // Calc joint frame - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - PfxVector3 axisInA = rotA * normalize(param.twistAxis); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - PfxVector3 axis1, axis2; - - pfxGetPlaneSpace(axisInA, axis1, axis2 ); - - joint.m_frameA = PfxMatrix3(axisInA, axis1, axis2); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -void pfxSetupSwingTwistJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - PfxVector3 vA = stateA.getLinearVelocity() + cross(stateA.getAngularVelocity(),rA); - PfxVector3 vB = stateB.getLinearVelocity() + cross(stateB.getAngularVelocity(),rB); - PfxVector3 vAB = vA-vB; - - PfxVector3 angAB = stateA.getAngularVelocity() - stateB.getAngularVelocity(); - - PfxVector3 distance = (stateA.getPosition() + rA) - (stateB.getPosition() + rB); - - PfxMatrix3 worldFrameA,worldFrameB; - worldFrameA = PfxMatrix3(solverBodyA.m_orientation) * joint.m_frameA; - worldFrameB = PfxMatrix3(solverBodyB.m_orientation) * joint.m_frameB; - - // Linear Constraint - PfxMatrix3 K = PfxMatrix3::scale(PfxVector3(solverBodyA.m_massInv + solverBodyB.m_massInv)) - - crossMatrix(rA) * solverBodyA.m_inertiaInv * crossMatrix(rA) - - crossMatrix(rB) * solverBodyB.m_inertiaInv * crossMatrix(rB); - - for(int c=0;c<3;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - PfxVector3 normal = worldFrameA[c]; - - PfxFloat posErr = dot(distance,-normal); - PfxFloat lowerLimit = -jointConstraint.m_maxImpulse; - PfxFloat upperLimit = jointConstraint.m_maxImpulse; - PfxFloat velocityAmp = 1.0f; - - pfxCalcLinearLimit(jointConstraint,posErr,velocityAmp,lowerLimit,upperLimit); - - PfxFloat denom = dot(K*normal,normal); - - constraint.m_rhs = -velocityAmp*dot(vAB,normal); - constraint.m_rhs -= (jointConstraint.m_bias * (-posErr)) / timeStep; - constraint.m_rhs *= jointConstraint.m_weight/denom; - constraint.m_jacDiagInv = jointConstraint.m_weight*velocityAmp/denom; - constraint.m_lowerLimit = lowerLimit; - constraint.m_upperLimit = upperLimit; - pfxStoreVector3(normal,constraint.m_normal); - } - - PfxVector3 axis[3]; - PfxFloat angle[3]; - pfxCalcJointAngleSwingTwist(worldFrameA,worldFrameB,angle,axis); - - // Angular Constraint - for(int c=3;c<6;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - PfxVector3 normal = axis[c-3]; - - PfxFloat posErr = angle[c-3]; - PfxFloat lowerLimit = -jointConstraint.m_maxImpulse; - PfxFloat upperLimit = jointConstraint.m_maxImpulse; - PfxFloat velocityAmp = 1.0f; - - pfxCalcAngularLimit(jointConstraint,posErr,velocityAmp,lowerLimit,upperLimit); - - PfxFloat denom = dot((solverBodyA.m_inertiaInv+solverBodyB.m_inertiaInv)*normal,normal); - - constraint.m_rhs = -velocityAmp*dot(angAB,normal); // velocity error - constraint.m_rhs -= (jointConstraint.m_bias * (-posErr)) / timeStep; // position error - constraint.m_rhs *= jointConstraint.m_weight/denom; - constraint.m_jacDiagInv = jointConstraint.m_weight*velocityAmp/denom; - constraint.m_lowerLimit = lowerLimit; - constraint.m_upperLimit = upperLimit; - pfxStoreVector3(normal,constraint.m_normal); - } -} - -void pfxWarmStartSwingTwistJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - // Linear Constraint - for(int c=0;c<3;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - if(jointConstraint.m_warmStarting == 0) { - constraint.m_accumImpulse = 0.0f; - } - else { - PfxVector3 normal = pfxReadVector3(constraint.m_normal); - PfxFloat deltaImpulse = constraint.m_accumImpulse; - solverBodyA.m_deltaLinearVelocity += deltaImpulse * solverBodyA.m_massInv * normal; - solverBodyA.m_deltaAngularVelocity += deltaImpulse * solverBodyA.m_inertiaInv * cross(rA,normal); - solverBodyB.m_deltaLinearVelocity -= deltaImpulse * solverBodyB.m_massInv * normal; - solverBodyB.m_deltaAngularVelocity -= deltaImpulse * solverBodyB.m_inertiaInv * cross(rB,normal); - } - } - - // Angular Constraint - for(int c=3;c<6;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - if(jointConstraint.m_warmStarting == 0) { - constraint.m_accumImpulse = 0.0f; - } - else { - PfxVector3 normal = pfxReadVector3(constraint.m_normal); - PfxFloat deltaImpulse = constraint.m_accumImpulse; - solverBodyA.m_deltaAngularVelocity += deltaImpulse * solverBodyA.m_inertiaInv * normal; - solverBodyB.m_deltaAngularVelocity -= deltaImpulse * solverBodyB.m_inertiaInv * normal; - } - } -} - -void pfxSolveSwingTwistJoint( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - // Linear Constraint -// ARA begin insert new code -#ifdef __ARM_NEON__ - pfxSolveLinearConstraintRowNEON(joint.m_constraints[0].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRowNEON(joint.m_constraints[1].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRowNEON(joint.m_constraints[2].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); -#else // __ARM_NEON__ -// ARA end - - pfxSolveLinearConstraintRow(joint.m_constraints[0].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRow(joint.m_constraints[1].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - - pfxSolveLinearConstraintRow(joint.m_constraints[2].m_constraintRow, - solverBodyA.m_deltaLinearVelocity,solverBodyA.m_deltaAngularVelocity,solverBodyA.m_massInv,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaLinearVelocity,solverBodyB.m_deltaAngularVelocity,solverBodyB.m_massInv,solverBodyB.m_inertiaInv,rB); - -// ARA begin insert new code -#endif // __ARM_NEON__ -// ARA end - - // Angular Constraint - pfxSolveAngularConstraintRow(joint.m_constraints[3].m_constraintRow, - solverBodyA.m_deltaAngularVelocity,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaAngularVelocity,solverBodyB.m_inertiaInv,rB); - - pfxSolveAngularConstraintRow(joint.m_constraints[4].m_constraintRow, - solverBodyA.m_deltaAngularVelocity,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaAngularVelocity,solverBodyB.m_inertiaInv,rB); - - pfxSolveAngularConstraintRow(joint.m_constraints[5].m_constraintRow, - solverBodyA.m_deltaAngularVelocity,solverBodyA.m_inertiaInv,rA, - solverBodyB.m_deltaAngularVelocity,solverBodyB.m_inertiaInv,rB); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_universal.cpp b/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_universal.cpp deleted file mode 100644 index 0e8a39ca5..000000000 --- a/Extras/PhysicsEffects/src/base_level/solver/pfx_joint_universal.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/base_level/solver/pfx_joint_universal.h" -#include "pfx_constraint_row_solver.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxInitializeUniversalJoint(PfxJoint &joint, - const PfxRigidState &stateA,const PfxRigidState &stateB, - const PfxUniversalJointInitParam ¶m) -{ - joint.m_active = 1; - joint.m_numConstraints = 6; - joint.m_userData = NULL; - joint.m_type = kPfxJointUniversal; - joint.m_rigidBodyIdA = stateA.getRigidBodyId(); - joint.m_rigidBodyIdB = stateB.getRigidBodyId(); - - for(int i=0;i<6;i++) { - joint.m_constraints[i].reset(); - } - - joint.m_constraints[0].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[1].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[2].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[3].m_lock = SCE_PFX_JOINT_LOCK_FIX; - joint.m_constraints[4].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - joint.m_constraints[5].m_lock = SCE_PFX_JOINT_LOCK_LIMIT; - - // Set swing angle limit - if(param.swing1LowerAngle > param.swing1UpperAngle || - !SCE_PFX_RANGE_CHECK(param.swing1LowerAngle,-SCE_PFX_PI,SCE_PFX_PI) || - !SCE_PFX_RANGE_CHECK(param.swing1UpperAngle,-SCE_PFX_PI,SCE_PFX_PI) || - param.swing2LowerAngle > param.swing2UpperAngle || - !SCE_PFX_RANGE_CHECK(param.swing2LowerAngle,-SCE_PFX_PI,SCE_PFX_PI) || - !SCE_PFX_RANGE_CHECK(param.swing2UpperAngle,-SCE_PFX_PI,SCE_PFX_PI)) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - joint.m_constraints[4].m_movableLowerLimit = param.swing1LowerAngle; - joint.m_constraints[4].m_movableUpperLimit = param.swing1UpperAngle; - joint.m_constraints[5].m_movableLowerLimit = param.swing2LowerAngle; - joint.m_constraints[5].m_movableUpperLimit = param.swing2UpperAngle; - - // Calc joint frame - PfxMatrix3 rotA = transpose(PfxMatrix3(stateA.getOrientation())); - PfxMatrix3 rotB = transpose(PfxMatrix3(stateB.getOrientation())); - - PfxVector3 axisInA = rotA * normalize(param.axis); - - joint.m_anchorA = rotA * (param.anchorPoint - stateA.getPosition()); - joint.m_anchorB = rotB * (param.anchorPoint - stateB.getPosition()); - - PfxVector3 axis1, axis2; - - pfxGetPlaneSpace(axisInA, axis1, axis2 ); - - joint.m_frameA = PfxMatrix3(axisInA, axis1, axis2); - joint.m_frameB = rotB * PfxMatrix3(stateA.getOrientation()) * joint.m_frameA; - - return SCE_PFX_OK; -} - -void pfxSetupUniversalJoint( - PfxJoint &joint, - const PfxRigidState &stateA, - const PfxRigidState &stateB, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB, - PfxFloat timeStep - ) -{ - PfxVector3 rA = rotate(solverBodyA.m_orientation,joint.m_anchorA); - PfxVector3 rB = rotate(solverBodyB.m_orientation,joint.m_anchorB); - - PfxVector3 vA = stateA.getLinearVelocity() + cross(stateA.getAngularVelocity(),rA); - PfxVector3 vB = stateB.getLinearVelocity() + cross(stateB.getAngularVelocity(),rB); - PfxVector3 vAB = vA-vB; - - PfxVector3 angAB = stateA.getAngularVelocity() - stateB.getAngularVelocity(); - - PfxVector3 distance = (stateA.getPosition() + rA) - (stateB.getPosition() + rB); - - PfxMatrix3 worldFrameA,worldFrameB; - worldFrameA = PfxMatrix3(solverBodyA.m_orientation) * joint.m_frameA; - worldFrameB = PfxMatrix3(solverBodyB.m_orientation) * joint.m_frameB; - - // Linear Constraint - PfxMatrix3 K = PfxMatrix3::scale(PfxVector3(solverBodyA.m_massInv + solverBodyB.m_massInv)) - - crossMatrix(rA) * solverBodyA.m_inertiaInv * crossMatrix(rA) - - crossMatrix(rB) * solverBodyB.m_inertiaInv * crossMatrix(rB); - - for(int c=0;c<3;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - PfxVector3 normal = worldFrameA[c]; - - PfxFloat posErr = dot(distance,-normal); - PfxFloat lowerLimit = -jointConstraint.m_maxImpulse; - PfxFloat upperLimit = jointConstraint.m_maxImpulse; - PfxFloat velocityAmp = 1.0f; - - pfxCalcLinearLimit(jointConstraint,posErr,velocityAmp,lowerLimit,upperLimit); - - PfxFloat denom = dot(K*normal,normal); - - constraint.m_rhs = -velocityAmp*dot(vAB,normal); - constraint.m_rhs -= (jointConstraint.m_bias * (-posErr)) / timeStep; - constraint.m_rhs *= jointConstraint.m_weight/denom; - constraint.m_jacDiagInv = jointConstraint.m_weight*velocityAmp/denom; - constraint.m_lowerLimit = lowerLimit; - constraint.m_upperLimit = upperLimit; - pfxStoreVector3(normal,constraint.m_normal); - } - - PfxVector3 axis[3]; - PfxFloat angle[3]; - pfxCalcJointAngleUniversal(worldFrameA,worldFrameB,angle,axis); - - // Angular Constraint - for(int c=3;c<6;c++) { - PfxJointConstraint &jointConstraint = joint.m_constraints[c]; - PfxConstraintRow &constraint = jointConstraint.m_constraintRow; - - PfxVector3 normal = axis[c-3]; - - PfxFloat posErr = angle[c-3]; - PfxFloat lowerLimit = -jointConstraint.m_maxImpulse; - PfxFloat upperLimit = jointConstraint.m_maxImpulse; - PfxFloat velocityAmp = 1.0f; - - pfxCalcAngularLimit(jointConstraint,posErr,velocityAmp,lowerLimit,upperLimit); - - PfxFloat denom = dot((solverBodyA.m_inertiaInv+solverBodyB.m_inertiaInv)*normal,normal); - - constraint.m_rhs = -velocityAmp*dot(angAB,normal); // velocity error - constraint.m_rhs -= (jointConstraint.m_bias * (-posErr)) / timeStep; // position error - constraint.m_rhs *= jointConstraint.m_weight/denom; - constraint.m_jacDiagInv = jointConstraint.m_weight*velocityAmp/denom; - constraint.m_lowerLimit = lowerLimit; - constraint.m_upperLimit = upperLimit; - pfxStoreVector3(normal,constraint.m_normal); - } -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/base_level/sort/pfx_sort.cpp b/Extras/PhysicsEffects/src/base_level/sort/pfx_sort.cpp deleted file mode 100644 index 7ce6509a1..000000000 --- a/Extras/PhysicsEffects/src/base_level/sort/pfx_sort.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/sort/pfx_sort.h" - -namespace sce { -namespace PhysicsEffects { - - -#define Key(a) pfxGetKey(a) - -/////////////////////////////////////////////////////////////////////////////// -// Merge Sort - - - -template -SCE_PFX_FORCE_INLINE -void pfxCompareAndSwap(SortData &d1,SortData &d2) -{ -if(Key(d1) > Key(d2)) { - SortData tmp = d1; - d1 = d2; - d2 = tmp; -} -} - -template -SCE_PFX_FORCE_INLINE -void pfxMergeTwoBuffers11(SortData* d1,int n1,SortData* d2,int n2) -{ -(void)n1,(void)n2,(void)d2; -pfxCompareAndSwap(d1[0],d1[1]); -} - -template -SCE_PFX_FORCE_INLINE -void pfxMergeTwoBuffers12(SortData* d1,int n1,SortData* d2,int n2) -{ -(void)n1,(void)d2,(void)n2; -pfxCompareAndSwap(d1[0],d1[1]); -pfxCompareAndSwap(d1[1],d1[2]); -} - -template -SCE_PFX_FORCE_INLINE -void pfxMergeTwoBuffers22(SortData* d1,int n1,SortData* d2,int n2) -{ -(void)n1,(void)d2,(void)n2; -pfxCompareAndSwap(d1[0],d1[2]); -pfxCompareAndSwap(d1[1],d1[3]); -pfxCompareAndSwap(d1[1],d1[2]); -} - -template -SCE_PFX_FORCE_INLINE -void pfxMergeTwoBuffers23(SortData* d1,int n1,SortData* d2,int n2) -{ -(void)n1,(void)d2,(void)n2; -pfxCompareAndSwap(d1[0],d1[2]); -pfxCompareAndSwap(d1[1],d1[4]); -pfxCompareAndSwap(d1[2],d1[3]); -pfxCompareAndSwap(d1[1],d1[2]); -pfxCompareAndSwap(d1[2],d1[3]); -} - -template -SCE_PFX_FORCE_INLINE -void pfxMergeTwoBuffers33(SortData* d1,int n1,SortData* d2,int n2) -{ -(void)n1,(void)d2,(void)n2; -pfxCompareAndSwap(d1[0],d1[3]); -pfxCompareAndSwap(d1[2],d1[5]); -pfxCompareAndSwap(d1[1],d1[2]); -pfxCompareAndSwap(d1[3],d1[4]); -pfxCompareAndSwap(d1[1],d1[3]); -pfxCompareAndSwap(d1[2],d1[4]); -pfxCompareAndSwap(d1[2],d1[3]); -} - -template -void pfxMergeTwoBuffers(SortData* d1,unsigned int n1,SortData* d2,unsigned int n2,SortData *buff) -{ -unsigned int i=0,j=0; - -while(i -void pfxMergeSort(SortData *d,SortData *buff,int n) -{ -int n1 = n>>1; -int n2 = n-n1; -if(n1>1) pfxMergeSort(d,buff,n1); -if(n2>1) pfxMergeSort(d+n1,buff,n2); - -int nadd = n1+n2; - -if(nadd==2) { - pfxMergeTwoBuffers11(d,n1,d+n1,n2); -} -else if(nadd==3) { - pfxMergeTwoBuffers12(d,n1,d+n1,n2); -} -else if(nadd==4) { - pfxMergeTwoBuffers22(d,n1,d+n1,n2); -} -else if(nadd==5) { - pfxMergeTwoBuffers23(d,n1,d+n1,n2); -} -else if(nadd==6) { - pfxMergeTwoBuffers33(d,n1,d+n1,n2); -} -else { - pfxMergeTwoBuffers(d,n1,d+n1,n2,buff); -} -} - - -/////////////////////////////////////////////////////////////////////////////// -// Bitonic Sort - - -template -void pfxBitonicMerge(SortData *d,unsigned int n,int dir) -{ -if(n > 1) { - unsigned int k = n>>1; - for(unsigned int i=0;i Key(d[i+k])) { - SortData t = d[i+k]; - d[i+k] = d[i]; - d[i] = t; - } - if(dir==1 && Key(d[i]) < Key(d[i+k])) { - SortData t = d[i+k]; - d[i+k] = d[i]; - d[i] = t; - } - } - pfxBitonicMerge(d,k,dir); - pfxBitonicMerge(d+k,k,dir); -} -} - -template -void pfxBitonicSortInternal(SortData *d,unsigned int n,unsigned int dir=0) -{ -if(n > 1) { - unsigned int k = n>>1; - pfxBitonicSortInternal(d,k,0); - pfxBitonicSortInternal(d+k,k,1); - pfxBitonicMerge(d,n,dir); -} -} - -template -void pfxBitonicSort(SortData *d,SortData *buff,unsigned int n) -{ -pfxBitonicSortInternal(d,n,0); -memcpy(buff,d,sizeof(SortData)*n); -} - - -/////////////////////////////////////////////////////////////////////////////// -// Hybrid Sort (Bitonic + Merge) - -struct PfxDiv2n { - unsigned int id; - unsigned int num; - - PfxDiv2n() {} - - PfxDiv2n(unsigned int i,unsigned int n) - { - id = i; - num = n; - } -}; - -template -void pfxHybridSort(SortData *data,SortData *buff,unsigned int n) -{ - unsigned int numDiv = 0; - PfxDiv2n divData[32]; - - unsigned int id = 0; - unsigned int rest = n; - unsigned int mask = 0x01; - - while(rest>0) { - if((mask&n)>0) { - divData[numDiv++] = PfxDiv2n(id,mask); - pfxBitonicSort(data+id,buff+id,mask); - rest ^= mask; - id += mask; - } - mask <<= 1; - } - - if(numDiv==1) { - for(unsigned int i=0;i 2 || param.axis < 0) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.proxies) || !SCE_PFX_PTR_IS_ALIGNED16(param.pairBuff)) return SCE_PFX_ERR_INVALID_ALIGN; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.workBuff,param.workBytes) < pfxGetWorkBytesOfFindPairs(param.maxPairs,maxTasks) ) return SCE_PFX_ERR_OUT_OF_BUFFER; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.pairBuff,param.pairBytes) < pfxGetPairBytesOfFindPairs(param.maxPairs) ) return SCE_PFX_ERR_OUT_OF_BUFFER; - return SCE_PFX_OK; -} - -PfxUInt32 pfxGetPairBytesOfDecomposePairs(PfxUInt32 numPreviousPairs,PfxUInt32 numCurrentPairs) -{ - return sizeof(PfxBroadphasePair)*(numPreviousPairs*2+numCurrentPairs); -} - -PfxInt32 pfxCheckParamOfDecomposePairs(const PfxDecomposePairsParam ¶m,int maxTasks) -{ - if(!param.workBuff || !param.pairBuff || !param.previousPairs || !param.currentPairs) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.previousPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.currentPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.pairBuff) ) return SCE_PFX_ERR_INVALID_ALIGN; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.workBuff,param.workBytes) < pfxGetWorkBytesOfDecomposePairs(param.numPreviousPairs,param.numCurrentPairs,maxTasks)) return SCE_PFX_ERR_OUT_OF_BUFFER; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.pairBuff,param.pairBytes) < pfxGetPairBytesOfDecomposePairs(param.numPreviousPairs,param.numCurrentPairs)) return SCE_PFX_ERR_OUT_OF_BUFFER; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -PfxInt32 pfxUpdateBroadphaseProxies(PfxUpdateBroadphaseProxiesParam ¶m,PfxUpdateBroadphaseProxiesResult &result) -{ - PfxInt32 ret = pfxCheckParamOfUpdateBroadphaseProxies(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxUpdateBroadphaseProxies") - - result.numOutOfWorldProxies = 0; - - for(int i=0;i<(int)param.numRigidBodies;i++) { - PfxInt32 chk = pfxUpdateBroadphaseProxy( - param.proxiesX[i], - param.proxiesY[i], - param.proxiesZ[i], - param.proxiesXb[i], - param.proxiesYb[i], - param.proxiesZb[i], - param.offsetRigidStates[i], - param.offsetCollidables[i], - param.worldCenter, - param.worldExtent); - - if(chk == SCE_PFX_ERR_OUT_OF_WORLD) { - result.numOutOfWorldProxies++; - - if(param.outOfWorldBehavior & SCE_PFX_OUT_OF_WORLD_BEHAVIOR_FIX_MOTION) { - PfxRigidState &state = param.offsetRigidStates[i]; - state.setMotionType(kPfxMotionTypeFixed); - pfxSetMotionMask(param.proxiesX[i],state.getMotionMask()); - pfxSetMotionMask(param.proxiesY[i],state.getMotionMask()); - pfxSetMotionMask(param.proxiesZ[i],state.getMotionMask()); - pfxSetMotionMask(param.proxiesXb[i],state.getMotionMask()); - pfxSetMotionMask(param.proxiesYb[i],state.getMotionMask()); - pfxSetMotionMask(param.proxiesZb[i],state.getMotionMask()); - } - - if(param.outOfWorldBehavior & SCE_PFX_OUT_OF_WORLD_BEHAVIOR_REMOVE_PROXY) { - pfxSetKey(param.proxiesX[i],SCE_PFX_SENTINEL_KEY); - pfxSetKey(param.proxiesY[i],SCE_PFX_SENTINEL_KEY); - pfxSetKey(param.proxiesZ[i],SCE_PFX_SENTINEL_KEY); - pfxSetKey(param.proxiesXb[i],SCE_PFX_SENTINEL_KEY); - pfxSetKey(param.proxiesYb[i],SCE_PFX_SENTINEL_KEY); - pfxSetKey(param.proxiesZb[i],SCE_PFX_SENTINEL_KEY); - } - } - } - - PfxHeapManager pool((unsigned char*)param.workBuff,param.workBytes); - PfxBroadphaseProxy *workProxies = (PfxBroadphaseProxy*)pool.allocate(sizeof(PfxBroadphaseProxy)*param.numRigidBodies,PfxHeapManager::ALIGN128); - - pfxSort(param.proxiesX,workProxies,param.numRigidBodies); - pfxSort(param.proxiesY,workProxies,param.numRigidBodies); - pfxSort(param.proxiesZ,workProxies,param.numRigidBodies); - pfxSort(param.proxiesXb,workProxies,param.numRigidBodies); - pfxSort(param.proxiesYb,workProxies,param.numRigidBodies); - pfxSort(param.proxiesZb,workProxies,param.numRigidBodies); - - pool.deallocate(workProxies); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -PfxInt32 pfxFindPairs(PfxFindPairsParam ¶m,PfxFindPairsResult &result) -{ - PfxInt32 ret = pfxCheckParamOfFindPairs(param,0); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxFindPairs") - - void *workBuff = param.workBuff; - PfxUInt32 workBytes = param.workBytes; - PfxBroadphaseProxy *proxies = param.proxies; - PfxUInt32 numProxies = param.numProxies; - PfxUInt32 maxPairs = param.maxPairs; - int axis = param.axis; - - (void) workBytes; - - PfxBroadphasePair *pairs = (PfxBroadphasePair*)SCE_PFX_PTR_ALIGN16(param.pairBuff); - PfxUInt32 numPairs = 0; - - for(PfxUInt32 i=0;i= maxPairs) - return SCE_PFX_ERR_OUT_OF_MAX_PAIRS; - - PfxBroadphasePair &pair = pairs[numPairs++]; - pfxSetActive(pair,true); - pfxSetObjectIdA(pair,pfxGetObjectId(proxyA)); - pfxSetObjectIdB(pair,pfxGetObjectId(proxyB)); - pfxSetMotionMaskA(pair,pfxGetMotionMask(proxyA)); - pfxSetMotionMaskB(pair,pfxGetMotionMask(proxyB)); - - pfxSetKey(pair,pfxCreateUniqueKey(pfxGetObjectId(proxyA),pfxGetObjectId(proxyB))); - } - } - } - - pfxSort(pairs,(PfxBroadphasePair*)workBuff,numPairs); - - result.pairs = pairs; - result.numPairs = numPairs; - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -PfxInt32 pfxDecomposePairs(PfxDecomposePairsParam ¶m,PfxDecomposePairsResult &result) -{ - PfxInt32 ret = pfxCheckParamOfDecomposePairs(param,0); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxDecomposePairs") - - PfxBroadphasePair *previousPairs = param.previousPairs; - PfxUInt32 numPreviousPairs = param.numPreviousPairs; - PfxBroadphasePair *currentPairs = param.currentPairs; - PfxUInt32 numCurrentPairs = param.numCurrentPairs; - - PfxBroadphasePair *outNewPairs = (PfxBroadphasePair*)SCE_PFX_PTR_ALIGN16(param.pairBuff); - PfxBroadphasePair *outKeepPairs = outNewPairs + numCurrentPairs; - PfxBroadphasePair *outRemovePairs = outKeepPairs + numPreviousPairs; - - PfxUInt32 nNew = 0; - PfxUInt32 nKeep = 0; - PfxUInt32 nRemove = 0; - - PfxUInt32 oldId = 0,newId = 0; - - while(oldId pfxGetKey(previousPairs[oldId])) { - // remove - SCE_PFX_ASSERT(nRemove<=numPreviousPairs); - outRemovePairs[nRemove] = previousPairs[oldId]; - nRemove++; - oldId++; - } - else if(pfxGetKey(currentPairs[newId]) == pfxGetKey(previousPairs[oldId])) { - // keep - SCE_PFX_ASSERT(nKeep<=numPreviousPairs); - outKeepPairs[nKeep] = currentPairs[newId]; - pfxSetContactId(outKeepPairs[nKeep],pfxGetContactId(previousPairs[oldId])); - nKeep++; - oldId++; - newId++; - } - else { - // new - SCE_PFX_ASSERT(nNew<=numCurrentPairs); - outNewPairs[nNew] = currentPairs[newId]; - nNew++; - newId++; - } - }; - - if(newIdio); - - PfxRayInput *rayInputs = (PfxRayInput*)arg->data[0]; - PfxRayOutput *rayOutputs = (PfxRayOutput*)arg->data[1]; - PfxUInt32 iFirstRay = arg->data[2]; - PfxUInt32 iEndRay = arg->data[3]; - - for(PfxUInt32 i = iFirstRay; i < iEndRay; i++) - { - pfxCastSingleRay(rayInputs[i], rayOutputs[i], param); - } -} - -//---------------------------------------------------------------------------- -// pfxCastRays -// -/// Perform cast rays in parallel using a task manager. -/// -/// @param rayInputs [in] Array of rays to cast -/// @param rayOutputs [out] On return contains output of ray casts -/// @param param Information about ray cast -/// @param taskManager Pointer to the thread task manager to use -//---------------------------------------------------------------------------- -void pfxCastRays(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays, - PfxRayCastParam ¶m,PfxTaskManager *taskManager) -{ - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesX)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesY)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesZ)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesXb)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesYb)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.proxiesZb)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates)); - SCE_PFX_ALWAYS_ASSERT(SCE_PFX_PTR_IS_ALIGNED16(param.offsetCollidables)); - - SCE_PFX_PUSH_MARKER("pfxCastRays"); - - PfxUInt32 maxBatchSize = numRays / (PfxUInt32)(taskManager->getNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxCastRaysStartTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), (PfxUInt32)rayInputs, (PfxUInt32)rayOutputs, iStart, iEnd); - } - - // send final task - iEnd = numRays; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_batched_ray_cast_single.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_batched_ray_cast_single.cpp deleted file mode 100644 index 49a4c43d3..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_batched_ray_cast_single.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/low_level/collision/pfx_batched_ray_cast.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -void pfxCastRaysStart(PfxRayInput *rayInputs,PfxRayOutput *rayOutputs,int numRays,PfxRayCastParam ¶m) -{ - for(int i=0;iio); - - PfxUInt32 iFirstContactPair = arg->data[0]; - PfxUInt32 iEndContactPair = arg->data[1]; - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxCollidable *offsetCollidables = param.offsetCollidables; - PfxUInt32 numRigidBodies = param.numRigidBodies; - - for(PfxUInt32 i = iFirstContactPair; i < iEndContactPair; i++) - { - const PfxBroadphasePair &pair = contactPairs[i]; - if(!pfxCheckCollidableInCollision(pair)) - continue; - - PfxUInt32 iContact = pfxGetContactId(pair); - PfxUInt32 iA = pfxGetObjectIdA(pair); - PfxUInt32 iB = pfxGetObjectIdB(pair); - - PfxContactManifold &contact = offsetContactManifolds[iContact]; - - SCE_PFX_ALWAYS_ASSERT(iA==contact.getRigidBodyIdA()); - SCE_PFX_ALWAYS_ASSERT(iB==contact.getRigidBodyIdB()); - - PfxRigidState &stateA = offsetRigidStates[iA]; - PfxRigidState &stateB = offsetRigidStates[iB]; - PfxCollidable &collA = offsetCollidables[iA]; - PfxCollidable &collB = offsetCollidables[iB]; - PfxTransform3 tA0(stateA.getOrientation(), stateA.getPosition()); - PfxTransform3 tB0(stateB.getOrientation(), stateB.getPosition()); - - PfxContactCache contactCache; - - PfxShapeIterator itrShapeA(collA); - for(PfxUInt32 j=0;jgetNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxDetectCollisionTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numContactPairs; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_collision_detection_single.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_collision_detection_single.cpp deleted file mode 100644 index 424230f9b..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_collision_detection_single.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/collision/pfx_shape_iterator.h" -#include "../../../include/physics_effects/low_level/collision/pfx_collision_detection.h" -#include "../../base_level/broadphase/pfx_check_collidable.h" -#include "../../base_level/collision/pfx_contact_cache.h" -#include "pfx_detect_collision_func.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// - -int pfxCheckParamOfDetectCollision(PfxDetectCollisionParam ¶m) -{ - if(!param.contactPairs || !param.offsetContactManifolds || !param.offsetRigidStates|| !param.offsetCollidables ) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.contactPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetContactManifolds) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetCollidables)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -#define SCE_PFX_CONTACT_THRESHOLD 0.0f - -PfxInt32 pfxDetectCollision(PfxDetectCollisionParam ¶m) -{ - PfxInt32 ret = pfxCheckParamOfDetectCollision(param); - if(ret != SCE_PFX_OK) - return ret; - - SCE_PFX_PUSH_MARKER("pfxDetectCollision"); - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxUInt32 numContactPairs = param.numContactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxCollidable *offsetCollidables = param.offsetCollidables; - PfxUInt32 numRigidBodies = param.numRigidBodies; - - for(PfxUInt32 i=0;i= kPfxShapeCount || shapeTypeB >= kPfxShapeCount) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - funcTbl_detectCollision[shapeTypeA][shapeTypeB] = func; - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_detect_collision_func.h b/Extras/PhysicsEffects/src/low_level/collision/pfx_detect_collision_func.h deleted file mode 100644 index 77a5a46de..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_detect_collision_func.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_DETECT_COLLISION_FUNC_H -#define _SCE_PFX_DETECT_COLLISION_FUNC_H - -#include "../../base_level/collision/pfx_contact_cache.h" - -namespace sce { -namespace PhysicsEffects { - -typedef void (*pfx_detect_collision_func)( - PfxContactCache &contacts, - const PfxShape & shapeA,const PfxTransform3 &offsetTransformA,const PfxTransform3 &worldTransformA,int shapeIdA, - const PfxShape & shapeB,const PfxTransform3 &offsetTransformB,const PfxTransform3 &worldTransformB,int shapeIdB, - float contactThreshold); - -pfx_detect_collision_func pfxGetDetectCollisionFunc(PfxUInt8 shapeTypeA,PfxUInt8 shapeTypeB); - -int pfxSetDetectCollisionFunc(PfxUInt8 shapeTypeA,PfxUInt8 shapeTypeB,pfx_detect_collision_func func); - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_DETECT_COLLISION_FUNC_H diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.cpp deleted file mode 100644 index 78467cd97..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/collision/pfx_shape.h" -#include "../../base_level/collision/pfx_intersect_ray_box.h" -#include "../../base_level/collision/pfx_intersect_ray_sphere.h" -#include "../../base_level/collision/pfx_intersect_ray_capsule.h" -#include "../../base_level/collision/pfx_intersect_ray_cylinder.h" -#include "../../base_level/collision/pfx_intersect_ray_convex.h" -#include "../../base_level/collision/pfx_intersect_ray_large_tri_mesh.h" -#include "pfx_intersect_ray_func.h" - - -namespace sce { -namespace PhysicsEffects { - - -/////////////////////////////////////////////////////////////////////////////// -// Ray Intersection Function Table - -PfxBool intersectRayFuncDummy( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ - (void)ray,(void)out,(void)shape,(void)transform; - return false; -} - -PfxBool intersectRayFuncBox( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ - return pfxIntersectRayBox(ray,out,shape.getBox(),transform); -} - -PfxBool intersectRayFuncSphere( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ - return pfxIntersectRaySphere(ray,out,shape.getSphere(),transform); -} - -PfxBool intersectRayFuncCapsule( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ - return pfxIntersectRayCapsule(ray,out,shape.getCapsule(),transform); -} - -PfxBool intersectRayFuncCylinder( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ - return pfxIntersectRayCylinder(ray,out,shape.getCylinder(),transform); -} - -PfxBool intersectRayFuncConvex( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ -const PfxConvexMesh *convex = shape.getConvexMesh(); - - PfxBool ret = pfxIntersectRayConvex(ray,out,(const void*)convex,transform); - - - return ret; -} - -PfxBool intersectRayFuncLargeTriMesh( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform) -{ -const PfxLargeTriMesh *lmesh = shape.getLargeTriMesh(); - - PfxBool ret = pfxIntersectRayLargeTriMesh(ray,out,(const void*)lmesh,transform); - - - return ret; -} - -PfxIntersectRayFunc funcTbl_intersectRay[kPfxShapeCount] = { - intersectRayFuncSphere, - intersectRayFuncBox, - intersectRayFuncCapsule, - intersectRayFuncCylinder, - intersectRayFuncConvex, - intersectRayFuncLargeTriMesh, - intersectRayFuncDummy, - intersectRayFuncDummy, - intersectRayFuncDummy, - intersectRayFuncDummy, - intersectRayFuncDummy, - intersectRayFuncDummy, -}; - -/////////////////////////////////////////////////////////////////////////////// -// Ray Intersection Function Table Interface - -PfxIntersectRayFunc pfxGetIntersectRayFunc(PfxUInt8 shapeType) -{ - return funcTbl_intersectRay[shapeType]; -} - -PfxInt32 pfxSetIntersectRayFunc(PfxUInt8 shapeType,PfxIntersectRayFunc func) -{ - if(shapeType >= kPfxShapeCount) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - funcTbl_intersectRay[shapeType] = func; - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.h b/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.h deleted file mode 100644 index e0e53f9ac..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_intersect_ray_func.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_INTERSECT_RAY_FUNC_H -#define _SCE_PFX_INTERSECT_RAY_FUNC_H - -#include "../../../include/physics_effects/base_level/collision/pfx_ray.h" - -namespace sce { -namespace PhysicsEffects { - -typedef PfxBool (*PfxIntersectRayFunc)( - const PfxRayInput &ray,PfxRayOutput &out, - const PfxShape &shape,const PfxTransform3 &transform); - -PfxIntersectRayFunc pfxGetIntersectRayFunc(PfxUInt8 shapeType); - -PfxInt32 pfxSetIntersectRayFunc(PfxUInt8 shapeType,PfxIntersectRayFunc func); - -} //namespace PhysicsEffects -} //namespace sce - -#endif /* _SCE_PFX_INTERSECT_RAY_FUNC_H */ diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_island_generation.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_island_generation.cpp deleted file mode 100644 index bb65583bf..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_island_generation.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/rigidbody/pfx_rigid_state.h" -#include "../../../include/physics_effects/low_level/collision/pfx_island_generation.h" - -namespace sce { -namespace PhysicsEffects { - -struct PfxIslandNode { - PfxUInt32 rootId; - PfxUInt32 rank; - PfxUInt32 islandId; - PfxUInt32 isRoot; -}; - -struct PfxIslandUnit -{ - PfxUInt32 id; - PfxIslandUnit *next; -}; - -struct PfxIsland -{ - PfxUInt32 numNodes; - PfxUInt32 numIslands; - PfxIslandNode *nodes; - PfxIslandUnit *islandsUnits; - PfxIslandUnit **islandsHeads; -}; - -PfxUInt32 pfxIslandNodeFind(PfxUInt32 i,PfxIsland *island) -{ - if( i != island->nodes[i].rootId ) { - island->nodes[i].rootId = pfxIslandNodeFind(island->nodes[i].rootId,island); - } - return island->nodes[i].rootId; -} - -void pfxIslandNodeLink(PfxUInt32 iA,PfxUInt32 iB,PfxIsland *island) -{ - if(island->nodes[iA].rank > island->nodes[iB].rank) { - island->nodes[iB].rootId = iA; - } - else if(island->nodes[iA].rank == island->nodes[iB].rank) { - island->nodes[iA].rootId = iB; - island->nodes[iB].rank++; - } - else { - island->nodes[iA].rootId = iB; - } -} - -void pfxIslandNodeUnion(PfxUInt32 iA,PfxUInt32 iB,PfxIsland *island) -{ - SCE_PFX_ALWAYS_ASSERT(iAnumNodes); - SCE_PFX_ALWAYS_ASSERT(iBnumNodes); - - pfxIslandNodeLink(pfxIslandNodeFind(iA,island),pfxIslandNodeFind(iB,island),island); -} - -PfxUInt32 pfxGetIslandBytesOfGenerateIsland(PfxUInt32 numObjects) -{ - return 16 + - SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxIsland)) + - SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxIslandNode)*numObjects) + - SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxIslandUnit*)*numObjects) + - SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxIslandUnit)*numObjects); -} - -SCE_PFX_FORCE_INLINE int pfxCheckParamOfGenerateIsland(const PfxGenerateIslandParam ¶m) -{ - if(!param.islandBuff || !param.pairs) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.pairs)) return SCE_PFX_ERR_INVALID_ALIGN; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.islandBuff,param.islandBytes) < pfxGetIslandBytesOfGenerateIsland(param.numObjects) ) return SCE_PFX_ERR_OUT_OF_BUFFER; - return SCE_PFX_OK; -} - -PfxInt32 pfxGenerateIsland(PfxGenerateIslandParam ¶m,PfxGenerateIslandResult &result) -{ - int ret = pfxCheckParamOfGenerateIsland(param); - if(ret != SCE_PFX_OK) return ret; - - PfxConstraintPair *pairs = param.pairs; - PfxUInt32 numPairs = param.numPairs; - PfxUInt32 numUnits = param.numObjects; - - memset(param.islandBuff,0,param.islandBytes); - - PfxHeapManager pool((unsigned char*)param.islandBuff,param.islandBytes); - - PfxIsland *island = (PfxIsland*)pool.allocate(sizeof(PfxIsland)); - island->numIslands = 0; - island->numNodes = numUnits; - island->nodes = (PfxIslandNode*)pool.allocate(sizeof(PfxIslandNode)*numUnits); - island->islandsHeads = (PfxIslandUnit**)pool.allocate(sizeof(PfxIslandUnit*)*numUnits); - island->islandsUnits = (PfxIslandUnit*)pool.allocate(sizeof(PfxIslandUnit)*numUnits); - - result.island = island; - - // åˆæœŸåŒ– - for(PfxUInt32 i=0;inumNodes;i++) { - island->nodes[i].rootId = i; - island->nodes[i].rank = 0; - } - - return pfxAppendPairs(island,pairs,numPairs); -} - -PfxUInt32 pfxGetNumIslands(const PfxIsland *islands) -{ - SCE_PFX_ALWAYS_ASSERT(islands); - return islands->numIslands; -} - -PfxIslandUnit *pfxGetFirstUnitInIsland(const PfxIsland *islands,PfxUInt32 islandId) -{ - SCE_PFX_ALWAYS_ASSERT(islands); - SCE_PFX_ALWAYS_ASSERT(islandId < islands->numIslands); - return islands->islandsHeads[islandId]; -} - -PfxIslandUnit *pfxGetNextUnitInIsland(const PfxIslandUnit *islandUnit) -{ - SCE_PFX_ALWAYS_ASSERT(islandUnit); - return islandUnit->next; -} - -PfxUInt32 pfxGetUnitId(const PfxIslandUnit *islandUnit) -{ - SCE_PFX_ALWAYS_ASSERT(islandUnit); - return islandUnit->id; -} - -PfxUInt32 pfxGetIslandId(const PfxIsland *islands,PfxUInt32 unitId) -{ - SCE_PFX_ALWAYS_ASSERT(islands&&unitIdnumNodes); - return islands->nodes[unitId].islandId; -} - -PfxInt32 pfxAppendPairs(PfxIsland *island,PfxConstraintPair *pairs,PfxUInt32 numPairs) -{ - if(numPairs == 0) { - return SCE_PFX_OK; - } - - if(!island || !pairs) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(island) || !SCE_PFX_PTR_IS_ALIGNED16(pairs)) return SCE_PFX_ERR_INVALID_ALIGN; - - // çµ±åˆ - for(PfxUInt32 i=0;inumNodes); - SCE_PFX_ALWAYS_ASSERT(iBnumNodes); - - if( (SCE_PFX_MOTION_MASK_DYNAMIC(pfxGetMotionMaskA(pair)&SCE_PFX_MOTION_MASK_TYPE)) && - (SCE_PFX_MOTION_MASK_DYNAMIC(pfxGetMotionMaskB(pair)&SCE_PFX_MOTION_MASK_TYPE)) ) { - pfxIslandNodeUnion(iA,iB,island); - } - } - } - - // アイランド生æˆã®ãŸã‚ã®åˆæœŸåŒ– - for(PfxUInt32 i=0;inumNodes;i++) { - island->nodes[i].islandId = 0; - island->nodes[i].isRoot = 0; - island->islandsHeads[i] = NULL; - } - - // 親ã¸ç›´çµ - PfxUInt32 id = 0; - for(PfxUInt32 i=0;inumNodes;i++) { - PfxUInt32 rootId = pfxIslandNodeFind(i,island); - if( island->nodes[rootId].isRoot == 0 ) { - island->nodes[rootId].islandId = id++; - island->nodes[rootId].isRoot = 1; - } - island->nodes[i].islandId = island->nodes[rootId].islandId; - } - - // ã‚¢ã‚¤ãƒ©ãƒ³ãƒ‰ä½œæˆ - PfxUInt32 n = 0; - for(PfxUInt32 i=0;inumNodes;i++) { - PfxUInt32 islandId = island->nodes[i].islandId; - PfxIslandUnit *newUnit = &island->islandsUnits[n++]; - newUnit->id = i; - - if(!island->islandsHeads[islandId]) { - island->islandsHeads[islandId] = newUnit; - continue; - } - - PfxIslandUnit *unit=island->islandsHeads[islandId]; - island->islandsHeads[islandId] = newUnit; - newUnit->next = unit; - } - - island->numIslands = id; - - return SCE_PFX_OK; -} - -void pfxResetIsland(PfxIsland *island) -{ - SCE_PFX_ALWAYS_ASSERT(island); - island->numIslands = 0; - for(PfxUInt32 i=0;inumNodes;i++) { - island->nodes[i].rootId = i; - island->nodes[i].rank = 0; - } -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_ray_cast.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_ray_cast.cpp deleted file mode 100644 index 20b8446c0..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_ray_cast.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_vec_utils.h" -#include "../../../include/physics_effects/low_level/collision/pfx_ray_cast.h" -#include "../../../include/physics_effects/base_level/collision/pfx_shape_iterator.h" -#include "pfx_intersect_ray_func.h" -#include "../../base_level/collision/pfx_intersect_common.h" - - -namespace sce { -namespace PhysicsEffects { - - -void pfxRayTraverseForward( - const PfxRayInput &ray,PfxRayOutput &out,const PfxAabb16 &rayAABB, - PfxBroadphaseProxy *proxies,int numProxies, - PfxRigidState *offsetRigidStates, - PfxCollidable *offsetCollidables, - int axis,const PfxVector3 ¢er,const PfxVector3 &half) -{ -#ifdef SCE_PFX_USE_GEOMETRY - PfxGeomSegment segment((PfxPoint3)ray.m_startPosition,ray.m_direction); -#endif - - for(int i=0;i=0;i--) { - PfxBroadphaseProxy &proxy = proxies[i]; - - // 終了æ¡ä»¶ã®ãƒã‚§ãƒƒã‚¯ - if(pfxGetXYZMax(proxy,axis) < pfxGetXYZMin(rayAABB,axis)) { - return; - } - - PfxVector3 boundOnRay = ray.m_startPosition + out.m_variable * ray.m_direction; - PfxVector3 AABBmin = pfxConvertCoordLocalToWorld(PfxVecInt3((PfxInt32)pfxGetXMin(proxy),(PfxInt32)pfxGetYMin(proxy),(PfxInt32)pfxGetZMin(proxy)),center,half); - PfxVector3 AABBmax = pfxConvertCoordLocalToWorld(PfxVecInt3((PfxInt32)pfxGetXMax(proxy),(PfxInt32)pfxGetYMax(proxy),(PfxInt32)pfxGetZMax(proxy)),center,half); - - if(AABBmax[axis] < boundOnRay[axis]) { - return; - } - - // スキップ - if(pfxGetXYZMax(rayAABB,axis) < pfxGetXYZMin(proxy,axis)) { - continue; - } - - PfxUInt16 rigidbodyId = pfxGetObjectId(proxy); - PfxUInt32 contactFilterSelf = pfxGetSelf(proxy); - PfxUInt32 contactFilterTarget = pfxGetTarget(proxy); - -#ifdef SCE_PFX_USE_GEOMETRY - PfxFloatInVec t_(1.0f); - PfxGeomAabb aabb((PfxPoint3)AABBmin,(PfxPoint3)AABBmax); - if( (ray.m_contactFilterSelf&contactFilterTarget) && (ray.m_contactFilterTarget&contactFilterSelf) && pfxTestAabb(rayAABB,proxy) && - intersectionPoint(segment,aabb,&t_) && t_ < out.m_variable ) { -#else - float t_=1.0f; - if( (ray.m_contactFilterSelf&contactFilterTarget) && (ray.m_contactFilterTarget&contactFilterSelf) && pfxTestAabb(rayAABB,proxy) && - pfxIntersectRayAABBFast(ray.m_startPosition,ray.m_direction,(AABBmax+AABBmin)*0.5f,(AABBmax-AABBmin)*0.5f,t_) && t_ < out.m_variable ) { -#endif - - PfxRigidState &state = offsetRigidStates[rigidbodyId]; - PfxCollidable &coll = offsetCollidables[rigidbodyId]; - PfxTransform3 transform(state.getOrientation(), state.getPosition()); - - PfxRayOutput tout = out; - - PfxShapeIterator itrShape(coll); - for(PfxUInt32 j=0;j 0) { - pfxRayTraverseForward( - ray,out,rayAABB, - proxies[axis],param.numProxies, - param.offsetRigidStates,param.offsetCollidables, - axis,param.rangeCenter,param.rangeExtent); - } - else { - pfxRayTraverseBackward( - ray,out,rayAABB, - proxies[axis+3],param.numProxies, - param.offsetRigidStates,param.offsetCollidables, - axis,param.rangeCenter,param.rangeExtent); - } -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_parallel.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_parallel.cpp deleted file mode 100644 index 4c167ab4a..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_parallel.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* -Applied Research Associates Inc. (c)2011 - -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/sort/pfx_sort.h" -#include "../../../include/physics_effects/low_level/collision/pfx_refresh_contacts.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// This function is implemented in pfx_refresh_contacts_single.cpp -extern int pfxCheckParamOfRefreshContacts(PfxRefreshContactsParam ¶m); - -/////////////////////////////////////////////////////////////////////////////// -// MULTIPLE THREADS - -//---------------------------------------------------------------------------- -// pfxRefreshContactsTaskEntry -// -/// The thread PfxTaskEntry function used to perform refresh contacts in -/// parallel -//---------------------------------------------------------------------------- -void pfxRefreshContactsTaskEntry(PfxTaskArg *arg) -{ - PfxRefreshContactsParam ¶m = *((PfxRefreshContactsParam*)arg->io); - - PfxUInt32 iFirstContactPair = arg->data[0]; - PfxUInt32 iEndContactPair = arg->data[1]; - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxUInt32 numRigidBodies = param.numRigidBodies; - - for(PfxUInt32 i = iFirstContactPair; i < iEndContactPair; i++) - { - PfxBroadphasePair &pair = contactPairs[i]; - - PfxUInt32 iContact = pfxGetContactId(pair); - PfxUInt32 iA = pfxGetObjectIdA(pair); - PfxUInt32 iB = pfxGetObjectIdB(pair); - - PfxContactManifold &contact = offsetContactManifolds[iContact]; - - SCE_PFX_ALWAYS_ASSERT(iA==contact.getRigidBodyIdA()); - SCE_PFX_ALWAYS_ASSERT(iB==contact.getRigidBodyIdB()); - - PfxRigidState &instA = offsetRigidStates[iA]; - PfxRigidState &instB = offsetRigidStates[iB]; - - contact.refresh( - instA.getPosition(),instA.getOrientation(), - instB.getPosition(),instB.getOrientation() ); - } -} - -//---------------------------------------------------------------------------- -// pfxRefreshContacts -// -/// Perform refresh contacts in parallel using a task manager. -/// -/// @param param Information about contact pairs -/// @param taskManager Pointer to the thread task manager to use -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m, PfxTaskManager *taskManager) -{ - PfxInt32 ret = pfxCheckParamOfRefreshContacts(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxRefreshContacts"); - - PfxUInt32 maxBatchSize = param.numContactPairs / (PfxUInt32)(taskManager->getNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxRefreshContactsTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numContactPairs; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_single.cpp b/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_single.cpp deleted file mode 100644 index 8bce7d5cf..000000000 --- a/Extras/PhysicsEffects/src/low_level/collision/pfx_refresh_contacts_single.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/sort/pfx_sort.h" -#include "../../../include/physics_effects/low_level/collision/pfx_refresh_contacts.h" - -namespace sce { -namespace PhysicsEffects { - -int pfxCheckParamOfRefreshContacts(PfxRefreshContactsParam ¶m) -{ - if(!param.contactPairs || !param.offsetContactManifolds || !param.offsetRigidStates ) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.contactPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetContactManifolds) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -PfxInt32 pfxRefreshContacts(PfxRefreshContactsParam ¶m) -{ - PfxInt32 ret = pfxCheckParamOfRefreshContacts(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxRefreshContacts"); - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxUInt32 numContactPairs = param.numContactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxUInt32 numRigidBodies = param.numRigidBodies; - - for(PfxUInt32 i=0;i0&&(!param.contactPairs||!param.offsetContactManifolds)) || - (param.numJointPairs>0&&(!param.jointPairs||!param.offsetJoints)) || !param.offsetRigidStates || !param.offsetSolverBodies) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.contactPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetContactManifolds) || - !SCE_PFX_PTR_IS_ALIGNED16(param.jointPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetJoints) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetSolverBodies)) return SCE_PFX_ERR_INVALID_ALIGN; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.workBuff,param.workBytes) < pfxGetWorkBytesOfSolveConstraints(param.numRigidBodies,param.numContactPairs,param.numJointPairs, taskManager->getNumTasks()) ) return SCE_PFX_ERR_OUT_OF_BUFFER; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// MULTIPLE THREADS - -//---------------------------------------------------------------------------- -// pfxSetupSolverBodiesTaskEntry -// -/// The thread PfxTaskEntry function used to setup solver bodies in parallel. -//---------------------------------------------------------------------------- -void pfxSetupSolverBodiesTaskEntry(PfxTaskArg *arg) -{ - PfxSetupSolverBodiesParam ¶m = *((PfxSetupSolverBodiesParam*)arg->io); - - PfxUInt32 iFirstBody = arg->data[0]; - PfxUInt32 iEndBody = arg->data[1]; - - PfxRigidState *states = param.states; - PfxRigidBody *bodies = param.bodies; - PfxSolverBody *solverBodies = param.solverBodies; - - for(PfxUInt32 i = iFirstBody; i < iEndBody; i++) - { - PfxRigidState &state = states[i]; - PfxRigidBody &body = bodies[i]; - PfxSolverBody &solverBody = solverBodies[i]; - - solverBody.m_orientation = state.getOrientation(); - solverBody.m_deltaLinearVelocity = PfxVector3(0.0f); - solverBody.m_deltaAngularVelocity = PfxVector3(0.0f); - solverBody.m_motionType = state.getMotionMask(); - - if(SCE_PFX_MOTION_MASK_DYNAMIC(state.getMotionType())) { - PfxMatrix3 ori(solverBody.m_orientation); - solverBody.m_massInv = body.getMassInv(); - solverBody.m_inertiaInv = ori * body.getInertiaInv() * transpose(ori); - } - else { - solverBody.m_massInv = 0.0f; - solverBody.m_inertiaInv = PfxMatrix3(0.0f); - } - } - - SCE_PFX_POP_MARKER(); -} - -//---------------------------------------------------------------------------- -// pfxSetupSolverBodies -// -/// Perform setup solver bodies in parallel using a task manager. -/// -/// @param param Information about rigid bodies -/// @param taskManager Pointer to the thread task manager to use -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m, - PfxTaskManager *taskManager) -{ - PfxInt32 ret = pfxCheckParamOfSetupSolverBodies(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxSetupSolverBodies"); - - PfxUInt32 maxBatchSize = param.numRigidBodies / (PfxUInt32)(taskManager->getNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxSetupSolverBodiesTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numRigidBodies; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -//---------------------------------------------------------------------------- -// pfxSetupContactConstraintsTaskEntry -// -/// The thread PfxTaskEntry function used to setup contact constraints in -/// parallel. -//---------------------------------------------------------------------------- -void pfxSetupContactConstraintsTaskEntry(PfxTaskArg *arg) -{ - PfxSetupContactConstraintsParam ¶m = *((PfxSetupContactConstraintsParam*)arg->io); - - PfxUInt32 iFirstContactPair = arg->data[0]; - PfxUInt32 iEndContactPair = arg->data[1]; - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxUInt32 numContactPairs = param.numContactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxRigidBody *offsetRigidBodies = param.offsetRigidBodies; - PfxSolverBody *offsetSolverBodies = param.offsetSolverBodies; - - for(PfxUInt32 i = iFirstContactPair; i < iEndContactPair; i++) - { - PfxConstraintPair &pair = contactPairs[i]; - if(!pfxCheckSolver(pair)) - { - continue; - } - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - PfxUInt32 iConstraint = pfxGetConstraintId(pair); - - PfxContactManifold &contact = offsetContactManifolds[iConstraint]; - - SCE_PFX_ALWAYS_ASSERT(iA==contact.getRigidBodyIdA()); - SCE_PFX_ALWAYS_ASSERT(iB==contact.getRigidBodyIdB()); - - PfxRigidState &stateA = offsetRigidStates[iA]; - PfxRigidBody &bodyA = offsetRigidBodies[iA]; - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - - PfxRigidState &stateB = offsetRigidStates[iB]; - PfxRigidBody &bodyB = offsetRigidBodies[iB]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - contact.setInternalFlag(0); - - PfxFloat restitution = 0.5f * (bodyA.getRestitution() + bodyB.getRestitution()); - if(contact.getDuration() > 1) restitution = 0.0f; - - PfxFloat friction = sqrtf(bodyA.getFriction() * bodyB.getFriction()); - - for(int j=0;jgetNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxSetupContactConstraintsTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numContactPairs; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -//---------------------------------------------------------------------------- -// pfxSetupJointConstraintsTaskEntry -// -/// The thread PfxTaskEntry function used to setup joint constraints in -/// parallel. -//---------------------------------------------------------------------------- -void pfxSetupJointConstraintsTaskEntry(PfxTaskArg *arg) -{ - PfxSetupJointConstraintsParam ¶m = *((PfxSetupJointConstraintsParam*)arg->io); - - PfxUInt32 iFirstJointPair = arg->data[0]; - PfxUInt32 iEndJointPair = arg->data[1]; - - PfxConstraintPair *jointPairs = param.jointPairs; - PfxUInt32 numJointPairs = param.numJointPairs; - PfxJoint *offsetJoints = param.offsetJoints; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxSolverBody *offsetSolverBodies = param.offsetSolverBodies; - - for(PfxUInt32 i = iFirstJointPair; i < iEndJointPair; i++) - { - PfxConstraintPair &pair = jointPairs[i]; - if(!pfxCheckSolver(pair)) - { - continue; - } - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - PfxUInt32 iConstraint = pfxGetConstraintId(pair); - - PfxJoint &joint = offsetJoints[iConstraint]; - - SCE_PFX_ALWAYS_ASSERT(iA==joint.m_rigidBodyIdA); - SCE_PFX_ALWAYS_ASSERT(iB==joint.m_rigidBodyIdB); - - PfxRigidState &stateA = offsetRigidStates[iA]; - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - - PfxRigidState &stateB = offsetRigidStates[iB]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - pfxGetSetupJointConstraintFunc(joint.m_type)( - joint, - stateA, - stateB, - solverBodyA, - solverBodyB, - param.timeStep); - } -} - -//---------------------------------------------------------------------------- -// pfxSetupJointConstraints -// -/// Perform setup joint constraints in parallel using a task manager. -/// -/// @param param Information about joint constraints -/// @param taskManager Pointer to the thread task manager to use -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -PfxInt32 pfxSetupJointConstraints(PfxSetupJointConstraintsParam ¶m, - PfxTaskManager *taskManager) -{ - PfxInt32 ret = pfxCheckParamOfSetupJointConstraints(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxSetupJointConstraints"); - - PfxUInt32 maxBatchSize = param.numJointPairs / (PfxUInt32)(taskManager->getNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxSetupJointConstraintsTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numJointPairs; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -//---------------------------------------------------------------------------- -// pfxSplitConstraints -// -/// Given a set of constraints to be solved, split the constraints into -/// a collection of phases, with each phase having one or more independent -/// batches that can be solved in parallel. The phases must be solved -/// sequentially. -/// -/// @param numRigidBodies [in] Total number of rigid bodies referenced -/// in the given set of constraints -/// @param constraintpairs [in] Pointer to array of constraints to split. -/// For clarity, note that the pairs always stay -/// together. Some pairs are split to be solved -/// in parallel with other pairs. -/// @param numConstraints [in] Number of constraints to split -/// @param taskManager [in] Pointer to the thread task manager that will -/// eventually be used to solve the constraints. -/// @param group [out] On return, contains information about -/// the phases and batches that define the splitting -/// @param batches [out] Caller should pass a pointer to a pre- -/// allocated array of SCE_PFX_MAX_SOLVER_BATCHES -/// PfxParallelBatch objects. On output, these will -/// be populated with the correct number of pairs -/// for each batch. - -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -void pfxSplitConstraints(PfxUInt32 numRigidBodies, PfxConstraintPair *constraintPairs, - PfxUInt32 numConstraints, PfxTaskManager *taskManager, PfxParallelGroup *group, - PfxParallelBatch *batches) -{ - SCE_PFX_PUSH_MARKER("pfxSplitConstraints"); - - // allocate a table that will be used to indicate, for a given phase being - // populated, which batch a given body belongs to. - PfxInt32 bufSize = sizeof(PfxUInt8) * numRigidBodies; - bufSize = ((bufSize + 127) >> 7) << 7; // 128 bytes alignment - PfxUInt8 *bodyTable = (PfxUInt8*)taskManager->allocate(bufSize); - - // allocate a table that will be used to indicate, for a given phase being - // populated, which batch a given pair of bodies belongs to. - PfxUInt32 *pairTable; - size_t allocSize = sizeof(PfxUInt32)*((numConstraints + 31) / 32); - pairTable = (PfxUInt32*)taskManager->allocate(allocSize); - memset(pairTable, 0, allocSize); - - // - PfxUInt32 numTasks = taskManager->getNumTasks(); - PfxUInt32 targetCount = SCE_PFX_MAX(PfxUInt32(SCE_PFX_MIN_SOLVER_PAIRS), - SCE_PFX_MIN(numConstraints / (numTasks * 2), PfxUInt32(SCE_PFX_MAX_SOLVER_PAIRS))); - PfxUInt32 startIndex = 0; - - PfxUInt32 phaseId; - PfxUInt32 batchId; - PfxUInt32 totalCount = 0; - - PfxUInt32 maxBatches = SCE_PFX_MIN(numTasks, PfxUInt32(SCE_PFX_MAX_SOLVER_BATCHES)); - - // accumulate phases and batches until group resources are exhausted or all incoming - // pairs are accounted for. - for (phaseId = 0; phaseId < SCE_PFX_MAX_SOLVER_PHASES && totalCount < numConstraints; phaseId++) - { - bool startIndexCheck = true; - - group->numBatches[phaseId] = 0; - - PfxUInt32 i = startIndex; - // Initialize body table such that no body is assigned to any batch. (0xff is explicitly assumed to - // mean no batch assigned) - memset(bodyTable, 0xff, bufSize); - - // accumulate batches within the current phase. This code creates batches that are - // independent, e.g., no batch on this phase will touch the same bodies as any other - // batch on the phase. Batches within a phase can be solved in parallel on shared memory - // multiprocessor hardware. - for (batchId = 0; i < numConstraints && totalCount < numConstraints && batchId < maxBatches; batchId++) - { - PfxUInt32 pairCount=0; - PfxParallelBatch &batch = batches[(phaseId * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - PfxUInt32 pairId = 0; - - // iterate through pairs, and assigns the pairs to batches - for (; i < numConstraints && pairCount < targetCount; i++) - { - PfxUInt32 idxP = i >> 5; - PfxUInt32 maskP = 1L << (i & 31); - - if(pairTable[idxP] & maskP) // pair is already assigned to a phase/batch - continue; - - PfxUInt16 idxA = pfxGetObjectIdA(constraintPairs[i]); - PfxUInt16 idxB = pfxGetObjectIdB(constraintPairs[i]); - - // It is possible an incoming constraint pair can be skipped. For example, if the pair is inactive, - // or if both its objects are static, unmoving objects and therefore would be unaffected by constraints. - // This conditional statement addresses constraints to be skipped. - if (!pfxGetActive(constraintPairs[i]) || - (SCE_PFX_MOTION_MASK_STATIC(pfxGetMotionMaskA(constraintPairs[i])&SCE_PFX_MOTION_MASK_TYPE) && - SCE_PFX_MOTION_MASK_STATIC(pfxGetMotionMaskB(constraintPairs[i])&SCE_PFX_MOTION_MASK_TYPE)) ) - { - if (startIndexCheck) - startIndex++; - - //assign pair -> skip it because it has no constraints - pairTable[idxP] |= maskP; - totalCount++; - continue; - } - - // If either body of the current pair belongs to another batch already, we cannot add the current - // pair to the current batch. Must defer to another phase - if( (bodyTable[idxA] != batchId && bodyTable[idxA] != 0xff) || - (bodyTable[idxB] != batchId && bodyTable[idxB] != 0xff) ) - { - startIndexCheck = false; // so we will revisit this during allocation of next phase - continue; - } - - // Dynamic bodies for current pair are assigned to the current batch in this phase. - // Static bodies are not assigned. Since they never move, and their corresponding solver - // bodies are therefore never touched, they can actually be used by any batch. - if (SCE_PFX_MOTION_MASK_DYNAMIC(pfxGetMotionMaskA(constraintPairs[i])&SCE_PFX_MOTION_MASK_TYPE)) - bodyTable[idxA] = batchId; - - if (SCE_PFX_MOTION_MASK_DYNAMIC(pfxGetMotionMaskB(constraintPairs[i])&SCE_PFX_MOTION_MASK_TYPE)) - bodyTable[idxB] = batchId; - - if(startIndexCheck) - startIndex++; - - pairTable[idxP] |= maskP; // pair has been handled - - //add the pair 'i' to the current batch - batch.pairIndices[pairId++] = i; - pairCount++; - } - - group->numPairs[(phaseId * SCE_PFX_MAX_SOLVER_BATCHES) + batchId] = (PfxUInt16)pairId; - totalCount += pairCount; - } - group->numBatches[phaseId] = batchId; - } - - group->numPhases = phaseId; - - taskManager->deallocate(bodyTable); - taskManager->deallocate(pairTable); - - SCE_PFX_POP_MARKER(); -} - -//---------------------------------------------------------------------------- -// pfxSolveConstraintsTaskEntry -// -/// The thread PfxTaskEntry function used to solve constraints in parallel. -//---------------------------------------------------------------------------- -void pfxSolveConstraintsTaskEntry(PfxTaskArg *arg) -{ - PfxSolveConstraintsParam ¶m = *((PfxSolveConstraintsParam*)arg->io); - - PfxConstraintPair *contactPairs = param.contactPairs; - PfxContactManifold *offsetContactManifolds = param.offsetContactManifolds; - PfxConstraintPair *jointPairs = param.jointPairs; - PfxJoint *offsetJoints = param.offsetJoints; - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxSolverBody *offsetSolverBodies = param.offsetSolverBodies; - - PfxParallelGroup *jointgroup = (PfxParallelGroup*)arg->data[0]; - PfxParallelBatch *jointbatches = (PfxParallelBatch*)arg->data[1]; - PfxParallelGroup *contactgroup = (PfxParallelGroup*)arg->data[2]; - PfxParallelBatch *contactbatches = (PfxParallelBatch*)arg->data[3]; - - // Warm Starting - { - // Joints - for (PfxUInt16 phase = 0; phase < jointgroup->numPhases; phase++) - { - for (PfxUInt16 batchId = 0; batchId < jointgroup->numBatches[phase]; batchId++) - { - PfxUInt16 numJointPairs = jointgroup->numPairs[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - if ((arg->taskId == (batchId % arg->maxTasks)) && numJointPairs > 0) // only spend time on batches meant for this task - { - const PfxParallelBatch &batch = jointbatches[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - for (PfxUInt16 i = 0; i < numJointPairs; i++) - { - PfxConstraintPair &pair = jointPairs[batch.pairIndices[i]]; - if(!pfxCheckSolver(pair)) - continue; - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - - PfxJoint &joint = offsetJoints[pfxGetConstraintId(pair)]; - - SCE_PFX_ASSERT(iA==joint.m_rigidBodyIdA); - SCE_PFX_ASSERT(iB==joint.m_rigidBodyIdB); - - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - pfxGetWarmStartJointConstraintFunc(joint.m_type)( - joint, - solverBodyA, - solverBodyB); - } - } - - arg->barrier->sync(); // block until all threads are ready to go to next phase - } - } - - // Contacts - for (PfxUInt16 phase = 0; phase < contactgroup->numPhases; phase++) - { - for (PfxUInt16 batchId = 0; batchId < contactgroup->numBatches[phase]; batchId++) - { - PfxUInt16 numContactPairs = contactgroup->numPairs[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - if ((arg->taskId == (batchId % arg->maxTasks)) && numContactPairs > 0) // only spend time on batches meant for this task - { - const PfxParallelBatch &batch = contactbatches[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - for (PfxUInt16 i = 0; i < numContactPairs; i++) - { - PfxConstraintPair &pair = contactPairs[batch.pairIndices[i]]; - if(!pfxCheckSolver(pair)) - { - continue; - } - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - - PfxContactManifold &contact = offsetContactManifolds[pfxGetConstraintId(pair)]; - - SCE_PFX_ASSERT(iA==contact.getRigidBodyIdA()); - SCE_PFX_ASSERT(iB==contact.getRigidBodyIdB()); - - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - PfxFloat massInvA = solverBodyA.m_massInv; - PfxFloat massInvB = solverBodyB.m_massInv; - PfxMatrix3 inertiaInvA = solverBodyA.m_inertiaInv; - PfxMatrix3 inertiaInvB = solverBodyB.m_inertiaInv; - - if(solverBodyA.m_motionType == kPfxMotionTypeOneWay) - { - massInvB = 0.0f; - inertiaInvB = PfxMatrix3(0.0f); - } - - if(solverBodyB.m_motionType == kPfxMotionTypeOneWay) - { - massInvA = 0.0f; - inertiaInvA = PfxMatrix3(0.0f); - } - - for(int j = 0; j < contact.getNumContacts(); j++) - { - PfxContactPoint &cp = contact.getContactPoint(j); - - PfxVector3 rA = rotate(solverBodyA.m_orientation,pfxReadVector3(cp.m_localPointA)); - PfxVector3 rB = rotate(solverBodyB.m_orientation,pfxReadVector3(cp.m_localPointB)); - - for(int k = 0; k < 3; k++) - { - PfxVector3 normal = pfxReadVector3(cp.m_constraintRow[k].m_normal); - PfxFloat deltaImpulse = cp.m_constraintRow[k].m_accumImpulse; - solverBodyA.m_deltaLinearVelocity += deltaImpulse * massInvA * normal; - solverBodyA.m_deltaAngularVelocity += deltaImpulse * inertiaInvA * cross(rA,normal); - solverBodyB.m_deltaLinearVelocity -= deltaImpulse * massInvB * normal; - solverBodyB.m_deltaAngularVelocity -= deltaImpulse * inertiaInvB * cross(rB,normal); - } - } - } - } - } - - arg->barrier->sync(); // block until all threads are ready to go to next phase - } - } - - // Solver - for(PfxUInt32 iteration = 0; iteration < param.iteration; iteration++) - { - // Joints - for (PfxUInt16 phase = 0; phase < jointgroup->numPhases; phase++) - { - for (PfxUInt16 batchId = 0; batchId < jointgroup->numBatches[phase]; batchId++) - { - PfxUInt16 numJointPairs = jointgroup->numPairs[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - if ((arg->taskId == (batchId % arg->maxTasks)) && numJointPairs > 0) // only spend time on batches meant for this task - { - const PfxParallelBatch &batch = jointbatches[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - for(PfxUInt16 i = 0; i < numJointPairs; i++) - { - PfxConstraintPair &pair = jointPairs[batch.pairIndices[i]]; - if(!pfxCheckSolver(pair)) - continue; - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - - PfxJoint &joint = offsetJoints[pfxGetConstraintId(pair)]; - - SCE_PFX_ASSERT(iA==joint.m_rigidBodyIdA); - SCE_PFX_ASSERT(iB==joint.m_rigidBodyIdB); - - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - pfxGetSolveJointConstraintFunc(joint.m_type)( - joint, - solverBodyA, - solverBodyB); - } - } - } - - arg->barrier->sync(); // block until all threads are ready to go to next phase - } - - // Contacts - for (PfxUInt32 phase = 0; phase < contactgroup->numPhases; phase++) - { - for (PfxUInt32 batchId = 0; batchId < contactgroup->numBatches[phase]; batchId++) - { - PfxUInt32 numContactPairs = contactgroup->numPairs[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - if ((arg->taskId == (batchId % arg->maxTasks)) && numContactPairs > 0) // only spend time on batches meant for this task - { - const PfxParallelBatch &batch = contactbatches[(phase * SCE_PFX_MAX_SOLVER_BATCHES) + batchId]; - for(PfxUInt32 i = 0; i < numContactPairs; i++) - { - PfxConstraintPair &pair = contactPairs[batch.pairIndices[i]]; - if(!pfxCheckSolver(pair)) - continue; - - PfxUInt16 iA = pfxGetObjectIdA(pair); - PfxUInt16 iB = pfxGetObjectIdB(pair); - - PfxContactManifold &contact = offsetContactManifolds[pfxGetConstraintId(pair)]; - - SCE_PFX_ASSERT(iA==contact.getRigidBodyIdA()); - SCE_PFX_ASSERT(iB==contact.getRigidBodyIdB()); - - PfxSolverBody &solverBodyA = offsetSolverBodies[iA]; - PfxSolverBody &solverBodyB = offsetSolverBodies[iB]; - - for(int j = 0; j < contact.getNumContacts(); j++) - { - PfxContactPoint &cp = contact.getContactPoint(j); - - pfxSolveContactConstraint( - cp.m_constraintRow[0], - cp.m_constraintRow[1], - cp.m_constraintRow[2], - pfxReadVector3(cp.m_localPointA), - pfxReadVector3(cp.m_localPointB), - solverBodyA, - solverBodyB, - contact.getCompositeFriction() - ); - } - } - } - } - - arg->barrier->sync(); // block until all threads are ready to go to next phase - } - } -} - -//---------------------------------------------------------------------------- -// pfxSolveConstraints -// -/// Perform setup joint constraints in parallel using a task manager. -/// -/// @param param Information about constraints -/// @param taskManager Pointer to the thread task manager to use -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -PfxInt32 pfxSolveConstraints(PfxSolveConstraintsParam ¶m, - PfxTaskManager *taskManager) -{ - PfxInt32 ret = pfxCheckParamOfSolveConstraints(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxSolveConstraints"); - - PfxParallelGroup *contactgroup = (PfxParallelGroup*)taskManager->allocate(sizeof(PfxParallelGroup)); - PfxParallelBatch *contactbatches = (PfxParallelBatch*)taskManager->allocate(sizeof(PfxParallelBatch) * (SCE_PFX_MAX_SOLVER_PHASES * SCE_PFX_MAX_SOLVER_BATCHES)); - PfxParallelGroup *jointgroup = (PfxParallelGroup*)taskManager->allocate(sizeof(PfxParallelGroup)); - PfxParallelBatch *jointbatches = (PfxParallelBatch*)taskManager->allocate(sizeof(PfxParallelBatch) * (SCE_PFX_MAX_SOLVER_PHASES * SCE_PFX_MAX_SOLVER_BATCHES)); - - // split constraints into independent phases and batches. Phases allow - // a set of non-independent constraints to be solved in parallel. One - // phase may have dependencies within another phase, but the phases are - // solved sequentially. Within a phases, there are multiple batches, and - // the batches are independent. Since they are independent, they can be - // distributed to different processors and solved in parallel. - pfxSplitConstraints(param.numRigidBodies, param.contactPairs, param.numContactPairs, - taskManager, contactgroup, contactbatches); - pfxSplitConstraints(param.numRigidBodies, param.jointPairs, param.numJointPairs, - taskManager, jointgroup, jointbatches); - - // parallel solve - taskManager->setTaskEntry((void*)pfxSolveConstraintsTaskEntry); - int task = 0; - for (; task < taskManager->getNumTasks(); task++) - { - taskManager->startTask(task, static_cast(¶m), (PfxUInt32)jointgroup, (PfxUInt32)jointbatches, - (PfxUInt32)contactgroup, (PfxUInt32)contactbatches); - } - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - // post solve - PfxRigidState *offsetRigidStates = param.offsetRigidStates; - PfxSolverBody *offsetSolverBodies = param.offsetSolverBodies; - for (PfxUInt32 i = 0; i < param.numRigidBodies; i++) - { - param.offsetRigidStates[i].setLinearVelocity(param.offsetRigidStates[i].getLinearVelocity() + - param.offsetSolverBodies[i].m_deltaLinearVelocity); - param.offsetRigidStates[i].setAngularVelocity(param.offsetRigidStates[i].getAngularVelocity() + - param.offsetSolverBodies[i].m_deltaAngularVelocity); - } - - taskManager->clearPool(); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/solver/pfx_constraint_solver_single.cpp b/Extras/PhysicsEffects/src/low_level/solver/pfx_constraint_solver_single.cpp deleted file mode 100644 index 49bd6fa6a..000000000 --- a/Extras/PhysicsEffects/src/low_level/solver/pfx_constraint_solver_single.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/solver/pfx_contact_constraint.h" -#include "../../../include/physics_effects/low_level/solver/pfx_joint_constraint_func.h" -#include "../../../include/physics_effects/low_level/solver/pfx_constraint_solver.h" -#include "../../base_level/solver/pfx_check_solver.h" -#include "pfx_parallel_group.h" - -namespace sce { -namespace PhysicsEffects { - -PfxUInt32 pfxGetWorkBytesOfSolveConstraints(PfxUInt32 numRigidBodies,PfxUInt32 numContactPairs,PfxUInt32 numJointPairs,PfxUInt32 maxTasks) -{ - (void)maxTasks; - PfxUInt32 workBytes = SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxUInt8) * numRigidBodies) + - SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxUInt32)*((SCE_PFX_MAX(numContactPairs,numJointPairs)+31)/32)); - - workBytes += 128 + (SCE_PFX_ALLOC_BYTES_ALIGN16(sizeof(PfxParallelGroup)) + - SCE_PFX_ALLOC_BYTES_ALIGN128(sizeof(PfxParallelBatch)*(SCE_PFX_MAX_SOLVER_PHASES*SCE_PFX_MAX_SOLVER_BATCHES))) * 2; - - return workBytes; -} - -PfxInt32 pfxCheckParamOfSetupSolverBodies(const PfxSetupSolverBodiesParam ¶m) -{ - if(!param.states || !param.bodies || !param.solverBodies ) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.states) || !SCE_PFX_PTR_IS_ALIGNED16(param.bodies) || !SCE_PFX_PTR_IS_ALIGNED16(param.solverBodies)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -PfxInt32 pfxCheckParamOfSetupContactConstraints(const PfxSetupContactConstraintsParam ¶m) -{ - if((param.numContactPairs>0&&(!param.contactPairs||!param.offsetContactManifolds)) || !param.offsetRigidStates || - !param.offsetRigidBodies || !param.offsetSolverBodies || param.timeStep <= 0.0f) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.contactPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetContactManifolds) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidBodies) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetSolverBodies)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -PfxInt32 pfxCheckParamOfSetupJointConstraints(const PfxSetupJointConstraintsParam ¶m) -{ - if((param.numJointPairs>0&&(!param.jointPairs||!param.offsetJoints)) || !param.offsetRigidStates || - !param.offsetRigidBodies || !param.offsetSolverBodies || param.timeStep <= 0.0f) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.jointPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetJoints) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidBodies) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetSolverBodies)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -PfxInt32 pfxCheckParamOfSolveConstraints(const PfxSolveConstraintsParam ¶m) -{ - if((param.numContactPairs>0&&(!param.contactPairs||!param.offsetContactManifolds)) || - (param.numJointPairs>0&&(!param.jointPairs||!param.offsetJoints)) || !param.offsetRigidStates || !param.offsetSolverBodies) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.contactPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetContactManifolds) || - !SCE_PFX_PTR_IS_ALIGNED16(param.jointPairs) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetJoints) || !SCE_PFX_PTR_IS_ALIGNED16(param.offsetRigidStates) || - !SCE_PFX_PTR_IS_ALIGNED16(param.offsetSolverBodies)) return SCE_PFX_ERR_INVALID_ALIGN; - if(SCE_PFX_AVAILABLE_BYTES_ALIGN16(param.workBuff,param.workBytes) < pfxGetWorkBytesOfSolveConstraints(param.numRigidBodies,param.numContactPairs,param.numJointPairs) ) return SCE_PFX_ERR_OUT_OF_BUFFER; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -PfxInt32 pfxSetupSolverBodies(PfxSetupSolverBodiesParam ¶m) -{ - PfxInt32 ret = pfxCheckParamOfSetupSolverBodies(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxSetupSolverBodies"); - - PfxRigidState *states = param.states; - PfxRigidBody *bodies = param.bodies; - PfxSolverBody *solverBodies = param.solverBodies; - PfxUInt32 numRigidBodies = param.numRigidBodies; - - for(PfxUInt32 i=0;i 1) restitution = 0.0f; - - PfxFloat friction = sqrtf(bodyA.getFriction() * bodyB.getFriction()); - - for(int j=0;j= kPfxJointCount) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - funcTbl_setupJointConstraint[jointType] = func; - - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// Warm Start Joint Constraint Function Table - -void warmStartJointConstraintDummy( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB) -{ - (void)joint,(void)solverBodyA,(void)solverBodyB; -} - -PfxWarmStartJointConstraintFunc funcTbl_warmStartJointConstraint[kPfxJointCount] = { - pfxWarmStartBallJoint, - pfxWarmStartSwingTwistJoint, - pfxWarmStartSwingTwistJoint, - pfxWarmStartSwingTwistJoint, - pfxWarmStartSwingTwistJoint, - pfxWarmStartSwingTwistJoint, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, - warmStartJointConstraintDummy, -}; - -/////////////////////////////////////////////////////////////////////////////// -// Warm Start Joint Constraint Function Table Interface - -PfxWarmStartJointConstraintFunc pfxGetWarmStartJointConstraintFunc(PfxUInt8 jointType) -{ - SCE_PFX_ASSERT(jointType= kPfxJointCount) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - funcTbl_warmStartJointConstraint[jointType] = func; - - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// Solve Joint Constraint Function Table - -void solveJointConstraintDummy( - PfxJoint &joint, - PfxSolverBody &solverBodyA, - PfxSolverBody &solverBodyB) -{ - (void)joint,(void)solverBodyA,(void)solverBodyB; -} - -PfxSolveJointConstraintFunc funcTbl_solveJointConstraint[kPfxJointCount] = { - pfxSolveBallJoint, - pfxSolveSwingTwistJoint, - pfxSolveSwingTwistJoint, - pfxSolveSwingTwistJoint, - pfxSolveSwingTwistJoint, - pfxSolveSwingTwistJoint, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, - solveJointConstraintDummy, -}; - -/////////////////////////////////////////////////////////////////////////////// -// Solve Joint Constraint Function Table Interface - -PfxSolveJointConstraintFunc pfxGetSolveJointConstraintFunc(PfxUInt8 jointType) -{ - SCE_PFX_ASSERT(jointType= kPfxJointCount) { - return SCE_PFX_ERR_OUT_OF_RANGE; - } - - funcTbl_solveJointConstraint[jointType] = func; - - return SCE_PFX_OK; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/solver/pfx_parallel_group.h b/Extras/PhysicsEffects/src/low_level/solver/pfx_parallel_group.h deleted file mode 100644 index 6b4664cfe..000000000 --- a/Extras/PhysicsEffects/src/low_level/solver/pfx_parallel_group.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_PARALLEL_GROUP_H -#define _SCE_PFX_PARALLEL_GROUP_H - -/////////////////////////////////////////////////////////////////////////////// -// Parallel Group - -#define SCE_PFX_MAX_SOLVER_PHASES 64 // 最大フェーズ数 -#define SCE_PFX_MAX_SOLVER_BATCHES 32 // 1フェーズã«å«ã¾ã‚Œã‚‹æœ€å¤§ä¸¦åˆ—処ç†ãƒãƒƒãƒ -#define SCE_PFX_MAX_SOLVER_PAIRS 64 // 1ãƒãƒƒãƒã«å«ã¾ã‚Œã‚‹æœ€å¤§ãƒšã‚¢æ•° -#define SCE_PFX_MIN_SOLVER_PAIRS 16 // 1ãƒãƒƒãƒã«å«ã¾ã‚Œã‚‹æœ€å°ãƒšã‚¢æ•° - -namespace sce { -namespace PhysicsEffects { - -struct SCE_PFX_ALIGNED(128) PfxParallelBatch { - PfxUInt16 pairIndices[SCE_PFX_MAX_SOLVER_PAIRS]; -}; - -struct SCE_PFX_ALIGNED(128) PfxParallelGroup { - PfxUInt16 numPhases; - PfxUInt16 numBatches[SCE_PFX_MAX_SOLVER_PHASES]; // å„フェーズã®ä¿æŒã™ã‚‹ä¸¦åˆ—実行å¯èƒ½ãªãƒãƒƒãƒã®æ•° - PfxUInt16 numPairs[SCE_PFX_MAX_SOLVER_PHASES*SCE_PFX_MAX_SOLVER_BATCHES]; // å„ãƒãƒƒãƒã®ä¿æŒã™ã‚‹ãƒšã‚¢ã®æ•° -SCE_PFX_PADDING(1,126) -}; - -} //namespace PhysicsEffects -} //namespace sce -#endif // _SCE_PFX_PARALLEL_GROUP_H diff --git a/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_parallel.cpp b/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_parallel.cpp deleted file mode 100644 index 1c90e210e..000000000 --- a/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_parallel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -Applied Research Associates Inc. (c)2011 - -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/solver/pfx_integrate.h" -#include "../../../include/physics_effects/low_level/solver/pfx_update_rigid_states.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// This function is implemented in pfx_update_rigid_states_single.cpp -extern PfxInt32 pfxCheckParamOfUpdateRigidStates(const PfxUpdateRigidStatesParam ¶m); - -/////////////////////////////////////////////////////////////////////////////// -// MULTIPLE THREADS - -//---------------------------------------------------------------------------- -// pfxUpdateRigidStatesTaskEntry -// -/// The thread PfxTaskEntry function used to update rigid body states in -/// parallel. -//---------------------------------------------------------------------------- -void pfxUpdateRigidStatesTaskEntry(PfxTaskArg *arg) -{ - PfxUpdateRigidStatesParam ¶m = *((PfxUpdateRigidStatesParam*)arg->io); - - PfxUInt32 iFirstBody = arg->data[0]; - PfxUInt32 iEndBody = arg->data[1]; - - for(PfxUInt32 i = iFirstBody; i < iEndBody; i++) - { - pfxIntegrate(param.states[i],param.bodies[i],param.timeStep); - } -} - -//---------------------------------------------------------------------------- -// pfxUpdateRigidStates -// -/// Perform update rigid states in parallel using a task manager. -/// -/// @param param Information about rigid bodies -/// @param taskManager Pointer to the thread task manager to use -/// -/// @return SCE_PFX_OK if successful, otherwise, returns an error code. -//---------------------------------------------------------------------------- -PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m, PfxTaskManager *taskManager) -{ - PfxInt32 ret = pfxCheckParamOfUpdateRigidStates(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxUpdateRigidStates"); - - PfxUInt32 maxBatchSize = param.numRigidBodies / (PfxUInt32)(taskManager->getNumTasks()); - PfxUInt32 iEnd = maxBatchSize, iStart = 0; - int task = 0; - taskManager->setTaskEntry((void*)pfxUpdateRigidStatesTaskEntry); - - for (task = 0; task < taskManager->getNumTasks() - 1; task++, iStart += maxBatchSize, iEnd += maxBatchSize) - { - taskManager->startTask(task, static_cast(¶m), iStart, iEnd, 0, 0); - } - - // send final task - iEnd = param.numRigidBodies; - taskManager->startTask(taskManager->getNumTasks() - 1, static_cast(¶m), iStart, iEnd, 0, 0); - - // wait for tasks to complete - PfxUInt32 data1, data2, data3, data4; - for (PfxUInt32 i = 0; i < taskManager->getNumTasks(); i++) - taskManager->waitTask(task, data1, data2, data3, data4); - - SCE_PFX_POP_MARKER(); - - return SCE_PFX_OK; -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_single.cpp b/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_single.cpp deleted file mode 100644 index 827daff3d..000000000 --- a/Extras/PhysicsEffects/src/low_level/solver/pfx_update_rigid_states_single.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../../include/physics_effects/base_level/base/pfx_perf_counter.h" -#include "../../../include/physics_effects/base_level/solver/pfx_integrate.h" -#include "../../../include/physics_effects/low_level/solver/pfx_update_rigid_states.h" - -namespace sce { -namespace PhysicsEffects { - -PfxInt32 pfxCheckParamOfUpdateRigidStates(const PfxUpdateRigidStatesParam ¶m) -{ - if(!param.states || !param.bodies || param.timeStep <= 0.0f) return SCE_PFX_ERR_INVALID_VALUE; - if(!SCE_PFX_PTR_IS_ALIGNED16(param.states) || !SCE_PFX_PTR_IS_ALIGNED16(param.bodies)) return SCE_PFX_ERR_INVALID_ALIGN; - return SCE_PFX_OK; -} - -/////////////////////////////////////////////////////////////////////////////// -// SINGLE THREAD - -PfxInt32 pfxUpdateRigidStates(PfxUpdateRigidStatesParam ¶m) -{ - PfxInt32 ret = pfxCheckParamOfUpdateRigidStates(param); - if(ret != SCE_PFX_OK) return ret; - - SCE_PFX_PUSH_MARKER("pfxUpdateRigidStates"); - - for(PfxUInt32 i=0;i 0) - { - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_destroy(&m_mutex)); - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_cond_destroy(&m_cond)); - } -} - -//---------------------------------------------------------------------------- -// PfxPthreadsBarrier::sync -// -/// This function is used to sync m_numThreads worker threads. Each worker -/// should call sync() when it finishes a task. All workers will block until -/// the last worker also calls sync(). -//---------------------------------------------------------------------------- -void PfxPthreadsBarrier::sync() -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_lock(&m_mutex)); - - m_called++; - - if (m_called == m_maxThreads) - { - // last thread to join broadcasts a condition that will release - // all the threads waiting at the barrier. The barrier is reset - // to be ready for the next sync point. - m_called = 0; - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_cond_broadcast(&m_cond)); - } - else - { - // First m_numThreads - 1 worker threads block on the condition. - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_cond_wait(&m_cond, &m_mutex)); - } - - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_unlock(&m_mutex)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsBarrier::setMaxCount -// -/// Set the number of threads that the barrier should wait for. This also -/// initializes a mutex and condition variable that are used to implement -/// the barrier. -/// -/// @param n Number of threads that should wait at the barrier. -//---------------------------------------------------------------------------- -void PfxPthreadsBarrier::setMaxCount(int n) -{ - if (m_maxThreads > 0) - { - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_destroy(&m_mutex)); - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_cond_destroy(&m_cond)); - } - - m_called = 0; - - if (0 < n) - { - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_init(&m_mutex,NULL)); - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_cond_init(&m_cond,NULL)); - } - - m_maxThreads = n; -} - -//---------------------------------------------------------------------------- -// PfxPthreadsBarrier::getMaxCount -// -/// Get the number of threads that the barrier will wait for. -/// -/// @return The number of threads the barrier waits for -//---------------------------------------------------------------------------- -int PfxPthreadsBarrier::getMaxCount() -{ - return m_maxThreads; -} - -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::PfxPthreadsCriticalSection -// -/// Default constructor -//---------------------------------------------------------------------------- -PfxPthreadsCriticalSection::PfxPthreadsCriticalSection() -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_init(&m_mutex,NULL)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::~PfxPthreadsCriticalSection -// -/// Destructor -//---------------------------------------------------------------------------- -PfxPthreadsCriticalSection::~PfxPthreadsCriticalSection() -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_destroy(&m_mutex)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::getSharedParam -// -/// Get the value of a shared parameter. Note that user must lock the -/// critical section before performing this action. -/// -/// @param i index of shared parameter to retrieve. Must have value -/// between 0 and 31 -/// -/// @return Shared parameter value -//---------------------------------------------------------------------------- -PfxUInt32 PfxPthreadsCriticalSection::getSharedParam(int i) -{ - return(m_commonBuff[i]); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::setSharedParam -// -/// Set the value of a shared parameter. Note that user must lock the -/// critical section before performing this action. -/// -/// @param i index of shared parameter to set. Must have value -/// between 0 and 31 -/// @param p Value to assign to shared parameter -//---------------------------------------------------------------------------- -void PfxPthreadsCriticalSection::setSharedParam(int i,PfxUInt32 p) -{ - m_commonBuff[i] = p; -} - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::lock -// -/// Lock the critical section -//---------------------------------------------------------------------------- -void PfxPthreadsCriticalSection::lock() -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_lock(&m_mutex)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsCriticalSection::lock -// -/// Unlock the critical section -//---------------------------------------------------------------------------- -void PfxPthreadsCriticalSection::unlock() -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_mutex_unlock(&m_mutex)); -} - -//---------------------------------------------------------------------------- -// Factory functions -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// PfxCreateBarrierPthreads -// -/// Factory function to create a pthreads-based barrier -/// -/// @param n Max number of tasks -//---------------------------------------------------------------------------- -PfxBarrier *PfxCreateBarrierPthreads(int n) -{ - PfxPthreadsBarrier *barrier = new PfxPthreadsBarrier; - barrier->setMaxCount(n); - return(barrier); -} - -//---------------------------------------------------------------------------- -// PfxCreateCriticalSectionPthreads -// -/// Factory function to create a pthreads-based critical section -//---------------------------------------------------------------------------- -PfxCriticalSection *PfxCreateCriticalSectionPthreads() -{ - PfxPthreadsCriticalSection *cs = new PfxPthreadsCriticalSection; - return(cs); -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif //__ANDROID__ diff --git a/Extras/PhysicsEffects/src/low_level/task/pfx_sync_components_pthreads.h b/Extras/PhysicsEffects/src/low_level/task/pfx_sync_components_pthreads.h deleted file mode 100644 index 1bc405201..000000000 --- a/Extras/PhysicsEffects/src/low_level/task/pfx_sync_components_pthreads.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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 _SCE_PFX_SYNC_COMPONENTS_PTHREADS_H -#define _SCE_PFX_SYNC_COMPONENTS_PTHREADS_H - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -#include "../../../include/physics_effects/low_level/task/pfx_pthreads.h" -#include "../../../include/physics_effects/low_level/task/pfx_sync_components.h" -#include -#include - -namespace sce { -namespace PhysicsEffects { - -//---------------------------------------------------------------------------- -// PfxPthreadsBarrier -// -/// Implementation of a barrier using pthreads. This version uses a mutex -/// and condition variable rather than using native pthreads barrier, which -/// enables it to be used on platforms that don't support pthreads barriers -/// (such as Android 2.3x) -//---------------------------------------------------------------------------- -class PfxPthreadsBarrier : public PfxBarrier -{ - public: - PfxPthreadsBarrier(); - virtual ~PfxPthreadsBarrier(); - - // from PfxBarrier - virtual void sync(); - virtual void setMaxCount(int n); - virtual int getMaxCount(); - - private: - pthread_mutex_t m_mutex; ///< Mutex used to block worker threads - pthread_cond_t m_cond; ///< Condition variable - - int m_maxThreads; ///< Maximum number of worker threads - int m_called; ///< Number of worker threads waiting at barrier -}; - -//---------------------------------------------------------------------------- -// PfxPthreadsBarrier -// -/// Implementation of a critical section using pthreads. -//---------------------------------------------------------------------------- -class PfxPthreadsCriticalSection : public PfxCriticalSection -{ - public: - PfxPthreadsCriticalSection(); - virtual ~PfxPthreadsCriticalSection(); - - // from PfxCriticalSection - virtual PfxUInt32 getSharedParam(int i); - virtual void setSharedParam(int i,PfxUInt32 p); - - virtual void lock(); - virtual void unlock(); - - private: - pthread_mutex_t m_mutex; ///< Mutex used to implement lock -}; - -} //namespace PhysicsEffects -} //namespace sce - -#endif // _SCE_PFX_SYNC_COMPONENTS_PTHREADS_H diff --git a/Extras/PhysicsEffects/src/low_level/task/pfx_task_manager_pthreads.cpp b/Extras/PhysicsEffects/src/low_level/task/pfx_task_manager_pthreads.cpp deleted file mode 100644 index cecc5aa8c..000000000 --- a/Extras/PhysicsEffects/src/low_level/task/pfx_task_manager_pthreads.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* - Applied Research Associates Inc. (c)2011 - - 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 Applied Research Associates 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. -*/ - -#ifdef __ANDROID__ - -#include "../../../include/physics_effects/base_level/base/pfx_common.h" -#include "../../../include/physics_effects/low_level/task/pfx_pthreads.h" -#include "../../../include/physics_effects/low_level/task/pfx_task_manager.h" -#include "../../../include/physics_effects/low_level/task/pfx_sync_components.h" -#include "pfx_sync_components_pthreads.h" - -namespace sce { -namespace PhysicsEffects { - -//---------------------------------------------------------------------------- -// Standalone functions and structs -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// PfxPthreadsThreadData -// -/// Struct to store information needed by worker threads -//---------------------------------------------------------------------------- -struct PfxPthreadsThreadData -{ - // task runner information - PfxTaskArg *taskargument; ///< Pointer to argument for the task entry function - PfxTaskEntry taskEntry; ///< Pointer to current task entry function - - // pthreads synchronization and thread info - pthread_t thread; ///< Current thread - sem_t semaphore; ///< Semaphore used to wake the thread - sem_t *taskmanagersemaphore; ///< Semaphore used to notify parent thread -}; - -//---------------------------------------------------------------------------- -// PfxPthreadsThreadFunction -// -/// The thread function used for threads created and managed using a -/// PfxPthreadsThreadPool -//---------------------------------------------------------------------------- -void *PfxPthreadsThreadFunction(void *argument) -{ - PfxPthreadsThreadData *threaddata = (PfxPthreadsThreadData*)argument; - - while (1) - { - // wait until a task is available - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_wait(&threaddata->semaphore)); - - // do work - if (threaddata->taskEntry) - threaddata->taskEntry(threaddata->taskargument); - - // notify threadpool that task is done - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_post(threaddata->taskmanagersemaphore)); - - // If no task, then exit - if (!threaddata->taskEntry) - pthread_exit(0); - } - - return 0; -} - -//---------------------------------------------------------------------------- -// Class definitions -//---------------------------------------------------------------------------- -class PfxPthreadsTaskManager : public PfxTaskManager -{ - public: - PfxPthreadsTaskManager(PfxUInt32 numTasks, PfxUInt32 maxTasks, void *workBuff, PfxUInt32 workBytes) : - PfxTaskManager(numTasks, maxTasks, workBuff, workBytes), - m_threads(NULL) {} - - // from PfxTaskManager - virtual PfxUInt32 getSharedParam(int i); - virtual void setSharedParam(int i, PfxUInt32 p); - virtual void startTask(int taskId, void *io, PfxUInt32 data1, PfxUInt32 data2, - PfxUInt32 data3, PfxUInt32 data4); - virtual void waitTask(int &taskId, PfxUInt32 &data1, PfxUInt32 &data2, - PfxUInt32 &data3, PfxUInt32 &data4); - - virtual void initialize(); - virtual void finalize(); - - protected: - PfxPthreadsTaskManager() : PfxTaskManager(), m_threads(NULL) {} - - private: - PfxPthreadsThreadData *m_threads; ///< Pointer to array of running threads (count is m_numThreads); - PfxPthreadsBarrier m_barrier; ///< Barrier used to sync task groups - PfxPthreadsCriticalSection m_cs; ///< Critical section used to manage shared parameters - sem_t m_taskmanagersemaphore; ///< Synchronization semaphore for task manager -}; - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager -// -/// Implementation of a task manager using pthreads. -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::initialize -// -/// Initialize the task manager -//---------------------------------------------------------------------------- -void PfxPthreadsTaskManager::initialize() -{ - if (0 == m_maxTasks) - return; - - if (m_threads) // already started - { - SCE_PFX_PRINTF("PfxPthreadsThreadPool attempt to start threads when they are already started, line %i, file %s\n", __LINE__, __FILE__); - return; - } - - m_threads = (PfxPthreadsThreadData*)m_pool.allocate(sizeof(PfxPthreadsThreadData)*m_maxTasks); - if (!m_threads) - { - SCE_PFX_PRINTF("PfxPthreadsThreadPool unable to allocate threads at line %i in file %s\n", __LINE__, __FILE__); - return; - } - - m_barrier.setMaxCount(m_maxTasks); - - // Initialize sync semaphore - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_init(&m_taskmanagersemaphore, 0, 0)); - - // Allocate and start the threads - for (unsigned int i = 0; i < m_maxTasks; i++) - { - // Prepare argument data structure for task entry functions. Mostly, this is - // setting parameters that are fixed until the simulation ends - m_taskArg[i].taskId = i; - m_taskArg[i].maxTasks = m_maxTasks; - m_taskArg[i].barrier = &m_barrier; - m_taskArg[i].criticalSection = &m_cs; - m_taskArg[i].io = NULL; - - // Prepare other per-thread data - m_threads[i].taskEntry = NULL; - m_threads[i].taskargument = &m_taskArg[i]; - m_threads[i].taskmanagersemaphore = &m_taskmanagersemaphore; - - // Now create the thread's semaphore, then start the thread - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_init(&m_threads[i].semaphore, 0, 0)); - SCE_PFX_CHECK_PTHREADS_OUTCOME(pthread_create(&m_threads[i].thread, NULL, PfxPthreadsThreadFunction, (void*)&m_threads[i])); - } -} - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::finalize -// -/// Finalize the task manager -//---------------------------------------------------------------------------- -void PfxPthreadsTaskManager::finalize() -{ - // stop the threads - for (unsigned int i = 0; i < m_maxTasks; i++) - { - m_threads[i].taskEntry = NULL; // NULL task tells thread to exit - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_post(&m_threads[i].semaphore)); - } - - // wait for them all to exit - for (unsigned int i = 0; i < m_maxTasks; i++) - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_wait(&m_taskmanagersemaphore)); - - // destroy per-thread semaphores - for (unsigned int i = 0; i < m_maxTasks; i++) - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_destroy(&m_threads[i].semaphore)); - - // delete thread pool - delete [] m_threads; - m_threads = NULL; - - // destroy task manager semaphore and reset barrier - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_destroy(&m_taskmanagersemaphore)); - - m_barrier.setMaxCount(0); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::startTask -// -/// Start a task -/// -/// @param taskId [in] task thread identifier/index -/// @param io [in, out] task input and output buffer -/// @param data1 [in] first of four user parameter data values for the task -/// @param data2 [in] second of four user parameter data values for the task -/// @param data3 [in] third of four user parameter data values for the task -/// @param data4 [in] fourth of four user parameter data values for the task -//---------------------------------------------------------------------------- -void PfxPthreadsTaskManager::startTask(int taskId,void *io,PfxUInt32 data1, - PfxUInt32 data2,PfxUInt32 data3,PfxUInt32 data4) -{ - m_threads[taskId].taskEntry = m_taskEntry; - m_taskArg[taskId].io = io; - m_taskArg[taskId].data[0] = data1; - m_taskArg[taskId].data[1] = data2; - m_taskArg[taskId].data[2] = data3; - m_taskArg[taskId].data[3] = data4; - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_post(&m_threads[taskId].semaphore)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::waitTask -// -/// Wait for a task to finish -/// -/// @param taskId [out] task thread identifier/index -/// @param data1 [out] first of four data values from the task -/// @param data2 [out] second of four data values from the task -/// @param data3 [out] third of four data values from the task -/// @param data4 [out] fourth of four data values from the task -//---------------------------------------------------------------------------- -void PfxPthreadsTaskManager::waitTask(int &taskId,PfxUInt32 &data1,PfxUInt32 &data2, - PfxUInt32 &data3,PfxUInt32 &data4) -{ - SCE_PFX_CHECK_PTHREADS_OUTCOME(sem_wait(&m_taskmanagersemaphore)); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::getSharedParam -// -/// Get the value of a shared parameter -/// -/// @param i index of shared parameter to retrieve. Must have value -/// between 0 and 31 -/// -/// @return Shared parameter value -//---------------------------------------------------------------------------- -PfxUInt32 PfxPthreadsTaskManager::getSharedParam(int i) -{ - m_cs.lock(); - PfxUInt32 paramval = m_cs.getSharedParam(i); - m_cs.unlock(); - return(paramval); -} - -//---------------------------------------------------------------------------- -// PfxPthreadsTaskManager::setSharedParam -// -/// Set the value of a shared parameter -/// -/// @param i index of shared parameter to set. Must have value -/// between 0 and 31 -/// @param p Value to assign to shared parameter -//---------------------------------------------------------------------------- -void PfxPthreadsTaskManager::setSharedParam(int i, PfxUInt32 p) -{ - m_cs.lock(); - PfxUInt32 paramval = m_cs.getSharedParam(i); - m_cs.setSharedParam(i, p); - m_cs.unlock(); -} - -//---------------------------------------------------------------------------- -// Factory functions -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// PfxCreateTaskManagerPthreads -// -/// Factory function to create a pthreads-based task manager -/// -/// @param numTasks number of tasks -/// @param maxTasks max number of tasks -/// @param workBuff work buffer -/// @param workBytes size of work buffer, in bytes -//---------------------------------------------------------------------------- -PfxTaskManager *PfxCreateTaskManagerPthreads(PfxUInt32 numTasks,PfxUInt32 maxTasks, - void *workBuff,PfxUInt32 workBytes) -{ - PfxTaskManager *taskmanager = new PfxPthreadsTaskManager(numTasks, maxTasks, - workBuff, workBytes); - return(taskmanager); -} - -} //namespace PhysicsEffects -} //namespace sce - -#endif //__ANDROID__ diff --git a/Extras/PhysicsEffects/src/util/CMakeLists.txt b/Extras/PhysicsEffects/src/util/CMakeLists.txt deleted file mode 100644 index 223cfa467..000000000 --- a/Extras/PhysicsEffects/src/util/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -INCLUDE_DIRECTORIES( ${PHYSICS_EFFECTS_SOURCE_DIR}/include ) - -SET(PfxUtil_SRCS - pfx_mass.cpp - pfx_mesh_creator.cpp -) - -SET(PfxUtil_HDRS - pfx_array.h - pfx_array_implementation.h - pfx_util_common.h -) - - - - -ADD_LIBRARY(PfxUtil ${PfxUtil_SRCS} ${PfxUtil_HDRS}) - -SET_TARGET_PROPERTIES(PfxUtil PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(PfxUtil PROPERTIES SOVERSION ${BULLET_VERSION}) diff --git a/Extras/PhysicsEffects/src/util/pfx_array.h b/Extras/PhysicsEffects/src/util/pfx_array.h deleted file mode 100644 index b25834680..000000000 --- a/Extras/PhysicsEffects/src/util/pfx_array.h +++ /dev/null @@ -1,187 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#ifndef _SCE_PFX_ARRAY_H -#define _SCE_PFX_ARRAY_H - -#include "../../include/physics_effects/base_level/base/pfx_common.h" -#include "pfx_util_common.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// 基本的ãªã‚³ãƒ³ãƒ†ãƒŠã‚¯ãƒ©ã‚¹ - -/////////////////////////////////////////////////////////////////////////////// -// PfxArray - -/* - å¯å¤‰é…列 -*/ - -template -class PfxArray -{ -private: - PfxUInt32 m_numData; - PfxUInt32 m_maxData; - SCE_PFX_PADDING(1,8) - T SCE_PFX_ALIGNED(16) *m_data; - SCE_PFX_PADDING(2,12) - -public: - PfxArray() : m_numData(0),m_maxData(100) - { - m_data = (T*)SCE_PFX_UTIL_ALLOC(16,sizeof(T)*m_maxData); - } - - PfxArray(PfxUInt32 maxData) : m_numData(0),m_maxData(maxData) - { - m_data = (T*)SCE_PFX_UTIL_ALLOC(16,sizeof(T)*m_maxData); - } - - ~PfxArray() - { - SCE_PFX_UTIL_FREE(m_data); - } - - PfxUInt32 size() const {return m_numData;} - - inline T& operator[](PfxUInt32 i); - - inline const T& operator[](PfxUInt32 i) const; - - inline const PfxArray& operator=(const PfxArray &array); - - // 指定数分ã®ãƒ‡ãƒ¼ã‚¿ã‚’準備ã™ã‚‹ - inline void assign(PfxUInt32 num,const T &initData); - - // データを追加 - inline PfxUInt32 push(const T& data); - - // i番目ã®ãƒ‡ãƒ¼ã‚¿ã‚’消去 - inline bool remove(PfxUInt32 i); - - inline bool empty() const {return m_numData==0;} - - inline void clear() {m_numData = 0;} -}; - -/////////////////////////////////////////////////////////////////////////////// -// PfxQueue - -/* - キュー(最大数固定) -*/ - -template -class PfxQueue -{ -private: - PfxUInt32 m_numData; - PfxUInt32 m_maxData; - PfxUInt32 m_head; - PfxUInt32 m_tail; - T SCE_PFX_ALIGNED(16) *m_data; - SCE_PFX_PADDING(1,12) - - PfxQueue() {} - -public: - - PfxQueue(PfxUInt32 maxData) : m_numData(0),m_maxData(maxData),m_head(0),m_tail(0) - { - m_data = (T*)SCE_PFX_UTIL_ALLOC(16,sizeof(T)*m_maxData); - } - - ~PfxQueue() - { - SCE_PFX_UTIL_FREE(m_data); - } - - PfxUInt32 size() const {return m_numData;} - - // データをキューã«å…¥ã‚Œã‚‹ - inline PfxUInt32 push(const T& data); - - // 最後尾ã®ãƒ‡ãƒ¼ã‚¿ã‚’消去 - inline void pop(); - - // 先頭ã®ãƒ‡ãƒ¼ã‚¿ã‚’å‚ç…§ - inline T& front(); - - // 先頭ã®ãƒ‡ãƒ¼ã‚¿ã‚’å‚ç…§ - inline const T& front() const; - - inline bool empty() const {return m_numData==0;} - - inline void clear() {m_numData = 0;} -}; - -/////////////////////////////////////////////////////////////////////////////// -// PfxStack - -/* - スタック(最大数固定) -*/ - -template -class PfxStack -{ -private: - PfxUInt32 m_numData; - PfxUInt32 m_maxData; - T SCE_PFX_ALIGNED(16) *m_data; - - PfxStack() {} - -public: - - PfxStack(PfxUInt32 maxData) : m_numData(0),m_maxData(maxData) - { - m_data = (T*)SCE_PFX_UTIL_ALLOC(16,sizeof(T)*m_maxData); - } - - ~PfxStack() - { - SCE_PFX_UTIL_FREE(m_data); - } - - PfxUInt32 size() const {return m_numData;} - - // データをスタックã«å…¥ã‚Œã‚‹ - inline PfxUInt32 push(const T& data); - - // 末尾ã®ãƒ‡ãƒ¼ã‚¿ã‚’消去 - inline void pop(); - - // 末尾ã®ãƒ‡ãƒ¼ã‚¿ã‚’å‚ç…§ - inline T& top(); - - // 末尾ã®ãƒ‡ãƒ¼ã‚¿ã‚’å‚ç…§ - inline const T& top() const; - - inline bool empty() const {return m_numData==0;} - - inline void clear() {m_numData = 0;} -}; - -} //namespace PhysicsEffects -} //namespace sce -#include "pfx_array_implementation.h" - -#endif // _SCE_PFX_ARRAY_H diff --git a/Extras/PhysicsEffects/src/util/pfx_array_implementation.h b/Extras/PhysicsEffects/src/util/pfx_array_implementation.h deleted file mode 100644 index 21374088a..000000000 --- a/Extras/PhysicsEffects/src/util/pfx_array_implementation.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -/////////////////////////////////////////////////////////////////////////////// -// PfxArray - -namespace sce { -namespace PhysicsEffects { -template -inline T& PfxArray::operator[](PfxUInt32 i) -{ - return m_data[i]; -} - -template -inline const T& PfxArray::operator[](PfxUInt32 i) const -{ - return m_data[i]; -} - -template -inline const PfxArray& PfxArray::operator=(const PfxArray &array) -{ - clear(); - if(array.size() > m_maxData) { - m_maxData = array.size(); - m_data = (T*)SCE_PFX_UTIL_REALLOC(m_data,16,sizeof(T)*m_maxData); - SCE_PFX_ASSERT(m_data); - } - for(PfxUInt32 i=0;i -inline void PfxArray::assign(PfxUInt32 num,const T &initData) -{ - clear(); - if(num > m_maxData) { - m_maxData = num; - m_data = (T*)SCE_PFX_UTIL_REALLOC(m_data,16,sizeof(T)*m_maxData); - SCE_PFX_ASSERT(m_data); - } - for(PfxUInt32 i=0;i -inline PfxUInt32 PfxArray::push(const T& data) -{ - if(m_numData == m_maxData) { - m_maxData<<=1; - m_data = (T*)SCE_PFX_UTIL_REALLOC(m_data,16,sizeof(T)*m_maxData); - SCE_PFX_ASSERT(m_data); - } - - PfxUInt32 id = m_numData++; - m_data[id] = data; - return id; -} - -template -inline bool PfxArray::remove(PfxUInt32 i) -{ - if(i>=m_numData) { - return false; - } - - m_numData--; - m_data[i] = m_data[m_numData]; - - return true; -} - -/////////////////////////////////////////////////////////////////////////////// -// PfxQueue - -template -inline PfxUInt32 PfxQueue::push(const T& data) -{ - SCE_PFX_ASSERT(m_numData -inline void PfxQueue::pop() -{ - SCE_PFX_ASSERT(m_numData>0); - m_head = (m_head+1)%m_maxData; - m_numData--; -} - -template -inline T& PfxQueue::front() -{ - SCE_PFX_ASSERT(m_numData>0); - return m_data[m_head]; -} - -template -inline const T& PfxQueue::front() const -{ - SCE_PFX_ASSERT(m_numData>0); - return m_data[m_head]; -} - -/////////////////////////////////////////////////////////////////////////////// -// PfxStack - -template -inline PfxUInt32 PfxStack::push(const T& data) -{ - SCE_PFX_ASSERT(m_numData -inline void PfxStack::pop() -{ - SCE_PFX_ASSERT(m_numData>0); - m_numData--; -} - -template -inline T& PfxStack::top() -{ - SCE_PFX_ASSERT(m_numData>0); - return m_data[m_numData-1]; -} - -template -inline const T& PfxStack::top() const -{ - SCE_PFX_ASSERT(m_numData>0); - return m_data[m_numData-1]; -} -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/util/pfx_mass.cpp b/Extras/PhysicsEffects/src/util/pfx_mass.cpp deleted file mode 100644 index ef274bc17..000000000 --- a/Extras/PhysicsEffects/src/util/pfx_mass.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../include/physics_effects/util/pfx_mass.h" - -namespace sce { -namespace PhysicsEffects { - -/////////////////////////////////////////////////////////////////////////////// -// Box - -PfxFloat pfxCalcMassBox(PfxFloat density,const PfxVector3 &halfExtent) -{ - return density * halfExtent[0] * halfExtent[1] * halfExtent[2] * 8; -} - -PfxMatrix3 pfxCalcInertiaBox(const PfxVector3 &halfExtent,PfxFloat mass) -{ - PfxVector3 sqrSz = halfExtent * 2.0f; - sqrSz = mulPerElem(sqrSz,sqrSz); - PfxMatrix3 inertia = PfxMatrix3::identity(); - inertia[0][0] = (mass*(sqrSz[1]+sqrSz[2]))/12.0f; - inertia[1][1] = (mass*(sqrSz[0]+sqrSz[2]))/12.0f; - inertia[2][2] = (mass*(sqrSz[0]+sqrSz[1]))/12.0f; - return inertia; -} - -/////////////////////////////////////////////////////////////////////////////// -// Sphere - -PfxFloat pfxCalcMassSphere(PfxFloat density,PfxFloat radius) -{ - return (4.0f/3.0f) * SCE_PFX_PI * radius * radius * radius * density; -} - -PfxMatrix3 pfxCalcInertiaSphere(PfxFloat radius,PfxFloat mass) -{ - PfxMatrix3 inertia = PfxMatrix3::identity(); - inertia[0][0] = inertia[1][1] = inertia[2][2] = 0.4f * mass * radius * radius; - return inertia; -} - -/////////////////////////////////////////////////////////////////////////////// -// Cylinder - -PfxFloat pfxCalcMassCylinder(PfxFloat density,PfxFloat halfLength,PfxFloat radius) -{ - return SCE_PFX_PI * radius * radius * 2.0f * halfLength * density; -} - -static inline -PfxMatrix3 pfxCalcInertiaCylinder(PfxFloat halfLength,PfxFloat radius,PfxFloat mass,int axis) -{ - PfxMatrix3 inertia = PfxMatrix3::identity(); - inertia[0][0] = inertia[1][1] = inertia[2][2] = 0.25f * mass * radius * radius + 0.33f * mass * halfLength * halfLength; - inertia[axis][axis] = 0.5f * mass * radius * radius; - return inertia; -} - -PfxMatrix3 pfxCalcInertiaCylinderX(PfxFloat halfLength,PfxFloat radius,PfxFloat mass) -{ - return pfxCalcInertiaCylinder(radius,halfLength,mass,0); -} - -PfxMatrix3 pfxCalcInertiaCylinderY(PfxFloat halfLength,PfxFloat radius,PfxFloat mass) -{ - return pfxCalcInertiaCylinder(radius,halfLength,mass,1); -} - -PfxMatrix3 pfxCalcInertiaCylinderZ(PfxFloat halfLength,PfxFloat radius,PfxFloat mass) -{ - return pfxCalcInertiaCylinder(radius,halfLength,mass,2); -} - -/////////////////////////////////////////////////////////////////////////////// - -PfxMatrix3 pfxMassTranslate(PfxFloat mass,const PfxMatrix3 &inertia,const PfxVector3 &translation) -{ - PfxMatrix3 m = crossMatrix(translation); - return inertia + mass * (-m*m); -} - -PfxMatrix3 pfxMassRotate(const PfxMatrix3 &inertia,const PfxMatrix3 &rotate) -{ - return rotate * inertia * transpose(rotate); -} - -} //namespace PhysicsEffects -} //namespace sce diff --git a/Extras/PhysicsEffects/src/util/pfx_mesh_creator.cpp b/Extras/PhysicsEffects/src/util/pfx_mesh_creator.cpp deleted file mode 100644 index 6613cb19c..000000000 --- a/Extras/PhysicsEffects/src/util/pfx_mesh_creator.cpp +++ /dev/null @@ -1,944 +0,0 @@ -/* -Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc. -All rights reserved. - -Physics Effects is open software; you can redistribute it and/or -modify it under the terms of the BSD License. - -Physics Effects is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the BSD License for more details. - -A copy of the BSD License is distributed with -Physics Effects under the filename: physics_effects_license.txt -*/ - -#include "../../include/physics_effects/util/pfx_mesh_creator.h" -#include "pfx_array.h" -#include "../base_level/collision/pfx_intersect_common.h" - -namespace sce { -namespace PhysicsEffects { - -#define SCE_PFX_LARGETRIMESH_MAX_ISLANDS 256 - -/////////////////////////////////////////////////////////////////////////////// -// å‡¸ãƒ¡ãƒƒã‚·ãƒ¥ä½œæˆæ™‚ã«ä½¿ç”¨ã™ã‚‹é–¢æ•° - -PfxInt32 pfxCreateConvexMesh(PfxConvexMesh &convex,const PfxCreateConvexMeshParam ¶m) -{ - // Check input - if(param.numVerts == 0 || param.numTriangles == 0 || !param.verts || !param.triangles) - return SCE_PFX_ERR_INVALID_VALUE; - - if(param.numVerts >= SCE_PFX_NUMMESHVERTICES || param.numTriangles >= SCE_PFX_NUMMESHFACETS) - return SCE_PFX_ERR_OUT_OF_RANGE; - - PfxArray vertList; - for(PfxUInt32 i=0;i facetList; - for(PfxUInt32 i=0;i facetsInIsland[SCE_PFX_MAX_LARGETRIMESH_ISLANDS]; - PfxUInt32 numIslands; - SCE_PFX_PADDING(1,12) - - PfxMcIslands() - { - numIslands = 0; - } - - void add(PfxArray &facets) - { - facetsInIsland[numIslands++] = facets; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// ãƒ©ãƒ¼ã‚¸ãƒ¡ãƒƒã‚·ãƒ¥ä½œæˆæ™‚ã«ä½¿ç”¨ã™ã‚‹è£œåŠ©é–¢æ•° - -static -bool intersect(const PfxMcFacet &facetA,const PfxMcFacet &facetB,PfxFloat &closestDistance) -{ - const PfxFloat epsilon = 0.00001f; - - PfxVector3 pA[3] = { - facetA.v[0]->coord, - facetA.v[1]->coord, - facetA.v[2]->coord - }; - - PfxVector3 pB[3] = { - facetB.v[0]->coord, - facetB.v[1]->coord, - facetB.v[2]->coord - }; - - // é¢BãŒé¢Aã®åŽšã¿ã‚’考慮ã—ãŸç¯„å›²å†…ã«æœ‰ã‚‹ã‹ã©ã†ã‹ãƒã‚§ãƒƒã‚¯ - - // ä¸Šä¸‹é¢ - { - PfxPlane planeA(facetA.n,pA[0]); - PfxFloat dmin = SCE_PFX_FLT_MAX; - PfxFloat dmax = -SCE_PFX_FLT_MAX; - for(int i=0;i<3;i++) { - PfxFloat d = planeA.onPlane(pB[i]); - dmin = SCE_PFX_MIN(dmin,d); - dmax = SCE_PFX_MAX(dmax,d); - } - - if(dmin > -epsilon || dmax < -facetA.thickness) return false; - - // é¢Aã¨é¢Bã®æœ€è¿‘接è·é›¢ - if(dmax > 0.0f) { - // é¢A,Bã¯äº¤å·® - return false; - } - else if(dmax > -epsilon) { - // éš£æŽ¥é¢ - return false; - } - else { - closestDistance = -dmax; - } - } - - // å´é¢ - for(int p=0;p<3;p++) { - PfxVector3 sideVec = normalize(cross((pA[(p+1)%3]-pA[p]),facetA.n)); - PfxPlane planeA(sideVec,pA[p]); - - PfxFloat dmin = SCE_PFX_FLT_MAX; - for(int i=0;i<3;i++) { - PfxFloat d = planeA.onPlane(pB[i]); - dmin = SCE_PFX_MIN(dmin,d); - } - - if(dmin > -epsilon) return false; - } - - return true; -} - -static -void divideMeshes( - PfxUInt32 numFacetsLimit,PfxFloat islandsRatio, - PfxMcIslands &islands, - PfxArray &facets, - const PfxVector3 ¢er,const PfxVector3 &half) -{ - PfxFloat halfLimit = length(half) * islandsRatio; - - // å«ã¾ã‚Œã‚‹é¢æ•°ãŒè¦å®šå€¤ä»¥ä¸‹ã§ã‚れã°ã€ã‚¢ã‚¤ãƒ©ãƒ³ãƒ‰ã«ç™»éŒ² - if((facets.size() <= SCE_PFX_NUMMESHFACETS && length(half) < halfLimit) || - (facets.size() <= numFacetsLimit ) ) { - islands.add(facets); - return; - } - - // ã•らã«åˆ†å‰² - PfxVector3 newCenter0,newCenter1; - PfxVector3 newHalf0,newHalf1; - PfxArray newFacets0; - PfxArray newFacets1; - - // 最もé©åˆ‡ã¨æ€ã‚れる分離軸を探㙠- int divAxis; - { - if(half[0] > half[1]) { - if(half[0] > half[2]) { - divAxis = 0; - } - else if(half[1] > half[2]) { - divAxis = 1; - } - else { - divAxis = 2; - } - } - else { - if(half[1] > half[2]) { - divAxis = 1; - } - else if(half[0] > half[2]) { - divAxis = 0; - } - else { - divAxis = 2; - } - } - } - - // 中心ã§åˆ†å‰²ã—ã¦ã€ã•らã«å†å¸°çš„ã«å‡¦ç†ã‚’ç¶šã‘ã‚‹ - { - PfxVector3 movCenter(0.0f); - movCenter[divAxis] = 0.5f*half[divAxis]; - - newCenter0 = center + movCenter; - newCenter1 = center - movCenter; - newHalf0 = half; - newHalf0[divAxis] *= 0.5f; - newHalf1 = newHalf0; - } - - // æ–°ã—ã„AABBã«å«ã¾ã‚Œã‚‹é¢ã‚’ãれãžã‚Œã®é ˜åŸŸã«åˆ†é… - for(PfxUInt32 f=0;faabbMin + facets[f]->aabbMax) * 0.5f; - PfxVector3 facetHalf = (facets[f]->aabbMax - facets[f]->aabbMin) * 0.5f; - - // AABB判定 - if(!(fabsf(newCenter0[divAxis]-facetCenter[divAxis]) > (newHalf0[divAxis]+facetHalf[divAxis]))) { - // ã“ã®é¢ã¯AABB0ã«ç™»éŒ² - newFacets0.push(facets[f]); - } - else { - // ã“ã®é¢ã¯AABB1ã«ç™»éŒ² - newFacets1.push(facets[f]); - } - } - - if(newFacets0.size() < newFacets1.size()) { - if(newFacets0.size() > 0) - divideMeshes(numFacetsLimit,islandsRatio,islands,newFacets0,newCenter0,newHalf0); - if(newFacets1.size() > 0) - divideMeshes(numFacetsLimit,islandsRatio,islands,newFacets1,newCenter1,newHalf1); - } - else { - if(newFacets1.size() > 0) - divideMeshes(numFacetsLimit,islandsRatio,islands,newFacets1,newCenter1,newHalf1); - if(newFacets0.size() > 0) - divideMeshes(numFacetsLimit,islandsRatio,islands,newFacets0,newCenter0,newHalf0); - } -} - -static -int addIslandToLargeTriMesh(PfxLargeTriMesh &lmesh,PfxTriMesh &island) -{ - SCE_PFX_ASSERT(island.m_numFacets <= SCE_PFX_NUMMESHFACETS); - - int newIsland = lmesh.m_numIslands++; - lmesh.m_islands[newIsland] = island; - - // アイランドローカルã®AABBを計算 - if(island.m_numFacets > 0) { - PfxVector3 aabbMin(SCE_PFX_FLT_MAX),aabbMax(-SCE_PFX_FLT_MAX); - - for(PfxUInt32 i=0;i &facets) -{ - if(facets.empty()) return; - - island.m_numFacets = facets.size(); - - PfxUInt32 vertsFlag[(0xff*SCE_PFX_NUMMESHFACETS*3+31)/32]; - memset(vertsFlag,0,sizeof(PfxUInt32)*((0xff*SCE_PFX_NUMMESHFACETS*3+31)/32)); - - PfxArray edgeHead(facets.size()*3); - PfxArray edgeList(facets.size()*3); - - PfxMcEdgeEntry* nl = NULL; - edgeHead.assign(facets.size()*3,nl); - edgeList.assign(facets.size()*3,PfxMcEdgeEntry()); - - int vcnt = 0; - int ecnt = 0; - for(PfxUInt32 f=0;fv[v]; - PfxUInt32 idx = vert->i; - PfxUInt32 mask = 1 << (idx & 31); - if((vertsFlag[idx>>5] & mask) == 0) { - SCE_PFX_ASSERT(vcnt>5] |= mask; - island.m_verts[vcnt] = vert->coord; - vert->flag = vcnt;// æ–°ã—ã„インデックス - vcnt++; - } - oFacet.m_vertIds[v] = (PfxUInt8)vert->flag; - } - - // Edge - for(int v=0;v<3;v++) { - PfxUInt8 viMin = SCE_PFX_MIN(oFacet.m_vertIds[v],oFacet.m_vertIds[(v+1)%3]); - PfxUInt8 viMax = SCE_PFX_MAX(oFacet.m_vertIds[v],oFacet.m_vertIds[(v+1)%3]); - int key = ((0x8da6b343*viMin+0xd8163841*viMax)%(island.m_numFacets*3)); - for(PfxMcEdgeEntry *e=edgeHead[key];;e=e->next) { - if(!e) { - edgeList[ecnt].vertId[0] = viMin; - edgeList[ecnt].vertId[1] = viMax; - edgeList[ecnt].facetId[0] = f; - edgeList[ecnt].numFacets = 1; - edgeList[ecnt].edgeNum[0] = v; - edgeList[ecnt].edgeId = ecnt; - edgeList[ecnt].dir = normalize(island.m_verts[viMax]-island.m_verts[viMin]); - edgeList[ecnt].next = edgeHead[key]; - edgeHead[key] = &edgeList[ecnt]; - - PfxEdge edge; - edge.m_angleType = iEdge[v]->angleType; - // 厚ã¿è§’ã®è¨­å®š 0~πを0~255ã®æ•´æ•°å€¤ã«å¤‰æ›ã—ã¦æ ¼ç´ - edge.m_tilt = (PfxUInt8)((iEdge[v]->angle/(0.5f*SCE_PFX_PI))*255.0f); - edge.m_vertId[0] = viMin; - edge.m_vertId[1] = viMax; - - oFacet.m_edgeIds[v] = ecnt; - island.m_edges[ecnt] = edge; - SCE_PFX_ASSERT(ecnt <= SCE_PFX_NUMMESHEDGES); - ecnt++; - break; - } - - if(e->vertId[0] == viMin && e->vertId[1] == viMax) { - SCE_PFX_ASSERT(e->numFacets==1); - e->facetId[1] = f; - e->edgeNum[1] = v; - e->numFacets = 2; - oFacet.m_edgeIds[v] = e->edgeId; - break; - } - } - } - } - - island.m_numEdges = ecnt; - island.m_numVerts = vcnt; - - island.updateAABB(); -} - -/////////////////////////////////////////////////////////////////////////////// -// ラージメッシュ - -PfxInt32 pfxCreateLargeTriMesh(PfxLargeTriMesh &lmesh,const PfxCreateLargeTriMeshParam ¶m) -{ - // Check input - if(param.numVerts == 0 || param.numTriangles == 0 || !param.verts || !param.triangles) - return SCE_PFX_ERR_INVALID_VALUE; - - if(param.islandsRatio < 0.0f || param.islandsRatio > 1.0f) - return SCE_PFX_ERR_OUT_OF_RANGE; - - if(param.numFacetsLimit == 0 || param.numFacetsLimit > SCE_PFX_NUMMESHFACETS) - return SCE_PFX_ERR_OUT_OF_RANGE; - - const PfxFloat epsilon = 0.00001f; - - PfxArray vertList(param.numVerts); // 頂点é…列 - PfxArray facetList(param.numTriangles); // é¢é…列 - PfxArray edgeList(param.numTriangles*3); // エッジé…列 - PfxArray edgeHead(param.numTriangles*3); - - //J 頂点é…åˆ—ä½œæˆ - for(PfxUInt32 i=0;i triEntry(numTriangles*3); - PfxArray triHead(numTriangles*3); // 頂点ã‹ã‚‰é¢ã¸ã®å‚照リスト - PfxInt32 cnt = 0; - - PfxMcTriList* nl = NULL; - triEntry.assign(numTriangles*3,PfxMcTriList()); - triHead.assign(numTriangles*3,nl); - - // 頂点ã‹ã‚‰é¢ã¸ã®å‚ç…§ãƒªã‚¹ãƒˆã‚’ä½œæˆ - for(PfxUInt32 i=0;ii; - triEntry[cnt].facet = &facetList[i]; - triEntry[cnt].next = triHead[vertId]; - triHead[vertId] = &triEntry[cnt++]; - } - } - - // åŒä¸€é ‚点をã¾ã¨ã‚ã‚‹ - if(param.flag & SCE_PFX_MESH_FLAG_AUTO_ELIMINATION) { - for(PfxUInt32 i=0;inext) { - for(PfxInt32 k=0;k<3;k++) { - if(f->facet->v[k] == &vertList[j]) { - f->facet->v[k] = &vertList[i]; // é ‚ç‚¹ã‚’ä»˜ã‘æ›¿ãˆã‚‹ - break; - } - } - } - } - } - } - } - } - - // 接続é¢é–“ã®è§’度を算出ã—ã¦é¢ã«ã‚»ãƒƒãƒˆ - PfxMcEdge *nl = NULL; - edgeHead.assign(numTriangles*3,nl); - edgeList.assign(numTriangles*3,PfxMcEdge()); - - // エッジé…列ã®ä½œæˆ - PfxUInt32 ecnt = 0; - for(PfxUInt32 i=0;inext) { - if(!e) { - edgeList[ecnt].vertId[0] = viMin; - edgeList[ecnt].vertId[1] = viMax; - edgeList[ecnt].facetId[0] = i; - edgeList[ecnt].edgeId[0] = v; - edgeList[ecnt].numFacets = 1; - edgeList[ecnt].next = edgeHead[key]; - edgeList[ecnt].angleType = SCE_PFX_EDGE_CONVEX; - edgeList[ecnt].angle = 0.0f; - edgeHead[key] = &edgeList[ecnt]; - f.e[v] = &edgeList[ecnt]; - ecnt++; - break; - } - - if(e->vertId[0] == viMin && e->vertId[1] == viMax) { - SCE_PFX_ALWAYS_ASSERT_MSG(e->numFacets == 1,"An edge connected with over 2 triangles is invalid"); - e->facetId[1] = i; - e->edgeId[1] = v; - e->numFacets = 2; - f.e[v] = e; - f.neighbor[v] = e->facetId[0]; - f.neighborEdgeId[v] = e->edgeId[0]; - facetList[e->facetId[0]].neighbor[e->edgeId[0]] = i; - facetList[e->facetId[0]].neighborEdgeId[e->edgeId[0]] = e->edgeId[1]; - break; - } - } - } - } - - // 角度を計算 - for(PfxUInt32 i=0;i cqueue(ecnt); - - for(PfxUInt32 j=0;j<3;j++) { - if(facetA.neighbor[j] >= 0) { - cqueue.push(PfxMcFacetLink( - j, - facetA.e[j]->vertId[0],facetA.e[j]->vertId[1], - i,j, - facetA.neighbor[j],facetA.neighborEdgeId[j])); - } - } - - while(!cqueue.empty()) { - PfxMcFacetLink link = cqueue.front(); - cqueue.pop(); - - PfxMcFacet &ofacet = facetList[link.ofacetId]; - PfxMcEdge *edge = ofacet.e[link.oedgeId]; - - // facetAã¨ã®ãªã™è§’を計算 - { - // é¢ã«å«ã¾ã‚Œã‚‹ãŒã€ã“ã®ã‚¨ãƒƒã‚¸ã«å«ã¾ã‚Œãªã„点 - PfxUInt32 ids[3] = {2,0,1}; - PfxVector3 v1 = facetA.v[ids[link.baseEdgeId]]->coord; - PfxVector3 v2 = ofacet.v[ids[link.oedgeId]]->coord; - - // エッジã®å‡¹å‡¸åˆ¤å®š - PfxVector3 midPnt = (v1 + v2) * 0.5f; - PfxVector3 pntOnEdge = facetA.v[link.baseEdgeId]->coord; - - PfxFloat chk1 = dot(facetA.n,midPnt-pntOnEdge); - PfxFloat chk2 = dot(ofacet.n,midPnt-pntOnEdge); - - if(chk1 < -epsilon && chk2 < -epsilon) { - if(link.ifacetId == i) edge->angleType = SCE_PFX_EDGE_CONVEX; - - // 厚ã¿è§’ã®åˆ¤å®šã«ä½¿ã†è§’度をセット - if(param.flag & SCE_PFX_MESH_FLAG_AUTO_THICKNESS) { - edge->angle = 0.5f*acosf(dot(facetA.n,ofacet.n)); - } - } - else if(chk1 > epsilon && chk2 > epsilon) { - if(link.ifacetId == i) edge->angleType = SCE_PFX_EDGE_CONCAVE; - } - else { - if(link.ifacetId == i) edge->angleType = SCE_PFX_EDGE_FLAT; - } - } - - // æ¬¡ã®æŽ¥ç¶šé¢ã‚’登録(コメントアウトã™ã‚‹ã¨é ‚ç‚¹ã§æŽ¥ç¶šã•れãŸé¢ã‚’考慮ã—ãªã„) - if(param.flag & SCE_PFX_MESH_FLAG_AUTO_THICKNESS) { - PfxInt32 nextEdgeId = (link.oedgeId+1)%3; - PfxMcEdge *nextEdge = ofacet.e[nextEdgeId]; - if(ofacet.neighbor[nextEdgeId] >= 0 && ofacet.neighbor[nextEdgeId] != i && - ((PfxInt32)nextEdge->vertId[0] == link.vid1 || (PfxInt32)nextEdge->vertId[0] == link.vid2 || - (PfxInt32)nextEdge->vertId[1] == link.vid1 || (PfxInt32)nextEdge->vertId[1] == link.vid2) ) { - cqueue.push(PfxMcFacetLink( - link.baseEdgeId, - link.vid1,link.vid2, - link.ofacetId,link.iedgeId, - ofacet.neighbor[nextEdgeId],ofacet.neighborEdgeId[nextEdgeId])); - } - nextEdgeId = (link.oedgeId+2)%3; - nextEdge = ofacet.e[nextEdgeId]; - if(ofacet.neighbor[nextEdgeId] >= 0 && ofacet.neighbor[nextEdgeId] != i && - ((PfxInt32)nextEdge->vertId[0] == link.vid1 || (PfxInt32)nextEdge->vertId[0] == link.vid2 || - (PfxInt32)nextEdge->vertId[1] == link.vid1 || (PfxInt32)nextEdge->vertId[1] == link.vid2) ) { - cqueue.push(PfxMcFacetLink( - link.baseEdgeId, - link.vid1,link.vid2, - link.ofacetId,link.iedgeId, - ofacet.neighbor[nextEdgeId],ofacet.neighborEdgeId[nextEdgeId])); - } - } - } - } - - // é¢ã«åŽšã¿ã‚’付ã‘ã‚‹ - if(param.flag & SCE_PFX_MESH_FLAG_AUTO_THICKNESS) { - for(PfxUInt32 i=0;ifacetId[0] || - j == (PfxInt32)facetA.e[0]->facetId[1] || - j == (PfxInt32)facetA.e[1]->facetId[0] || - j == (PfxInt32)facetA.e[1]->facetId[1] || - j == (PfxInt32)facetA.e[2]->facetId[0] || - j == (PfxInt32)facetA.e[2]->facetId[1]) { - continue; - } - - PfxMcFacet &facetB = facetList[j]; - - // 交差判定 - PfxFloat closestDistance=0; - if(intersect(facetA,facetB,closestDistance)) { - // 最近接è·é›¢/2を厚ã¿ã¨ã—ã¦æŽ¡ç”¨ - facetA.thickness = SCE_PFX_MAX(param.defaultThickness,SCE_PFX_MIN(facetA.thickness,closestDistance * 0.5f)); - } - } - - } - } - - // é¢ã®é¢ç©ã«ã‚ˆã£ã¦ï¼“種類ã«åˆ†é¡žã™ã‚‹ - PfxFloat areaMin=SCE_PFX_FLT_MAX,areaMax=-SCE_PFX_FLT_MAX; - for(PfxUInt32 f=0;f<(PfxUInt32)numTriangles;f++) { - PfxVector3 pnts[3] = { - facetList[f].v[0]->coord, - facetList[f].v[1]->coord, - facetList[f].v[2]->coord, - }; - areaMin = SCE_PFX_MIN(areaMin,facetList[f].area); - areaMax = SCE_PFX_MAX(areaMax,facetList[f].area); - - // é¢ã®AABBを算出 - facetList[f].aabbMin = minPerElem(pnts[2],minPerElem(pnts[1],pnts[0])); - facetList[f].aabbMax = maxPerElem(pnts[2],maxPerElem(pnts[1],pnts[0])); - } - - PfxFloat areaDiff = (areaMax-areaMin)/3.0f; - PfxFloat areaLevel0,areaLevel1; - areaLevel0 = areaMin + areaDiff; - areaLevel1 = areaMin + areaDiff * 2.0f; - - PfxArray facetsLv0(numTriangles); - PfxArray facetsLv1(numTriangles); - PfxArray facetsLv2(numTriangles); - - for(PfxUInt32 f=0;f areaLevel1) { - facetsLv2.push(fct); - } - else { - facetsLv1.push(fct); - } - } - - // アイランドã®é…列 - PfxMcIslands islands; - PfxVector3 lmeshSize; - - // レベル毎ã«PfxTriMeshã‚’ä½œæˆ - if(!facetsLv0.empty()) { - // 全体ã®AABBを求ã‚ã‚‹ - PfxVector3 aabbMin,aabbMax,center,half; - aabbMin =facetsLv0[0]->aabbMin; - aabbMax = facetsLv0[0]->aabbMax; - for(PfxUInt32 f=1;faabbMin,aabbMin); - aabbMax = maxPerElem(facetsLv0[f]->aabbMax,aabbMax); - } - center = ( aabbMin + aabbMax ) * 0.5f; - half = ( aabbMax - aabbMin ) * 0.5f; - - // å†å¸°çš„ã«å‡¦ç† - divideMeshes( - param.numFacetsLimit,param.islandsRatio, - islands, - facetsLv0, - center,half); - - lmeshSize = maxPerElem(lmeshSize,maxPerElem(absPerElem(aabbMin),absPerElem(aabbMax))); - } - - if(!facetsLv1.empty()) { - // 全体ã®AABBを求ã‚ã‚‹ - PfxVector3 aabbMin,aabbMax,center,half; - aabbMin =facetsLv1[0]->aabbMin; - aabbMax = facetsLv1[0]->aabbMax; - for(PfxUInt32 f=1;faabbMin,aabbMin); - aabbMax = maxPerElem(facetsLv1[f]->aabbMax,aabbMax); - } - center = ( aabbMin + aabbMax ) * 0.5f; - half = ( aabbMax - aabbMin ) * 0.5f; - - // å†å¸°çš„ã«å‡¦ç† - divideMeshes( - param.numFacetsLimit,param.islandsRatio, - islands, - facetsLv1, - center,half); - - lmeshSize = maxPerElem(lmeshSize,maxPerElem(absPerElem(aabbMin),absPerElem(aabbMax))); - } - - if(!facetsLv2.empty()) { - // 全体ã®AABBを求ã‚ã‚‹ - PfxVector3 aabbMin,aabbMax,center,half; - aabbMin =facetsLv2[0]->aabbMin; - aabbMax = facetsLv2[0]->aabbMax; - for(PfxUInt32 f=1;faabbMin,aabbMin); - aabbMax = maxPerElem(facetsLv2[f]->aabbMax,aabbMax); - } - center = ( aabbMin + aabbMax ) * 0.5f; - half = ( aabbMax - aabbMin ) * 0.5f; - - // å†å¸°çš„ã«å‡¦ç† - divideMeshes( - param.numFacetsLimit,param.islandsRatio, - islands, - facetsLv2, - center,half); - - lmeshSize = maxPerElem(lmeshSize,maxPerElem(absPerElem(aabbMin),absPerElem(aabbMax))); - } - - lmesh.m_half = lmeshSize; - - // Check Islands - //for(PfxInt32 i=0;iv[0]->i,facet->v[1]->i,facet->v[2]->i); - // } - //} - - // PfxLargeTriMeshã®ç”Ÿæˆ - if(islands.numIslands > 0) { - lmesh.m_numIslands = 0; - lmesh.m_aabbList = (PfxAabb16*)SCE_PFX_UTIL_ALLOC(128,sizeof(PfxAabb16)*islands.numIslands); - lmesh.m_islands = (PfxTriMesh*)SCE_PFX_UTIL_ALLOC(128,sizeof(PfxTriMesh)*islands.numIslands); - - PfxInt32 maxFacets=0,maxVerts=0,maxEdges=0; - for(PfxUInt32 i=0;i - -#ifdef _WIN32 - #define SCE_PFX_UTIL_ALLOC(align,size) _aligned_malloc(size,align) - #define SCE_PFX_UTIL_REALLOC(ptr,align,size) _aligned_realloc(ptr,size,align) - #define SCE_PFX_UTIL_FREE(ptr) if(ptr) {_aligned_free(ptr);ptr=NULL;} -#else - #define SCE_PFX_UTIL_ALLOC(align,size) malloc(size) - #define SCE_PFX_UTIL_REALLOC(ptr,align,size) realloc(ptr,size) - #define SCE_PFX_UTIL_FREE(ptr) if(ptr) {free(ptr);ptr=NULL;} -#endif - -#endif // _SCE_PFX_UTIL_COMMON_H diff --git a/Extras/PhysicsEffects/src/util/premake4.lua b/Extras/PhysicsEffects/src/util/premake4.lua deleted file mode 100644 index 483f81775..000000000 --- a/Extras/PhysicsEffects/src/util/premake4.lua +++ /dev/null @@ -1,12 +0,0 @@ - project "physicseffects2_util" - - kind "StaticLib" - targetdir "../../build/lib" - includedirs { - ".", - } - files { - "**.cpp", - "../../include/physics_effects/util/**.h" - - } \ No newline at end of file diff --git a/Extras/iff/CMakeLists.txt b/Extras/iff/CMakeLists.txt deleted file mode 100644 index 17d798c42..000000000 --- a/Extras/iff/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -INCLUDE_DIRECTORIES( -${BULLET_PHYSICS_SOURCE_DIR}/Extras/iff -) - -ADD_LIBRARY(Iff -iff.h -iffr.cpp -iffw.cpp -) - -#SUBDIRS( BulletIffConverter ) diff --git a/Extras/iff/IFF.txt b/Extras/iff/IFF.txt deleted file mode 100644 index 9d4ae8b78..000000000 --- a/Extras/iff/IFF.txt +++ /dev/null @@ -1,1423 +0,0 @@ - -"EA IFF 85" Standard for Interchange Format Files - -Document Date: January 14, 1985 -From: Jerry Morrison, Electronic Arts -Status of Standard: Released and in use - -1. Introduction - -Standards are Good for Software Developers - -As home computer hardware evolves to better and better media machines, -the demand increases for higher quality, more detailed data. Data -development gets more expensive, requires more expertise and better -tools, and has to be shared across projects. Think about several ports -of a product on one CD-ROM with 500M Bytes of common data! - -Development tools need standard interchange file formats. Imagine -scanning in images of "player" shapes, moving them to a paint program -for editing, then incorporating them into a game. Or writing a theme -song with a Macintosh score editor and incorporating it into an Amiga -game. The data must at times be transformed, clipped, filled out, -and moved across machine kinds. Media projects will depend on data -transfer from graphic, music, sound effect, animation, and script -tools. - -Standards are Good for Software Users - -Customers should be able to move their own data between independently -developed software products. And they should be able to buy data libraries -usable across many such products. The types of data objects to exchange -are open-ended and include plain and formatted text, raster and structured -graphics, fonts, music, sound effects, musical instrument descriptions, -and animation. - -The problem with expedient file formats typically memory dumps is -that they're too provincial. By designing data for one particular -use (e.g. a screen snapshot), they preclude future expansion (would -you like a full page picture? a multi-page document?). In neglecting -the possibility that other programs might read their data, they fail -to save contextual information (how many bit planes? what resolution?). -Ignoring that other programs might create such files, they're intolerant -of extra data (texture palette for a picture editor), missing data -(no color map), or minor variations (smaller image). In practice, -a filed representation should rarely mirror an in-memory representation. -The former should be designed for longevity; the latter to optimize -the manipulations of a particular program. The same filed data will -be read into different memory formats by different programs. - -The IFF philosophy: "A little behind-the-scenes conversion when programs -read and write files is far better than NxM explicit conversion utilities -for highly specialized formats." - -So we need some standardization for data interchange among development -tools and products. The more developers that adopt a standard, the -better for all of us and our customers. - -Here is "EA IFF 1985" - -Here is our offering: Electronic Arts' IFF standard for Interchange -File Format. The full name is "EA IFF 1985". Alternatives and justifications -are included for certain choices. Public domain subroutine packages -and utility programs are available to make it easy to write and use -IFF-compatible programs. - -Part 1 introduces the standard. Part 2 presents its requirements and -background. Parts 3, 4, and 5 define the primitive data types, FORMs, -and LISTs, respectively, and how to define new high level types. Part -6 specifies the top level file structure. Appendix A is included for -quick reference and Appendix B names the committee responsible for -this standard. - -References - -American National Standard Additional Control Codes for Use with ASCII, -ANSI standard 3.64-1979 for an 8-bit character set. See also ISO standard -2022 and ISO/DIS standard 6429.2. - -Amiga[tm] is a trademark of Commodore-Amiga, Inc. - -C, A Reference Manual, Samuel P. Harbison and Guy L. Steele Jr., Tartan -Laboratories. Prentice-Hall, Englewood Cliffs, NJ, 1984. - -Compiler Construction, An Advanced Course, edited by F. L. Bauer and -J. Eickel (Springer-Verlag, 1976). This book is one of many sources -for information on recursive descent parsing. - -DIF Technical Specification (c)1981 by Software Arts, Inc. DIF[tm] is -the format for spreadsheet data interchange developed by Software -Arts, Inc. -DIF[tm] is a trademark of Software Arts, Inc. - -Electronic Arts[tm] is a trademark of Electronic Arts. - -"FTXT" IFF Formatted Text, from Electronic Arts. IFF supplement document -for a text format. - -Inside Macintosh (c) 1982, 1983, 1984, 1985 Apple Computer, Inc., a -programmer's reference manual. -Apple(R) is a trademark of Apple Computer, Inc. -Macintosh[tm] is a trademark licensed to Apple Computer, Inc. - -"ILBM" IFF Interleaved Bitmap, from Electronic Arts. IFF supplement -document for a raster image format. - -M68000 16/32-Bit Microprocessor Programmer's Reference Manual(c) 1984, -1982, 1980, 1979 by Motorola, Inc. - -PostScript Language Manual (c) 1984 Adobe Systems Incorporated. -PostScript[tm] is a trademark of Adobe Systems, Inc. -Times and Helvetica(R) are trademarks of Allied Corporation. - -InterScript: A Proposal for a Standard for the Interchange of Editable -Documents (c)1984 Xerox Corporation. -Introduction to InterScript (c) 1985 Xerox Corporation. - - - -2. Background for Designers - -Part 2 is about the background, requirements, and goals for the standard. -It's geared for people who want to design new types of IFF objects. -People just interested in using the standard may wish to skip this -part. - -What Do We Need? - -A standard should be long on prescription and short on overhead. It -should give lots of rules for designing programs and data files for -synergy. But neither the programs nor the files should cost too much -more than the expedient variety. While we're looking to a future with -CD-ROMs and perpendicular recording, the standard must work well on -floppy disks. - -For program portability, simplicity, and efficiency, formats should -be designed with more than one implementation style in mind. (In practice, -pure stream I/O is adequate although random access makes it easier -to write files.) It ought to be possible to read one of many objects -in a file without scanning all the preceding data. Some programs need -to read and play out their data in real time, so we need good compromises -between generality and efficiency. - -As much as we need standards, they can't hold up product schedules. -So we also need a kind of decentralized extensibility where any software -developer can define and refine new object types without some "standards -authority" in the loop. Developers must be able to extend existing -formats in a forward- and backward-compatible way. A central repository -for design information and example programs can help us take full -advantage of the standard. - -For convenience, data formats should heed the restrictions of various -processors and environments. E.g. word-alignment greatly helps 68000 -access at insignificant cost to 8088 programs. - -Other goals include the ability to share common elements over a list -of objects and the ability to construct composite objects containing -other data objects with structural information like directories. - -And finally, "Simple things should be simple and complex things should -be possible." Alan Kay. - -Think Ahead - -Let's think ahead and build programs that read and write files for -each other and for programs yet to be designed. Build data formats -to last for future computers so long as the overhead is acceptable. -This extends the usefulness and life of today's programs and data. - -To maximize interconnectivity, the standard file structure and the -specific object formats must all be general and extensible. Think -ahead when designing an object. It should serve many purposes and -allow many programs to store and read back all the information they -need; even squeeze in custom data. Then a programmer can store the -available data and is encouraged to include fixed contextual details. -Recipient programs can read the needed parts, skip unrecognized stuff, -default missing data, and use the stored context to help transform -the data as needed. - -Scope - -IFF addresses these needs by defining a standard file structure, some -initial data object types, ways to define new types, and rules for -accessing these files. We can accomplish a great deal by writing programs -according to this standard, but don't expect direct compatibility -with existing software. We'll need conversion programs to bridge the -gap from the old world. - -IFF is geared for computers that readily process information in 8-bit -bytes. It assumes a "physical layer" of data storage and transmission -that reliably maintains "files" as strings of 8-bit bytes. The standard -treats a "file" as a container of data bytes and is independent of -how to find a file and whether it has a byte count. - -This standard does not by itself implement a clipboard for cutting -and pasting data between programs. A clipboard needs software to mediate -access, to maintain a "contents version number" so programs can detect -updates, and to manage the data in "virtual memory". - -Data Abstraction - -The basic problem is how to represent information in a way that's -program-independent, compiler- independent, machine-independent, and -device-independent. - -The computer science approach is "data abstraction", also known as -"objects", "actors", and "abstract data types". A data abstraction -has a "concrete representation" (its storage format), an "abstract -representation" (its capabilities and uses), and access procedures -that isolate all the calling software from the concrete representation. -Only the access procedures touch the data storage. Hiding mutable -details behind an interface is called "information hiding". What data -abstraction does is abstract from details of implementing the object, -namely the selected storage representation and algorithms for manipulating -it. - -The power of this approach is modularity. By adjusting the access -procedures we can extend and restructure the data without impacting -the interface or its callers. Conversely, we can extend and restructure -the interface and callers without making existing data obsolete. It's -great for interchange! - -But we seem to need the opposite: fixed file formats for all programs -to access. Actually, we could file data abstractions ("filed objects") -by storing the data and access procedures together. We'd have to encode -the access procedures in a standard machine-independent programming -language la PostScript. Even still, the interface can't evolve freely -since we can't update all copies of the access procedures. So we'll -have to design our abstract representations for limited evolution -and occasional revolution (conversion). - -In any case, today's microcomputers can't practically store data abstractions. -They can do the next best thing: store arbitrary types of data in -"data chunks", each with a type identifier and a length count. The -type identifier is a reference by name to the access procedures (any -local implementation). The length count enables storage-level object -operations like "copy" and "skip to next" independent of object type. - -Chunk writing is straightforward. Chunk reading requires a trivial -parser to scan each chunk and dispatch to the proper access/conversion -procedure. Reading chunks nested inside other chunks requires recursion, -but no lookahead or backup. - -That's the main idea of IFF. There are, of course, a few other detailsI - -Previous Work - -Where our needs are similar, we borrow from existing standards. - -Our basic need to move data between independently developed programs -is similar to that addressed by the Apple Macintosh desk scrap or -"clipboard" [Inside Macintosh chapter "Scrap Manager"]. The Scrap -Manager works closely with the Resource Manager, a handy filer and -swapper for data objects (text strings, dialog window templates, pictures, -fontsI) including types yet to be designed [Inside Macintosh chapter -"Resource Manager"]. The Resource Manager is a kin to Smalltalk's -object swapper. - -We will probably write a Macintosh desk accessory that converts IFF -files to and from the Macintosh clipboard for quick and easy interchange -with programs like MacPaint and Resource Mover. - -Macintosh uses a simple and elegant scheme of 4-character "identifiers" -to identify resource types, clipboard format types, file types, and -file creator programs. Alternatives are unique ID numbers assigned -by a central authority or by hierarchical authorities, unique ID numbers -generated by algorithm, other fixed length character strings, and -variable length strings. Character string identifiers double as readable -signposts in data files and programs. The choice of 4 characters is -a good tradeoff between storage space, fetch/compare/store time, and -name space size. We'll honor Apple's designers by adopting this scheme. - -"PICT" is a good example of a standard structured graphics format -(including raster images) and its many uses [Inside Macintosh chapter -"QuickDraw"]. Macintosh provides QuickDraw routines in ROM to create, -manipulate, and display PICTs. Any application can create a PICT by -simply asking QuickDraw to record a sequence of drawing commands. -Since it's just as easy to ask QuickDraw to render a PICT to a screen -or a printer, it's very effective to pass them between programs, say -from an illustrator to a word processor. An important feature is the -ability to store "comments" in a PICT which QuickDraw will ignore. -Actually, it passes them to your optional custom "comment handler". - -PostScript, Adobe's print file standard, is a more general way to -represent any print image (which is a specification for putting marks -on paper) [PostScript Language Manual]. In fact, PostScript is a full-fledged -programming language. To interpret a PostScript program is to render -a document on a raster output device. The language is defined in layers: -a lexical layer of identifiers, constants, and operators; a layer -of reverse polish semantics including scope rules and a way to define -new subroutines; and a printing-specific layer of built-in identifiers -and operators for rendering graphic images. It is clearly a powerful -(Turing equivalent) image definition language. PICT and a subset of -PostScript are candidates for structured graphics standards. - -A PostScript document can be printed on any raster output device (including -a display) but cannot generally be edited. That's because the original -flexibility and constraints have been discarded. Besides, a PostScript -program may use arbitrary computation to supply parameters like placement -and size to each operator. A QuickDraw PICT, in comparison, is a more -restricted format of graphic primitives parameterized by constants. -So a PICT can be edited at the level of the primitives, e.g. move -or thicken a line. It cannot be edited at the higher level of, say, -the bar chart data which generated the picture. - -PostScript has another limitation: Not all kinds of data amount to -marks on paper. A musical instrument description is one example. PostScript -is just not geared for such uses. - -"DIF" is another example of data being stored in a general format -usable by future programs [DIF Technical Specification]. DIF is a -format for spreadsheet data interchange. DIF and PostScript are both -expressed in plain ASCII text files. This is very handy for printing, -debugging, experimenting, and transmitting across modems. It can have -substantial cost in compaction and read/write work, depending on use. -We won't store IFF files this way but we could define an ASCII alternate -representation with a converter program. - -InterScript is Xerox' standard for interchange of editable documents -[Introduction to InterScript]. It approaches a harder problem: How -to represent editable word processor documents that may contain formatted -text, pictures, cross-references like figure numbers, and even highly -specialized objects like mathematical equations? InterScript aims -to define one standard representation for each kind of information. -Each InterScript-compatible editor is supposed to preserve the objects -it doesn't understand and even maintain nested cross-references. So -a simple word processor would let you edit the text of a fancy document -without discarding the equations or disrupting the equation numbers. - -Our task is similarly to store high level information and preserve -as much content as practical while moving it between programs. But -we need to span a larger universe of data types and cannot expect -to centrally define them all. Fortunately, we don't need to make programs -preserve information that they don't understand. And for better or -worse, we don't have to tackle general-purpose cross-references yet. - - - -3. Primitive Data Types - -Atomic components such as integers and characters that are interpretable -directly by the CPU are specified in one format for all processors. -We chose a format that's most convenient for the Motorola MC68000 -processor [M68000 16/32-Bit Microprocessor Programmer's Reference -Manual]. - -N.B.: Part 3 dictates the format for "primitive" data types where and -only where used in the overall file structure and standard kinds of -chunks (Cf. Chunks). The number of such occurrences will be small -enough that the costs of conversion, storage, and management of processor- -specific files would far exceed the costs of conversion during I/O by "foreign" -programs. A particular data chunk may be specified with a different -format for its internal primitive types or with processor- or environment- -speci fic variants if necessary to optimize local usage. Since that hurts -data interchange, it's not recommended. (Cf. Designing New Data Sections, -in Part 4.) - -Alignment - -All data objects larger than a byte are aligned on even byte addresses -relative to the start of the file. This may require padding. Pad bytes -are to be written as zeros, but don't count on that when reading. - -This means that every odd-length "chunk" (see below) must be padded -so that the next one will fall on an even boundary. Also, designers -of structures to be stored in chunks should include pad fields where -needed to align every field larger than a byte. Zeros should be stored -in all the pad bytes. - -Justification: Even-alignment causes a little extra work for files -that are used only on certain processors but allows 68000 programs -to construct and scan the data in memory and do block I/O. You just -add an occasional pad field to data structures that you're going to -block read/write or else stream read/write an extra byte. And the -same source code works on all processors. Unspecified alignment, on -the other hand, would force 68000 programs to (dis)assemble word and -long-word data one byte at a time. Pretty cumbersome in a high level -language. And if you don't conditionally compile that out for other -processors, you won't gain anything. - -Numbers - -Numeric types supported are two's complement binary integers in the -format used by the MC68000 processor high byte first, high word first the -reverse of 8088 and 6502 format. They could potentially include signed -and unsigned 8, 16, and 32 bit integers but the standard only uses -the following: - -UBYTE 8 bits unsigned -WORD 16 bits signed -UWORD 16 bits unsigned -LONG 32 bits signed - -The actual type definitions depend on the CPU and the compiler. In -this document, we'll express data type definitions in the C programming -language. [See C, A Reference Manual.] In 68000 Lattice C: - -typedef unsigned char UBYTE; /* 8 bits unsigned */ -typedef short WORD; /* 16 bits signed */ -typedef unsigned short UWORD; /* 16 bits unsigned */ -typedef long LONG; /* 32 bits signed */ - -Characters - -The following character set is assumed wherever characters are used, -e.g. in text strings, IDs, and TEXT chunks (see below). - -Characters are encoded in 8-bit ASCII. Characters in the range NUL -(hex 0) through DEL (hex 7F) are well defined by the 7-bit ASCII standard. -IFF uses the graphic group RJS (SP, hex 20) through R~S (hex 7E). - -Most of the control character group hex 01 through hex 1F have no -standard meaning in IFF. The control character LF (hex 0A) is defined -as a "newline" character. It denotes an intentional line break, that -is, a paragraph or line terminator. (There is no way to store an automatic -line break. That is strictly a function of the margins in the environment -the text is placed.) The control character ESC (hex 1B) is a reserved -escape character under the rules of ANSI standard 3.64-1979 American -National Standard Additional Control Codes for Use with ASCII, ISO -standard 2022, and ISO/DIS standard 6429.2. - -Characters in the range hex 7F through hex FF are not globally defined -in IFF. They are best left reserved for future standardization. But -note that the FORM type FTXT (formatted text) defines the meaning -of these characters within FTXT forms. In particular, character values -hex 7F through hex 9F are control codes while characters hex A0 through -hex FF are extended graphic characters like , as per the ISO and -ANSI standards cited above. [See the supplementary document "FTXT" -IFF Formatted Text.] - -Dates - -A "creation date" is defined as the date and time a stream of data -bytes was created. (Some systems call this a "last modified date".) -Editing some data changes its creation date. Moving the data between -volumes or machines does not. - -The IFF standard date format will be one of those used in MS-DOS, -Macintosh, or Amiga DOS (probably a 32-bit unsigned number of seconds -since a reference point). Issue: Investigate these three. - -Type IDs - -A "type ID", "property name", "FORM type", or any other IFF identifier -is a 32-bit value: the concatenation of four ASCII characters in the -range R S (SP, hex 20) through R~S (hex 7E). Spaces (hex 20) should -not precede printing characters; trailing spaces are ok. Control characters -are forbidden. - -typedef CHAR ID[4]; - -IDs are compared using a simple 32-bit case-dependent equality test. - -Data section type IDs (aka FORM types) are restriced IDs. (Cf. Data -Sections.) Since they may be stored in filename extensions (Cf. Single -Purpose Files) lower case letters and punctuation marks are forbidden. -Trailing spaces are ok. - -Carefully choose those four characters when you pick a new ID. Make -them mnemonic so programmers can look at an interchange format file -and figure out what kind of data it contains. The name space makes -it possible for developers scattered around the globe to generate -ID values with minimal collisions so long as they choose specific -names like "MUS4" instead of general ones like "TYPE" and "FILE". -EA will "register" new FORM type IDs and format descriptions as they're -devised, but collisions will be improbable so there will be no pressure -on this "clearinghouse" process. Appendix A has a list of currently -defined IDs. - -Sometimes it's necessary to make data format changes that aren't backward -compatible. Since IDs are used to denote data formats in IFF, new -IDs are chosen to denote revised formats. Since programs won't read -chunks whose IDs they don't recognize (see Chunks, below), the new -IDs keep old programs from stumbling over new data. The conventional -way to chose a "revision" ID is to increment the last character if -it's a digit or else change the last character to a digit. E.g. first -and second revisions of the ID "XY" would be "XY1" and "XY2". Revisions -of "CMAP" would be "CMA1" and "CMA2". - -Chunks - -Chunks are the building blocks in the IFF structure. The form expressed -as a C typedef is: - -typedef struct { - ID ckID; - LONG ckSize; /* sizeof(ckData) */ - UBYTE ckData[/* ckSize */]; - } Chunk; - -We can diagram an example chunk a "CMAP" chunk containing 12 data -bytes like this: - ---------------- - ckID: | 'CMAP' | - ckSize: | 12 | - ckData: | 0, 0, 0, 32 | -------- - | 0, 0, 64, 0 | 12 bytes - | 0, 0, 64, 0 | --------- - ---------------- - -The fixed header part means "Here's a type ckID chunk with ckSize -bytes of data." - -The ckID identifies the format and purpose of the chunk. As a rule, -a program must recognize ckID to interpret ckData. It should skip -over all unrecognized chunks. The ckID also serves as a format version -number as long as we pick new IDs to identify new formats of ckData -(see above). - -The following ckIDs are universally reserved to identify chunks with -particular IFF meanings: "LIST", "FORM", "PROP", "CAT ", and " -". The special ID " " (4 spaces) is a ckID for "filler" chunks, -that is, chunks that fill space but have no meaningful contents. The -IDs "LIS1" through "LIS9", "FOR1" through "FOR9", and "CAT1" through -"CAT9" are reserved for future "version number" variations. All IFF-compatible -software must account for these 23 chunk IDs. Appendix A has a list -of predefined IDs. - -The ckSize is a logical block size how many data bytes are in ckData. -If ckData is an odd number of bytes long, a 0 pad byte follows which -is not included in ckSize. (Cf. Alignment.) A chunk's total physical -size is ckSize rounded up to an even number plus the size of the header. -So the smallest chunk is 8 bytes long with ckSize = 0. For the sake -of following chunks, programs must respect every chunk's ckSize as -a virtual end-of-file for reading its ckData even if that data is -malformed, e.g. if nested contents are truncated. - -We can describe the syntax of a chunk as a regular expression with -"#" representing the ckSize, i.e. the length of the following {braced} -bytes. The "[0]" represents a sometimes needed pad byte. (The regular -expressions in this document are collected in Appendix A along with -an explanation of notation.) - -Chunk ::= ID #{ UBYTE* } [0] - -One chunk output technique is to stream write a chunk header, stream -write the chunk contents, then random access back to the header to -fill in the size. Another technique is to make a preliminary pass -over the data to compute the size, then write it out all at once. - -Strings, String Chunks, and String Properties - -In a string of ASCII text, LF denotes a forced line break (paragraph -or line terminator). Other control characters are not used. (Cf. Characters.) - -The ckID for a chunk that contains a string of plain, unformatted -text is "TEXT". As a practical matter, a text string should probably -not be longer than 32767 bytes. The standard allows up to 231 - 1 -bytes. - -When used as a data property (see below), a text string chunk may -be 0 to 255 characters long. Such a string is readily converted to -a C string or a Pascal STRING[255]. The ckID of a property must be -the property name, not "TEXT". - -When used as a part of a chunk or data property, restricted C string -format is normally used. That means 0 to 255 characters followed by -a NUL byte (ASCII value 0). - -Data Properties - -Data properties specify attributes for following (non-property) chunks. -A data property essentially says "identifier = value", for example -"XY = (10, 200)", telling something about following chunks. Properties -may only appear inside data sections ("FORM" chunks, cf. Data Sections) -and property sections ("PROP" chunks, cf. Group PROP). - -The form of a data property is a special case of Chunk. The ckID is -a property name as well as a property type. The ckSize should be small -since data properties are intended to be accumulated in RAM when reading -a file. (256 bytes is a reasonable upper bound.) Syntactically: - -Property ::= Chunk - -When designing a data object, use properties to describe context information -like the size of an image, even if they don't vary in your program. -Other programs will need this information. - -Think of property settings as assignments to variables in a programming -language. Multiple assignments are redundant and local assignments -temporarily override global assignments. The order of assignments -doesn't matter as long as they precede the affected chunks. (Cf. LISTs, -CATs, and Shared Properties.) - -Each object type (FORM type) is a local name space for property IDs. -Think of a "CMAP" property in a "FORM ILBM" as the qualified ID "ILBM.CMAP". -Property IDs specified when an object type is designed (and therefore -known to all clients) are called "standard" while specialized ones -added later are "nonstandard". - -Links - -Issue: A standard mechanism for "links" or "cross references" is very -desirable for things like combining images and sounds into animations. -Perhaps we'll define "link" chunks within FORMs that refer to other -FORMs or to specific chunks within the same and other FORMs. This -needs further work. EA IFF 1985 has no standard link mechanism. - -For now, it may suffice to read a list of, say, musical instruments, -and then just refer to them within a musical score by index number. - -File References - -Issue: We may need a standard form for references to other files. -A "file ref" could name a directory and a file in the same type of -operating system as the ref's originator. Following the reference -would expect the file to be on some mounted volume. In a network environment, -a file ref could name a server, too. - -Issue: How can we express operating-system independent file refs? - -Issue: What about a means to reference a portion of another file? -Would this be a "file ref" plus a reference to a "link" within the -target file? - - - -4. Data Sections - -The first thing we need of a file is to check: Does it contain IFF -data and, if so, does it contain the kind of data we're looking for? -So we come to the notion of a "data section". - -A "data section" or IFF "FORM" is one self-contained "data object" -that might be stored in a file by itself. It is one high level data -object such as a picture or a sound effect. The IFF structure "FORM" -makes it self- identifying. It could be a composite object like a -musical score with nested musical instrument descriptions. - -Group FORM - -A data section is a chunk with ckID "FORM" and this arrangement: - -FORM ::= "FORM" #{ FormType (LocalChunk | FORM | LIST | CAT)* -} -FormType ::= ID -LocalChunk ::= Property | Chunk - -The ID "FORM" is a syntactic keyword like "struct" in C. Think of -a "struct ILBM" containing a field "CMAP". If you see "FORM" you'll -know to expect a FORM type ID (the structure name, "ILBM" in this -example) and a particular contents arrangement or "syntax" (local -chunks, FORMs, LISTs, and CATs). (LISTs and CATs are discussed in -part 5, below.) A "FORM ILBM", in particular, might contain a local -chunk "CMAP", an "ILBM.CMAP" (to use a qualified name). - -So the chunk ID "FORM" indicates a data section. It implies that the -chunk contains an ID and some number of nested chunks. In reading -a FORM, like any other chunk, programs must respect its ckSize as -a virtual end-of-file for reading its contents, even if they're truncated. - -The FormType (or FORM type) is a restricted ID that may not contain -lower case letters or punctuation characters. (Cf. Type IDs. Cf. Single -Purpose Files.) - -The type-specific information in a FORM is composed of its "local -chunks": data properties and other chunks. Each FORM type is a local -name space for local chunk IDs. So "CMAP" local chunks in other FORM -types may be unrelated to "ILBM.CMAP". More than that, each FORM type -defines semantic scope. If you know what a FORM ILBM is, you'll know -what an ILBM.CMAP is. - -Local chunks defined when the FORM type is designed (and therefore -known to all clients of this type) are called "standard" while specialized -ones added later are "nonstandard". - -Among the local chunks, property chunks give settings for various -details like text font while the other chunks supply the essential -information. This distinction is not clear cut. A property setting -cancelled by a later setting of the same property has effect only -on data chunks in between. E.g. in the sequence: - -prop1 = x (propN = value)* prop1 = y - -where the propNs are not prop1, the setting prop1 = x has no effect. - -The following universal chunk IDs are reserved inside any FORM: "LIST", -"FORM", "PROP", "CAT ", "JJJJ", "LIS1" through "LIS9", "FOR1" through -"FOR9", and "CAT1" through "CAT9". (Cf. Chunks. Cf. Group LIST. Cf. -Group PROP.) For clarity, these universal chunk names may not be FORM -type IDs, either. - -Part 5, below, talks about grouping FORMs into LISTs and CATs. They -let you group a bunch of FORMs but don't impose any particular meaning -or constraints on the grouping. Read on. - -Composite FORMs - -A FORM chunk inside a FORM is a full-fledged data section. This means -you can build a composite object like a multi-frame animation sequence -from available picture FORMs and sound effect FORMs. You can insert -additional chunks with information like frame rate and frame count. - -Using composite FORMs, you leverage on existing programs that create -and edit the component FORMs. Those editors may even look into your -composite object to copy out its type of component, although it'll -be the rare program that's fancy enough to do that. Such editors are -not allowed to replace their component objects within your composite -object. That's because the IFF standard lets you specify consistency -requirements for the composite FORM such as maintaining a count or -a directory of the components. Only programs that are written to uphold -the rules of your FORM type should create or modify such FORMs. - -Therefore, in designing a program that creates composite objects, -you are strongly requested to provide a facility for your users to -import and export the nested FORMs. Import and export could move the -data through a clipboard or a file. - -Here are several existing FORM types and rules for defining new ones. - -FTXT - -An FTXT data section contains text with character formatting information -like fonts and faces. It has no paragraph or document formatting information -like margins and page headers. FORM FTXT is well matched to the text -representation in Amiga's Intuition environment. See the supplemental -document "FTXT" IFF Formatted Text. - -ILBM - -"ILBM" is an InterLeaved BitMap image with color map; a machine-independent -format for raster images. FORM ILBM is the standard image file format -for the Commodore-Amiga computer and is useful in other environments, -too. See the supplemental document "ILBM" IFF Interleaved Bitmap. - -PICS - -The data chunk inside a "PICS" data section has ID "PICT" and holds -a QuickDraw picture. Issue: Allow more than one PICT in a PICS? See -Inside Macintosh chapter "QuickDraw" for details on PICTs and how -to create and display them on the Macintosh computer. - -The only standard property for PICS is "XY", an optional property -that indicates the position of the PICT relative to "the big picture". -The contents of an XY is a QuickDraw Point. - -Note: PICT may be limited to Macintosh use, in which case there'll -be another format for structured graphics in other environments. - -Other Macintosh Resource Types - -Some other Macintosh resource types could be adopted for use within -IFF files; perhaps MWRT, ICN, ICN#, and STR#. - -Issue: Consider the candidates and reserve some more IDs. - -Designing New Data Sections - -Supplemental documents will define additional object types. A supplement -needs to specify the object's purpose, its FORM type ID, the IDs and -formats of standard local chunks, and rules for generating and interpreting -the data. It's a good idea to supply typedefs and an example source -program that accesses the new object. See "ILBM" IFF Interleaved Bitmap -for a good example. - -Anyone can pick a new FORM type ID but should reserve it with Electronic -Arts at their earliest convenience. [Issue: EA contact person? Hand -this off to another organization?] While decentralized format definitions -and extensions are possible in IFF, our preference is to get design -consensus by committee, implement a program to read and write it, -perhaps tune the format, and then publish the format with example -code. Some organization should remain in charge of answering questions -and coordinating extensions to the format. - -If it becomes necessary to revise the design of some data section, -its FORM type ID will serve as a version number (Cf. Type IDs). E.g. -a revised "VDEO" data section could be called "VDE1". But try to get -by with compatible revisions within the existing FORM type. - -In a new FORM type, the rules for primitive data types and word-alignment -(Cf. Primitive Data Types) may be overriden for the contents of its -local chunks but not for the chunk structure itself if your documentation -spells out the deviations. If machine-specific type variants are needed, -e.g. to store vast numbers of integers in reverse bit order, then -outline the conversion algorithm and indicate the variant inside each -file, perhaps via different FORM types. Needless to say, variations -should be minimized. - -In designing a FORM type, encapsulate all the data that other programs -will need to interpret your files. E.g. a raster graphics image should -specify the image size even if your program always uses 320 x 200 -pixels x 3 bitplanes. Receiving programs are then empowered to append -or clip the image rectangle, to add or drop bitplanes, etc. This enables -a lot more compatibility. - -Separate the central data (like musical notes) from more specialized -information (like note beams) so simpler programs can extract the -central parts during read-in. Leave room for expansion so other programs -can squeeze in new kinds of information (like lyrics). And remember -to keep the property chunks manageably short let's say 2 256 bytes. - -When designing a data object, try to strike a good tradeoff between -a super-general format and a highly-specialized one. Fit the details -to at least one particular need, for example a raster image might -as well store pixels in the current machine's scan order. But add -the kind of generality that makes it usable with foreseeable hardware -and software. E.g. use a whole byte for each red, green, and blue -color value even if this year's computer has only 4-bit video DACs. -Think ahead and help other programs so long as the overhead is acceptable. -E.g. run compress a raster by scan line rather than as a unit so future -programs can swap images by scan line to and from secondary storage. - -Try to design a general purpose "least common multiple" format that -encompasses the needs of many programs without getting too complicated. -Let's coalesce our uses around a few such formats widely separated -in the vast design space. Two factors make this flexibility and simplicity -practical. First, file storage space is getting very plentiful, so -compaction is not a priority. Second, nearly any locally-performed -data conversion work during file reading and writing will be cheap -compared to the I/O time. - -It must be ok to copy a LIST or FORM or CAT intact, e.g. to incorporate -it into a composite FORM. So any kind of internal references within -a FORM must be relative references. They could be relative to the -start of the containing FORM, relative from the referencing chunk, -or a sequence number into a collection. - -With composite FORMs, you leverage on existing programs that create -and edit the components. If you write a program that creates composite -objects, please provide a facility for your users to import and export -the nested FORMs. The import and export functions may move data through -a separate file or a clipboard. - -Finally, don't forget to specify all implied rules in detail. - - - -5. LISTs, CATs, and Shared Properties - -Data often needs to be grouped together like a list of icons. Sometimes -a trick like arranging little images into a big raster works, but -generally they'll need to be structured as a first class group. The -objects "LIST" and "CAT" are IFF-universal mechanisms for this purpose. - -Property settings sometimes need to be shared over a list of similar -objects. E.g. a list of icons may share one color map. LIST provides -a means called "PROP" to do this. One purpose of a LIST is to define -the scope of a PROP. A "CAT", on the other hand, is simply a concatenation -of objects. - -Simpler programs may skip LISTs and PROPs altogether and just handle -FORMs and CATs. All "fully-conforming" IFF programs also know about -"CAT ", "LIST", and "PROP". Any program that reads a FORM inside a -LIST must process shared PROPs to correctly interpret that FORM. - -Group CAT - -A CAT is just an untyped group of data objects. - -Structurally, a CAT is a chunk with chunk ID "CAT " containing a "contents -type" ID followed by the nested objects. The ckSize of each contained -chunk is essentially a relative pointer to the next one. - -CAT ::= "CAT " #{ ContentsType (FORM | LIST | CAT)* } -ContentsType ::= ID -- a hint or an "abstract data type" ID - -In reading a CAT, like any other chunk, programs must respect it's -ckSize as a virtual end-of-file for reading the nested objects even -if they're malformed or truncated. - -The "contents type" following the CAT's ckSize indicates what kind -of FORMs are inside. So a CAT of ILBMs would store "ILBM" there. It's -just a hint. It may be used to store an "abstract data type". A CAT -could just have blank contents ID ("JJJJ") if it contains more than -one kind of FORM. - -CAT defines only the format of the group. The group's meaning is open -to interpretation. This is like a list in LISP: the structure of cells -is predefined but the meaning of the contents as, say, an association -list depends on use. If you need a group with an enforced meaning -(an "abstract data type" or Smalltalk "subclass"), some consistency -constraints, or additional data chunks, use a composite FORM instead -(Cf. Composite FORMs). - -Since a CAT just means a concatenation of objects, CATs are rarely -nested. Programs should really merge CATs rather than nest them. - -Group LIST - -A LIST defines a group very much like CAT but it also gives a scope -for PROPs (see below). And unlike CATs, LISTs should not be merged -without understanding their contents. - -Structurally, a LIST is a chunk with ckID "LIST" containing a "contents -type" ID, optional shared properties, and the nested contents (FORMs, -LISTs, and CATs), in that order. The ckSize of each contained chunk -is a relative pointer to the next one. A LIST is not an arbitrary -linked list the cells are simply concatenated. - -LIST ::= "LIST" #{ ContentsType PROP* (FORM | LIST | CAT)* } -ContentsType ::= ID - -Group PROP - -PROP chunks may appear in LISTs (not in FORMs or CATs). They supply -shared properties for the FORMs in that LIST. This ability to elevate -some property settings to shared status for a list of forms is useful -for both indirection and compaction. E.g. a list of images with the -same size and colors can share one "size" property and one "color -map" property. Individual FORMs can override the shared settings. - -The contents of a PROP is like a FORM with no data chunks: - -PROP ::= "PROP" #{ FormType Property* } - -It means, "Here are the shared properties for FORM type <." - -A LIST may have at most one PROP of a FORM type, and all the PROPs -must appear before any of the FORMs or nested LISTs and CATs. You -can have subsequences of FORMs sharing properties by making each subsequence -a LIST. - -Scoping: Think of property settings as variable bindings in nested -blocks of a programming language. Where in C you could write: - -TEXT_FONT text_font = Courier; /* program's global default */ - -File(); { - TEXT_FONT text_font = TimesRoman; /* shared setting */ - - { - TEXT_FONT text_font = Helvetica; /* local setting */ - Print("Hello "); /* uses font Helvetica */ - } - - { - Print("there."); /* uses font TimesRoman */ - } - } - -An IFF file could contain: - -LIST { - PROP TEXT { - FONT {TimesRoman} /* shared setting */ - } - - FORM TEXT { - FONT {Helvetica} /* local setting */ - CHRS {Hello } /* uses font Helvetica */ - } - - FORM TEXT { - CHRS {there.} /* uses font TimesRoman */ - } - } - -The shared property assignments selectively override the reader's -global defaults, but only for FORMs within the group. A FORM's own -property assignments selectively override the global and group-supplied -values. So when reading an IFF file, keep property settings on a stack. -They're designed to be small enough to hold in main memory. - -Shared properties are semantically equivalent to copying those properties -into each of the nested FORMs right after their FORM type IDs. - -Properties for LIST - -Optional "properties for LIST" store the origin of the list's contents -in a PROP chunk for the fake FORM type "LIST". They are the properties -originating program "OPGM", processor family "OCPU", computer type -"OCMP", computer serial number or network address "OSN ", and user -name "UNAM". In our imperfect world, these could be called upon to -distinguish between unintended variations of a data format or to work -around bugs in particular originating/receiving program pairs. Issue: -Specify the format of these properties. - -A creation date could also be stored in a property but let's ask that -file creating, editing, and transporting programs maintain the correct -date in the local file system. Programs that move files between machine -types are expected to copy across the creation dates. - - - -6. Standard File Structure - -File Structure Overview - -An IFF file is just a single chunk of type FORM, LIST, or CAT. Therefore -an IFF file can be recognized by its first 4 bytes: "FORM", "LIST", -or "CAT ". Any file contents after the chunk's end are to be ignored. - -Since an IFF file can be a group of objects, programs that read/write -single objects can communicate to an extent with programs that read/write -groups. You're encouraged to write programs that handle all the objects -in a LIST or CAT. A graphics editor, for example, could process a -list of pictures as a multiple page document, one page at a time. - -Programs should enforce IFF's syntactic rules when reading and writing -files. This ensures robust data transfer. The public domain IFF reader/writer -subroutine package does this for you. A utility program "IFFCheck" -is available that scans an IFF file and checks it for conformance -to IFF's syntactic rules. IFFCheck also prints an outline of the chunks -in the file, showing the ckID and ckSize of each. This is quite handy -when building IFF programs. Example programs are also available to -show details of reading and writing IFF files. - -A merge program "IFFJoin" will be available that logically appends -IFF files into a single CAT group. It "unwraps" each input file that -is a CAT so that the combined file isn't nested CATs. - -If we need to revise the IFF standard, the three anchoring IDs will -be used as "version numbers". That's why IDs "FOR1" through "FOR9", -"LIS1" through "LIS9", and "CAT1" through "CAT9" are reserved. - -IFF formats are designed for reasonable performance with floppy disks. -We achieve considerable simplicity in the formats and programs by -relying on the host file system rather than defining universal grouping -structures like directories for LIST contents. On huge storage systems, -IFF files could be leaf nodes in a file structure like a B-tree. Let's -hope the host file system implements that for us! - -Thre are two kinds of IFF files: single purpose files and scrap files. -They differ in the interpretation of multiple data objects and in -the file's external type. - -Single Purpose Files - -A single purpose IFF file is for normal "document" and "archive" storage. -This is in contrast with "scrap files" (see below) and temporary backing -storage (non-interchange files). - -The external file type (or filename extension, depending on the host -file system) indicates the file's contents. It's generally the FORM -type of the data contained, hence the restrictions on FORM type IDs. - -Programmers and users may pick an "intended use" type as the filename -extension to make it easy to filter for the relevant files in a filename -requestor. This is actually a "subclass" or "subtype" that conveniently -separates files of the same FORM type that have different uses. Programs -cannot demand conformity to its expected subtypes without overly restricting -data interchange since they cannot know about the subtypes to be used -by future programs that users will want to exchange data with. - -Issue: How to generate 3-letter MS-DOS extensions from 4-letter FORM -type IDs? - -Most single purpose files will be a single FORM (perhaps a composite -FORM like a musical score containing nested FORMs like musical instrument -descriptions). If it's a LIST or a CAT, programs should skip over -unrecognized objects to read the recognized ones or the first recognized -one. Then a program that can read a single purpose file can read something -out of a "scrap file", too. - -Scrap Files - -A "scrap file" is for maximum interconnectivity in getting data between -programs; the core of a clipboard function. Scrap files may have type -"IFF " or filename extension ".IFF". - -A scrap file is typically a CAT containing alternate representations -of the same basic information. Include as many alternatives as you -can readily generate. This redundancy improves interconnectivity in -situations where we can't make all programs read and write super-general -formats. [Inside Macintosh chapter "Scrap Manager".] E.g. a graphically- -annotated musical score might be supplemented by a stripped down 4-voice -melody and by a text (the lyrics). - -The originating program should write the alternate representations -in order of "preference": most preferred (most comprehensive) type -to least preferred (least comprehensive) type. A receiving program -should either use the first appearing type that it understands or -search for its own "preferred" type. - -A scrap file should have at most one alternative of any type. (A LIST -of same type objects is ok as one of the alternatives.) But don't -count on this when reading; ignore extra sections of a type. Then -a program that reads scrap files can read something out of single -purpose files. - -Rules for Reader Programs - -Here are some notes on building programs that read IFF files. If you -use the standard IFF reader module "IFFR.C", many of these rules and -details will be automatically handled. (See "Support Software" in -Appendix A.) We recommend that you start from the example program -"ShowILBM.C". You should also read up on recursive descent parsers. -[See, for example, Compiler Construction, An Advanced Course.] - -% The standard is very flexible so many programs can exchange -data. This implies a program has to scan the file and react to what's -actually there in whatever order it appears. An IFF reader program -is a parser. - -% For interchange to really work, programs must be willing to -do some conversion during read-in. If the data isn't exactly what -you expect, say, the raster is smaller than those created by your -program, then adjust it. Similarly, your program could crop a large -picture, add or drop bitplanes, and create/discard a mask plane. The -program should give up gracefully on data that it can't convert. - -% If it doesn't start with "FORM", "LIST", or "CAT ", it's not -an IFF-85 file. - -% For any chunk you encounter, you must recognize its type ID -to understand its contents. - -% For any FORM chunk you encounter, you must recognize its FORM -type ID to understand the contained "local chunks". Even if you don't -recognize the FORM type, you can still scan it for nested FORMs, LISTs, -and CATs of interest. - -% Don't forget to skip the pad byte after every odd-length chunk. - -% Chunk types LIST, FORM, PROP, and CAT are generic groups. They -always contain a subtype ID followed by chunks. - -% Readers ought to handle a CAT of FORMs in a file. You may treat -the FORMs like document pages to sequence through or just use the -first FORM. - -% Simpler IFF readers completely skip LISTs. "Fully IFF-conforming" -readers are those that handle LISTs, even if just to read the first -FORM from a file. If you do look into a LIST, you must process shared -properties (in PROP chunks) properly. The idea is to get the correct -data or none at all. - -% The nicest readers are willing to look into unrecognized FORMs -for nested FORM types that they do recognize. For example, a musical -score may contain nested instrument descriptions and an animation -file may contain still pictures. - -Note to programmers: Processing PROP chunks is not simple! You'll -need some background in interpreters with stack frames. If this is -foreign to you, build programs that read/write only one FORM per file. -For the more intrepid programmers, the next paragraph summarizes how -to process LISTs and PROPs. See the general IFF reader module "IFFR.C" -and the example program "ShowILBM.C" for details. - -Allocate a stack frame for every LIST and FORM you encounter and initialize -it by copying the stack frame of the parent LIST or FORM. At the top -level, you'll need a stack frame initialized to your program's global -defaults. While reading each LIST or FORM, store all encountered properties -into the current stack frame. In the example ShowILBM, each stack -frame has a place for a bitmap header property ILBM.BMHD and a color -map property ILBM.CMAP. When you finally get to the ILBM's BODY chunk, -use the property settings accumulated in the current stack frame. - -An alternate implementation would just remember PROPs encountered, -forgetting each on reaching the end of its scope (the end of the containing -LIST). When a FORM XXXX is encountered, scan the chunks in all remembered -PROPs XXXX, in order, as if they appeared before the chunks actually -in the FORM XXXX. This gets trickier if you read FORMs inside of FORMs. - -Rules for Writer Programs - -Here are some notes on building programs that write IFF files, which -is much easier than reading them. If you use the standard IFF writer -module "IFFW.C" (see "Support Software" in Appendix A), many of these -rules and details will automatically be enforced. See the example -program "Raw2ILBM.C". - -% An IFF file is a single FORM, LIST, or CAT chunk. - -% Any IFF-85 file must start with the 4 characters "FORM", "LIST", -or "CAT ", followed by a LONG ckSize. There should be no data after -the chunk end. - -% Chunk types LIST, FORM, PROP, and CAT are generic. They always -contain a subtype ID followed by chunks. These three IDs are universally -reserved, as are "LIS1" through "LIS9", "FOR1" through "FOR9", "CAT1" -through "CAT9", and " ". - -% Don't forget to write a 0 pad byte after each odd-length chunk. - -% Four techniques for writing an IFF group: (1) build the data -in a file mapped into virtual memory, (2) build the data in memory -blocks and use block I/O, (3) stream write the data piecemeal and -(don't forget!) random access back to set the group length count, -and (4) make a preliminary pass to compute the length count then stream -write the data. - -% Do not try to edit a file that you don't know how to create. -Programs may look into a file and copy out nested FORMs of types that -they recognize, but don't edit and replace the nested FORMs and don't -add or remove them. That could make the containing structure inconsistent. -You may write a new file containing items you copied (or copied and -modified) from another IFF file, but don't copy structural parts you -don't understand. - -% You must adhere to the syntax descriptions in Appendex A. E.g. -PROPs may only appear inside LISTs. - - - - -Appendix A. Reference - -Type Definitions - -The following C typedefs describe standard IFF structures. Declarations -to use in practice will vary with the CPU and compiler. For example, -68000 Lattice C produces efficient comparison code if we define ID -as a "LONG". A macro "MakeID" builds these IDs at compile time. - -/* Standard IFF types, expressed in 68000 Lattice C. */ - -typedef unsigned char UBYTE; /* 8 bits unsigned */ -typedef short WORD; /* 16 bits signed */ -typedef unsigned short UWORD; /* 16 bits unsigned */ -typedef long LONG; /* 32 bits signed */ - -typedef char ID[4]; /* 4 chars in ' ' through '~' */ - -typedef struct { - ID ckID; - LONG ckSize; /* sizeof(ckData) */ - UBYTE ckData[/* ckSize */]; - } Chunk; - -/* ID typedef and builder for 68000 Lattice C. */ -typedef LONG ID; /* 4 chars in ' ' through '~' */ -#define MakeID(a,b,c,d) ( (a)<<<<24 | (b)<<<<16 | (c)<<<<8 | (d) ) - -/* Globally reserved IDs. */ -#define ID_FORM MakeID('F','O','R','M') -#define ID_LIST MakeID('L','I','S','T') -#define ID_PROP MakeID('P','R','O','P') -#define ID_CAT MakeID('C','A','T',' ') -#define ID_FILLER MakeID(' ',' ',' ',' ') - -Syntax Definitions - -Here's a collection of the syntax definitions in this document. - -Chunk ::= ID #{ UBYTE* } [0] - -Property ::= Chunk - -FORM ::= "FORM" #{ FormType (LocalChunk | FORM | LIST | CAT)* -} -FormType ::= ID -LocalChunk ::= Property | Chunk - -CAT ::= "CAT " #{ ContentsType (FORM | LIST | CAT)* } -ContentsType ::= ID -- a hint or an "abstract data type" ID - -LIST ::= "LIST" #{ ContentsType PROP* (FORM | LIST | CAT)* } -PROP ::= "PROP" #{ FormType Property* } - -In this extended regular expression notation, the token "#" represents -a ckSize LONG count of the following {braced} data bytes. Literal -items are shown in "quotes", [square bracketed items] are optional, -and "*" means 0 or more instances. A sometimes-needed pad byte is -shown as "[0]". - -Defined Chunk IDs - -This is a table of currently defined chunk IDs. We may also borrow -some Macintosh IDs and data formats. - -Group chunk IDs - FORM, LIST, PROP, CAT. -Future revision group chunk IDs - FOR1 I FOR9, LIS1 I LIS9, CAT1 I CAT9. -FORM type IDs - (The above group chunk IDs may not be used for FORM type IDs.) - (Lower case letters and punctuation marks are forbidden in FORM -type IDs.) - 8SVX 8-bit sampled sound voice, ANBM animated bitmap, FNTR raster -font, FNTV vector font, FTXT formatted text, GSCR general-use musical -score, ILBM interleaved raster bitmap image, PDEF Deluxe Print page -definition, PICS Macintosh picture, PLBM (obsolete), USCR Uhuru Sound -Software musical score, UVOX Uhuru Sound Software Macintosh voice, -SMUS simple musical score, VDEO Deluxe Video Construction Set video. -Data chunk IDs - "JJJJ", TEXT, PICT. -PROP LIST property IDs - OPGM, OCPU, OCMP, OSN, UNAM. - - - -Support Software - -These public domain C source programs are available for use in building -IFF-compatible programs: - -IFF.H, IFFR.C, IFFW.C - - IFF reader and writer package. - These modules handle many of the details of reliably - reading and writing IFF files. - -IFFCheck.C This handy utility program scans an IFF file, checks - that the contents are well formed, and prints an outline - of the chunks. - -PACKER.H, Packer.C, UnPacker.C - - Run encoder and decoder used for ILBM files. - -ILBM.H, ILBMR.C, ILBMW.C - - Reader and writer support routines for raster image - FORM ILBM. ILBMR calls IFFR and UnPacker. ILBMW calls - IFFW and Packer. - -ShowILBM.C - Example caller of IFFR and ILBMR modules. This - Commodore-Amiga program reads and displays a FORM ILBM. -Raw2ILBM.C - Example ILBM writer program. As a demonstration, it - reads a raw raster image file and writes the image - as a FORM ILBM file. -ILBM2Raw.C - Example ILBM reader program. Reads a FORM ILBM file - and writes it into a raw raster image. - -REMALLOC.H, Remalloc.c - - Memory allocation routines used in these examples. - -INTUALL.H generic "include almost everything" include-file - with the sequence of includes correctly specified. - -READPICT.H, ReadPict.c - - given an ILBM file, read it into a bitmap and - a color map - -PUTPICT.H, PutPict.c - - given a bitmap and a color map, save it as - an ILBM file. - -GIO.H, Gio.c generic I/O speedup package. Attempts to speed - disk I/O by buffering writes and reads. - -giocall.c sample call to gio. - -ilbmdump.c reads in ILBM file, prints out ascii representation - for including in C files. - -bmprintc.c prints out a C-language representation of data for - a bitmap. - - - -Example Diagrams - -Here's a box diagram for an example IFF file, a raster image FORM -ILBM. This FORM contains a bitmap header property chunk BMHD, a color -map property chunk CMAP, and a raster data chunk BODY. This particular -raster is 320 x 200 pixels x 3 bit planes uncompressed. The "0" after -the CMAP chunk represents a zero pad byte; included since the CMAP -chunk has an odd length. The text to the right of the diagram shows -the outline that would be printed by the IFFCheck utility program -for this particular file. - - +-----------------------------------+ - |'FORM' 24070 | FORM 24070 IBLM - +-----------------------------------+ - |'ILBM' | - +-----------------------------------+ - | +-------------------------------+ | - | | 'BMHD' 20 | | .BMHD 20 - | | 320, 200, 0, 0, 3, 0, 0, ... | | - | + ------------------------------+ | - | | 'CMAP' 21 | | .CMAP 21 - | | 0, 0, 0; 32, 0, 0; 64,0,0; .. | | - | +-------------------------------+ | - | 0 | - +-----------------------------------+ - |'BODY' 24000 | .BODY 24000 - |0, 0, 0, ... | - +-----------------------------------+ - -This second diagram shows a LIST of two FORMs ILBM sharing a common -BMHD property and a common CMAP property. Again, the text on the right -is an outline a la IFFCheck. - - - +-----------------------------------------+ - |'LIST' 48114 | LIST 48114 AAAA - +-----------------------------------------+ - |'AAAA' | .PROP 62 ILBM - | +-----------------------------------+ | - | |'PROP' 62 | | - | +-----------------------------------+ | - | |'ILBM' | | - | +-----------------------------------+ | - | | +-------------------------------+ | | - | | | 'BMHD' 20 | | | ..BMHD 20 - | | | 320, 200, 0, 0, 3, 0, 0, ... | | | - | | | ------------------------------+ | | - | | | 'CMAP' 21 | | | ..CMAP 21 - | | | 0, 0, 0; 32, 0, 0; 64,0,0; .. | | | - | | +-------------------------------+ | | - | | 0 | | - | +-----------------------------------+ | - | +-----------------------------------+ | - | |'FORM' 24012 | | .FORM 24012 ILBM - | +-----------------------------------+ | - | |'ILBM' | | - | +-----------------------------------+ | - | | +-----------------------------+ | | - | | |'BODY' 24000 | | | ..BODY 24000 - | | |0, 0, 0, ... | | | - | | +-----------------------------+ | | - | +-----------------------------------+ | - | +-----------------------------------+ | - | |'FORM' 24012 | | .FORM 24012 ILBM - | +-----------------------------------+ | - | |'ILBM' | | - | +-----------------------------------+ | - | | +-----------------------------+ | | - | | |'BODY' 24000 | | | ..BODY 24000 - | | |0, 0, 0, ... | | | - | | +-----------------------------+ | | - | +-----------------------------------+ | - +-----------------------------------------+ - - - -Appendix B. Standards Committee - -The following people contributed to the design of this IFF standard: - -Bob "Kodiak" Burns, Commodore-Amiga -R. J. Mical, Commodore-Amiga -Jerry Morrison, Electronic Arts -Greg Riker, Electronic Arts -Steve Shaw, Electronic Arts -Barry Walsh, Commodore-Amiga diff --git a/Extras/iff/iff.h b/Extras/iff/iff.h deleted file mode 100644 index bc467f3a5..000000000 --- a/Extras/iff/iff.h +++ /dev/null @@ -1,460 +0,0 @@ -#ifndef IFF_H -#define IFF_H -/*----------------------------------------------------------------------*/ -/* IFF.H defs for IFF-85 Interchange Format Files. 10/8/85 */ -/* */ -/* By Jerry Morrison and Steve Shaw, Electronic Arts. */ -/* This software is in the public domain. */ -/* Original version was for the Commodore-Amiga computer. */ -/* This version is compatible with PC, OSX, PS3, Wii, iPhone. 10/26/2008*/ -/*----------------------------------------------------------------------*/ - - - -#define NL 0L /** A ver of NULL So Manx will like it **/ -#include //printf debugging -typedef unsigned char UBYTE; -typedef FILE* BPTR; -typedef unsigned short int UWORD; -typedef short int WORD; -typedef char BYTE; -#define LOCAL -#define TRUE 1 -#define FALSE 0 -typedef int BOOL; -#define OFFSET_END SEEK_END -#define OFFSET_CURRENT SEEK_CUR -#define OFFSET_BEGINNING SEEK_SET - -#define Seek fseek -#define Write fwrite -#define Read(file,buffer,nbytes) fread(buffer,1,nbytes,file) -#define GWriteFlush(file) (0) -//#define GWrite(file, buffer, nBytes) fwrite(buffer,1,nBytes,file) -#define GSeek(file, position, mode) Seek(file, position, mode) - - - - - - -typedef int IFFP; /* Status code result from an IFF procedure */ -/* int, because must be type compatable with ID for GetChunkHdr.*/ -/* Note that the error codes below are not legal IDs.*/ -#define IFF_OKAY 0L /* Keep going...*/ -#define END_MARK -1L /* As if there was a chunk at end of group.*/ -#define IFF_DONE -2L /* clientProc returns this when it has READ enough. -* It means return thru all levels. File is Okay.*/ -#define DOS_ERROR -3L -#define NOT_IFF -4L /* not an IFF file.*/ -#define NO_FILE -5L /* Tried to open file, DOS didn't find it.*/ -#define CLIENT_ERROR -6L /* Client made invalid request, for instance, asking -* for more bytes than existed in chunk.*/ -#define BAD_FORM -7L /* A client read proc complains about FORM semantics; -* e.g. valid IFF, but missing a required chunk.*/ -#define SHORT_CHUNK -8L /* Client asked to IFFReadBytes more bytes than left -* in the chunk. Could be client bug or bad form.*/ -#define BAD_IFF -9L /* mal-formed IFF file. [TBD] Expand this into a -* range of error codes.*/ -#define LAST_ERROR (short)BAD_IFF - -/* This MACRO is used to RETURN immediately when a termination condition is -* found. This is a pretty weird macro. It requires the caller to declare a -* local "IFFP iffp" and assign it. This wouldn't work as a subroutine since -* it returns for it's caller. */ -#define CheckIFFP() { if (iffp != IFF_OKAY) return(iffp); } - - -/* ---------- ID -------------------------------------------------------*/ - -typedef int ID; /* An ID is four printable ASCII chars but - * stored as a int for efficient copy & compare.*/ - -/* Four-character IDentifier builder.*/ -#define MakeID(a,b,c,d) (((long)(a)) | ((long)(b))<<8L | (c)<<16L | (d)<<24L) -//#define MakeID(a,b,c,d) (((long)(a))<<24L | ((long)(b))<<16L | (c)<<8 | (d)) - -/* Standard group IDs. A chunk with one of these IDs contains a -SubTypeID followed by zero or more chunks.*/ -#define FORM MakeID('F','O','R','M') -#define PROP MakeID('P','R','O','P') -#define LIST MakeID('L','I','S','T') -#define CAT MakeID('C','A','T',' ') -#define FILLER MakeID(' ',' ',' ',' ') -/* The IDs "FOR1".."FOR9", "LIS1".."LIS9", & "CAT1".."CAT9" are reserved -* for future standardization.*/ - -/* Pseudo-ID used internally by chunk reader and writer.*/ -#define NULL_CHUNK 0L /* No current chunk.*/ - - -/* ---------- Chunk ----------------------------------------------------*/ - -/* All chunks start with a type ID and a count of the data bytes that -follow--the chunk's "logical size" or "data size". If that number is odd, -a 0 pad byte is written, too. */ -typedef struct { - ID ckID; - int ckSize; -} ChunkHeader; - -typedef struct { - ID ckID; - int ckSize; - UBYTE ckData[ 1 /*REALLY: ckSize*/ ]; -} Chunk; - -/* Pass ckSize = szNotYetKnown to the writer to mean "compute the size".*/ -#define szNotYetKnown 0x80000001L - -/* Need to know whether a value is odd so can word-align.*/ -#define IS_ODD(a) ((a) & 1) - -/* This macro rounds up to an even number. */ -#define WordAlign(size) ((size+1)&~1) - -/* ALL CHUNKS MUST BE PADDED TO EVEN NUMBER OF BYTES. -* ChunkPSize computes the total "physical size" of a padded chunk from -* its "data size" or "logical size". */ -#define ChunkPSize(dataSize) (WordAlign(dataSize) + (long)sizeof(ChunkHeader)) - -/* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of -* chunks after a subtype ID that identifies the content chunks. -* "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated -* with FORM type XXXX", or "conCATenation of XXXX".*/ -typedef struct { - ID ckID; - int ckSize; /* this ckSize includes "grpSubID".*/ - ID grpSubID; -} GroupHeader; - -typedef struct { - ID ckID; - int ckSize; - ID grpSubID; - UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ]; -} GroupChunk; - - -/* ---------- IFF Reader -----------------------------------------------*/ - -/******** Routines to support a stream-oriented IFF file reader ******* -* -* These routines handle lots of details like error checking and skipping -* over padding. They're also careful not to read past any containing context. -* -* These routines ASSUME they're the only ones reading from the file. -* Client should check IFFP error codes. Don't press on after an error! -* These routines try to have no side effects in the error case, except -* partial I/O is sometimes unavoidable. -* -* All of these routines may return DOS_ERROR. In that case, ask DOS for the -* specific error code. -* -* The overall scheme for the low level chunk reader is to open a "group read -* context" with OpenRIFF or OpenRGroup, read the chunks with GetChunkHdr -* (and its kin) and IFFReadBytes, and close the context with CloseRGroup. -* -* The overall scheme for reading an IFF file is to use ReadIFF, ReadIList, -* and ReadICat to scan the file. See those procedures, ClientProc (below), -* and the skeleton IFF reader. */ - -/* Client passes ptrs to procedures of this type to ReadIFF which call them -* back to handle LISTs, FORMs, CATs, and PROPs. -* -* Use the GroupContext ptr when calling reader routines like GetChunkHdr. -* Look inside the GroupContext ptr for your ClientFrame ptr. You'll -* want to type cast it into a ptr to your containing struct to get your -* private contextual data (stacked property settings). See below. */ -typedef IFFP ClientProc( struct _GroupContext * ); - -/* Client's context for reading an IFF file or a group. -* Client should actually make this the first component of a larger struct -* (it's personal stack "frame") that has a field to store each "interesting" -* property encountered. -* Either initialize each such field to a global default or keep a boolean -* indicating if you've read a property chunk into that field. -* Your getList and getForm procs should allocate a new "frame" and copy the -* parent frame's contents. The getProp procedure should store into the frame -* allocated by getList for the containing LIST. */ -typedef struct _ClientFrame { - ClientProc *getList, *getProp, *getForm, *getCat; - /* client's own data follows; place to stack property settings */ -} ClientFrame; - -/* Our context for reading a group chunk. */ -typedef struct _GroupContext { - struct _GroupContext *parent; /* Containing group; NULL => whole file. */ - ClientFrame *clientFrame; /* Reader data & client's context state. */ - BPTR file; /* Byte-stream file handle. */ - int position; /* The context's logical file position. */ - int bound; /* File-absolute context bound - * or szNotYetKnown (writer only). */ - ChunkHeader ckHdr; /* Current chunk header. ckHdr.ckSize = szNotYetKnown - * means we need to go back and set the size (writer onl - y). - * See also Pseudo-IDs, above. */ - ID subtype; /* Group's subtype ID when reading. */ - int bytesSoFar; /* # bytes read/written of current chunk's data. */ -} GroupContext; - -/* Computes the number of bytes not yet read from the current chunk, given -* a group read context gc. */ -#define ChunkMoreBytes(gc) ((gc)->ckHdr.ckSize - (gc)->bytesSoFar) - - -/***** Low Level IFF Chunk Reader *****/ - -/* Given an open file, open a read context spanning the whole file. -* This is normally only called by ReadIFF. -* This sets new->clientFrame = clientFrame. -* ASSUME context allocated by caller but not initialized. -* ASSUME caller doesn't deallocate the context before calling CloseRGroup. -* NOT_IFF ERROR if the file is too short for even a chunk header.*/ -extern IFFP OpenRIFF(BPTR file, GroupContext *, ClientFrame * ); - -/* Open the remainder of the current chunk as a group read context. -* This will be called just after the group's subtype ID has been read -* (automatically by GetChunkHdr for LIST, FORM, PROP, and CAT) so the -* remainder is a sequence of chunks. -* This sets new->clientFrame = parent->clientFrame. The caller should repoint -* it at a new clientFrame if opening a LIST context so it'll have a "stack -* frame" to store PROPs for the LIST. (It's usually convenient to also -* allocate a new Frame when you encounter FORM of the right type.) -* -* ASSUME new context allocated by caller but not initialized. -* ASSUME caller doesn't deallocate the context or access the parent context -* before calling CloseRGroup. -* BAD_IFF ERROR if context end is odd or extends past parent. */ -extern IFFP OpenRGroup(GroupContext *, GroupContext * ); -/* parent, new */ - -/* Close a group read context, updating its parent context. -* After calling this, the old context may be deallocated and the parent -* context can be accessed again. It's okay to call this particular procedure -* after an error has occurred reading the group. -* This always returns IFF_OKAY. */ -extern IFFP CloseRGroup( GroupContext * ); -/* old */ - -/* Skip any remaining bytes of the previous chunk and any padding, then -* read the next chunk header into context.ckHdr. -* If the ckID is LIST, FORM, CAT, or PROP, this automatically reads the -* subtype ID into context->subtype. -* Caller should dispatch on ckID (and subtype) to an appropriate handler. -* -* RETURNS context.ckHdr.ckID (the ID of the new chunk header); END_MARK -* if there are no more chunks in this context; or NOT_IFF if the top level -* file chunk isn't a FORM, LIST, or CAT; or BAD_IFF if malformed chunk, e.g. -* ckSize is negative or too big for containing context, ckID isn't positive, -* or we hit end-of-file. -* -* See also GetFChunkHdr, GetF1ChunkHdr, and GetPChunkHdr, below.*/ -extern ID GetChunkHdr(/* GroupContext * */); -/* context.ckHdr.ckID context */ - -/* Read nBytes number of data bytes of current chunk. (Use OpenGroup, etc. -* instead to read the contents of a group chunk.) You can call this several -* times to read the data piecemeal. -* CLIENT_ERROR if nBytes < 0. SHORT_CHUNK if nBytes > ChunkMoreBytes(context) -* which could be due to a client bug or a chunk that's shorter than it -* ought to be (bad form). (on either CLIENT_ERROR or SHORT_CHUNK, -* IFFReadBytes won't read any bytes.) */ -extern IFFP IFFReadBytes( GroupContext *, BYTE *, int ); -/* context, buffer, nBytes */ - - -/***** IFF File Reader *****/ - -/* This is a noop ClientProc that you can use for a getList, getForm, getProp, -* or getCat procedure that just skips the group. A simple reader might just -* implement getForm, store &ReadICat in the getCat field of clientFrame, and -* use &SkipGroup for the getList and getProp procs.*/ -extern IFFP SkipGroup( GroupContext* ); - -/* IFF file reader. -* Given an open file, allocate a group context and use it to read the FORM, -* LIST, or CAT and it's contents. The idea is to parse the file's contents, -* and for each FORM, LIST, CAT, or PROP encountered, call the getForm, -* getList, getCat, or getProp procedure in clientFrame, passing the -* GroupContext ptr. -* This is achieved with the aid of ReadIList (which your getList should -* call) and ReadICat (which your getCat should call, if you don't just use -* &ReadICat for your getCat). If you want to handle FORMs, LISTs, and CATs -* nested within FORMs, the getForm procedure must dispatch to getForm, -* getList, and getCat (it can use GetF1ChunkHdr to make this easy). -* -* Normal return is IFF_OKAY (if whole file scanned) or IFF_DONE (if a client -* proc said "done" first). -* See the skeletal getList, getForm, getCat, and getProp procedures. */ -extern IFFP ReadIFF( BPTR, ClientFrame * ); -/* file, clientFrame */ - -/* IFF LIST reader. -* Your "getList" procedure should allocate a ClientFrame, copy the parent's -* ClientFrame, and then call this procedure to do all the work. -* -* Normal return is IFF_OKAY (if whole LIST scanned) or IFF_DONE (if a client -* proc said "done" first). -* BAD_IFF ERROR if a PROP appears after a non-PROP. */ -extern IFFP ReadIList(GroupContext* parent, ClientFrame * clientFrame ); - -/* IFF CAT reader. -* Most clients can simply use this to read their CATs. If you must do extra -* setup work, put a ptr to your getCat procedure in the clientFrame, and -* have that procedure call ReadICat to do the detail work. -* -* Normal return is IFF_OKAY (if whole CAT scanned) or IFF_DONE (if a client -* proc said "done" first). -* BAD_IFF ERROR if a PROP appears in the CAT. */ -extern IFFP ReadICat( GroupContext * ); -/* parent */ - -/* Call GetFChunkHdr instead of GetChunkHdr to read each chunk inside a FORM. -* It just calls GetChunkHdr and returns BAD_IFF if it gets a PROP chunk. */ -extern ID GetFChunkHdr( GroupContext * ); -/* context.ckHdr.ckID context */ - -/* GetF1ChunkHdr is like GetFChunkHdr, but it automatically dispatches to the -* getForm, getList, and getCat procedure (and returns the result) if it -* encounters a FORM, LIST, or CAT. */ -extern ID GetF1ChunkHdr( GroupContext * ); -/* context.ckHdr.ckID context */ - -/* Call GetPChunkHdr instead of GetChunkHdr to read each chunk inside a PROP. -* It just calls GetChunkHdr and returns BAD_IFF if it gets a group chunk. */ -extern ID GetPChunkHdr( GroupContext * ); -/* context.ckHdr.ckID context */ - -/** endianSwap32/endianSwap16 convert integers from big endian to little endian on little-endian platforms. -* They have no effect on big-endian platforms -**/ -extern int endianSwap32(int value); -extern short int endianSwap16(short int value); - - - -/* ---------- IFF Writer -----------------------------------------------*/ - -/******* Routines to support a stream-oriented IFF file writer ******* -* -* These routines will random access back to set a chunk size value when the -* caller doesn't know it ahead of time. They'll also do things automatically -* like padding and error checking. -* -* These routines ASSUME they're the only ones writing to the file. -* Client should check IFFP error codes. Don't press on after an error! -* These routines try to have no side effects in the error case, except that -* partial I/O is sometimes unavoidable. -* -* All of these routines may return DOS_ERROR. In that case, ask DOS for the -* specific error code. -* -* The overall scheme is to open an output GroupContext via OpenWIFF or -* OpenWGroup, call either PutCk or {PutCkHdr {IFFWriteBytes}* PutCkEnd} for -* each chunk, then use CloseWGroup to close the GroupContext. -* -* To write a group (LIST, FORM, PROP, or CAT), call StartWGroup, write out -* its chunks, then call EndWGroup. StartWGroup automatically writes the -* group header and opens a nested context for writing the contents. -* EndWGroup closes the nested context and completes the group chunk. */ - - -/* Given a file open for output, open a write context. -* The "limit" arg imposes a fence or upper limit on the logical file -* position for writing data in this context. Pass in szNotYetKnown to be -* bounded only by disk capacity. -* ASSUME new context structure allocated by caller but not initialized. -* ASSUME caller doesn't deallocate the context before calling CloseWGroup. -* The caller is only allowed to write out one FORM, LIST, or CAT in this top -* level context (see StartWGroup and PutCkHdr). -* CLIENT_ERROR if limit is odd.*/ -extern IFFP OpenWIFF( BPTR, GroupContext *, int ); -/* file, new, limit {file position} */ - -/* Start writing a group (presumably LIST, FORM, PROP, or CAT), opening a -* nested context. The groupSize includes all nested chunks + the subtype ID. -* -* The subtype of a LIST or CAT is a hint at the contents' FORM type(s). Pass -* in FILLER if it's a mixture of different kinds. -* -* This writes the chunk header via PutCkHdr, writes the subtype ID via -* IFFWriteBytes, and calls OpenWGroup. The caller may then write the nested -* chunks and finish by calling EndWGroup. -* The OpenWGroup call sets new->clientFrame = parent->clientFrame. -* -* ASSUME new context structure allocated by caller but not initialized. -* ASSUME caller doesn't deallocate the context or access the parent context -* before calling CloseWGroup. -* ERROR conditions: See PutCkHdr, IFFWriteBytes, OpenWGroup. */ -extern IFFP StartWGroup( GroupContext *, int, int, int, GroupContext * ); -/* End a group started by StartWGroup. -* This just calls CloseWGroup and PutCkEnd. -* ERROR conditions: See CloseWGroup and PutCkEnd. */ -extern IFFP EndWGroup( GroupContext * ); -/* old */ - -/* Open the remainder of the current chunk as a group write context. -* This is normally only called by StartWGroup. -* -* Any fixed limit to this group chunk or a containing context will impose -* a limit on the new context. -* This will be called just after the group's subtype ID has been written -* so the remaining contents will be a sequence of chunks. -* This sets new->clientFrame = parent->clientFrame. -* ASSUME new context structure allocated by caller but not initialized. -* ASSUME caller doesn't deallocate the context or access the parent context -* before calling CloseWGroup. -* CLIENT_ERROR if context end is odd or PutCkHdr wasn't called first. */ -extern IFFP OpenWGroup( GroupContext *, GroupContext *); - - -/* Close a write context and update its parent context. -* This is normally only called by EndWGroup. -* -* If this is a top level context (created by OpenWIFF) we'll set the file's -* EOF (end of file) but won't close the file. -* After calling this, the old context may be deallocated and the parent -* context can be accessed again. -* -* Amiga DOS Note: There's no call to set the EOF. We just position to the -* desired end and return. Caller must Close file at that position. -* CLIENT_ERROR if PutCkEnd wasn't called first. */ -extern IFFP CloseWGroup( GroupContext * ); -/* old */ - -/* Write a whole chunk to a GroupContext. This writes a chunk header, ckSize -* data bytes, and (if needed) a pad byte. It also updates the GroupContext. -* CLIENT_ERROR if ckSize == szNotYetKnown. See also PutCkHdr errors. */ -extern IFFP PutCk( GroupContext *, ID, int, BYTE * ); -/* context, ckID, ckSize, *data */ - -/* Write just a chunk header. Follow this will any number of calls to -* IFFWriteBytes and finish with PutCkEnd. -* If you don't yet know how big the chunk is, pass in ckSize = szNotYetKnown, -* then PutCkEnd will set the ckSize for you later. -* Otherwise, IFFWriteBytes and PutCkEnd will ensure that the specified -* number of bytes get written. -* CLIENT_ERROR if the chunk would overflow the GroupContext's bound, if -* PutCkHdr was previously called without a matching PutCkEnd, if ckSize < 0 -* (except szNotYetKnown), if you're trying to write something other -* than one FORM, LIST, or CAT in a top level (file level) context, or -* if ckID <= 0 (these illegal ID values are used for error codes). */ -extern IFFP PutCkHdr( GroupContext* context, int ckID, int ckSize); - -/* Write nBytes number of data bytes for the current chunk and update -* GroupContext. -* CLIENT_ERROR if this would overflow the GroupContext's limit or the -* current chunk's ckSize, or if PutCkHdr wasn't called first, or if -* nBytes < 0. */ -extern IFFP IFFWriteBytes(GroupContext *context0, BYTE *data, int nBytes); - -/* Complete the current chunk, write a pad byte if needed, and update -* GroupContext. -* If current chunk's ckSize = szNotYetKnown, this goes back and sets the -* ckSize in the file. -* CLIENT_ERROR if PutCkHdr wasn't called first, or if client hasn't -* written 'ckSize' number of bytes with IFFWriteBytes. */ -extern IFFP PutCkEnd( GroupContext* context ); - -#endif diff --git a/Extras/iff/iffCheck/iffcheck.cpp b/Extras/iff/iffCheck/iffcheck.cpp deleted file mode 100644 index a3cdfeecf..000000000 --- a/Extras/iff/iffCheck/iffcheck.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/*---------------------------------------------------------------------* -* IFFCheck.C Print out the structure of an IFF-85 file, 11/19/85 -* checking for structural errors. -* -* DO NOT USE THIS AS A SKELETAL PROGRAM FOR AN IFF READER! -* See ShowILBM.C for a skeletal example. -* -* Original version was for the Commodore-Amiga computer. -/* This version is compatible with PC, OSX, PS3, Wii, iPhone. 10/26/2008 -*----------------------------------------------------------------------*/ - -#include "iff.h" -#include "stdlib.h" //for exit - -/* ---------- IFFCheck -------------------------------------------------*/ -/* [TBD] More extensive checking could be done on the IDs encountered in the -* file. Check that the reserved IDs "FOR1".."FOR9", "LIS1".."LIS9", and -* "CAT1".."CAT9" aren't used. Check that reserved IDs aren't used as Form -* types. Check that all IDs are made of 4 printable characters (trailing -* spaces ok). */ - -typedef struct { - ClientFrame clientFrame; - int levels; /* # groups currently nested within.*/ -} Frame; - -char MsgOkay[] = { "----- (IFF_OKAY) A good IFF file." }; -char MsgEndMark[] = {"----- (END_MARK) How did you get this message??" }; -char MsgDone[] = { "----- (IFF_DONE) How did you get this message??" }; -char MsgDos[] = { "----- (DOS_ERROR) The DOS gave back an error." }; -char MsgNot[] = { "----- (NOT_IFF) not an IFF file." }; -char MsgNoFile[] = { "----- (NO_FILE) no such file found." }; -char MsgClientError[] = {"----- (CLIENT_ERROR) IFF Checker bug."}; -char MsgForm[] = { "----- (BAD_FORM) How did you get this message??" }; -char MsgShort[] = { "----- (SHORT_CHUNK) How did you get this message??" }; -char MsgBad[] = { "----- (BAD_IFF) a mangled IFF file." }; - -/* MUST GET THESE IN RIGHT ORDER!!*/ -char *IFFPMessages[-LAST_ERROR+1] = { - /*IFF_OKAY*/ MsgOkay, - /*END_MARK*/ MsgEndMark, - /*IFF_DONE*/ MsgDone, - /*DOS_ERROR*/ MsgDos, - /*NOT_IFF*/ MsgNot, - /*NO_FILE*/ MsgNoFile, - /*CLIENT_ERROR*/ MsgClientError, - /*BAD_FORM*/ MsgForm, - /*SHORT_CHUNK*/ MsgShort, - /*BAD_IFF*/ MsgBad -}; - -/* FORWARD REFERENCES */ -extern IFFP GetList(GroupContext*); -extern IFFP GetForm(GroupContext*); -extern IFFP GetProp(GroupContext*); -extern IFFP GetCat (GroupContext*); - -void IFFCheck(char *name) -{ - IFFP iffp; - BPTR file = fopen(name,"rb");//Open(name, MODE_OLDFILE); - Frame frame; - - frame.levels = 0; - frame.clientFrame.getList = GetList; - frame.clientFrame.getForm = GetForm; - frame.clientFrame.getProp = GetProp; - frame.clientFrame.getCat = GetCat ; - - printf("----- Checking file '%s' -----\n", name); - if (file == 0) - iffp = NO_FILE; - else - iffp = ReadIFF(file, (ClientFrame *)&frame); - - fclose(file); - printf("%s\n", IFFPMessages[-iffp]); -} - -int main(int argc, char **argv) -{ - if (argc != 1+1) { - printf("Usage: 'iffcheck filename'\n"); - exit(0); - } - IFFCheck(argv[1]); - return 0; -} - -/* ---------- Put... ---------------------------------------------------*/ - -void PutLevels(int count) -{ - for ( ; count > 0; --count) { - printf("."); - } -} - -void PutID(int id) -{ - long int i = 1; - const char *p = (const char *) &i; - if (p[0] == 1) // Lowest address contains the least significant byte - { - //little endian machine - printf("%c%c%c%c ", (char)(id&0x7f) , (char)(id>>8)&0x7f, - (char)(id>>16)&0x7f, (char)(id>>24)&0x7f); - } else - { - //big endian machine - printf("%c%c%c%c ", (char)(id>>24)&0x7f, (char)(id>>16)&0x7f, - (char)(id>>8)&0x7f, (char)(id&0x7f)); - } - /* printf("id = %lx", id); */ -} - -void PutN(long n) -{ - printf(" %ld ", n); -} - -/* Put something like "...BMHD 14" or "...LIST 14 PLBM". */ -void PutHdr(GroupContext *context) -{ - PutLevels( ((Frame *)context->clientFrame)->levels ); - PutID(context->ckHdr.ckID); - PutN(context->ckHdr.ckSize); - - if (context->subtype != NULL_CHUNK) - PutID(context->subtype); - - printf("\n"); -} - -/* ---------- AtLeaf ---------------------------------------------------*/ - -/* At Leaf chunk. That is, a chunk which does NOT contain other chunks. -* Print "int size".*/ -IFFP AtLeaf(GroupContext *context) -{ - - PutHdr(context); - /* A typical reader would read the chunk's contents, using the "Frame" - * for local data, esp. shared property settings (PROP).*/ - /* IFFReadBytes(context, ...buffer, context->ckHdr->ckSize); */ - return(IFF_OKAY); -} - -/* ---------- GetList --------------------------------------------------*/ -/* Handle a LIST chunk. Print "LIST size subTypeID". -* Then dive into it.*/ -IFFP GetList(GroupContext *parent) -{ - Frame newFrame; - - newFrame = *(Frame *)parent->clientFrame; /* copy parent's frame*/ - newFrame.levels++; - - PutHdr(parent); - - return( ReadIList(parent, (ClientFrame *)&newFrame) ); -} - -/* ---------- GetForm --------------------------------------------------*/ -/* Handle a FORM chunk. Print "FORM size subTypeID". -* Then dive into it.*/ -IFFP GetForm(GroupContext *parent) -{ - /*CompilerBug register*/ IFFP iffp; - GroupContext newptr; - Frame newFrame; - - newFrame = *(Frame *)parent->clientFrame; /* copy parent's frame*/ - newFrame.levels++; - - PutHdr(parent); - - iffp = OpenRGroup(parent, &newptr); - CheckIFFP(); - newptr.clientFrame = (ClientFrame *)&newFrame; - - /* FORM reader for Checker. */ - /* LIST, FORM, PROP, CAT already handled by GetF1ChunkHdr. */ - do {if ( (iffp = GetF1ChunkHdr(&newptr)) > 0 ) - iffp = AtLeaf(&newptr); - } while (iffp >= IFF_OKAY); - - CloseRGroup(&newptr); - return(iffp == END_MARK ? IFF_OKAY : iffp); -} - -/* ---------- GetProp --------------------------------------------------*/ -/* Handle a PROP chunk. Print "PROP size subTypeID". -* Then dive into it.*/ -IFFP GetProp(GroupContext *listContext) -{ - /*CompilerBug register*/ IFFP iffp; - GroupContext newptr; - - PutHdr(listContext); - - iffp = OpenRGroup(listContext, &newptr); - CheckIFFP(); - - /* PROP reader for Checker. */ - ((Frame *)listContext->clientFrame)->levels++; - - do {if ( (iffp = GetPChunkHdr(&newptr)) > 0 ) - iffp = AtLeaf(&newptr); - } while (iffp >= IFF_OKAY); - - ((Frame *)listContext->clientFrame)->levels--; - - CloseRGroup(&newptr); - return(iffp == END_MARK ? IFF_OKAY : iffp); -} - -/* ---------- GetCat ---------------------------------------------------*/ -/* Handle a CAT chunk. Print "CAT size subTypeID". -* Then dive into it.*/ -IFFP GetCat(GroupContext *parent) -{ - IFFP iffp; - - ((Frame *)parent->clientFrame)->levels++; - - PutHdr(parent); - - iffp = ReadICat(parent); - - ((Frame *)parent->clientFrame)->levels--; - return(iffp); -} diff --git a/Extras/iff/iffCreateTest/main.cpp b/Extras/iff/iffCreateTest/main.cpp deleted file mode 100644 index 6bf301a4b..000000000 --- a/Extras/iff/iffCreateTest/main.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -Test read and write IFF-85, Interchange Format File -Copyright (c) 2008 Erwin Coumans http://bulletphysics.com - -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. -*/ - -/* -* IFF Support routines for writing IFF-85 files. 12/02/85 -* (IFF is Interchange Format File.) -* By Jerry Morrison and Steve Shaw, Electronic Arts. -* This software is in the public domain. -* -*/ - -#include - -#include "iff.h" - -IFFP MyReadICat(GroupContext *parent) -{ - printf("Found and skipped a CAT\n"); - return 0; -} - -IFFP MySkipGroup( GroupContext * ) -{ - printf("Found and skipped a LIST\n"); - return 0; -} - -typedef UBYTE Masking; /* Choice of masking technique.*/ -typedef UBYTE Compression; /* Choice of compression algorithm applied to - - /* A BitMapHeader is stored in a BMHD chunk. */ -typedef struct { - - UWORD w, h; /* raster width & height in pixels */ - - WORD x, y; /* position for this image */ - UBYTE nPlanes; /* # source bitplanes */ - Masking masking; /* masking technique */ - Compression compression; /* compression algoithm */ - UBYTE pad1; /* UNUSED. For consistency, put 0 here.*/ - UWORD transparentColor; /* transparent "color number" */ - UBYTE xAspect, yAspect; /* aspect ratio, a rational number x/y */ - WORD pageWidth, pageHeight; /* source "page" size in pixels */ - -} BitMapHeader; - - -#define bufSz 512 -BYTE bodyBuffer[bufSz]; - -static void btSwap(char* a, char* b) -{ - char tmp = *a; - *a = *b; - *b = tmp; -}; - -#define ID_ILBM MakeID('I','L','B','M') -#define ID_BMHD MakeID('B','M','H','D') -#define ID_CMAP MakeID('C','M','A','P') -#define ID_BODY MakeID('B','O','D','Y') - -#define ID_DYNAWORLD MakeID('B','T','D','W') -#define ID_RIGIDBODY MakeID('B','T','R','B') -#define ID_SID MakeID('S','I','D',' ') -#define ID_MASS MakeID('M','A','S','S') -#define ID_SHAPE MakeID('S','H','A','P') - - -#define ID_COLOBJ MakeID('C','O','B','J') -#define ID_CUBE MakeID('C','U','B','E') -#define ID_DIMENSIONS MakeID('D','I','M','E') - - -IFFP MyProcessGroup(GroupContext *parent) -{ - /*compilerBug register*/ IFFP iffp; - GroupContext rigidbodyContext; - - BitMapHeader bmHeader; - bool foundBMHD = false; - - - if (parent->subtype != ID_ILBM) - return(IFF_OKAY); /* just continue scaning the file */ - - iffp = OpenRGroup(parent, &rigidbodyContext); - CheckIFFP(); - - do { - iffp = GetFChunkHdr(&rigidbodyContext); - if (iffp == ID_BMHD) { - printf("found ID_BMHD\n"); - foundBMHD = true; - - iffp = IFFReadBytes(&rigidbodyContext, (BYTE *)&bmHeader, (long)sizeof(BitMapHeader)); - //do endian swap - bmHeader.w = endianSwap16(bmHeader.w); - bmHeader.h = endianSwap16(bmHeader.h); - bmHeader.pageWidth = endianSwap16(bmHeader.pageWidth); - bmHeader.pageHeight = endianSwap16(bmHeader.pageHeight); - } - - else if (iffp == ID_CMAP) { - printf("found ID_CMAP\n"); - - // ilbmFrame.nColorRegs = maxColorReg; /* we have room for this many */ - // iffp = GetCMAP( - // &rigidbodyContext, (WORD *)&ilbmFrame.colorMap, &ilbmFrame.nColorRegs); - } - - else if (iffp == ID_BODY) - { - printf("found ID_BODY\n"); - if (!foundBMHD) - return BAD_FORM; - // if (!ilbmFrame.foundBMHD) return(BAD_FORM); /* No BMHD chunk! */ - - int moreBytes = ChunkMoreBytes(&rigidbodyContext); - while (moreBytes>0) - { - int curRead = moreBytes > bufSz? bufSz : moreBytes; - //read - iffp = IFFReadBytes(&rigidbodyContext, bodyBuffer, curRead); - moreBytes -= curRead; - - } - printf("remaining=%d\n",moreBytes); - if (iffp == IFF_OKAY) - iffp = IFF_DONE; /* Eureka */ - - - - // nPlanes = MIN(ilbmFrame.bmHdr.nPlanes, EXDepth); - } - - else if (iffp == END_MARK) - iffp = BAD_FORM; - - } while (iffp >= IFF_OKAY); /* loop if valid ID of ignored chunk or a - * subroutine returned IFF_OKAY (no errors).*/ - - if (iffp != IFF_DONE) return(iffp); - - /* If we get this far, there were no errors. */ - CloseRGroup(&rigidbodyContext); - return(iffp); -} - - - -#define CkErr(expression) {if (ifferr == IFF_OKAY) ifferr = (expression);} - - -int main(int argc, char* argv[]) -{ - FILE* file = 0; - - { - //Create and write an IFF file from scratch - file = fopen("test.iff","wb"); - - GroupContext fileContext; - GroupContext catContext; - - IFFP ifferr=0; - - ifferr = OpenWIFF(file, &fileContext, szNotYetKnown) ; - //ifferr = StartWGroup(&fileContext, CAT, szNotYetKnown, ID_DYNAWORLD, &catContext); - ifferr = StartWGroup(&fileContext, LIST, szNotYetKnown, ID_DYNAWORLD, &catContext); - - { - GroupContext rigidbodyPropContext; - ifferr = StartWGroup(&catContext, PROP, szNotYetKnown, ID_MASS, &rigidbodyPropContext); - float mass = 0.1f; - PutCk(&rigidbodyPropContext, ID_MASS, 4,(char*)&mass); - ifferr = EndWGroup(&rigidbodyPropContext) ; - - for (int i=0;i<3;i++) - { - GroupContext rigidbodyContext; - ifferr = StartWGroup(&catContext, FORM, szNotYetKnown, ID_RIGIDBODY, &rigidbodyContext); - char sidbuffer[]="rb1"; - - float dimensions[3] = {2,2,2}; - PutCk(&rigidbodyContext, ID_SID, 3,sidbuffer); - { - GroupContext shapeContext; - ifferr = StartWGroup(&rigidbodyContext, FORM, szNotYetKnown, ID_SHAPE, &shapeContext); - PutCk(&shapeContext, ID_CUBE, 4,(char*)&mass); - PutCk(&shapeContext, ID_DIMENSIONS, sizeof(dimensions),(char*)&dimensions); - ifferr = EndWGroup(&shapeContext) ; - } - ifferr = EndWGroup(&rigidbodyContext) ; - } - - } - ifferr = EndWGroup(&catContext) ; - ifferr = CloseWGroup(&fileContext); - - fclose(file); - } - - { - //show a very simple way to skim through an ILBM or general IFF file - //for more verbose feedback, use iffcheck.c - IFFP result; - //file = fopen("pe_3000_fall.iff","rb"); - file = fopen("test.iff","rb"); - - ClientFrame clientFrame; - - clientFrame.getList = MySkipGroup; - clientFrame.getProp = MySkipGroup; - clientFrame.getForm = MyProcessGroup; - clientFrame.getCat = MyReadICat ; - - result = ReadIFF(file,&clientFrame); - fclose(file); - } - - - return 0; -} diff --git a/Extras/iff/iffr.cpp b/Extras/iff/iffr.cpp deleted file mode 100644 index 82377e764..000000000 --- a/Extras/iff/iffr.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/*----------------------------------------------------------------------* -* IFFR.C Support routines for reading IFF-85 files. 11/15/85 -* (IFF is Interchange Format File.) -* -* By Jerry Morrison and Steve Shaw, Electronic Arts. -* This software is in the public domain. -* -* Original version was for the Commodore-Amiga computer. -* This version is compatible with PC, OSX, PS3, Wii, iPhone. 10/26/2008 -*----------------------------------------------------------------------*/ - -#include "iff.h" -/* #include "DF1:iff/gio.h" */ -/* #define OFFSET_BEGINNING OFFSET_BEGINING */ - -/** Manx expects INTs as 16 bits, This wont matter on LAttice ***/ - - - -/* ---------- Read -----------------------------------------------------*/ - -extern int PutID(); /** Added as a diagnostic aid, will remove later ***/ - -/* ---------- OpenRIFF --------------------------------------------------*/ -IFFP OpenRIFF(BPTR file0, GroupContext *new0,ClientFrame *clientFrame) -{ - register BPTR file = file0; - register GroupContext *newtmp = new0; - IFFP iffp = IFF_OKAY; - - newtmp->parent = NL; /* "whole file" has no parent.*/ - newtmp->clientFrame = clientFrame; - newtmp->file = file; - newtmp->position = 0; - newtmp->ckHdr.ckID = newtmp->subtype = NULL_CHUNK; - newtmp->ckHdr.ckSize = newtmp->bytesSoFar = 0; - - /* Set newtmp->bound. AmigaDOS specific code.*/ - if (file <= 0) return(NO_FILE); - Seek(file, 0L, OFFSET_END); /* Seek to end of file.*/ - newtmp->bound = ftell(file);//Seek(file, 0L, OFFSET_CURRENT); /* Pos'n == #bytes in file.*/ - if (newtmp->bound < 0) return(DOS_ERROR); /* DOS being absurd.*/ - Seek(file, 0L, OFFSET_BEGINNING); /* Go to file start.*/ - /* Would just do this if Amiga DOS maintained fh_End: */ - /* newtmp->bound = (FileHandle *)BADDR(file)->fh_End; */ - - if ( newtmp->bound < (long)sizeof(ChunkHeader) ) - iffp = NOT_IFF; - return(iffp); -} - -/* ---------- OpenRGroup -----------------------------------------------*/ -IFFP OpenRGroup(GroupContext* parent0,GroupContext* new0) -{ - register GroupContext *parent = parent0; - register GroupContext *newtmp = new0; - IFFP iffp = IFF_OKAY; - - newtmp->parent = parent; - newtmp->clientFrame = parent->clientFrame; - newtmp->file = parent->file; - newtmp->position = parent->position; - newtmp->bound = parent->position + ChunkMoreBytes(parent); - newtmp->ckHdr.ckID = newtmp->subtype = NULL_CHUNK; - newtmp->ckHdr.ckSize = newtmp->bytesSoFar = 0; - - if ( newtmp->bound > parent->bound || IS_ODD(newtmp->bound) ) - iffp = BAD_IFF; - return(iffp); -} - -/* ---------- CloseRGroup -----------------------------------------------*/ -IFFP CloseRGroup(GroupContext *context) -{ - register int position; - - if (context->parent == NL) { - } /* Context for whole file.*/ - else { - position = context->position; - context->parent->bytesSoFar += position - context->parent->position; - context->parent->position = position; - } - return(IFF_OKAY); -} - -/* ---------- SkipFwd --------------------------------------------------*/ -/* Skip over bytes in a context. Won't go backwards.*/ -/* Updates context->position but not context->bytesSoFar.*/ -/* This implementation is AmigaDOS specific.*/ -IFFP SkipFwd(GroupContext *context,int bytes) -{ - IFFP iffp = IFF_OKAY; - - if (bytes > 0) { - if (-1 == Seek(context->file, bytes, OFFSET_CURRENT)) - iffp = BAD_IFF; /* Ran out of bytes before chunk complete.*/ - else - context->position += bytes; - } - return(iffp); -} - -short int endianSwap16(short int val) -{ - long int i = 1; - const char *p = (const char *) &i; - if (p[0] == 1) // Lowest address contains the least significant byte - { - return (((val & 0xff00) >> 8) | ((val & 0x00ff) << 8)); - } - return val; -} - - - -int endianSwap32(int val) -{ - long int i = 1; - const char *p = (const char *) &i; - if (p[0] == 1) // Lowest address contains the least significant byte - { - return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); - } - return val; -} - - - - - -/* ---------- GetChunkHdr ----------------------------------------------*/ -int GetChunkHdr(GroupContext *context0) -{ - register GroupContext *context = context0; - register IFFP iffp; - int remaining; - - /* Skip remainder of previous chunk & padding. */ - iffp = SkipFwd(context, - ChunkMoreBytes(context) + IS_ODD(context->ckHdr.ckSize)); - CheckIFFP(); - - /* Set up to read the newtmp header. */ - context->ckHdr.ckID = BAD_IFF; /* Until we know it's okay, mark it BAD.*/ - context->subtype = NULL_CHUNK; - context->bytesSoFar = 0; - - /* Generate a psuedo-chunk if at end-of-context. */ - remaining = context->bound - context->position; - if (remaining == 0 ) { - context->ckHdr.ckSize = 0; - context->ckHdr.ckID = END_MARK; - } - /* BAD_IFF if not enough bytes in the context for a ChunkHeader.*/ - else if ((long)sizeof(ChunkHeader) > remaining) { - context->ckHdr.ckSize = remaining; - } - - /* Read the chunk header (finally). */ - else { - switch (Read(context->file, - &context->ckHdr, (long)sizeof(ChunkHeader))) - { - case -1: return(context->ckHdr.ckID = DOS_ERROR); - case 0: return(context->ckHdr.ckID = BAD_IFF); - } - //swap endian-ness of ckSize on little endian machines - context->ckHdr.ckSize = endianSwap32(context->ckHdr.ckSize); - - - - - /*** $$$ *** - PutID(context->ckHdr.ckID); - printf("\n"); - printf("id = %lx\n", context->ckHdr.ckID); - **/ - - /* Check: Top level chunk must be LIST or FORM or CAT. */ - if (context->parent == NL) { - if (context->ckHdr.ckID != FORM && - context->ckHdr.ckID != LIST && - context->ckHdr.ckID != CAT ) - return(context->ckHdr.ckID = NOT_IFF); - } - - /* Update the context. */ - context->position += (long)sizeof(ChunkHeader); - remaining -= (long)sizeof(ChunkHeader); - - /* Non-positive int values are illegal and used for error codes.*/ - /* We could check for other illegal IDs...*/ - if (context->ckHdr.ckID <= 0 ) - context->ckHdr.ckID = BAD_IFF; - - /* Check: ckSize negative or larger than # bytes left in context? */ - else if (context->ckHdr.ckSize < 0 || - context->ckHdr.ckSize > remaining) { - context->ckHdr.ckSize = remaining; - context->ckHdr.ckID = BAD_IFF; - } - - /* Automatically read the LIST, FORM, PROP, or CAT subtype int */ - else { - if (context->ckHdr.ckID == LIST || - context->ckHdr.ckID == FORM || - context->ckHdr.ckID == PROP || - context->ckHdr.ckID == CAT) { - iffp = IFFReadBytes(context, (BYTE *)&context->subtype, - (long)sizeof(int)); - if (iffp != IFF_OKAY ) - context->ckHdr.ckID = iffp; - } - } - } - return(context->ckHdr.ckID); -} - -/* ---------- IFFReadBytes ---------------------------------------------*/ -IFFP IFFReadBytes(GroupContext *context,BYTE *buffer, int nBytes) -{ - register IFFP iffp = IFF_OKAY; - - if (nBytes < 0) - iffp = CLIENT_ERROR; - - else if (nBytes > ChunkMoreBytes(context)) - iffp = SHORT_CHUNK; - - else if (nBytes > 0 ) - switch ( Read(context->file, buffer, nBytes) ) { - case -1: {iffp = DOS_ERROR; break; } - case 0: {iffp = BAD_IFF; break; } - default: { - context->position += nBytes; - context->bytesSoFar += nBytes; - } - } - return(iffp); -} - -/* ---------- SkipGroup ------------------------------------------------*/ -IFFP SkipGroup( GroupContext* context) -{ - return 0; -} /* Nothing to do, thanks to GetChunkHdr */ - -/* ---------- ReadIFF --------------------------------------------------*/ -IFFP ReadIFF(BPTR file,ClientFrame *clientFrame) -{ - /*CompilerBug register*/ IFFP iffp; - GroupContext context; - - iffp = OpenRIFF(file, &context,clientFrame); - context.clientFrame = clientFrame; - - if (iffp == IFF_OKAY) { - iffp = GetChunkHdr(&context); - - if (iffp == FORM) - iffp = (*clientFrame->getForm)(&context); - - else if (iffp == LIST) - iffp = (*clientFrame->getList)(&context); - - else if (iffp == CAT) - iffp = (*clientFrame->getCat)(&context); - } - CloseRGroup(&context); - - if (iffp > 0 ) /* Make sure we don't return an int.*/ - iffp = NOT_IFF; /* GetChunkHdr should've caught this.*/ - return(iffp); -} - -/* ---------- ReadIList ------------------------------------------------*/ -IFFP ReadIList(GroupContext *parent,ClientFrame *clientFrame) -{ - GroupContext listContext; - IFFP iffp; - BOOL propOk = TRUE; - - iffp = OpenRGroup(parent, &listContext); - CheckIFFP(); - - /* One special case test lets us handle CATs as well as LISTs.*/ - if (parent->ckHdr.ckID == CAT) - propOk = FALSE; - else - listContext.clientFrame = clientFrame; - - do { - iffp = GetChunkHdr(&listContext); - if (iffp == PROP) { - if (propOk) - iffp = (*clientFrame->getProp)(&listContext); - else - iffp = BAD_IFF; - } - else if (iffp == FORM) - iffp = (*clientFrame->getForm)(&listContext); - - else if (iffp == LIST) - iffp = (*clientFrame->getList)(&listContext); - - else if (iffp == CAT) - iffp = (*clientFrame->getList)(&listContext); - - if (listContext.ckHdr.ckID != PROP) - propOk = FALSE; /* No PROPs allowed after this point.*/ - } while (iffp == IFF_OKAY); - - CloseRGroup(&listContext); - - if (iffp > 0 ) /* Only chunk types above are allowed in a LIST/CAT.*/ - iffp = BAD_IFF; - return(iffp == END_MARK ? IFF_OKAY : iffp); -} - -/* ---------- ReadICat -------------------------------------------------*/ -/* By special arrangement with the ReadIList implement'n, this is trivial.*/ -IFFP ReadICat(GroupContext *parent) -{ - return( ReadIList(parent, parent->clientFrame));//NL) ); -} - -/* ---------- GetFChunkHdr ---------------------------------------------*/ -int GetFChunkHdr(GroupContext *context) -{ - register int id; - - id = GetChunkHdr(context); - if (id == PROP) - context->ckHdr.ckID = id = BAD_IFF; - return(id); -} - -/* ---------- GetF1ChunkHdr ---------------------------------------------*/ -int GetF1ChunkHdr(GroupContext *context) -{ - register int id; - register ClientFrame *clientFrame = context->clientFrame; - - id = GetChunkHdr(context); - if (id == PROP) - id = BAD_IFF; - - else if (id == FORM) - id = (*clientFrame->getForm)(context); - - else if (id == LIST) - id = (*clientFrame->getForm)(context); - - else if (id == CAT) - id = (*clientFrame->getCat)(context); - - return(context->ckHdr.ckID = id); -} - -/* ---------- GetPChunkHdr ---------------------------------------------*/ -int GetPChunkHdr(GroupContext *context) -{ - register int id; - - id = GetChunkHdr(context); - if (id == LIST || id == FORM || id == PROP || id == CAT ) - id = context->ckHdr.ckID = BAD_IFF; - return(id); -} diff --git a/Extras/iff/iffw.cpp b/Extras/iff/iffw.cpp deleted file mode 100644 index 0e66f8a78..000000000 --- a/Extras/iff/iffw.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/*----------------------------------------------------------------------* -* IFFW.C Support routines for writing IFF-85 files. 12/02/85 -* (IFF is Interchange Format File.) -* -* By Jerry Morrison and Steve Shaw, Electronic Arts. -* This software is in the public domain. -* -* Original version was for the Commodore-Amiga computer. -* This version is compatible with PC, OSX, PS3, Wii, iPhone. 10/26/2008 -*----------------------------------------------------------------------*/ -#include "iff.h" - - - - -/* ---------- IFF Writer -----------------------------------------------*/ - -/* A macro to test if a chunk size is definite, i.e. not szNotYetKnown.*/ -#define Known(size) ( (size) != szNotYetKnown ) - -/* Yet another weird macro to make the source code simpler...*/ -#define IfIffp(expr) {if (iffp == IFF_OKAY) iffp = (expr);} - -/* ---------- OpenWIFF -------------------------------------------------*/ - -IFFP OpenWIFF(BPTR file, GroupContext *new0, int limit) -{ - register GroupContext *newtmp = new0; - register IFFP iffp = IFF_OKAY; - - newtmp->parent = NULL; - newtmp->clientFrame = NULL; - newtmp->file = file; - newtmp->position = 0; - newtmp->bound = limit; - newtmp->ckHdr.ckID = NULL_CHUNK; /* indicates no current chunk */ - newtmp->ckHdr.ckSize = newtmp->bytesSoFar = 0; - - if (0 > Seek(file, 0, OFFSET_BEGINNING)) /* Go to start of the file.*/ - iffp = DOS_ERROR; - else if ( Known(limit) && IS_ODD(limit) ) - iffp = CLIENT_ERROR; - return(iffp); -} - -/* ---------- StartWGroup ----------------------------------------------*/ -IFFP StartWGroup( GroupContext* parent, int groupType,int groupSize,int subtype, GroupContext * newtmp) -{ - register IFFP iffp; - - iffp = PutCkHdr(parent, groupType, groupSize); - IfIffp( IFFWriteBytes(parent, (char *)&subtype, sizeof(int)) ); - IfIffp( OpenWGroup(parent, newtmp) ); - return(iffp); -} - -/* ---------- OpenWGroup -----------------------------------------------*/ -IFFP OpenWGroup(GroupContext *parent0,GroupContext* new0) -{ - register GroupContext *parent = parent0; - register GroupContext *newtmp = new0; - register int ckEnd; - register IFFP iffp = IFF_OKAY; - - newtmp->parent = parent; - newtmp->clientFrame = parent->clientFrame; - newtmp->file = parent->file; - newtmp->position = parent->position; - newtmp->bound = parent->bound; - newtmp->ckHdr.ckID = NULL_CHUNK; - newtmp->ckHdr.ckSize = newtmp->bytesSoFar = 0; - - if ( Known(parent->ckHdr.ckSize) ) { - ckEnd = newtmp->position + ChunkMoreBytes(parent); - if ( newtmp->bound == szNotYetKnown || newtmp->bound > ckEnd ) - newtmp->bound = ckEnd; - }; - - if ( parent->ckHdr.ckID == NULL_CHUNK || /* not currently writing a chunk*/ - IS_ODD(newtmp->position) || - (Known(newtmp->bound) && IS_ODD(newtmp->bound)) ) - iffp = CLIENT_ERROR; - return(iffp); -} - -/* ---------- CloseWGroup ----------------------------------------------*/ -IFFP CloseWGroup(GroupContext *old0) -{ - register GroupContext *old = old0; - - if ( old->ckHdr.ckID != NULL_CHUNK ) /* didn't close the last chunk */ - return(CLIENT_ERROR); - - if ( old->parent == NULL ) { /* top level file context */ - GWriteFlush(old->file); - } - else { - old->parent->bytesSoFar += old->position - old->parent->position; - old->parent->position = old->position; - }; - return(IFF_OKAY); -} - -/* ---------- EndWGroup ------------------------------------------------*/ -IFFP EndWGroup(GroupContext *old) -{ - register GroupContext *parent = old->parent; - register IFFP iffp; - - - iffp = CloseWGroup(old); - IfIffp( PutCkEnd(parent) ); - return(iffp); -} - -/* ---------- PutCk ----------------------------------------------------*/ -IFFP PutCk(GroupContext *context, int ckID,int ckSize,char *data) -{ - register IFFP iffp = IFF_OKAY; - - if ( ckSize == szNotYetKnown ) - iffp = CLIENT_ERROR; - IfIffp( PutCkHdr(context, ckID, ckSize) ); - IfIffp( IFFWriteBytes(context, data, ckSize) ); - IfIffp( PutCkEnd(context) ); - return(iffp); -} - -/* ---------- PutCkHdr -------------------------------------------------*/ -IFFP PutCkHdr(GroupContext *context0, int ckID, int ckSize) -{ - register GroupContext *context = context0; - int minPSize = sizeof(ChunkHeader); /* physical chunk >= minPSize bytes*/ - - /* CLIENT_ERROR if we're already inside a chunk or asked to write - * other than one FORM, LIST, or CAT at the top level of a file */ - /* Also, non-positive int values are illegal and used for error codes.*/ - /* (We could check for other illegal IDs...)*/ - if ( context->ckHdr.ckID != NULL_CHUNK || ckID <= 0 ) - return(CLIENT_ERROR); - else if (context->parent == NULL) { - switch (ckID) { - case FORM: case LIST: case CAT: break; - default: return(CLIENT_ERROR); - } - if (context->position != 0) - return(CLIENT_ERROR); - } - - if ( Known(ckSize) ) { - if ( ckSize < 0 ) - return(CLIENT_ERROR); - minPSize += ckSize; - }; - if ( Known(context->bound) && - context->position + minPSize > context->bound ) - return(CLIENT_ERROR); - - context->ckHdr.ckID = ckID; - context->ckHdr.ckSize = ckSize; - context->bytesSoFar = 0; - { - context->ckHdr.ckSize = endianSwap32(context->ckHdr.ckSize); - if (0 > fwrite(&context->ckHdr, 1,sizeof(ChunkHeader),context->file)) - return(DOS_ERROR); - context->ckHdr.ckSize = endianSwap32(context->ckHdr.ckSize); - } - context->position += sizeof(ChunkHeader); - return(IFF_OKAY); -} - -/* ---------- IFFWriteBytes ---------------------------------------------*/ -IFFP IFFWriteBytes(GroupContext *context0, char *data, int nBytes) -{ - register GroupContext *context = context0; - - if ( context->ckHdr.ckID == NULL_CHUNK || /* not in a chunk */ - nBytes < 0 || /* negative nBytes */ - (Known(context->bound) && /* overflow context */ - context->position + nBytes > context->bound) || - (Known(context->ckHdr.ckSize) && /* overflow chunk */ - context->bytesSoFar + nBytes > context->ckHdr.ckSize) ) - { - return(CLIENT_ERROR); - } - - if (0 > fwrite(data, 1,nBytes,context->file)) - return(DOS_ERROR); - - context->bytesSoFar += nBytes; - context->position += nBytes; - return(IFF_OKAY); -} - -/* ---------- PutCkEnd -------------------------------------------------*/ -IFFP PutCkEnd(GroupContext *context0) -{ - register GroupContext *context = context0; - WORD zero = 0; /* padding source */ - - if ( context->ckHdr.ckID == NULL_CHUNK ) /* not in a chunk */ - return(CLIENT_ERROR); - - if ( context->ckHdr.ckSize == szNotYetKnown ) { - /* go back and set the chunk size to bytesSoFar */ - int offset = context->bytesSoFar+sizeof(int); - if ( 0 > GSeek(context->file, - -(offset), - OFFSET_CURRENT)) - { - return(DOS_ERROR); - } else - { - context->bytesSoFar = endianSwap32(context->bytesSoFar); - if (0 > fwrite(&context->bytesSoFar, 1,sizeof(int),context->file)) - return (DOS_ERROR); - context->bytesSoFar = endianSwap32(context->bytesSoFar); - if (0 > GSeek(context->file, context->bytesSoFar, OFFSET_CURRENT) ) - return (DOS_ERROR); - } - - - } - else { /* make sure the client wrote as many bytes as planned */ - if ( context->ckHdr.ckSize != context->bytesSoFar ) - return(CLIENT_ERROR); - }; - - /* Write a pad byte if needed to bring us up to an even boundary. - * Since the context end must be even, and since we haven't - * overwritten the context, if we're on an odd position there must - * be room for a pad byte. */ - if ( IS_ODD(context->bytesSoFar) ) { - if ( 0 > fwrite(&zero, 1,1,context->file) ) - return(DOS_ERROR); - context->position += 1; - }; - - context->ckHdr.ckID = NULL_CHUNK; - context->ckHdr.ckSize = context->bytesSoFar = 0; - return(IFF_OKAY); -} - diff --git a/Extras/simdmathlibrary/LICENSE b/Extras/simdmathlibrary/LICENSE deleted file mode 100644 index 5c316537d..000000000 --- a/Extras/simdmathlibrary/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ - SIMD math library functions for both the PowerPC (PPU) and the SPU. - 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. - diff --git a/Extras/simdmathlibrary/Make.defs b/Extras/simdmathlibrary/Make.defs deleted file mode 100644 index 87e9aee9b..000000000 --- a/Extras/simdmathlibrary/Make.defs +++ /dev/null @@ -1,92 +0,0 @@ -# -*- Makefile -*- -# Common definition for all make files in the libsimdmath library. -# 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. - -# PowerPC (32 bit) -ARCH_CFLAGS_ppu = -m32 -maltivec -mabi=altivec -fPIC -ARCH_LDFLAGS_ppu = -m32 -ENABLE_STATIC_ppu = 1 -ENABLE_SHARED_ppu = 1 - -# PowerPC (64 bit) -ARCH_DIR_ppu64 = ppu -ARCH_CFLAGS_ppu64 = -m64 -maltivec -mabi=altivec -fPIC -ARCH_LDFLAGS_ppu64 = -m64 -ENABLE_STATIC_ppu64 = 1 -ENABLE_SHARED_ppu64 = 1 - -# SPU -prefix_spu = /usr/spu -CROSS_spu = spu- -ENABLE_STATIC_spu = 1 -ENABLE_SHARED_spu = 0 - -# Common -prefix = $(if $(prefix_$(ARCH)),$(prefix_$(ARCH)),/usr) -DESTDIR = - -ARCH_DIR = $(if $(ARCH_DIR_$(ARCH)),$(ARCH_DIR_$(ARCH)),$(ARCH)) - -CROSS = $(CROSS_$(ARCH)) - -AR = $(CROSS)ar -CC= $(CROSS)gcc -CXX = $(CROSS)g++ -RANLIB = $(CROSS)ranlib - -ARCH_CFLAGS = $(ARCH_CFLAGS_$(ARCH)) -ARCH_LDFLAGS = $(ARCH_LDFLAGS_$(ARCH)) - -CFLAGS = -O2 -W -Wall -std=gnu99 -I. -I$(topdir)/common $(ARCH_CFLAGS) -LDFLAGS = $(ARCH_LDFLAGS) - -ENABLE_STATIC = $(ENABLE_STATIC_$(ARCH)) -ENABLE_SHARED = $(ENABLE_SHARED_$(ARCH)) - -INSTALL = install - -TEST_CMD = - -LIB_MAJOR_VERSION = 1 -LIB_MINOR_VERSION = 0 -LIB_RELEASE = 2 -LIB_FULL_VERSION = $(LIB_MAJOR_VERSION).$(LIB_MINOR_VERSION).$(LIB_RELEASE) - -LIB_BASE = simdmath -LIB_NAME = lib$(LIB_BASE) - -STATIC_LIB = $(LIB_NAME).a -ALL_STATIC_LIBS = $(STATIC_LIB) - -SHARED_LIB = $(LIB_NAME).so -SHARED_LIB_SONAME = $(SHARED_LIB).$(LIB_MAJOR_VERSION) -SHARED_LIB_FULL = $(SHARED_LIB).$(LIB_FULL_VERSION) -ALL_SHARED_LIBS = $(SHARED_LIB) $(SHARED_LIB_FULL) $(SHARED_LIB_SONAME) - -TAR_NAME = $(LIB_BASE)-$(LIB_FULL_VERSION) -TAR_BALL = $(TAR_NAME).tar.gz diff --git a/Extras/simdmathlibrary/Make.rules b/Extras/simdmathlibrary/Make.rules deleted file mode 100644 index ff58e2fb4..000000000 --- a/Extras/simdmathlibrary/Make.rules +++ /dev/null @@ -1,82 +0,0 @@ -# -*- Makefile -*- -# Common make rules for all make files in the libsimdmath library. -# 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. - -ifeq ($(ENABLE_STATIC),1) - ALL_LIBS += $(ALL_STATIC_LIBS) - INSTALL_LIBS += install-static -endif - -ifeq ($(ENABLE_SHARED),1) - ALL_LIBS += $(ALL_SHARED_LIBS) - INSTALL_LIBS += install-shared -endif - -all: $(ALL_LIBS) - -static: $(STATIC_LIB) - -shared: $(SHARED_LIB) - -$(STATIC_LIB): $(OBJS) - $(AR) cr $@ $(OBJS) - $(RANLIB) $@ - -$(SHARED_LIB_FULL): $(OBJS) - $(CC) -shared $(OBJS) -o $@ $(LDFLAGS) -Wl,-h,$(SHARED_LIB_SONAME) - -$(SHARED_LIB) $(SHARED_LIB_SONAME): $(SHARED_LIB_FULL) - ln -fs $(SHARED_LIB_FULL) $@ - -install: install-headers $(INSTALL_LIBS) - -install-headers: - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/simdmath - $(INSTALL) -m 644 simdmath/*.h $(DESTDIR)$(prefix)/include/simdmath/ - -install-static: $(ALL_STATIC_LIBS) - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/lib - $(INSTALL) -m 644 $(STATIC_LIB) $(DESTDIR)$(prefix)/lib/$(STATIC_LIB) - -install-shared: $(ALL_SHARED_LIBS) - $(INSTALL) -m 755 $(SHARED_LIB_FULL) $(DESTDIR)$(prefix)/lib/$(SHARED_LIB_FULL) - ln -fs $(SHARED_LIB_FULL) $(DESTDIR)$(prefix)/lib/$(SHARED_LIB_SONAME) - ln -fs $(SHARED_LIB_SONAME) $(DESTDIR)$(prefix)/lib/$(SHARED_LIB) - -clean: - $(MAKE) -C tests clean - -rm -f $(OBJS) - -rm -f $(STATIC_LIB) $(SHARED_LIB) $(SHARED_LIB_SONAME) $(SHARED_LIB_FULL) - -check: $(ALL_LIBS) - $(MAKE) -C tests all - $(MAKE) -C tests check - -%.o: ../common/%.c simdmath/%.h - $(CC) $(CFLAGS) -c -o $@ $< diff --git a/Extras/simdmathlibrary/Make.test b/Extras/simdmathlibrary/Make.test deleted file mode 100644 index 59c977276..000000000 --- a/Extras/simdmathlibrary/Make.test +++ /dev/null @@ -1,87 +0,0 @@ -# -*- Makefile -*- -# Common make rules for tests in the libsimdmath library. -# 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. - -STATIC_TESTS = $(TESTS) -SHARED_TESTS = $(TESTS:=.shared) - -ifeq ($(ENABLE_STATIC),1) - ALL_TESTS += $(STATIC_TESTS) -endif - -ifeq ($(ENABLE_SHARED),1) - ALL_TESTS += $(SHARED_TESTS) -endif - -STATIC_LDFLAGS = -static -SHARED_LDFLAGS = -Wl,-rpath=.. - -LDFLAGS += -L../ -l$(LIB_BASE) -lm - -all: $(ALL_TESTS) - -$(STATIC_TESTS): %: %.o ../$(STATIC_LIB) $(OBJS) - $(CC) $*.o $(OBJS) $(LDFLAGS) $(STATIC_LDFLAGS) -o $@ - -$(SHARED_TESTS): %.shared: %.o ../$(SHARED_LIB) $(OBJS) - $(CC) $*.o $(OBJS) $(LDFLAGS) $(SHARED_LDFLAGS) -o $@ - -clean: - rm -f *.o - rm -f $(STATIC_TESTS) $(SHARED_TESTS) - rm -f core* - -check: $(ALL_TESTS) - for test in $(ALL_TESTS); do \ - echo "TEST $${test}"; \ - if $(TEST_CMD) ./$${test}; then \ - pass="$$pass $$test"; \ - else \ - fail="$$fail $$test"; \ - fi \ - done; \ - echo; echo "PASS:$$pass"; echo "FAIL:$$fail"; \ - test -z "$$fail" - -static_check: - $(MAKE) ALL_TESTS="$(STATIC_TESTS)" check - -shared_check: - $(MAKE) ALL_TESTS="$(SHARED_TESTS)" check - -../$(STATIC_LIB): - $(MAKE) -C .. $(STATIC_LIB) - -../$(SHARED_LIB): - $(MAKE) -C .. $(SHARED_LIB) - -%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< - -%.o: %.cc - $(CXX) $(CFLAGS) -c -o $@ $< diff --git a/Extras/simdmathlibrary/Makefile b/Extras/simdmathlibrary/Makefile deleted file mode 100644 index 70e083939..000000000 --- a/Extras/simdmathlibrary/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# Toplevel make file to build the libsimdmath library for both SPU and PPU -# 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. - -topdir = . -ARCH = unknown - -include $(topdir)/Make.defs - -SUBDIRS = common $(ARCH_DIR) - -all install check: - @for _d in $(SUBDIRS); do $(MAKE) -C $$_d $@ || exit 1; done - -clean: - -@for _d in $(SUBDIRS); do $(MAKE) -C $$_d $@; done - -rm -rf $(TAR_BALL) .dist - -dist: - -rm -rf .dist - mkdir -p .dist/$(TAR_NAME) - find . -name .dist -prune -o -name '*~' -prune -o \ - -name .CVS -prune -o -name .svn -prune -o \ - -name .pc -prune -o -name patches -prune -o \ - '(' -name README -o -name LICENSE -o \ - -name 'Make*' -o -name '*.[ch]' -o -name '*.spec' ')' \ - -print | tar -T - -cf - | tar xf - -C .dist/$(TAR_NAME) - tar zcf $(TAR_BALL) -C .dist $(TAR_NAME) - -rm -rf .dist diff --git a/Extras/simdmathlibrary/README b/Extras/simdmathlibrary/README deleted file mode 100644 index 638535f22..000000000 --- a/Extras/simdmathlibrary/README +++ /dev/null @@ -1,128 +0,0 @@ - SIMD math library - - -* Overview - - The SIMD math library (SIMD math lib) is a SIMDized version of the - C99 standard math library (libm). - - -* License - - This library is licensed under the terms in the file 'LICENSE' in - this directory. - - -* Installing - - To install this library, run following commands: - - - 32 bit mode PowerPC with VMX - - $ make ARCH=ppu - $ make ARCH=ppu install - - - 64 bit mode PowerPC with VMX - - $ make ARCH=ppu64 - $ make ARCH=ppu64 install - - - SPU (Cell Broadband Engine Synergistic Processor Unit) - - $ make ARCH=spu - $ make ARCH=spu install - - The same library is created and installed for SPU regardless of - PPU's mode. - - - By default, files in the library will be placed as below: - - - libraries (except SPU library) - - /usr/lib/libsimdmath.a (static library) - /usr/lib/libsimdmath.so (shared library) - - - headers (except SPU headers) - - /usr/lib/simdmath.h (main header) - /usr/lib/simdmath/.h (header of inline version) - - - SPU library - - /usr/spu/lib/libsimdmath.a (static library) - (no shared library for SPU) - - - SPU headers - - /usr/spu/lib/simdmath.h (main header) - /usr/spu/lib/simdmath/.h (header of inline version) - - -* Packaging - - By running following command in this directory, a source tarball - 'simdmath-.tar.gz' can be created: - - $ make dist - - You can also create RPM packages by executing the command below with - the tarball: - - $ rpmbuild -tb simdmath-1.0.1.tar.gz --target=ppc - - Three packages, simdmath, simdmath-devel and spu-simdmath-devel, - will be created. - - -* Quick start - - - Including headers - - You must include the header simdmat.h in your source code, as - following: - - e.g.) - - #include - - If you want to use inlined version of the functions, you need to - include simdmath/.h instead of simdmath.h: - - e.g.) - - #include - - - Linking with library - - If you use non-inlined version of the library, you need to link - the library libsimdmath.a or libsimdmath.so: - - e.g.) - - $ gcc -o foo foo.o -lsimdmath - $ spu-gcc -o bar bar.o -lsimdmath - - - Function reference - - To obtain details about each function in this library, the - specification document "SIMD Math Library Specification for Cell - Broadband Engine Architecture" is avaiable at - "http://cell.scei.co.jp/". - - Note that the name of each inlined version of function is prefixed - by a character '_' against the corresponding non-inlined one. - - -* Contacting the project - - Module maintainer: Erwin Coumans - - Feedback and patches: - http://www.bulletphysics.com/Bullet/phpBB2/viewforum.php?f=18 - - Main repository URL: - http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/simdmathlibrary - ---- -EOF diff --git a/Extras/simdmathlibrary/common/Makefile b/Extras/simdmathlibrary/common/Makefile deleted file mode 100644 index 62c98329e..000000000 --- a/Extras/simdmathlibrary/common/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# make file to build the libsimdmath library for PPU and SPU -# 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. - -topdir = .. -ARCH = unknown - -include $(topdir)/Make.defs - -all: - @true - -install: - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/simdmath - $(INSTALL) -m 644 simdmath.h $(DESTDIR)$(prefix)/include/ - $(INSTALL) -m 644 simdmath/*.h $(DESTDIR)$(prefix)/include/simdmath/ - -check: - @true - -clean: - @true diff --git a/Extras/simdmathlibrary/common/absi4.c b/Extras/simdmathlibrary/common/absi4.c deleted file mode 100644 index 220103e5e..000000000 --- a/Extras/simdmathlibrary/common/absi4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* absi4 - for each of four integer slots, compute absolute value. - 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. - */ - -#include - -vector signed int -absi4 (vector signed int x) -{ - return _absi4( x ); -} diff --git a/Extras/simdmathlibrary/common/acosf4.c b/Extras/simdmathlibrary/common/acosf4.c deleted file mode 100644 index f43eacb57..000000000 --- a/Extras/simdmathlibrary/common/acosf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* acosf4 - - 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. - */ - -#include - -vector float -acosf4 (vector float x) -{ - return _acosf4( x ); -} diff --git a/Extras/simdmathlibrary/common/asinf4.c b/Extras/simdmathlibrary/common/asinf4.c deleted file mode 100644 index b71329238..000000000 --- a/Extras/simdmathlibrary/common/asinf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* asinf4 - Computes the inverse sine of all four slots of x - 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. - */ - -#include - -vector float -asinf4 (vector float x) -{ - return _asinf4( x ); -} diff --git a/Extras/simdmathlibrary/common/atan2f4.c b/Extras/simdmathlibrary/common/atan2f4.c deleted file mode 100644 index c7282f6f7..000000000 --- a/Extras/simdmathlibrary/common/atan2f4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* atan2f4 - - 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. - */ - -#include - -vector float -atan2f4 (vector float y, vector float x) -{ - return _atan2f4( y, x ); -} diff --git a/Extras/simdmathlibrary/common/atanf4.c b/Extras/simdmathlibrary/common/atanf4.c deleted file mode 100644 index 0fc50733b..000000000 --- a/Extras/simdmathlibrary/common/atanf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* atanf4 - - 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. - */ - -#include - -vector float -atanf4 (vector float x) -{ - return _atanf4( x ); -} diff --git a/Extras/simdmathlibrary/common/cbrtf4.c b/Extras/simdmathlibrary/common/cbrtf4.c deleted file mode 100644 index a51e8b1a0..000000000 --- a/Extras/simdmathlibrary/common/cbrtf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* cbrtf4 - - 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. - */ - -#include - -vector float -cbrtf4 (vector float x) -{ - return _cbrtf4( x ); -} diff --git a/Extras/simdmathlibrary/common/ceild2.c b/Extras/simdmathlibrary/common/ceild2.c deleted file mode 100644 index be4f3ffa2..000000000 --- a/Extras/simdmathlibrary/common/ceild2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ceild2 - for each of two doule slots, round up to smallest integer not less than the value. - 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. - */ - -#include - -vector double -ceild2(vector double in) -{ - return _ceild2(in); -} diff --git a/Extras/simdmathlibrary/common/ceilf4.c b/Extras/simdmathlibrary/common/ceilf4.c deleted file mode 100644 index d5de69d8b..000000000 --- a/Extras/simdmathlibrary/common/ceilf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ceilf4 - for each of four float slots, round up to smallest integer not less than the value. - 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. - */ - -#include - -vector float -ceilf4 (vector float x) -{ - return _ceilf4( x ); -} diff --git a/Extras/simdmathlibrary/common/common-test.h b/Extras/simdmathlibrary/common/common-test.h deleted file mode 100644 index 175effa6e..000000000 --- a/Extras/simdmathlibrary/common/common-test.h +++ /dev/null @@ -1,228 +0,0 @@ -/* Header file for common parts of the testsuite - 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. - */ - - -#include - -#ifdef __SPU__ - -#include - -static inline unsigned long long clock_start(void) -{ - spu_writech(SPU_WrDec, 0); - return -spu_readch(SPU_RdDec); -} - -static inline unsigned long long clock_stop(void) -{ - return -spu_readch(SPU_RdDec); -} - -#else - -static inline unsigned long long clock(void) -{ - unsigned long long ret; - /* This need to be fixed for the hardware errata. */ - __asm __volatile__ ( "mftb %0\n" - : "=r" (ret) - : - : "memory"); - return (ret); -} - -static inline unsigned long long clock_start(void) -{ - return clock(); -} - -static inline unsigned long long clock_stop(void) -{ - return clock(); -} - -#endif - -// Test files begin with TEST_SET_START("your initials","test set description") -// Individual tests begin with TEST_START("name of test") -// and end with TEST_PASS(), TEST_FAIL("reason for failure") or TEST_CHECK() -// Or you can run a test encapsulated in a function with: -// TEST_FUNCTION("name of test", function(), "reason for failure") -// -// The clock starts when you call TEST_START and stops with TEST_PASS, TEST_FAIL or TEST_CHECK -// After a start there can be several PASS, FAIL or CHECK calls, each one counts as a test, time is measured from the prior call -// -char - *__initials, // Test owner's initials - *__description, // short descriptive name for this test set - *__name, // name of the currently running test - *__set_id; // id of the the test set -int -// __zip=0, - __success=1, // set to 0 if any tests failed - __count, // Total number of tests run - __passed; // Total number of tests passed -unsigned long long - __ttemp, - __time, // For timing tests (usually start time of last test) - __ttime; // Cumulative test runtime NOT counting runtime of the TEST macros - -// TEST_SET_START -// Call at the start of a set of related tests to identify them -// Prints a "start of set banner message" -// set_id - unique test set identifyer a time in the format yyyymmddhhmmss followed by your initials ie: 20040716104615GAC -// initials - your initials -// description - brief descriptive name for this test set -#define TEST_SET_START(set_id,initials,description) \ - do { \ - __set_id=set_id; \ - __initials=initials; \ - __description=description; \ - __count=0; \ - __passed=0; \ - __ttime=0; \ - printf("0\t%s\t%d\t%s\tSTART\tpassed\ttotal\ttime\t%s\tunique test id \t%s\n",__FILE__,__LINE__,__initials,__set_id, __description); \ - __time = clock_start(); \ - } while(0) - -// TEST_START -// Begins a test, and starts the clock -// name - brief name for this test -#define TEST_START(name) \ - do { \ - (void)clock_stop(); \ - __name=name; \ - __time = clock_start(); \ - } while(0) - -// TEST_PASS -// Indicates the test passed -// test_id - unique test ID number, same format as the set_id number -// This should match the id provided to the matching TEST_FAIL call -#define TEST_PASS(test_id) \ - do { \ - __ttemp=clock_stop(); \ - __time=__ttemp-__time; \ - __ttime+=__time; \ - __count++; \ - __passed++; \ - printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%lld\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \ - __time=clock_start(); \ - } while(0) - -// TEST_FAIL -// Indicates the test failed -// test_id - unique test ID number, same format as the set_id number -// This should match the id provided to the matching TEST_PASS call -// why - brief description of why it failed -#define TEST_FAIL(test_id,why,error_code) \ - do { \ - __ttemp=clock_stop(); \ - __time=__ttemp-__time; \ - __ttime+=__time; \ - __count++; \ - __success=0; \ - printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%lld\t%s\t%s\t%s\tFAILED BECAUSE: %s\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,why,error_code); \ - __time=clock_start(); \ - } while(0) - -// TEST_CHECK -// Passes or fails the test after evaluating the "test" argument (just like assert but without terminating the program) -// The clock is immediately stopped so the time required to evaluate "test" will NOT be included in the reported time -// If the test failed, the reason will be printed as FAILED BECAUSE: check (value of "test") failed -// test_id - unique test ID number, same format as the set_id number -// test - expression evaluating to true/false -#define TEST_CHECK(test_id,test,error_code) \ - do { \ - __ttemp=clock_stop(); \ - __time=__ttemp-__time; \ - __ttime+=__time; \ - __count++; \ - if(test) \ - { \ - __passed++; \ - printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%lld\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \ - } \ - else \ - { \ - __success=0; \ - printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%lld\t%s\t%s\t%s\tFAILED BECAUSE: check %s failed\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,#test,error_code); \ - } \ - __time=clock_start(); \ - } while(0) - -// TEST_FUNCTION -// Runs a test encapsulated in a function that returns 0 if the test passed and an error number if it failed -// The clock is started on calling the function and stopped as soon as it returns so the branching logic will not be included in the time -// test_id - unique test ID number, same format as the set_id number -// name - brief name for the test -// func - function invocation (should include parenthesis, may have arguments) -// why - brief description to print if the test fails -#define TEST_FUNCTION(test_id,name,func,why) \ - do { \ - TEST_START(name); \ - int result=func; \ - __ttemp=clock_stop(); \ - __time=__ttemp-__time; \ - __ttime+=__time; \ - __count++; \ - if(result==0) \ - { \ - __passed++; \ - printf("1\t%s\t%d\t%s\tPASS\t%d\t%d\t%d\t%s\t%s\t%s\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name); \ - } \ - else \ - { \ - __success=0; \ - printf("1\t%s\t%d\t%s\tFAIL\t%d\t%d\t%d\t%s\t%s\t%s\tFAILED BECAUSE: %s\t%d\n",__FILE__,__LINE__,__initials,__passed,__count,__time,__set_id,test_id,__name,why,result); \ - } \ - __time=clock_start(); \ - } while(0) - -// TEST_SET_DONE -// Ends a set of tests, prints out the closing banner (OK if all tests pass, PROBLEM if any fail) -// Also prints count of tests passed, tests run and total time -#define TEST_SET_DONE() \ - do { \ - printf("9\t%s\t%d\t%s\t%s\t%d\t%d\t%lld\t%s\tunique test id \t%s\n",__FILE__,__LINE__,__initials,(__count==__passed)?"OK":"PROBLEM",__passed,__count,__ttime,__set_id,__description); \ - } while(0) - -// TEST_EXIT -// Call this ONCE at the very end of the test program, it calls "exit" to return -// EXIT_SUCCESS if all tests passed or EXIT_FAILURE if any tests failed. -// This allows the makefile/shell script running the tests to know which ones failed -#define TEST_EXIT() \ - do { \ - printf("FINISHED!\n"); \ - if(__success) \ - exit(0); \ - else \ - exit(-1); \ - } while (0) diff --git a/Extras/simdmathlibrary/common/copysignd2.c b/Extras/simdmathlibrary/common/copysignd2.c deleted file mode 100644 index 0321c1ef6..000000000 --- a/Extras/simdmathlibrary/common/copysignd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* copysignd2 - for each of two double slots, return value with magnitude from x and sign from y. - 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. - */ - -#include - -vector double -copysignd2 (vector double x, vector double y) -{ - return _copysignd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/copysignf4.c b/Extras/simdmathlibrary/common/copysignf4.c deleted file mode 100644 index 88575310b..000000000 --- a/Extras/simdmathlibrary/common/copysignf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* copysignf4 - for each of four float slots, return value with magnitude from x and sign from y. - 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. - */ - -#include - -vector float -copysignf4 (vector float x, vector float y) -{ - return _copysignf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/cosd2.c b/Extras/simdmathlibrary/common/cosd2.c deleted file mode 100644 index 8e9167f18..000000000 --- a/Extras/simdmathlibrary/common/cosd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* cosd2 - Computes the cosine of the each of two double slots. - 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. - */ - -#include - -vector double -cosd2 (vector double x) -{ - return _cosd2(x); -} diff --git a/Extras/simdmathlibrary/common/cosf4.c b/Extras/simdmathlibrary/common/cosf4.c deleted file mode 100644 index 1570c5ee5..000000000 --- a/Extras/simdmathlibrary/common/cosf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* cosf4 - - 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. - */ - -#include - -vector float -cosf4 (vector float x) -{ - return _cosf4( x ); -} diff --git a/Extras/simdmathlibrary/common/divd2.c b/Extras/simdmathlibrary/common/divd2.c deleted file mode 100644 index 4c18c2d32..000000000 --- a/Extras/simdmathlibrary/common/divd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* divd2 - for each of two double slots, divide numer by denom. - 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. - */ - -#include - -vector double -divd2 (vector double numer, vector double denom) -{ - return _divd2(numer, denom); -} diff --git a/Extras/simdmathlibrary/common/divf4.c b/Extras/simdmathlibrary/common/divf4.c deleted file mode 100644 index 45aa122ea..000000000 --- a/Extras/simdmathlibrary/common/divf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* divf4 - for each of four float slots, divide numer by denom. - 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. - */ - -#include - -vector float -divf4 (vector float numer, vector float denom) -{ - return _divf4( numer, denom ); -} diff --git a/Extras/simdmathlibrary/common/divi4.c b/Extras/simdmathlibrary/common/divi4.c deleted file mode 100644 index 7d2910a25..000000000 --- a/Extras/simdmathlibrary/common/divi4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* divi4 - - 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. - */ - -#include - -divi4_t -divi4 (vector signed int numer, vector signed int denom ) -{ - return _divi4( numer, denom ); -} diff --git a/Extras/simdmathlibrary/common/divu4.c b/Extras/simdmathlibrary/common/divu4.c deleted file mode 100644 index 011030030..000000000 --- a/Extras/simdmathlibrary/common/divu4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* divu4 - - 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. - */ - -#include - -divu4_t -divu4 (vector unsigned int numer, vector unsigned int denom) -{ - return _divu4(numer, denom); -} diff --git a/Extras/simdmathlibrary/common/exp2f4.c b/Extras/simdmathlibrary/common/exp2f4.c deleted file mode 100644 index 8e07fb0c8..000000000 --- a/Extras/simdmathlibrary/common/exp2f4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* exp2f4 - 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. - */ - -#include - -vector float -exp2f4 (vector float x) -{ - return _exp2f4( x ); -} diff --git a/Extras/simdmathlibrary/common/expf4.c b/Extras/simdmathlibrary/common/expf4.c deleted file mode 100644 index 3950d4b62..000000000 --- a/Extras/simdmathlibrary/common/expf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* expf4 - - 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. - */ - -#include - -vector float -expf4 (vector float x) -{ - return _expf4( x ); -} diff --git a/Extras/simdmathlibrary/common/expm1f4.c b/Extras/simdmathlibrary/common/expm1f4.c deleted file mode 100644 index faa429013..000000000 --- a/Extras/simdmathlibrary/common/expm1f4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* expm1f4 - - 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. - */ - -#include - -vector float -expm1f4 (vector float x) -{ - return _expm1f4( x ); -} diff --git a/Extras/simdmathlibrary/common/fabsd2.c b/Extras/simdmathlibrary/common/fabsd2.c deleted file mode 100644 index e38e333fc..000000000 --- a/Extras/simdmathlibrary/common/fabsd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fabsd2 - for each of two double slots, compute absolute value. - 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. - */ - -#include - -vector double -fabsd2 (vector double x) -{ - return _fabsd2(x); -} diff --git a/Extras/simdmathlibrary/common/fabsf4.c b/Extras/simdmathlibrary/common/fabsf4.c deleted file mode 100644 index 2fd7d2249..000000000 --- a/Extras/simdmathlibrary/common/fabsf4.c +++ /dev/null @@ -1,37 +0,0 @@ -/* fabsf4 - for each of four float slots, compute absolute value. - 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. - */ - -#include - -vector float -fabsf4 (vector float x) -{ - return _fabsf4( x ); -} - diff --git a/Extras/simdmathlibrary/common/fdimd2.c b/Extras/simdmathlibrary/common/fdimd2.c deleted file mode 100644 index 447f57b63..000000000 --- a/Extras/simdmathlibrary/common/fdimd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fdimd2 - 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. - */ - -#include - -vector double -fdimd2 (vector double x, vector double y) -{ - return _fdimd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/fdimf4.c b/Extras/simdmathlibrary/common/fdimf4.c deleted file mode 100644 index d476788a1..000000000 --- a/Extras/simdmathlibrary/common/fdimf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fdimf - - 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. - */ - -#include - -vector float -fdimf4 (vector float x, vector float y) -{ - return _fdimf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/floord2.c b/Extras/simdmathlibrary/common/floord2.c deleted file mode 100644 index 0dec5d5c2..000000000 --- a/Extras/simdmathlibrary/common/floord2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* floord2 - for each of two doule slots, round up to smallest integer not more than the value. - 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. - */ - -#include - -vector double -floord2(vector double in) -{ - return _floord2(in); -} diff --git a/Extras/simdmathlibrary/common/floorf4.c b/Extras/simdmathlibrary/common/floorf4.c deleted file mode 100644 index 3ef6e6f60..000000000 --- a/Extras/simdmathlibrary/common/floorf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* floorf4 - for each of four float slots, round down to largest integer not greater than the value. - 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. - */ - -#include - -vector float -floorf4 (vector float x) -{ - return _floorf4( x ); -} diff --git a/Extras/simdmathlibrary/common/fmad2.c b/Extras/simdmathlibrary/common/fmad2.c deleted file mode 100644 index b470080cf..000000000 --- a/Extras/simdmathlibrary/common/fmad2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmad2 - 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. - */ - -#include - -vector double -fmad2 (vector double x, vector double y, vector double z) -{ - return _fmad2(x, y, z); -} diff --git a/Extras/simdmathlibrary/common/fmaf4.c b/Extras/simdmathlibrary/common/fmaf4.c deleted file mode 100644 index b26afbcb8..000000000 --- a/Extras/simdmathlibrary/common/fmaf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmaf4 - 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. - */ - -#include - -vector float -fmaf4 (vector float x, vector float y, vector float z) -{ - return _fmaf4( x, y, z ); -} diff --git a/Extras/simdmathlibrary/common/fmaxd2.c b/Extras/simdmathlibrary/common/fmaxd2.c deleted file mode 100644 index 1380f280e..000000000 --- a/Extras/simdmathlibrary/common/fmaxd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmaxd2 - for each of two double slots, compute maximum of x and y - 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. - */ - -#include - -vector double -fmaxd2 (vector double x, vector double y) -{ - return _fmaxd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/fmaxf4.c b/Extras/simdmathlibrary/common/fmaxf4.c deleted file mode 100644 index ca5169274..000000000 --- a/Extras/simdmathlibrary/common/fmaxf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmaxf4 - for each of four float slots, compute maximum of x and y - 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. - */ - -#include - -vector float -fmaxf4 (vector float x, vector float y) -{ - return _fmaxf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/fmind2.c b/Extras/simdmathlibrary/common/fmind2.c deleted file mode 100644 index b30242f71..000000000 --- a/Extras/simdmathlibrary/common/fmind2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmind2 - for each of two double slots, compute minimum of x and y - 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. - */ - -#include - -vector double -fmind2 (vector double x, vector double y) -{ - return _fmind2(x, y); -} diff --git a/Extras/simdmathlibrary/common/fminf4.c b/Extras/simdmathlibrary/common/fminf4.c deleted file mode 100644 index 6bc2db8d4..000000000 --- a/Extras/simdmathlibrary/common/fminf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fminf4 - for each of four float slots, compute minimum of x and y - 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. - */ - -#include - -vector float -fminf4 (vector float x, vector float y) -{ - return _fminf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/fmodd2.c b/Extras/simdmathlibrary/common/fmodd2.c deleted file mode 100644 index 7428a9ab2..000000000 --- a/Extras/simdmathlibrary/common/fmodd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmodd2 - - 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. - */ - -#include - -vector double -fmodd2(vector double x, vector double y) -{ - return _fmodd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/fmodf4.c b/Extras/simdmathlibrary/common/fmodf4.c deleted file mode 100644 index d5446b44b..000000000 --- a/Extras/simdmathlibrary/common/fmodf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fmodf4 - for each of four float slots, compute remainder of x/y defined as x - truncated_integer(x/y) * y. - 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. - */ - -#include - -vector float -fmodf4 (vector float x, vector float y) -{ - return _fmodf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/fpclassifyd2.c b/Extras/simdmathlibrary/common/fpclassifyd2.c deleted file mode 100644 index b0f55bea6..000000000 --- a/Extras/simdmathlibrary/common/fpclassifyd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fpclassifyd2 - for each element of vector x, return classification of x': FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO - 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. - */ - -#include - -vector signed long long -fpclassifyd2 (vector double x) -{ - return _fpclassifyd2(x); -} diff --git a/Extras/simdmathlibrary/common/fpclassifyf4.c b/Extras/simdmathlibrary/common/fpclassifyf4.c deleted file mode 100644 index 1bc07c67a..000000000 --- a/Extras/simdmathlibrary/common/fpclassifyf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* fpclassifyf4 - for each element of vector x, return classification of x': FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO - 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. - */ - -#include - -vector signed int -fpclassifyf4 (vector float x) -{ - return _fpclassifyf4(x); -} diff --git a/Extras/simdmathlibrary/common/frexpd2.c b/Extras/simdmathlibrary/common/frexpd2.c deleted file mode 100644 index c950cacbe..000000000 --- a/Extras/simdmathlibrary/common/frexpd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* frexpd2 - for each element of vector x, return the normalized fraction and store the exponent of x' - 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. - */ - -#include - -vector double -frexpd2 (vector double x, vector signed long long *pexp) -{ - return _frexpd2(x, pexp); -} diff --git a/Extras/simdmathlibrary/common/frexpf4.c b/Extras/simdmathlibrary/common/frexpf4.c deleted file mode 100644 index f65c52079..000000000 --- a/Extras/simdmathlibrary/common/frexpf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* frexpf4 - - 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. - */ - -#include - -vector float -frexpf4 (vector float x, vector signed int *exp) -{ - return _frexpf4( x, exp ); -} diff --git a/Extras/simdmathlibrary/common/hypotd2.c b/Extras/simdmathlibrary/common/hypotd2.c deleted file mode 100644 index ab8edcae6..000000000 --- a/Extras/simdmathlibrary/common/hypotd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* hypotd2 - for each element of vector x and y, return the square root of (x')^2 + (y')^2 - 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. - */ - -#include - -vector double -hypotd2 (vector double x, vector double y) -{ - return _hypotd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/hypotf4.c b/Extras/simdmathlibrary/common/hypotf4.c deleted file mode 100644 index 7bcf73c3b..000000000 --- a/Extras/simdmathlibrary/common/hypotf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* hypotf4 - - 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. - */ - -#include - -vector float -hypotf4 (vector float x, vector float y) -{ - return _hypotf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/ilogbd2.c b/Extras/simdmathlibrary/common/ilogbd2.c deleted file mode 100644 index c0a74521d..000000000 --- a/Extras/simdmathlibrary/common/ilogbd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ilogbd2 - for each element of vector x, return integer exponent of normalized double x', FP_ILOGBNAN, or FP_ILOGB0 - 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. - */ - -#include - -vector signed long long -ilogbd2 (vector double x) -{ - return _ilogbd2(x); -} diff --git a/Extras/simdmathlibrary/common/ilogbf4.c b/Extras/simdmathlibrary/common/ilogbf4.c deleted file mode 100644 index 0dd3a0268..000000000 --- a/Extras/simdmathlibrary/common/ilogbf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ilogbf4 - - 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. - */ - -#include - -vector signed int -ilogbf4 (vector float x) -{ - return _ilogbf4( x ); -} diff --git a/Extras/simdmathlibrary/common/irintf4.c b/Extras/simdmathlibrary/common/irintf4.c deleted file mode 100644 index 2378b67c5..000000000 --- a/Extras/simdmathlibrary/common/irintf4.c +++ /dev/null @@ -1,39 +0,0 @@ -/* irintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model. - On SPU, the rounding mode for float is always towards zero. - vector singned int is returned. - 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. - */ - -#include - -vector signed int -irintf4(vector float in) -{ - return _irintf4(in); -} diff --git a/Extras/simdmathlibrary/common/iroundf4.c b/Extras/simdmathlibrary/common/iroundf4.c deleted file mode 100644 index 8f2f4c8c8..000000000 --- a/Extras/simdmathlibrary/common/iroundf4.c +++ /dev/null @@ -1,38 +0,0 @@ -/* iroundf4 - for each of four float slots, round to the nearest integer, - halfway cases are rounded away form zero. - - 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. - */ - -#include - -vector signed int -iroundf4(vector float in) -{ - return _iroundf4(in); -} diff --git a/Extras/simdmathlibrary/common/is0denormd2.c b/Extras/simdmathlibrary/common/is0denormd2.c deleted file mode 100644 index 75496664c..000000000 --- a/Extras/simdmathlibrary/common/is0denormd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* is0denormd2 - for each of two double slots, if input equals 0 or denorm return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -is0denormd2 (vector double x) -{ - return _is0denormd2(x); -} diff --git a/Extras/simdmathlibrary/common/is0denormf4.c b/Extras/simdmathlibrary/common/is0denormf4.c deleted file mode 100644 index 9e665b12a..000000000 --- a/Extras/simdmathlibrary/common/is0denormf4.c +++ /dev/null @@ -1,35 +0,0 @@ -/* is0denormf4 - for each element of vector x, return a mask of ones if x' is zero or denorm, zero otherwise - 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. - */ -#include - -vector unsigned int -is0denormf4 (vector float x) -{ - return _is0denormf4(x); -} diff --git a/Extras/simdmathlibrary/common/isequald2.c b/Extras/simdmathlibrary/common/isequald2.c deleted file mode 100644 index eeda92f76..000000000 --- a/Extras/simdmathlibrary/common/isequald2.c +++ /dev/null @@ -1,35 +0,0 @@ -/* isequald2 - for each of two double slots, if x = y return a mask of ones, else zero - 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. - */ -#include - -vector unsigned long long -isequald2 (vector double x, vector double y) -{ - return _isequald2(x, y); -} diff --git a/Extras/simdmathlibrary/common/isequalf4.c b/Extras/simdmathlibrary/common/isequalf4.c deleted file mode 100644 index 0bc43ba9f..000000000 --- a/Extras/simdmathlibrary/common/isequalf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isequalf4 - for each element of vector x and y, return a mask of ones if x' is equal to y', zero otherwise - 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. - */ - -#include - -vector unsigned int -isequalf4 (vector float x, vector float y) -{ - return _isequalf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/isfinited2.c b/Extras/simdmathlibrary/common/isfinited2.c deleted file mode 100644 index 2ccc0a870..000000000 --- a/Extras/simdmathlibrary/common/isfinited2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* isfinited2 - for each element of vector x, return a mask of ones if x' is finite, zero otherwise - 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. - */ - -#include - -vector unsigned long long -isfinited2 (vector double x) -{ - return _isfinited2(x); -} - diff --git a/Extras/simdmathlibrary/common/isfinitef4.c b/Extras/simdmathlibrary/common/isfinitef4.c deleted file mode 100644 index 52d37a139..000000000 --- a/Extras/simdmathlibrary/common/isfinitef4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isfinitef4 - for each element of vector x, return a mask of ones if x' is finite, zero otherwise - 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. - */ - -#include - -vector unsigned int -isfinitef4 (vector float x) -{ - return _isfinitef4(x); -} diff --git a/Extras/simdmathlibrary/common/isgreaterd2.c b/Extras/simdmathlibrary/common/isgreaterd2.c deleted file mode 100644 index ff9fd0db6..000000000 --- a/Extras/simdmathlibrary/common/isgreaterd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isgreaterd2 - for each of two double slots, if x > y return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -isgreaterd2 (vector double x, vector double y) -{ - return _isgreaterd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/isgreaterequald2.c b/Extras/simdmathlibrary/common/isgreaterequald2.c deleted file mode 100644 index d8a9c4515..000000000 --- a/Extras/simdmathlibrary/common/isgreaterequald2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isgreaterequald2 - for each of two double slots, if x is greater or equal to y return a mask of ones, else zero - 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. - */ - -#include - -vector unsigned long long -isgreaterequald2 (vector double x, vector double y) -{ - return _isgreaterequald2(x, y); -} diff --git a/Extras/simdmathlibrary/common/isgreaterequalf4.c b/Extras/simdmathlibrary/common/isgreaterequalf4.c deleted file mode 100644 index e06dd0ff4..000000000 --- a/Extras/simdmathlibrary/common/isgreaterequalf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isgreaterequalf4 - for each element of vector x and y, return a mask of ones if x' is greater than or equal to y', zero otherwise - 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. - */ - -#include - -vector unsigned int -isgreaterequalf4 (vector float x, vector float y) -{ - return _isgreaterequalf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/isgreaterf4.c b/Extras/simdmathlibrary/common/isgreaterf4.c deleted file mode 100644 index 22978988d..000000000 --- a/Extras/simdmathlibrary/common/isgreaterf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isgreaterf4 - for each element of vector x and y, return a mask of ones if x' is greater than y', zero otherwise - 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. - */ - -#include - -vector unsigned int -isgreaterf4 (vector float x, vector float y) -{ - return _isgreaterf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/isinfd2.c b/Extras/simdmathlibrary/common/isinfd2.c deleted file mode 100644 index 500fa2640..000000000 --- a/Extras/simdmathlibrary/common/isinfd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isinfd2 - for each of two double slots, if input equals +Inf or -Inf return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -isinfd2 (vector double x) -{ - return _isinfd2(x); -} diff --git a/Extras/simdmathlibrary/common/isinff4.c b/Extras/simdmathlibrary/common/isinff4.c deleted file mode 100644 index 15afc8b51..000000000 --- a/Extras/simdmathlibrary/common/isinff4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isinff4 - for each element of vector x, return a mask of ones if x' is INF, zero otherwise - 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. - */ - -#include - -vector unsigned int -isinff4 (vector float x) -{ - return _isinff4(x); -} diff --git a/Extras/simdmathlibrary/common/islessd2.c b/Extras/simdmathlibrary/common/islessd2.c deleted file mode 100644 index 40aecb8a1..000000000 --- a/Extras/simdmathlibrary/common/islessd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessd2 - for each of two double slots, if x < y return a mask of ones, else zero - 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. - */ - -#include - -vector unsigned long long -islessd2 (vector double x, vector double y) -{ - return _islessd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/islessequald2.c b/Extras/simdmathlibrary/common/islessequald2.c deleted file mode 100644 index 983e7491b..000000000 --- a/Extras/simdmathlibrary/common/islessequald2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessequald2 - for each of two double slots, if x <= y return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -islessequald2 (vector double x, vector double y) -{ - return _islessequald2(x, y); -} diff --git a/Extras/simdmathlibrary/common/islessequalf4.c b/Extras/simdmathlibrary/common/islessequalf4.c deleted file mode 100644 index 0eb7d7c1d..000000000 --- a/Extras/simdmathlibrary/common/islessequalf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessequalf4 - for each element of vector x and y, return a mask of ones if x' is less than or equal to y', zero otherwise - 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. - */ - -#include - -vector unsigned int -islessequalf4 (vector float x, vector float y) -{ - return _islessequalf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/islessf4.c b/Extras/simdmathlibrary/common/islessf4.c deleted file mode 100644 index e6d99f02b..000000000 --- a/Extras/simdmathlibrary/common/islessf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessf4 - for each element of vector x and y, return a mask of ones if x' is less than y', zero otherwise - 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. - */ - -#include - -vector unsigned int -islessf4 (vector float x, vector float y) -{ - return _islessf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/islessgreaterd2.c b/Extras/simdmathlibrary/common/islessgreaterd2.c deleted file mode 100644 index af4e5d812..000000000 --- a/Extras/simdmathlibrary/common/islessgreaterd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessgreaterd2 - for each of two double slots, if x is less or greater than y return a mask of ones, else zero - 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. - */ - -#include - -vector unsigned long long -islessgreaterd2 (vector double x, vector double y) -{ - return _islessgreaterd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/islessgreaterf4.c b/Extras/simdmathlibrary/common/islessgreaterf4.c deleted file mode 100644 index acb9dee9a..000000000 --- a/Extras/simdmathlibrary/common/islessgreaterf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* islessgreaterf4 - for each element of vector x and y, return a mask of ones if x' is less than or greater than y', zero otherwise - 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. - */ - -#include - -vector unsigned int -islessgreaterf4 (vector float x, vector float y) -{ - return _islessgreaterf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/isnand2.c b/Extras/simdmathlibrary/common/isnand2.c deleted file mode 100644 index cea82235b..000000000 --- a/Extras/simdmathlibrary/common/isnand2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isnand2 - for each of two double slots, if input is any type of NaN return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -isnand2 (vector double x) -{ - return _isnand2(x); -} diff --git a/Extras/simdmathlibrary/common/isnanf4.c b/Extras/simdmathlibrary/common/isnanf4.c deleted file mode 100644 index 2e0f8fe4a..000000000 --- a/Extras/simdmathlibrary/common/isnanf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isnanf4 - for each element of vector x, return a mask of ones if x' is NaN, zero otherwise - 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. - */ - -#include - -vector unsigned int -isnanf4 (vector float x) -{ - return _isnanf4(x); -} diff --git a/Extras/simdmathlibrary/common/isnormald2.c b/Extras/simdmathlibrary/common/isnormald2.c deleted file mode 100644 index 21a313f7f..000000000 --- a/Extras/simdmathlibrary/common/isnormald2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isnormald2 - for each element of vector x, return a mask of ones if x' is normal, not a NaN or INF, zero otherwise - 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. - */ - -#include - -vector unsigned long long -isnormald2 (vector double x) -{ - return _isnormald2(x); -} diff --git a/Extras/simdmathlibrary/common/isnormalf4.c b/Extras/simdmathlibrary/common/isnormalf4.c deleted file mode 100644 index 1271313fa..000000000 --- a/Extras/simdmathlibrary/common/isnormalf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isnormalf4 - for each element of vector x, return a mask of ones if x' is normal, not a NaN or INF, zero otherwise - 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. - */ - -#include - -vector unsigned int -isnormalf4 (vector float x) -{ - return _isnormalf4(x); -} diff --git a/Extras/simdmathlibrary/common/isunorderedd2.c b/Extras/simdmathlibrary/common/isunorderedd2.c deleted file mode 100644 index ee135f3e4..000000000 --- a/Extras/simdmathlibrary/common/isunorderedd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isunorderedd2 - for each element of vector x and y, return a mask of ones if x' is unordered to y', zero otherwise - 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. - */ - -#include - -vector unsigned long long -isunorderedd2 (vector double x, vector double y) -{ - return _isunorderedd2(x, y); -} diff --git a/Extras/simdmathlibrary/common/isunorderedf4.c b/Extras/simdmathlibrary/common/isunorderedf4.c deleted file mode 100644 index d216f4e7b..000000000 --- a/Extras/simdmathlibrary/common/isunorderedf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* isunorderedf4 - for each element of vector x and y, return a mask of ones if x' is unordered to y', zero otherwise - 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. - */ - -#include - -vector unsigned int -isunorderedf4 (vector float x, vector float y) -{ - return _isunorderedf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/ldexpd2.c b/Extras/simdmathlibrary/common/ldexpd2.c deleted file mode 100644 index a5b35433d..000000000 --- a/Extras/simdmathlibrary/common/ldexpd2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ldexpd2 - Multiply Double by 2 Raised to its Power - For large elements of ex (overflow), returns HUGE_VALF - For small elements of ex (underflow), returns 0. - 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. - */ - -#include - -vector double -ldexpd2(vector double x, vector signed long long ex) -{ - return _ldexpd2(x, ex); -} diff --git a/Extras/simdmathlibrary/common/ldexpf4.c b/Extras/simdmathlibrary/common/ldexpf4.c deleted file mode 100644 index e1680795d..000000000 --- a/Extras/simdmathlibrary/common/ldexpf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ldexpf4 - - 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. - */ - -#include - -vector float -ldexpf4 (vector float x, vector signed int exp) -{ - return _ldexpf4( x, exp ); -} diff --git a/Extras/simdmathlibrary/common/llabsi2.c b/Extras/simdmathlibrary/common/llabsi2.c deleted file mode 100644 index 454a3e0b0..000000000 --- a/Extras/simdmathlibrary/common/llabsi2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* llabsi2 - returns absolute value of input. - 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. - */ - -#include - -vector signed long long -llabsi2 (vector signed long long in) -{ - return _llabsi2(in); -} diff --git a/Extras/simdmathlibrary/common/lldivi2.c b/Extras/simdmathlibrary/common/lldivi2.c deleted file mode 100644 index 7e14fded3..000000000 --- a/Extras/simdmathlibrary/common/lldivi2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* lldivi2 - - 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. - */ - -#include - -lldivi2_t -lldivi2 (vector signed long long numer, vector signed long long denom) -{ - return _lldivi2(numer, denom); -} diff --git a/Extras/simdmathlibrary/common/lldivu2.c b/Extras/simdmathlibrary/common/lldivu2.c deleted file mode 100644 index 5b2fd89b0..000000000 --- a/Extras/simdmathlibrary/common/lldivu2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* lldivu2 - - 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. - */ - -#include - -lldivu2_t -lldivu2 (vector unsigned long long numer, vector unsigned long long denom) -{ - return _lldivu2(numer, denom); -} diff --git a/Extras/simdmathlibrary/common/llrintd2.c b/Extras/simdmathlibrary/common/llrintd2.c deleted file mode 100644 index 3d4456110..000000000 --- a/Extras/simdmathlibrary/common/llrintd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* llrintd2 - rounds two doubles in to two nearest 64bit integer. - consistent with the current rounding mode. - 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. - */ - -#include - -vector signed long long -llrintd2 (vector double in) -{ - return _llrintd2(in); -} diff --git a/Extras/simdmathlibrary/common/llrintf4.c b/Extras/simdmathlibrary/common/llrintf4.c deleted file mode 100644 index 96f956a2b..000000000 --- a/Extras/simdmathlibrary/common/llrintf4.c +++ /dev/null @@ -1,37 +0,0 @@ -/* llrintf4 - rounds four floats in to four nearest 64bit integer. - On SPU the rounding mode for floats is always towards 0. - 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. - */ - -#include - -llroundf4_t -llrintf4 (vector float in) -{ - return _llrintf4(in); -} diff --git a/Extras/simdmathlibrary/common/llroundd2.c b/Extras/simdmathlibrary/common/llroundd2.c deleted file mode 100644 index 680408e41..000000000 --- a/Extras/simdmathlibrary/common/llroundd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* llroundd2 - rounds two doubles in to two nearest 64bit integer. - 0.5 will be rounded to far from 0 - 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. - */ - -#include - -vector signed long long -llroundd2 (vector double in) -{ - return _llroundd2(in); -} diff --git a/Extras/simdmathlibrary/common/llroundf4.c b/Extras/simdmathlibrary/common/llroundf4.c deleted file mode 100644 index db00e9c00..000000000 --- a/Extras/simdmathlibrary/common/llroundf4.c +++ /dev/null @@ -1,37 +0,0 @@ -/* llroundf4 - rounds four floats in to four nearest 64bit integer. - 0.5 will be rounded to far from 0 - 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. - */ - -#include - -llroundf4_t -llroundf4 (vector float in) -{ - return _llroundf4(in); -} diff --git a/Extras/simdmathlibrary/common/log10f4.c b/Extras/simdmathlibrary/common/log10f4.c deleted file mode 100644 index a246f1fd1..000000000 --- a/Extras/simdmathlibrary/common/log10f4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* log10f4 - - 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. - */ - -#include - -vector float -log10f4 (vector float x) -{ - return _log10f4( x ); -} diff --git a/Extras/simdmathlibrary/common/log1pf4.c b/Extras/simdmathlibrary/common/log1pf4.c deleted file mode 100644 index 5571df07f..000000000 --- a/Extras/simdmathlibrary/common/log1pf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* log1pf4 - - 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. - */ - -#include - -vector float -log1pf4 (vector float x) -{ - return _log1pf4( x ); -} diff --git a/Extras/simdmathlibrary/common/log2f4.c b/Extras/simdmathlibrary/common/log2f4.c deleted file mode 100644 index 3c9d93a39..000000000 --- a/Extras/simdmathlibrary/common/log2f4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* log2f4 - - 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. - */ - -#include - -vector float -log2f4 (vector float x) -{ - return _log2f4( x ); -} diff --git a/Extras/simdmathlibrary/common/logbd2.c b/Extras/simdmathlibrary/common/logbd2.c deleted file mode 100644 index 0ea5b7d1d..000000000 --- a/Extras/simdmathlibrary/common/logbd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* logbd2 - for each element of vector x, return the exponent of normalized double x' as floating point value - 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. - */ - -#include - -vector double -logbd2 (vector double x) -{ - return _logbd2(x); -} diff --git a/Extras/simdmathlibrary/common/logbf4.c b/Extras/simdmathlibrary/common/logbf4.c deleted file mode 100644 index 19ab3a1ea..000000000 --- a/Extras/simdmathlibrary/common/logbf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* logbf4 - - 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. - */ - -#include - -vector float -logbf4 (vector float x) -{ - return _logbf4( x ); -} diff --git a/Extras/simdmathlibrary/common/logf4.c b/Extras/simdmathlibrary/common/logf4.c deleted file mode 100644 index fc2372e4d..000000000 --- a/Extras/simdmathlibrary/common/logf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* logf4 - - 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. - */ - -#include - -vector float -logf4 (vector float x) -{ - return _logf4( x ); -} diff --git a/Extras/simdmathlibrary/common/modfd2.c b/Extras/simdmathlibrary/common/modfd2.c deleted file mode 100644 index 52dcb3425..000000000 --- a/Extras/simdmathlibrary/common/modfd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* modfd2 - for each of two double slots, compute fractional and integral parts. - 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. - */ - -#include - -vector double -modfd2 (vector double x, vector double *iptr) -{ - return _modfd2(x, iptr); -} diff --git a/Extras/simdmathlibrary/common/modff4.c b/Extras/simdmathlibrary/common/modff4.c deleted file mode 100644 index b460ccfb3..000000000 --- a/Extras/simdmathlibrary/common/modff4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* modff4 - 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. - */ - -#include - -vector float -modff4 (vector float x, vector float *iptr) -{ - return _modff4( x, iptr ); -} diff --git a/Extras/simdmathlibrary/common/nearbyintd2.c b/Extras/simdmathlibrary/common/nearbyintd2.c deleted file mode 100644 index 354d7f08e..000000000 --- a/Extras/simdmathlibrary/common/nearbyintd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* nearbyintd2 - Round the input to the nearest integer according to - the current rounding mode without raising an inexact exception. - 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. - */ - -#include - -vector double -nearbyintd2(vector double in) -{ - return _nearbyintd2(in); -} diff --git a/Extras/simdmathlibrary/common/nearbyintf4.c b/Extras/simdmathlibrary/common/nearbyintf4.c deleted file mode 100644 index 56256501d..000000000 --- a/Extras/simdmathlibrary/common/nearbyintf4.c +++ /dev/null @@ -1,39 +0,0 @@ -/* nearbyintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model, - without raising an inexact floating-point exception. - On SPU, the rounding mode for float is always towards zero. - 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. - */ - -#include - -vector float -nearbyintf4(vector float x) -{ - return _nearbyintf4(x); -} diff --git a/Extras/simdmathlibrary/common/negated2.c b/Extras/simdmathlibrary/common/negated2.c deleted file mode 100644 index 66847d094..000000000 --- a/Extras/simdmathlibrary/common/negated2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* negated2 - for each of two double slots, negate the sign bit. - 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. - */ - -#include - -vector double -negated2 (vector double x) -{ - return _negated2(x); -} - diff --git a/Extras/simdmathlibrary/common/negatef4.c b/Extras/simdmathlibrary/common/negatef4.c deleted file mode 100644 index 185666368..000000000 --- a/Extras/simdmathlibrary/common/negatef4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* negatef4 - for each of four float slots, negate the sign bit. - 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. - */ - -#include - -vector float -negatef4 (vector float x) -{ - return _negatef4( x ); -} diff --git a/Extras/simdmathlibrary/common/negatei4.c b/Extras/simdmathlibrary/common/negatei4.c deleted file mode 100644 index 622fb7a4b..000000000 --- a/Extras/simdmathlibrary/common/negatei4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* negatei4 - for each of four int slots, negate the sign bit. - 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. - */ - -#include - -vector signed int -negatei4 (vector signed int x) -{ - return _negatei4( x ); -} diff --git a/Extras/simdmathlibrary/common/negatell2.c b/Extras/simdmathlibrary/common/negatell2.c deleted file mode 100644 index 36fc706da..000000000 --- a/Extras/simdmathlibrary/common/negatell2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* negatell2 - for each of 2 signed long long slots, negate the sign bit. - 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. - */ - -#include - -vector signed long long -negatell2 (vector signed long long x) -{ - return _negatell2(x); -} diff --git a/Extras/simdmathlibrary/common/nextafterd2.c b/Extras/simdmathlibrary/common/nextafterd2.c deleted file mode 100644 index 8b7f48c16..000000000 --- a/Extras/simdmathlibrary/common/nextafterd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* nextafterd2 - find next representable floating-point value towards 2nd param. - 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. - */ - -#include - -vector double -nextafterd2 (vector double xx, vector double yy) -{ - return _nextafterd2(xx, yy); -} diff --git a/Extras/simdmathlibrary/common/nextafterf4.c b/Extras/simdmathlibrary/common/nextafterf4.c deleted file mode 100644 index 9742db409..000000000 --- a/Extras/simdmathlibrary/common/nextafterf4.c +++ /dev/null @@ -1,38 +0,0 @@ -/* nextafterf4 - for each of four float slots, - return the the next representable value after x in the direction fo y, - if x is euqal to y, the result is y. - 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. - */ - -#include - -vector float -nextafterf4(vector float x, vector float y) -{ - return _nextafterf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/powf4.c b/Extras/simdmathlibrary/common/powf4.c deleted file mode 100644 index 00c3a82eb..000000000 --- a/Extras/simdmathlibrary/common/powf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* exp2f4 - 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. - */ - -#include - -vector float -powf4 (vector float x, vector float y) -{ - return _powf4( x, y ); -} diff --git a/Extras/simdmathlibrary/common/recipd2.c b/Extras/simdmathlibrary/common/recipd2.c deleted file mode 100644 index d84d01b98..000000000 --- a/Extras/simdmathlibrary/common/recipd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* recipd2 - for each of two double slots, compute reciprocal. - 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. - */ - -#include - -vector double -recipd2 (vector double x) -{ - return _recipd2(x); -} diff --git a/Extras/simdmathlibrary/common/recipf4.c b/Extras/simdmathlibrary/common/recipf4.c deleted file mode 100644 index 9743efe0c..000000000 --- a/Extras/simdmathlibrary/common/recipf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* recipf4 - for each of four float slots, compute reciprocal. - 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. - */ - -#include - -vector float -recipf4 (vector float x) -{ - return _recipf4( x ); -} diff --git a/Extras/simdmathlibrary/common/remainderd2.c b/Extras/simdmathlibrary/common/remainderd2.c deleted file mode 100644 index 082e98860..000000000 --- a/Extras/simdmathlibrary/common/remainderd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* A vector double is returned that contains the remainder xi REM yi, - for the corresponding elements of vector double x and vector double y. - 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. - */ - -#include - -vector double -remainderd2(vector double x, vector double yy) -{ - return _remainderd2(x, yy); -} diff --git a/Extras/simdmathlibrary/common/remainderf4.c b/Extras/simdmathlibrary/common/remainderf4.c deleted file mode 100644 index f65358798..000000000 --- a/Extras/simdmathlibrary/common/remainderf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* remainderf4 - for each of four float slots, compute remainder of x/y defined as x - nearest_integer(x/y) * y. - 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. - */ - -#include - -vector float -remainderf4 (vector float x, vector float y) -{ - return _remainderf4(x, y); -} diff --git a/Extras/simdmathlibrary/common/remquod2.c b/Extras/simdmathlibrary/common/remquod2.c deleted file mode 100644 index c06a4b4cd..000000000 --- a/Extras/simdmathlibrary/common/remquod2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* remquod2 - - 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. - */ - -#include - -vector double -remquod2(vector double x, vector double yy, vector signed long long *quo) -{ - return _remquod2(x, yy, quo); -} diff --git a/Extras/simdmathlibrary/common/remquof4.c b/Extras/simdmathlibrary/common/remquof4.c deleted file mode 100644 index 2429f9524..000000000 --- a/Extras/simdmathlibrary/common/remquof4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* remquof4 - - 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. - */ - -#include - -vector float -remquof4(vector float x, vector float y, vector signed int *quo) -{ - return _remquof4(x, y, quo); -} diff --git a/Extras/simdmathlibrary/common/rintd2.c b/Extras/simdmathlibrary/common/rintd2.c deleted file mode 100644 index a2e9435a2..000000000 --- a/Extras/simdmathlibrary/common/rintd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* rintd2 - Round the input to the nearest integer according to - the current rounding mode. - 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. - */ - -#include - -vector double -rintd2(vector double in) -{ - return _rintd2(in); -} diff --git a/Extras/simdmathlibrary/common/rintf4.c b/Extras/simdmathlibrary/common/rintf4.c deleted file mode 100644 index c8069dc91..000000000 --- a/Extras/simdmathlibrary/common/rintf4.c +++ /dev/null @@ -1,38 +0,0 @@ -/* rintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model. - On SPU, the rounding mode for float is always towards zero. - 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. - */ - -#include - -vector float -rintf4(vector float x) -{ - return _rintf4(x); -} diff --git a/Extras/simdmathlibrary/common/roundd2.c b/Extras/simdmathlibrary/common/roundd2.c deleted file mode 100644 index fadc41b83..000000000 --- a/Extras/simdmathlibrary/common/roundd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* roundd2 - rounds to nearest integer value in floating point format. - 0.5 will be rounded to far from 0 - 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. - */ - -#include - -vector double -roundd2 (vector double in) -{ - return _roundd2(in); -} diff --git a/Extras/simdmathlibrary/common/roundf4.c b/Extras/simdmathlibrary/common/roundf4.c deleted file mode 100644 index 65277151d..000000000 --- a/Extras/simdmathlibrary/common/roundf4.c +++ /dev/null @@ -1,37 +0,0 @@ -/* roundf4 - for each of four float slots, round to the nearest integer, - halfway cases are rounded away form zero. - 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. - */ - -#include - -vector float -roundf4(vector float in) -{ - return _roundf4(in); -} diff --git a/Extras/simdmathlibrary/common/rsqrtd2.c b/Extras/simdmathlibrary/common/rsqrtd2.c deleted file mode 100644 index bbd58c468..000000000 --- a/Extras/simdmathlibrary/common/rsqrtd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* rsqrtd2 - for each of two double slots, compute reciprocal square root. - 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. - */ - -#include - -vector double -rsqrtd2 (vector double x) -{ - return _rsqrtd2(x); -} diff --git a/Extras/simdmathlibrary/common/rsqrtf4.c b/Extras/simdmathlibrary/common/rsqrtf4.c deleted file mode 100644 index fa0dec3ab..000000000 --- a/Extras/simdmathlibrary/common/rsqrtf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sqrtf4 - - 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. - */ - -#include - -vector float -rsqrtf4 (vector float x) -{ - return _rsqrtf4( x ); -} diff --git a/Extras/simdmathlibrary/common/scalbllnd2.c b/Extras/simdmathlibrary/common/scalbllnd2.c deleted file mode 100644 index aad9e5cda..000000000 --- a/Extras/simdmathlibrary/common/scalbllnd2.c +++ /dev/null @@ -1,38 +0,0 @@ -/* scalbllnd2 - Multiply Double by 2 Raised to its Power - For large elements of ex (overflow), returns HUGE_VALF - For small elements of ex (underflow), returns 0. - 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. - */ - -#include - -vector double -scalbllnd2(vector double x, vector signed long long ex) -{ - return _scalbllnd2(x, ex); -} diff --git a/Extras/simdmathlibrary/common/scalbnf4.c b/Extras/simdmathlibrary/common/scalbnf4.c deleted file mode 100644 index 49db439d6..000000000 --- a/Extras/simdmathlibrary/common/scalbnf4.c +++ /dev/null @@ -1,38 +0,0 @@ -/* scalbnf4 computes x * 2^exp. This function is computed without - the assistence of any floating point operations and as such does - not set any floating point exceptions. - 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. - */ - -#include - -vector float -scalbnf4(vector float x, vector signed int n) -{ - return _scalbnf4(x, n); -} diff --git a/Extras/simdmathlibrary/common/signbitd2.c b/Extras/simdmathlibrary/common/signbitd2.c deleted file mode 100644 index facdb6cb9..000000000 --- a/Extras/simdmathlibrary/common/signbitd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* signbitd2 - for each of two double slots, if input has negative sign bit return mask of ones, else 0 - 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. - */ - -#include - -vector unsigned long long -signbitd2 (vector double x) -{ - return _signbitd2(x); -} diff --git a/Extras/simdmathlibrary/common/signbitf4.c b/Extras/simdmathlibrary/common/signbitf4.c deleted file mode 100644 index 811879ecd..000000000 --- a/Extras/simdmathlibrary/common/signbitf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* signbitf4 - for each element of vector x, return a mask of ones if x' has signbit one, zero otherwise - 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. - */ - -#include - -vector unsigned int -signbitf4 (vector float x) -{ - return _signbitf4(x); -} diff --git a/Extras/simdmathlibrary/common/simdmath.h b/Extras/simdmathlibrary/common/simdmath.h deleted file mode 100644 index e953d8dff..000000000 --- a/Extras/simdmathlibrary/common/simdmath.h +++ /dev/null @@ -1,732 +0,0 @@ -/* SIMD math library functions for both the PowerPC (PPU) and the SPU. - 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 ___SIMD_MATH_H___ -#define ___SIMD_MATH_H___ - -#define __SIMD_MATH_HAVE_VECTOR_f4 0 -#define __SIMD_MATH_HAVE_VECTOR_i4 0 -#define __SIMD_MATH_HAVE_VECTOR_d2 0 -#define __SIMD_MATH_HAVE_VECTOR_ll2 0 - -#ifdef __SPU__ - -/* SPU has vector float, vector double, - vector {un,}signed long long, and vector {un,signed} int. */ - -#include - -#undef __SIMD_MATH_HAVE_VECTOR_f4 -#define __SIMD_MATH_HAVE_VECTOR_f4 1 - -#undef __SIMD_MATH_HAVE_VECTOR_i4 -#define __SIMD_MATH_HAVE_VECTOR_i4 1 - -#undef __SIMD_MATH_HAVE_VECTOR_d2 -#define __SIMD_MATH_HAVE_VECTOR_d2 1 - -#undef __SIMD_MATH_HAVE_VECTOR_ll2 -#define __SIMD_MATH_HAVE_VECTOR_ll2 1 - -#elif defined(__ALTIVEC__) - -#include - -/* PPU has vector float, and vector int. */ -#undef __SIMD_MATH_HAVE_VECTOR_f4 -#define __SIMD_MATH_HAVE_VECTOR_f4 1 - -#undef __SIMD_MATH_HAVE_VECTOR_i4 -#define __SIMD_MATH_HAVE_VECTOR_i4 1 - -#else - -/* Just in case someone tries to include this in say a i686 build. */ - -#error "No functions defined" - -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Types */ - -#if __SIMD_MATH_HAVE_VECTOR_i4 -typedef struct divi4_s { - vector signed int quot; - vector signed int rem; -} divi4_t; -#endif - -#if __SIMD_MATH_HAVE_VECTOR_i4 -typedef struct divu4_s { - vector unsigned int quot; - vector unsigned int rem; -} divu4_t; -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -typedef struct lldivi2_s { - vector signed long long quot; - vector signed long long rem; -} lldivi2_t; -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -typedef struct lldivu2_s { - vector unsigned long long quot; - vector unsigned long long rem; -} lldivu2_t; -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_ll2 -typedef struct llroundf4_s { - vector signed long long vll[2]; -} llroundf4_t; -#endif - -/* integer divide */ - -#if __SIMD_MATH_HAVE_VECTOR_i4 -divi4_t divi4 (vector signed int, vector signed int); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_i4 -divu4_t divu4 (vector unsigned int, vector unsigned int); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -lldivi2_t lldivi2 (vector signed long long, vector signed long long); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -lldivu2_t lldivu2 (vector unsigned long long, vector unsigned long long); -#endif - -/* abs value */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fabsf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fabsd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int absi4 (vector signed int); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long llabsi2 (vector signed long long); -#endif - -/* negate value */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float negatef4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double negated2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int negatei4 (vector signed int); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long negatell2 (vector signed long long); -#endif - -/* trunc */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float truncf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double trund2 (vector double); -#endif - -/* floor */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float floorf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double floord2 (vector double); -#endif - -/* ceil */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float ceilf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double ceild2 (vector double); -#endif - -/* exp */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float expf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double expd2 (vector double); -#endif - -/* exp */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float exp2f4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double exp2d2 (vector double); -#endif - -/* expm1 */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float expm1f4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double expm1d2 (vector double); -#endif - -/* log */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float logf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double logd2 (vector double); -#endif - -/* log10 */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float log10f4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double log10d2 (vector double); -#endif - -/* log1p */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float log1pf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double log1pd2 (vector double); -#endif - -/* pow */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float powf4 (vector float, vector float); -#endif - -/* fma */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fmaf4 (vector float, vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fmad2 (vector double, vector double, vector double); -#endif - -/* fmax */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fmaxf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fmaxd2 (vector double, vector double); -#endif - -/* fmin */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fminf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fmind2 (vector double, vector double); -#endif - -/* fdim */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fdimf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fdimd2 (vector double, vector double); -#endif - - -/* fmod */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float fmodf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fmodd2 (vector double, vector double); -#endif - -/* log2 */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float log2f4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double log2d2 (vector double); -#endif - -/* logb */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float logbf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double logbd2 (vector double); -#endif - -/* ilogb */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int ilogbf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long ilogbd2 (vector double); -#endif - -/* modf */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float modff4 (vector float, vector float *); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double modfd2 (vector double, vector double *); -#endif - -/* sqrt */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float sqrtf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double sqrtd2 (vector double); -#endif - -/* hypot */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float hypotf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double hypotd2 (vector double, vector double); -#endif - -/* cbrtf4 */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float cbrtf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double cbrtd2 (vector double); -#endif - -/* sin */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float sinf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double sind2 (vector double); -#endif - - -/* asin */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float asinf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double asind2 (vector double); -#endif - - - -/* divide */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float divf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double divd2 (vector double, vector double); -#endif - -/* remainder */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float remainderf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double remainderd2 (vector double, vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector float remquof4(vector float x, vector float y, vector signed int *quo); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector double remquod2(vector double x, vector double y, vector signed long long *quo); -#endif - -/* copysign */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float copysignf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double copysignd2 (vector double, vector double); -#endif - -/* cos */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float cosf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double cosd2 (vector double); -#endif - -/* acos */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float acosf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double acosd2 (vector double); -#endif - -/* atan */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float atanf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double atand2 (vector double); -#endif - -/* atan2 */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float atan2f4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double atan2d2 (vector double, vector double); -#endif - - -/* tan */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float tanf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double tand2 (vector double); -#endif - -/* sincos */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -void sincosf4 (vector float, vector float *, vector float *); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -void sincosd2 (vector double, vector double *, vector double *); -#endif - - - -/* recip */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float recipf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double recipd2 (vector double); -#endif - - -/* rsqrt */ -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float rsqrtf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double rsqrtd2 (vector double); -#endif - - -/* frexp */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector float frexpf4 (vector float, vector signed int *); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector double frexpd2 (vector double, vector signed long long *); -#endif - -/* ldexp */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector float ldexpf4 (vector float, vector signed int ); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector double ldexpd2 (vector double, vector signed long long ); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector float scalbnf4(vector float x, vector signed int n); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector double scalbllnd2 (vector double, vector signed long long ); -#endif - - -/* isnan */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isnanf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isnand2 (vector double); -#endif - -/* isinf */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isinff4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isinfd2 (vector double); -#endif - -/* isfinite */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isfinitef4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isfinited2 (vector double); -#endif - -/* isnormal */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isnormalf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isnormald2 (vector double); -#endif - -/* isunordered */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isunorderedf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isunorderedd2 (vector double, vector double); -#endif - -/* is0denorm */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int is0denormf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long is0denormd2 (vector double); -#endif - -/* signbit */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int signbitf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long signbitd2 (vector double); -#endif - -/* isequal */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isequalf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isequald2 (vector double, vector double); -#endif - -/* islessgreater */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int islessgreaterf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long islessgreaterd2 (vector double, vector double); -#endif - -/* isless */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int islessf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long islessd2 (vector double, vector double); -#endif - -/* isgreater */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isgreaterf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isgreaterd2 (vector double, vector double); -#endif - -/* islessequal */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int islessequalf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long islessequald2 (vector double, vector double); -#endif - -/* isgreaterequal */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector unsigned int isgreaterequalf4 (vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector unsigned long long isgreaterequald2 (vector double, vector double); -#endif - -/* fpclassify */ -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int fpclassifyf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long fpclassifyd2 (vector double); -#endif - -/* round */ -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long llroundd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_ll2 -llroundf4_t llroundf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_ll2 -llroundf4_t llrintf4 (vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 && __SIMD_MATH_HAVE_VECTOR_ll2 -vector signed long long llrintd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float roundf4(vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int iroundf4(vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float rintf4(vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 && __SIMD_MATH_HAVE_VECTOR_i4 -vector signed int irintf4(vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double nextafterd2 (vector double, vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float nextafterf4(vector float, vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double nearbyintd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_f4 -vector float nearbyintf4(vector float); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double truncd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double roundd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double rintd2 (vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double ceild2(vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double floord2(vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double fmodd2(vector double, vector double); -#endif - -#if __SIMD_MATH_HAVE_VECTOR_d2 -vector double remainderd2(vector double, vector double); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Extras/simdmathlibrary/common/simdmath/_sincos.h b/Extras/simdmathlibrary/common/simdmath/_sincos.h deleted file mode 100644 index a604ae1e3..000000000 --- a/Extras/simdmathlibrary/common/simdmath/_sincos.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Common constants for Sin/Cos/Tan - 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 ___SIMD_MATH__SINCOS_H___ -#define ___SIMD_MATH__SINCOS_H___ - -// -// Common constants used to evaluate sind2/cosd2/tand2 -// -#define __SINCOSD_CC0 0.00000000206374484196 -#define __SINCOSD_CC1 -0.00000027555365134677 -#define __SINCOSD_CC2 0.00002480157946764225 -#define __SINCOSD_CC3 -0.00138888888730525966 -#define __SINCOSD_CC4 0.04166666666651986722 -#define __SINCOSD_CC5 -0.49999999999999547304 - -#define __SINCOSD_SC0 0.00000000015893606014 -#define __SINCOSD_SC1 -0.00000002505069049138 -#define __SINCOSD_SC2 0.00000275573131527032 -#define __SINCOSD_SC3 -0.00019841269827816117 -#define __SINCOSD_SC4 0.00833333333331908278 -#define __SINCOSD_SC5 -0.16666666666666612594 - -#define __SINCOSD_KC1 (13176794.0 / 8388608.0) -#define __SINCOSD_KC2 7.5497899548918821691639751442098584e-8 - - -// -// Common constants used to evaluate sinf4/cosf4/tanf4 -// -#define __SINCOSF_CC0 -0.0013602249f -#define __SINCOSF_CC1 0.0416566950f -#define __SINCOSF_CC2 -0.4999990225f -#define __SINCOSF_SC0 -0.0001950727f -#define __SINCOSF_SC1 0.0083320758f -#define __SINCOSF_SC2 -0.1666665247f - -#define __SINCOSF_KC1 1.57079625129f -#define __SINCOSF_KC2 7.54978995489e-8f - -// -// Common constants used to evaluate sinf4est/cosf4est -// -#define __SINCOSF_R1 -0.1666665668f -#define __SINCOSF_R2 0.8333025139e-2f -#define __SINCOSF_R3 -0.1980741872e-3f -#define __SINCOSF_R4 0.2601903036e-5f - -#define __SINCOSF_C1 (201.0f/64.0f) -#define __SINCOSF_C2 9.67653589793e-4f - -#endif diff --git a/Extras/simdmathlibrary/common/sincosd2.c b/Extras/simdmathlibrary/common/sincosd2.c deleted file mode 100644 index f5dce4d7e..000000000 --- a/Extras/simdmathlibrary/common/sincosd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sincosd2 - - 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. - */ - -#include - -void -sincosd2 (vector double x, vector double *s, vector double *c) -{ - _sincosd2( x, s, c ); -} diff --git a/Extras/simdmathlibrary/common/sincosf4.c b/Extras/simdmathlibrary/common/sincosf4.c deleted file mode 100644 index dfa2333d6..000000000 --- a/Extras/simdmathlibrary/common/sincosf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sincosf4 - - 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. - */ - -#include - -void -sincosf4 (vector float x, vector float *s, vector float *c) -{ - _sincosf4( x, s, c ); -} diff --git a/Extras/simdmathlibrary/common/sind2.c b/Extras/simdmathlibrary/common/sind2.c deleted file mode 100644 index 25e8ca0e5..000000000 --- a/Extras/simdmathlibrary/common/sind2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sind2 - 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. - */ - -#include - -vector double -sind2 (vector double x) -{ - return _sind2(x); -} diff --git a/Extras/simdmathlibrary/common/sinf4.c b/Extras/simdmathlibrary/common/sinf4.c deleted file mode 100644 index 7e5ffd02e..000000000 --- a/Extras/simdmathlibrary/common/sinf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sinf4 - - 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. - */ - -#include - -vector float -sinf4 (vector float x) -{ - return _sinf4( x ); -} diff --git a/Extras/simdmathlibrary/common/sqrtd2.c b/Extras/simdmathlibrary/common/sqrtd2.c deleted file mode 100644 index b73d95360..000000000 --- a/Extras/simdmathlibrary/common/sqrtd2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sqrtd2 - for each of two double slots, compute square root. - 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. - */ - -#include - -vector double -sqrtd2 (vector double x) -{ - return _sqrtd2(x); -} diff --git a/Extras/simdmathlibrary/common/sqrtf4.c b/Extras/simdmathlibrary/common/sqrtf4.c deleted file mode 100644 index 557c80fdf..000000000 --- a/Extras/simdmathlibrary/common/sqrtf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* sqrtf4 - - 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. - */ - -#include - -vector float -sqrtf4 (vector float x) -{ - return _sqrtf4( x ); -} diff --git a/Extras/simdmathlibrary/common/tand2.c b/Extras/simdmathlibrary/common/tand2.c deleted file mode 100644 index 083a35d2a..000000000 --- a/Extras/simdmathlibrary/common/tand2.c +++ /dev/null @@ -1,36 +0,0 @@ -/* tand2 - 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. - */ - -#include - -vector double -tand2 (vector double x) -{ - return _tand2(x); -} diff --git a/Extras/simdmathlibrary/common/tanf4.c b/Extras/simdmathlibrary/common/tanf4.c deleted file mode 100644 index 1857e048d..000000000 --- a/Extras/simdmathlibrary/common/tanf4.c +++ /dev/null @@ -1,36 +0,0 @@ -/* tanf4 - - 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. - */ - -#include - -vector float -tanf4 (vector float x) -{ - return _tanf4( x ); -} diff --git a/Extras/simdmathlibrary/common/truncd2.c b/Extras/simdmathlibrary/common/truncd2.c deleted file mode 100644 index 7a01c480f..000000000 --- a/Extras/simdmathlibrary/common/truncd2.c +++ /dev/null @@ -1,37 +0,0 @@ -/* truncd2 - Round the input to the nearest integer. - Always rounds towards 0. - 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. - */ - -#include - -vector double -truncd2(vector double in) -{ - return _truncd2(in); -} diff --git a/Extras/simdmathlibrary/common/truncf4.c b/Extras/simdmathlibrary/common/truncf4.c deleted file mode 100644 index 2e73376a6..000000000 --- a/Extras/simdmathlibrary/common/truncf4.c +++ /dev/null @@ -1,37 +0,0 @@ -/* truncf4 - for each of four float slots, round towards zero to integer value. - 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. - */ - -#include - -vector float -truncf4 (vector float x) -{ - return _truncf4( x ); -} - diff --git a/Extras/simdmathlibrary/ppu/Makefile b/Extras/simdmathlibrary/ppu/Makefile deleted file mode 100644 index 59316ccac..000000000 --- a/Extras/simdmathlibrary/ppu/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# make file to build the libsimdmath library for PPU -# 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. - -topdir = .. -ARCH = ppu - -include $(topdir)/Make.defs - -# All that you do to add a file is edit OBJS, the rest will just work - -OBJS = fabsf4.o absi4.o truncf4.o sqrtf4.o tanf4.o \ - negatef4.o fmaf4.o copysignf4.o modff4.o \ - fmaxf4.o fminf4.o fdimf4.o sinf4.o asinf4.o \ - floorf4.o recipf4.o ceilf4.o divf4.o divi4.o \ - cosf4.o hypotf4.o cbrtf4.o logf4.o sincosf4.o \ - rsqrtf4.o log2f4.o ldexpf4.o expf4.o frexpf4.o \ - expm1f4.o logbf4.o log1pf4.o log10f4.o ilogbf4.o \ - fmodf4.o negatei4.o exp2f4.o powf4.o atanf4.o \ - atan2f4.o acosf4.o - -include $(topdir)/Make.rules - -$(OBJS): ../common/simdmath.h simdmath/_vec_utils.h - - -# Some Objects have special header files. -sinf4.o cosf4.o sincosf4.o tanf4.o: ../common/simdmath/_sincos.h diff --git a/Extras/simdmathlibrary/ppu/simdmath/_vec_utils.h b/Extras/simdmathlibrary/ppu/simdmath/_vec_utils.h deleted file mode 100644 index b5bf40aa3..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/_vec_utils.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Common types for PPU SIMD Math Library - 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 ___SIMD_MATH_VEC_UTILS_H___ -#define ___SIMD_MATH_VEC_UTILS_H___ - -static inline vector float -__vec_splatsf4(const float x) -{ - return (vector float) {x, x, x, x}; -} - -static inline vector signed int -__vec_splatsi4(const signed int x) -{ - return (vector signed int) {x, x, x, x}; -} - -static inline vector unsigned int -__vec_splatsu4(const unsigned int x) -{ - return (vector unsigned int) {x, x, x, x}; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/absi4.h b/Extras/simdmathlibrary/ppu/simdmath/absi4.h deleted file mode 100644 index 65cdc959c..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/absi4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* absi4 - for each of four integer slots, compute absolute value. - 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 ___SIMD_MATH_ABSI4_H___ -#define ___SIMD_MATH_ABSI4_H___ - -#include -#include - -static inline vector signed int -_absi4 (vector signed int x) -{ - return vec_abs( x ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/acosf4.h b/Extras/simdmathlibrary/ppu/simdmath/acosf4.h deleted file mode 100644 index e84e803e8..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/acosf4.h +++ /dev/null @@ -1,82 +0,0 @@ -/* acosf4 - - 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 ___SIMD_MATH_ACOSF4_H___ -#define ___SIMD_MATH_ACOSF4_H___ - -#include -#include - -#include - -// -// Computes the inverse cosine of all four slots of x. -// -static inline vector float -_acosf4 (vector float x) -{ - vector float result, xabs; - vector float t1; - vector float xabs2, xabs4; - vector float hi, lo; - vector float neg, pos; - vector unsigned int select; - - xabs = vec_abs(x); - select = (vector unsigned int)(vec_sra((vector signed int)(x), __vec_splatsu4(31))); - - t1 = _sqrtf4(vec_sub(__vec_splatsf4(1.0f), xabs)); - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - xabs2 = vec_madd(xabs, xabs, __vec_splatsf4(0.0f) ); - xabs4 = vec_madd(xabs2, xabs2, __vec_splatsf4(0.0f) ); - hi = vec_madd(__vec_splatsf4(-0.0012624911) , xabs, __vec_splatsf4(0.0066700901)); - hi = vec_madd(hi, xabs, __vec_splatsf4(-0.0170881256)); - hi = vec_madd(hi, xabs, __vec_splatsf4( 0.0308918810)); - lo = vec_madd(__vec_splatsf4(-0.0501743046), xabs, __vec_splatsf4(0.0889789874)); - lo = vec_madd(lo, xabs, __vec_splatsf4(-0.2145988016)); - lo = vec_madd(lo, xabs, __vec_splatsf4( 1.5707963050)); - - result = vec_madd(hi, xabs4, lo); - - /* Adjust the result if x is negactive. - */ - neg = vec_nmsub(t1, result, __vec_splatsf4(3.1415926535898f)); - pos = vec_madd(t1, result, __vec_splatsf4(0.0f)); - - result = vec_sel(pos, neg, select); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/asinf4.h b/Extras/simdmathlibrary/ppu/simdmath/asinf4.h deleted file mode 100644 index 51a7d671a..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/asinf4.h +++ /dev/null @@ -1,95 +0,0 @@ -/* asinf4 - Computes the inverse sine of all four slots of x - 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 ___SIMD_MATH_ASINF4_H___ -#define ___SIMD_MATH_ASINF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_asinf4 (vector float x) -{ - // positive = (x > 0) - // - vector unsigned int positive = (vector unsigned int)vec_cmpgt(x, __vec_splatsf4(0.0f)); - - // x = absf(x) - // - x = vec_abs(x); - - // gtHalf = (|x| > 0.5) - // - vector unsigned int gtHalf = (vector unsigned int)vec_cmpgt(x, __vec_splatsf4(0.5f)); - - - // if (x > 0.5) - // g = 0.5 - 0.5*x - // x = -2 * sqrtf(g) - // else - // g = x * x - // - vector float g = - vec_sel(vec_madd(x, x, __vec_splatsf4(0.0f)), - vec_madd(__vec_splatsf4(-0.5f), x, __vec_splatsf4(0.5f)), gtHalf); - - x = vec_sel(x, vec_madd(__vec_splatsf4(-2.0f), _sqrtf4(g), __vec_splatsf4(0.0f)), gtHalf); - - // Compute the polynomials and take their ratio - // denom = (1.0f*g + -0.554846723e+1f)*g + 5.603603363f - // num = x * g * (-0.504400557f * g + 0.933933258f) - // - vector float denom = vec_add(g, __vec_splatsf4(-5.54846723f)); - vector float num = vec_madd(__vec_splatsf4(-0.504400557f), g, __vec_splatsf4(0.933933258f)); - denom = vec_madd(denom, g, __vec_splatsf4(5.603603363f)); - num = vec_madd(vec_madd(x, g, __vec_splatsf4(0.0f)), num, __vec_splatsf4(0.0f)); - - - // x = x + num / denom - // - x = vec_add(x,_divf4(num,denom)); - - // if (x > 0.5) - // x = x + M_PI_2 - // - x = vec_sel(x,vec_add(x, __vec_splatsf4(1.57079632679489661923f)), gtHalf); - - - // if (!positive) x = -x - // - x = vec_sel((vector float)vec_xor(__vec_splatsi4(0x80000000), (vector signed int)x), - x, positive); - - return x; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/atan2f4.h b/Extras/simdmathlibrary/ppu/simdmath/atan2f4.h deleted file mode 100644 index d201e3595..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/atan2f4.h +++ /dev/null @@ -1,67 +0,0 @@ -/* atan2f4 - - 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 ___SIMD_MATH_ATAN2F4_H___ -#define ___SIMD_MATH_ATAN2F4_H___ - -#include -#include - -#include - -// -// Inverse tangent function of two variables -// -static inline vector float -_atan2f4 (vector float y, vector float x) -{ - vector float res = _atanf4(divf4(y,x)); - - // Use the arguments to determine the quadrant of the result: - // if (x < 0) - // if (y < 0) - // res = -PI + res - // else - // res = PI + res - // - vector unsigned int yNeg = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.0f), y); - vector unsigned int xNeg = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.0f) ,x); - - vector float bias = - vec_sel(__vec_splatsf4(3.14159265358979323846f), - __vec_splatsf4(-3.14159265358979323846f), yNeg); - - vector float newRes = vec_add(bias, res); - - res = vec_sel(res,newRes,xNeg); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/atanf4.h b/Extras/simdmathlibrary/ppu/simdmath/atanf4.h deleted file mode 100644 index a495ecb04..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/atanf4.h +++ /dev/null @@ -1,87 +0,0 @@ -/* atanf4 - - 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 ___SIMD_MATH_ATANF4_H___ -#define ___SIMD_MATH_ATANF4_H___ - -#include -#include - -#include - -// -// Computes the inverse tangent of all four slots of x. -// -static inline vector float -_atanf4 (vector float x) -{ - vector float bias; - vector float x2, x3, x4, x8, x9; - vector float hi, lo; - vector float result; - vector float inv_x; - vector unsigned int sign; - vector unsigned int select; - vector float xabs; - vector float vzero = __vec_splatsf4(0.0f); - - sign = vec_and((vector unsigned int)x, __vec_splatsu4(0x80000000)); - xabs = (vector float)vec_andc((vector unsigned int)x, __vec_splatsu4(0x80000000)); - inv_x = _recipf4(x); - inv_x = (vector float)vec_xor((vector unsigned int)inv_x, __vec_splatsu4(0x80000000)); - select = (vector unsigned int)vec_cmpgt(xabs, __vec_splatsf4(1.0f)); - bias = (vector float)vec_or(sign, (vector unsigned int)(__vec_splatsf4(1.57079632679489661923f))); - bias = (vector float)vec_and((vector unsigned int)bias, select); - - x = vec_sel(x, inv_x, select); - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves(hi and lo). - */ - bias = vec_add(bias, x); - x2 = vec_madd(x, x, vzero); - x3 = vec_madd(x2, x, vzero); - x4 = vec_madd(x2, x2, vzero); - x8 = vec_madd(x4, x4, vzero); - x9 = vec_madd(x8, x, vzero); - hi = vec_madd(__vec_splatsf4(0.0028662257), x2, __vec_splatsf4(-0.0161657367)); - hi = vec_madd(hi, x2, __vec_splatsf4(0.0429096138)); - hi = vec_madd(hi, x2, __vec_splatsf4(-0.0752896400)); - hi = vec_madd(hi, x2, __vec_splatsf4(0.1065626393)); - lo = vec_madd(__vec_splatsf4(-0.1420889944), x2, __vec_splatsf4(0.1999355085)); - lo = vec_madd(lo, x2, __vec_splatsf4(-0.3333314528)); - lo = vec_madd(lo, x3, bias); - - result = vec_madd(hi, x9, lo); - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/cbrtf4.h b/Extras/simdmathlibrary/ppu/simdmath/cbrtf4.h deleted file mode 100644 index 3546b40e2..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/cbrtf4.h +++ /dev/null @@ -1,97 +0,0 @@ -/* cbrtf4 - - 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 ___SIMD_MATH_CBRTF4_H___ -#define ___SIMD_MATH_CBRTF4_H___ - -#include -#include - -#include -#include -#include - -static inline vector signed int -__cbrtf4_calc_quot(vector signed int n) -{ - vector signed int quot; - vector unsigned int negxexpmask = (vector unsigned int)vec_cmpgt(__vec_splatsi4(0), n); - n = vec_sel(n, vec_add(n, __vec_splatsi4(2)), negxexpmask); - - quot = vec_add(vec_sra(n, __vec_splatsu4(2)), vec_sra(n, __vec_splatsu4(4))); - quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(4))); - quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(8))); - quot = vec_add(quot, vec_sra(quot, __vec_splatsu4(16))); - vector signed int r = vec_sub(vec_sub(n,quot), vec_sl(quot, __vec_splatsu4(1))); - quot = vec_add(quot, - vec_sra(vec_add(vec_add(r, __vec_splatsi4(5)), - vec_sl (r, __vec_splatsu4(2))), - __vec_splatsu4(4))); - - return quot; -} - -#define __CBRTF_cbrt2 1.2599210498948731648 // 2^(1/3) -#define __CBRTF_sqr_cbrt2 1.5874010519681994748 // 2^(2/3) - -static inline vector float -_cbrtf4 (vector float x) -{ - vector float zeros = __vec_splatsf4(0.0f); - vector signed int xexp; - vector float sgnmask = (vector float)__vec_splatsi4(0x80000000); - vector unsigned int negmask = (vector unsigned int)vec_cmpgt(zeros, x); - x = vec_andc(x, sgnmask); - - x = _frexpf4(x, &xexp); - vector float p = - vec_madd(vec_madd(x, __vec_splatsf4(-0.191502161678719066f), __vec_splatsf4(0.697570460207922770f)), - x, - __vec_splatsf4(0.492659620528969547f)); - vector float p3 = vec_madd(p, vec_madd(p, p, zeros), zeros); - - vector signed int quot = __cbrtf4_calc_quot(xexp); - // mod = xexp - 3*quotient - vector signed int modval = vec_sub(vec_sub(xexp,quot), vec_sl(quot, __vec_splatsu4(1))); - vector float factor = __vec_splatsf4(1.0/__CBRTF_sqr_cbrt2); - factor = vec_sel(factor, __vec_splatsf4(1.0/__CBRTF_cbrt2), vec_cmpeq(modval, __vec_splatsi4(-1))); - factor = vec_sel(factor, __vec_splatsf4( 1.0), vec_cmpeq(modval, __vec_splatsi4( 0))); - factor = vec_sel(factor, __vec_splatsf4( __CBRTF_cbrt2), vec_cmpeq(modval, __vec_splatsi4( 1))); - factor = vec_sel(factor, __vec_splatsf4(__CBRTF_sqr_cbrt2), vec_cmpeq(modval, __vec_splatsi4( 2))); - - vector float pre = vec_madd(p, factor, zeros); - vector float numr = vec_madd(x , __vec_splatsf4(2.0f), p3); - vector float denr = vec_madd(p3, __vec_splatsf4(2.0f), x ); - vector float res = vec_madd(pre, _divf4(numr, denr), zeros); - res = _ldexpf4(res, quot); - - return vec_sel(res, vec_or(res,sgnmask), negmask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/ceilf4.h b/Extras/simdmathlibrary/ppu/simdmath/ceilf4.h deleted file mode 100644 index 9235a94ec..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/ceilf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ceilf4 - for each of four float slots, round up to smallest integer not less than the value. - 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 ___SIMD_MATH_CEILF4_H___ -#define ___SIMD_MATH_CEILF4_H___ - -#include -#include - -static inline vector float -_ceilf4(vector float x) -{ - return vec_ceil( x ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/copysignf4.h b/Extras/simdmathlibrary/ppu/simdmath/copysignf4.h deleted file mode 100644 index ad16c84fd..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/copysignf4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* copysignf4 - for each of four float slots, return value with magnitude from x and sign from y. - 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 ___SIMD_MATH_COPYSIGNF4_H___ -#define ___SIMD_MATH_COPYSIGNF4_H___ - -#include -#include - -#include - - -static inline vector float -_copysignf4(vector float x, vector float y) -{ - return vec_sel(x, y, __vec_splatsu4(0x80000000)); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/cosf4.h b/Extras/simdmathlibrary/ppu/simdmath/cosf4.h deleted file mode 100644 index d774a8392..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/cosf4.h +++ /dev/null @@ -1,107 +0,0 @@ -/* cosf4 - - 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 ___SIMD_MATH_COSF4_H___ -#define ___SIMD_MATH_COSF4_H___ - -#include -#include - -#include -#include - - -// -// Computes the cosine of each of the four slots -// by using a polynomial approximation. -// -static inline vector float -_cosf4 (vector float x) -{ - vector float xl,xl2,xl3,res; - vector signed int q; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_madd(x, __vec_splatsf4(0.63661977236f), __vec_splatsf4(0.0f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - xl = vec_add(xl, vec_sel(__vec_splatsf4(0.5f), xl, __vec_splatsu4(0x80000000))); - q = vec_cts(xl, 0); - - - // Compute an offset based on the quadrant that the angle falls in - // - vector signed int offset = vec_add(__vec_splatsi4(1), vec_and(q, __vec_splatsi4(0x3))); - - // Remainder in range [-pi/4..pi/4] - // - vector float qf = vec_ctf(q,0); - vector float p1 = vec_nmsub(qf, __vec_splatsf4(__SINCOSF_KC1), x); - xl = vec_nmsub(qf, __vec_splatsf4(__SINCOSF_KC2), p1); - - // Compute x^2 and x^3 - // - xl2 = vec_madd(xl, xl, __vec_splatsf4(0.0f)); - xl3 = vec_madd(xl2, xl, __vec_splatsf4(0.0f)); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0), xl2, __vec_splatsf4(__SINCOSF_CC1)); - vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0), xl2, __vec_splatsf4(__SINCOSF_SC1)); - - vector float ct2 = vec_madd(ct1, xl2, __vec_splatsf4(__SINCOSF_CC2)); - vector float st2 = vec_madd(st1, xl2, __vec_splatsf4(__SINCOSF_SC2)); - - vector float cx = vec_madd(ct2, xl2, __vec_splatsf4(1.0f)); - vector float sx = vec_madd(st2, xl3, xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vector unsigned int mask1 = - (vector unsigned int)vec_cmpeq(vec_and(offset, __vec_splatsi4(0x1)), __vec_splatsi4(0)); - res = vec_sel(cx, sx, mask1); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - vector unsigned int mask2 = - (vector unsigned int)vec_cmpeq(vec_and(offset, __vec_splatsi4(0x2)), __vec_splatsi4(0)); - res = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000U), (vector unsigned int)res), res, mask2); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/divf4.h b/Extras/simdmathlibrary/ppu/simdmath/divf4.h deleted file mode 100644 index 67d7dae97..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/divf4.h +++ /dev/null @@ -1,51 +0,0 @@ -/* divf4 - for each of four float slots, divide numer by denom. - 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 ___SIMD_MATH_DIVF4_H___ -#define ___SIMD_MATH_DIVF4_H___ - -#include -#include - -#include - - -static inline vector float -_divf4 (vector float numer, vector float denom) -{ - // Reciprocal estimate and 1 Newton-Raphson iteration. - - vector float y0, y0numer; - - y0 = vec_re(denom); - y0numer = vec_madd(numer, y0, __vec_splatsf4(0.0f)); - return vec_madd(vec_nmsub(denom, y0, __vec_splatsf4(1.0f)), y0numer, y0numer); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/divi4.h b/Extras/simdmathlibrary/ppu/simdmath/divi4.h deleted file mode 100644 index 8290cfb63..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/divi4.h +++ /dev/null @@ -1,105 +0,0 @@ -/* divi4 - - 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 ___SIMD_MATH_DIVI4_H___ -#define ___SIMD_MATH_DIVI4_H___ - -#include -#include - -#include - -// divi4 - for each of four integer slots, compute quotient and remainder of numer/denom -// and store in divi4_t struct. Divide by zero produces quotient = 0, remainder = numerator. - -static inline divi4_t -_divi4 (vector signed int numer, vector signed int denom ) -{ - vector signed int minusone = __vec_splatsi4(-1); - vector unsigned int zero = __vec_splatsu4(0); - vector unsigned int one = __vec_splatsu4(1); - vector unsigned int k158 = __vec_splatsu4(158); - vector unsigned int k23 = __vec_splatsu4(23); - - divi4_t res; - vector unsigned int numerPos, denomPos, quotNeg; - vector unsigned int numerAbs, denomAbs; - vector unsigned int denomZeros, numerZeros, shift, denomShifted, oneShifted; - vector unsigned int quot, newQuot, skip, newNum, cont; - int anyCont; - - // determine whether result needs sign change - - numerPos = (vector unsigned int)vec_cmpgt( numer, minusone ); - denomPos = (vector unsigned int)vec_cmpgt( denom, minusone ); - quotNeg = vec_xor( numerPos, denomPos ); - - // use absolute values of numerator, denominator - - numerAbs = (vector unsigned int)vec_sel( vec_sub( (vector signed int)zero, numer ), numer, numerPos ); - denomAbs = (vector unsigned int)vec_sel( vec_sub( (vector signed int)zero, denom ), denom, denomPos ); - - // get difference of leading zeros to align denom with numer - - denomZeros = vec_sub( k158, vec_sr( (vector unsigned int)vec_ctf( denomAbs, 0 ), k23 ) ); - numerZeros = vec_sub( k158, vec_sr( (vector unsigned int)vec_ctf( numerAbs, 0 ), k23 ) ); - - shift = vec_sub( denomZeros, numerZeros ); - denomShifted = vec_sl( denomAbs, shift ); - oneShifted = vec_sl( one, shift ); - oneShifted = vec_sel( oneShifted, zero, vec_or( vec_cmpeq( denomAbs, zero ), - vec_cmpgt( denomAbs, numerAbs ) ) ); - - // long division - - quot = zero; - - do - { - cont = (vector unsigned int)vec_cmpgt( oneShifted, zero ); - anyCont = vec_any_gt( oneShifted, zero ); - skip = (vector unsigned int)vec_cmpgt( denomShifted, numerAbs ); - - newQuot = vec_or( quot, oneShifted ); - newNum = vec_sub( numerAbs, denomShifted ); - - oneShifted = vec_sr( oneShifted, one ); - denomShifted = vec_sr( denomShifted, one ); - - quot = vec_sel( newQuot, quot, skip ); - numerAbs = vec_sel( numerAbs, newNum, vec_andc( cont, skip ) ); - } - while ( anyCont ); - - res.quot = (vector signed int)vec_sel( quot, vec_sub( zero, quot ), quotNeg ); - res.rem = (vector signed int)vec_sel( (vector unsigned int)vec_sub( (vector signed int)zero, (vector signed int)numerAbs ), numerAbs, numerPos ); - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/exp2f4.h b/Extras/simdmathlibrary/ppu/simdmath/exp2f4.h deleted file mode 100644 index 6a4bc0f19..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/exp2f4.h +++ /dev/null @@ -1,137 +0,0 @@ -/* exp2f4 - 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 ___SIMD_MATH_EXP2F4_H___ -#define ___SIMD_MATH_EXP2F4_H___ - -#include -#include -#include - -#include - -/* - * FUNCTION - * vector float _exp2_v(vector float x) - * - * DESCRIPTION - * _exp2_v computes 2 raised to the input vector x. Computation is - * performed by observing the 2^(a+b) = 2^a * 2^b. - * We decompose x into a and b (above) by letting. - * a = ceil(x), b = x - a; - * - * 2^a is easilty computed by placing a into the exponent - * or a floating point number whose mantissa is all zeros. - * - * 2^b is computed using the following polynomial approximation. - * (C. Hastings, Jr, 1955). - * - * __7__ - * \ - * \ - * 2^(-x) = / Ci*x^i - * /____ - * i=1 - * - * for x in the range 0.0 to 1.0 - * - * C0 = 1.0 - * C1 = -0.9999999995 - * C2 = 0.4999999206 - * C3 = -0.1666653019 - * C4 = 0.0416573475 - * C5 = -0.0083013598 - * C6 = 0.0013298820 - * C7 = -0.0001413161 - * - * This function does not handle out of range conditions. It - * assumes that x is in the range (-128.0, 127.0]. Values outside - * this range will produce undefined results. - */ - - -#define __EXP2F_LN2 0.69314718055995f /* ln(2) */ - -static inline vector float -_exp2f4 (vector float x) -{ - vector signed int ix; - vector unsigned int overflow; - vector unsigned int underflow; - vector float frac, frac2, frac4; - vector float exp_int, exp_frac; - vector float result; - vector float hi, lo; - vector float zeros = __vec_splatsf4(0.0f); - vector float bias; - /* Break in the input x into two parts ceil(x), x - ceil(x). - */ -#if 1 - bias = (vector float)(vec_sra((vector signed int)x, __vec_splatsu4(31) )); - bias = (vector float)(vec_andc(__vec_splatsu4(0x3F7FFFFF), (vector unsigned int)bias)); - ix = vec_cts(vec_add(x, bias), 0); -#else - bias = vec_sel(vec_floor(x), vec_ceil(x), vec_cmpgt(x, __vec_splatsf4(0.0f))); - ix = vec_cts(bias, 0); -#endif - frac = vec_sub(vec_ctf(ix, 0), x); - frac = vec_madd(frac, __vec_splatsf4(__EXP2F_LN2), zeros); - - overflow = (vector unsigned int)vec_cmpgt(x, (vector float)(__vec_splatsi4(0x4300FFFF))); // !!! Biggest possible exponent to fit in range. - underflow = (vector unsigned int)vec_cmpgt(__vec_splatsf4(-126.0f), x); - - exp_int = (vector float)(vec_sl(vec_add(ix, __vec_splatsi4(126)), __vec_splatsu4(23))); // !!! HRD <- add with saturation - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - frac2 = vec_madd(frac, frac, zeros); - frac4 = vec_madd(frac2, frac2, zeros); - - hi = vec_madd(frac, __vec_splatsf4(-0.0001413161), __vec_splatsf4(0.0013298820)); - hi = vec_madd(frac, hi, __vec_splatsf4(-0.0083013598)); - hi = vec_madd(frac, hi, __vec_splatsf4(0.0416573475)); - lo = vec_madd(frac, __vec_splatsf4(-0.1666653019), __vec_splatsf4(0.4999999206)); - lo = vec_madd(frac, lo, __vec_splatsf4(-0.9999999995)); - lo = vec_madd(frac, lo, __vec_splatsf4(1.0)); - - exp_frac = vec_madd(frac4, hi, lo); - result = vec_madd(exp_frac, exp_int, zeros); - result = vec_madd(exp_frac, exp_int, result); // !!! HRD - - /* Handle overflow */ - result = vec_sel(result, __vec_splatsf4(HUGE_VALF), overflow); - result = vec_sel(result, zeros, underflow); - - return (result); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/expf4.h b/Extras/simdmathlibrary/ppu/simdmath/expf4.h deleted file mode 100644 index ccdf071c4..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/expf4.h +++ /dev/null @@ -1,69 +0,0 @@ -/* expf4 - - 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 ___SIMD_MATH_EXPF4_H___ -#define ___SIMD_MATH_EXPF4_H___ - -#include -#include - -#include -#include - -#define __EXPF_C1 -0.6931470632553101f -#define __EXPF_C2 -1.1730463525082e-7f - -#define __EXPF_INVLN2 1.4426950408889634f - -static inline vector float -_expf4 (vector float x) -{ - vector float zeros = __vec_splatsf4(0.0f); - vector unsigned int xnegmask = (vector unsigned int)vec_cmpgt(zeros, x); - vector float goffset = vec_sel(__vec_splatsf4( 0.5f),__vec_splatsf4(-0.5f),xnegmask); - vector float g = vec_madd(x, __vec_splatsf4(__EXPF_INVLN2), zeros); - vector signed int xexp = vec_cts(vec_add(g, goffset),0); - - g = vec_ctf(xexp, 0); - g = vec_madd(g, __vec_splatsf4(__EXPF_C2), vec_madd(g, __vec_splatsf4(__EXPF_C1), x)); - vector float z = vec_madd(g, g, zeros); - vector float a = vec_madd(z, __vec_splatsf4(0.0999748594f), zeros); - vector float b = vec_madd(g, - vec_madd(z, - __vec_splatsf4(0.0083208258f), - __vec_splatsf4(0.4999999992f)), - zeros); - - vector float foo = _divf4(vec_add(__vec_splatsf4(1.0f), vec_add(a, b)), - vec_add(__vec_splatsf4(1.0f), vec_sub(a, b))); - - return _ldexpf4(foo, xexp); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/expm1f4.h b/Extras/simdmathlibrary/ppu/simdmath/expm1f4.h deleted file mode 100644 index 4bc566fe4..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/expm1f4.h +++ /dev/null @@ -1,63 +0,0 @@ -/* expm1f4 - - 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 ___SIMD_MATH_EXPM1F4_H___ -#define ___SIMD_MATH_EXPM1F4_H___ - -#include -#include - -#include - -#define __EXPM1F_ln1by2 -0.6931471805599f -#define __EXPM1F_ln3by2 0.4054651081082f - -static inline vector float -_expm1f4 (vector float x) -{ - vector float zeros = __vec_splatsf4(0.0f); - vector unsigned int nearzeromask = - (vector unsigned int)vec_and(vec_cmpgt(x, __vec_splatsf4(__EXPM1F_ln1by2)), - vec_cmpgt(__vec_splatsf4(__EXPM1F_ln3by2), x)); - vector float x2 = vec_madd(x,x,zeros); - vector float d0, d1, n0, n1; - - d0 = vec_madd(x , __vec_splatsf4(-0.3203561199f), __vec_splatsf4(0.9483177697f)); - d1 = vec_madd(x2, __vec_splatsf4( 0.0326527809f), d0); - - n0 = vec_madd(x , __vec_splatsf4(0.1538026623f), __vec_splatsf4(0.9483177732f)); - n1 = vec_madd(x , __vec_splatsf4(0.0024490478f), __vec_splatsf4(0.0305274668f)); - n1 = vec_madd(x2, n1, n0); - - return vec_sel(vec_sub(expf4(x), __vec_splatsf4(1.0f)), - vec_madd(x, divf4(n1, d1), zeros), - nearzeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fabsf4.h b/Extras/simdmathlibrary/ppu/simdmath/fabsf4.h deleted file mode 100644 index e2a3fc953..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fabsf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fabsf4 - for each of four float slots, compute absolute value. - 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 ___SIMD_MATH_FABSF4_H___ -#define ___SIMD_MATH_FABSF4_H___ - -#include -#include - -static inline vector float -_fabsf4(vector float x) -{ - return vec_abs( x ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fdimf4.h b/Extras/simdmathlibrary/ppu/simdmath/fdimf4.h deleted file mode 100644 index f6b9407b3..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fdimf4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* fdimf - - 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 ___SIMD_MATH_FDIMF4_H___ -#define ___SIMD_MATH_FDIMF4_H___ - -#include -#include - -#include - -static inline vector float -_fdimf4 (vector float x, vector float y) -{ - vector float diff = vec_sub(x,y); - return vec_sel(__vec_splatsf4(0.0f), diff, vec_cmpgt(x,y)); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/floorf4.h b/Extras/simdmathlibrary/ppu/simdmath/floorf4.h deleted file mode 100644 index 099c7a9c6..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/floorf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* floorf4 - for each of four float slots, round down to largest integer not greater than the value. - 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 ___SIMD_MATH_FLOORF4_H___ -#define ___SIMD_MATH_FLOORF4_H___ - -#include -#include - - -static inline vector float -_floorf4 (vector float x) -{ - return vec_floor( x ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fmaf4.h b/Extras/simdmathlibrary/ppu/simdmath/fmaf4.h deleted file mode 100644 index 08262f010..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fmaf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fmaf4 - 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 ___SIMD_MATH_FMAF4_H___ -#define ___SIMD_MATH_FMAF4_H___ - -#include -#include - -static inline vector float -_fmaf4 (vector float x, vector float y, vector float z) -{ - return vec_madd(x,y,z); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fmaxf4.h b/Extras/simdmathlibrary/ppu/simdmath/fmaxf4.h deleted file mode 100644 index e5932d14a..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fmaxf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* fmaxf4 - for each of four float slots, compute maximum of x and y - 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 ___SIMD_MATH_FMAXF4_H___ -#define ___SIMD_MATH_FMAXF4_H___ - -#include -#include - - -static inline vector float -_fmaxf4 (vector float x, vector float y) -{ - return vec_max( x, y ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fminf4.h b/Extras/simdmathlibrary/ppu/simdmath/fminf4.h deleted file mode 100644 index 1bf0f0927..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fminf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* fminf4 - for each of four float slots, compute minimum of x and y - 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 ___SIMD_MATH_FMINF4_H___ -#define ___SIMD_MATH_FMINF4_H___ - -#include -#include - - -static inline vector float -_fminf4 (vector float x, vector float y) -{ - return vec_min( x, y ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/fmodf4.h b/Extras/simdmathlibrary/ppu/simdmath/fmodf4.h deleted file mode 100644 index 37292d35e..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/fmodf4.h +++ /dev/null @@ -1,88 +0,0 @@ -/* fmodf4 - for each of four float slots, compute remainder of x/y defined as x - truncated_integer(x/y) * y. - 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 ___SIMD_MATH_FMODF4_H___ -#define ___SIMD_MATH_FMODF4_H___ - -#include -#include - -#include -#include -#include - -// -// This returns an accurate result when |divf4(x,y)| < 2^20 and |x| < 2^128, and otherwise returns zero. -// If x == 0, the result is 0. -// If x != 0 and y == 0, the result is undefined. - -static inline vector float -_fmodf4 (vector float x, vector float y) -{ - vector float q, xabs, yabs, qabs, xabs2; - vector signed int qi0, qi1, qi2; - vector float i0, i1, i2, r1, r2, i; - vector unsigned int inrange; - - // Find i = truncated_integer(|x/y|) - - // If |divf4(x,y)| < 2^20, the quotient is at most off by 1.0. - // Thus i is either the truncated quotient, one less, or one greater. - - q = _divf4( x, y ); - xabs = _fabsf4( x ); - yabs = _fabsf4( y ); - qabs = _fabsf4( q ); - xabs2 = vec_add( xabs, xabs ); - - inrange = (vector unsigned int)vec_cmpgt( (vector float)(__vec_splatsu4(0x49800000)), qabs ); - - qi1 = vec_cts( qabs, 0 ); - qi0 = vec_add( qi1, __vec_splatsi4(-1) ); - qi2 = vec_add( qi1, __vec_splatsi4(1) ); - - i0 = vec_ctf( qi0, 0 ); - i1 = vec_ctf( qi1, 0 ); - i2 = vec_ctf( qi2, 0 ); - - // Correct i will be the largest one such that |x| - i*|y| >= 0. - - r1 = vec_nmsub( i1, yabs, xabs ); - r2 = vec_nmsub( i2, yabs, xabs ); - - i = i0; - i = vec_sel( i1, i, vec_cmpgt( __vec_splatsi4(0), (vector signed int)r1 ) ); - i = vec_sel( i2, i, vec_cmpgt( __vec_splatsi4(0), (vector signed int)r2 ) ); - - i = _copysignf4( i, q ); - - return vec_sel( __vec_splatsf4(0.0f), vec_nmsub( i, y, x ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/frexpf4.h b/Extras/simdmathlibrary/ppu/simdmath/frexpf4.h deleted file mode 100644 index 0cb809ec7..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/frexpf4.h +++ /dev/null @@ -1,54 +0,0 @@ -/* frexpf4 - - 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 ___SIMD_MATH_FREXPF4_H___ -#define ___SIMD_MATH_FREXPF4_H___ - -#include -#include - -#include - -static inline vector float -_frexpf4 (vector float x, vector signed int *exp) -{ - vector signed int zeros = __vec_splatsi4(0); - vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(x, (vector float)zeros); - - vector signed int expmask = __vec_splatsi4(0x7F800000); - vector signed int e1 = vec_and ( (vector signed int)x, expmask); - vector signed int e2 = vec_sub(vec_sr(e1, __vec_splatsu4(23) ), __vec_splatsi4(126) ); - *exp = vec_sel(e2, zeros, zeromask); - - vector float m2 = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask); - - return vec_sel(m2, (vector float)zeros, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/hypotf4.h b/Extras/simdmathlibrary/ppu/simdmath/hypotf4.h deleted file mode 100644 index 1e692c34b..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/hypotf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* hypotf4 - - 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 ___SIMD_MATH_HYPOTF4_H___ -#define ___SIMD_MATH_HYPOTF4_H___ - -#include -#include - -#include - -static inline vector float -_hypotf4 (vector float x, vector float y) -{ - vector float sum = vec_madd( x, x, __vec_splatsf4(0.0f) ); - sum = vec_madd(y, y, sum); - return _sqrtf4(sum); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/ilogbf4.h b/Extras/simdmathlibrary/ppu/simdmath/ilogbf4.h deleted file mode 100644 index 2ca828793..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/ilogbf4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ilogbf4 - - 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 ___SIMD_MATH_ILOGBF4_H___ -#define ___SIMD_MATH_ILOGBF4_H___ - -#include -#include -#include - -#include - -static inline vector signed int -_ilogbf4 (vector float x) -{ - vector signed int minus127 = __vec_splatsi4(-127); - - vector signed int e1 = vec_and((vector signed int)x, __vec_splatsi4(0x7F800000)); - vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(e1, __vec_splatsi4(0)); - vector signed int e2 = vec_add(vec_sr(e1,__vec_splatsu4(23)), minus127); - - return vec_sel(e2, __vec_splatsi4(FP_ILOGB0), zeromask); - -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/ldexpf4.h b/Extras/simdmathlibrary/ppu/simdmath/ldexpf4.h deleted file mode 100644 index 05a61a2a3..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/ldexpf4.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ldexpf4 - - 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 ___SIMD_MATH_LDEXPF4_H___ -#define ___SIMD_MATH_LDEXPF4_H___ - -#include -#include - -#include - -static inline vector float -_ldexpf4 (vector float x, vector signed int exp) -{ - vector signed int zeros = __vec_splatsi4(0); - - vector signed int expmask = __vec_splatsi4(0x7F800000); - vector signed int e1 = vec_and((vector signed int)x, expmask); - vector signed int e2 = vec_sr(e1,__vec_splatsu4(23)); - - vector unsigned int maxmask = (vector unsigned int)vec_cmpgt(exp, __vec_splatsi4(255)); - vector unsigned int minmask = (vector unsigned int)vec_cmpgt(__vec_splatsi4(-255), exp); - minmask = vec_or (minmask, (vector unsigned int)vec_cmpeq(x, (vector float)zeros)); - - vector signed int esum = vec_add(e2, exp); - - maxmask = vec_or (maxmask, (vector unsigned int)vec_cmpgt(esum, __vec_splatsi4(255))); - maxmask = vec_and(maxmask, __vec_splatsu4(0x7FFFFFFF)); - minmask = vec_or (minmask, (vector unsigned int)vec_cmpgt(zeros, esum)); - - x = vec_sel(x, (vector float)vec_sl(esum,__vec_splatsu4(23)), (vector unsigned int)expmask); - x = vec_sel(x, (vector float)zeros, minmask); - x = vec_sel(x, (vector float)maxmask, maxmask); - return x; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/log10f4.h b/Extras/simdmathlibrary/ppu/simdmath/log10f4.h deleted file mode 100644 index 9eeaf381e..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/log10f4.h +++ /dev/null @@ -1,83 +0,0 @@ -/* log10f4 - - 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 ___SIMD_MATH_LOG10F4_H___ -#define ___SIMD_MATH_LOG10F4_H___ - -#include -#include - -#include - -#define __LOG10F_loga2msb 0.3010299205780f -#define __LOG10F_loga2lsb 7.5085978266e-8f -#define __LOG10F_logaemsb 0.4342944622040f -#define __LOG10F_logaelsb 1.9699272335e-8f -#define __LOG10F_neglogae -0.4342944819033f - -#define __LOG10F_c0 -0.2988439998f -#define __LOG10F_c1 -0.3997655209f -#define __LOG10F_c2 -0.6666679125f - -static inline vector float -_log10f4 (vector float x) -{ - vector signed int zeros = __vec_splatsi4(0); - vector float ones = __vec_splatsf4(1.0f); - - vector signed int expmask = __vec_splatsi4(0x7F800000); - vector signed int xexp = - vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) ); - x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask); - - vector unsigned int mask = (vector unsigned int)vec_cmpgt( __vec_splatsf4(0.7071067811865f), x); - x = vec_sel(x , vec_add(x, x) , mask); - xexp = vec_sel(xexp, vec_sub(xexp, __vec_splatsi4(1)), mask); - - vector float x1 = vec_sub(x , ones); - vector float z = _divf4 (x1, vec_add(x, ones)); - vector float w = vec_madd(z , z, (vector float)zeros); - vector float polywneg; - polywneg = vec_madd(__vec_splatsf4(__LOG10F_c0), w, __vec_splatsf4(__LOG10F_c1)); - polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOG10F_c2)); - - vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros); - vector float wnew = vec_ctf(xexp,0); - - vector float zz1 = vec_madd(__vec_splatsf4(__LOG10F_logaemsb), x1, - vec_madd(__vec_splatsf4(__LOG10F_loga2msb),wnew,(vector float)zeros)); - vector float zz2 = vec_madd(__vec_splatsf4(__LOG10F_logaelsb), x1, - vec_madd(__vec_splatsf4(__LOG10F_loga2lsb), wnew, - vec_madd(__vec_splatsf4(__LOG10F_neglogae),y,(vector float)zeros)) - ); - - return vec_add(zz1, zz2); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/log1pf4.h b/Extras/simdmathlibrary/ppu/simdmath/log1pf4.h deleted file mode 100644 index 16a9de46e..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/log1pf4.h +++ /dev/null @@ -1,61 +0,0 @@ -/* log1pf4 - - 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 ___SIMD_MATH_LOG1PF4_H___ -#define ___SIMD_MATH_LOG1PF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_log1pf4 (vector float x) -{ - vector unsigned int nearzeromask = - (vector unsigned int)vec_and(vec_cmpgt(x, __vec_splatsf4(-0.5f)), - vec_cmpgt(__vec_splatsf4(0.5f), x)); - vector float x2 = vec_madd(x,x,__vec_splatsf4(0.0f)); - vector float d0, d1, n0, n1; - - d0 = vec_madd(x , __vec_splatsf4(1.5934420741f), __vec_splatsf4(0.8952856868f)); - d1 = vec_madd(x , __vec_splatsf4(0.1198195734f), __vec_splatsf4(0.8377145063f)); - d1 = vec_madd(x2, d1, d0); - - n0 = vec_madd(x , __vec_splatsf4(1.1457993413f), __vec_splatsf4(0.8952856678f)); - n1 = vec_madd(x , __vec_splatsf4(0.0082862580f), __vec_splatsf4(0.3394238808f)); - n1 = vec_madd(x2, n1, n0); - - return vec_sel(_logf4(vec_add(x, __vec_splatsf4(1.0f))), - vec_madd(x, _divf4(n1, d1), __vec_splatsf4(0.0f)), - nearzeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/log2f4.h b/Extras/simdmathlibrary/ppu/simdmath/log2f4.h deleted file mode 100644 index a8baca1a1..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/log2f4.h +++ /dev/null @@ -1,77 +0,0 @@ -/* log2f4 - - 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 ___SIMD_MATH_LOG2F4_H___ -#define ___SIMD_MATH_LOG2F4_H___ - -#include -#include - -#include - - -#define __LOG2F_l2emsb 1.4426950216293f -#define __LOG2F_l2elsb 1.9259629911e-8f -#define __LOG2F_negl2e -1.4426950408890f - -#define __LOG2F_c0 -0.2988439998f -#define __LOG2F_c1 -0.3997655209f -#define __LOG2F_c2 -0.6666679125f - -static inline vector float -_log2f4 (vector float x) -{ - vector signed int zeros = __vec_splatsi4(0); - vector float ones = __vec_splatsf4(1.0f); - - vector signed int expmask = __vec_splatsi4(0x7F800000); - vector signed int xexp = - vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) ); - x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask); - - vector unsigned int mask = (vector unsigned int)vec_cmpgt( __vec_splatsf4(0.7071067811865f), x); - x = vec_sel(x , vec_add(x, x) , mask); - xexp = vec_sel(xexp, vec_sub(xexp, __vec_splatsi4(1) ), mask); - - vector float x1 = vec_sub(x , ones); - vector float z = _divf4(x1, vec_add(x, ones)); - vector float w = vec_madd(z , z, (vector float)zeros); - vector float polywneg; - polywneg = vec_madd(__vec_splatsf4(__LOG2F_c0), w, __vec_splatsf4(__LOG2F_c1)); - polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOG2F_c2)); - - vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros); - vector float zz1 = vec_madd(__vec_splatsf4(__LOG2F_l2emsb), x1, vec_ctf(xexp,0)); - vector float zz2 = vec_madd(__vec_splatsf4(__LOG2F_l2elsb), x1, - vec_madd(__vec_splatsf4(__LOG2F_negl2e), y, (vector float)zeros)); - - return vec_add(zz1,zz2); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/logbf4.h b/Extras/simdmathlibrary/ppu/simdmath/logbf4.h deleted file mode 100644 index b6f43d753..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/logbf4.h +++ /dev/null @@ -1,48 +0,0 @@ -/* logbf4 - - 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 ___SIMD_MATH_LOGBF4_H___ -#define ___SIMD_MATH_LOGBF4_H___ - -#include -#include -#include - -#include - -static inline vector float -_logbf4 (vector float x) -{ - vector signed int e1 = vec_and((vector signed int)x, __vec_splatsi4(0x7F800000)); - vector unsigned int zeromask = (vector unsigned int)vec_cmpeq(e1, __vec_splatsi4(0)); - e1 = vec_sub(e1, __vec_splatsi4(0x3F800000)); - return vec_sel(vec_ctf(e1,23), __vec_splatsf4(-HUGE_VALF), zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/logf4.h b/Extras/simdmathlibrary/ppu/simdmath/logf4.h deleted file mode 100644 index c6d66d633..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/logf4.h +++ /dev/null @@ -1,77 +0,0 @@ -/* logf4 - - 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 ___SIMD_MATH_LOGF4_H___ -#define ___SIMD_MATH_LOGF4_H___ - -#include -#include - -#include - - -#define __LOGF_ln2msb 0.6931470632553f -#define __LOGF_negln2lsb -1.1730463525e-7f - -#define __LOGF_c0 -0.2988439998f -#define __LOGF_c1 -0.3997655209f -#define __LOGF_c2 -0.6666679125f - -static inline vector float -_logf4 (vector float x) -{ - vector signed int zeros = __vec_splatsi4(0); - vector float ones = __vec_splatsf4(1.0f); - - vector signed int expmask = __vec_splatsi4(0x7F800000); - vector signed int xexp = - vec_add( vec_sr(vec_and((vector signed int)x, expmask), __vec_splatsu4(23)), __vec_splatsi4(-126) ); - x = vec_sel(x, (vector float)(__vec_splatsi4(0x3F000000)), (vector unsigned int)expmask); - - - vector unsigned int mask = (vector unsigned int)vec_cmpgt(__vec_splatsf4(0.7071067811865f), x); - x = vec_sel(x , vec_add(x, x) , mask); - xexp = vec_sel(xexp, vec_sub(xexp,__vec_splatsi4(1)), mask); - - vector float x1 = vec_sub(x , ones); - vector float z = _divf4 (x1, vec_add(x, ones)); - vector float w = vec_madd(z , z, (vector float)zeros); - vector float polywneg; - polywneg = vec_madd(__vec_splatsf4(__LOGF_c0), w, __vec_splatsf4(__LOGF_c1)); - polywneg = vec_madd(polywneg , w, __vec_splatsf4(__LOGF_c2)); - - vector float y = vec_madd(z, vec_madd(polywneg, w, x1), (vector float)zeros); - vector float wnew = vec_ctf(xexp,0); - vector float zz1 = vec_madd(__vec_splatsf4(__LOGF_ln2msb) , wnew, x1); - vector float zz2neg = vec_madd(__vec_splatsf4(__LOGF_negln2lsb), wnew, y ); - - return vec_sub(zz1,zz2neg); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/modff4.h b/Extras/simdmathlibrary/ppu/simdmath/modff4.h deleted file mode 100644 index 3d6f7e786..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/modff4.h +++ /dev/null @@ -1,53 +0,0 @@ -/* modff4 - 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 ___SIMD_MATH_MODFF4_H___ -#define ___SIMD_MATH_MODFF4_H___ - -#include -#include - -#include - -// modff4 - for each of four float slots, compute fractional and integral parts. -// Returns fractional part and stores integral part in *iptr. - -static inline vector float -_modff4 (vector float x, vector float *iptr) -{ - vector float integral, fraction; - - integral = _truncf4( x ); - fraction = vec_sub( x, integral ); - - *iptr = integral; - return fraction; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/negatef4.h b/Extras/simdmathlibrary/ppu/simdmath/negatef4.h deleted file mode 100644 index 292b6ab8f..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/negatef4.h +++ /dev/null @@ -1,44 +0,0 @@ -/* negatef4 - for each of four float slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATEF4_H___ -#define ___SIMD_MATH_NEGATEF4_H___ - -#include -#include - -#include - -static inline vector float -_negatef4 (vector float x) -{ - return (vector float)vec_xor( (vector unsigned int)x, __vec_splatsu4(0x80000000) ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/negatei4.h b/Extras/simdmathlibrary/ppu/simdmath/negatei4.h deleted file mode 100644 index 57ddd6577..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/negatei4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* negatei4 - for each of four int slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATEI4_H___ -#define ___SIMD_MATH_NEGATEI4_H___ - -#include -#include - -#include - -static inline vector signed int -_negatei4 (vector signed int x) -{ - vector signed int zero = __vec_splatsi4(0); - return vec_sub (zero, x); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/powf4.h b/Extras/simdmathlibrary/ppu/simdmath/powf4.h deleted file mode 100644 index d7fcbfdd4..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/powf4.h +++ /dev/null @@ -1,61 +0,0 @@ -/* exp2f4 - 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 ___SIMD_MATH_POWF4_H___ -#define ___SIMD_MATH_POWF4_H___ - -#include -#include -#include - -#include -#include - -static inline vector float -_powf4 (vector float x, vector float y) -{ - vector signed int zeros = __vec_splatsi4(0); - vector unsigned int zeromask = (vector unsigned int)vec_cmpeq((vector float)zeros, x); - - vector unsigned int negmask = (vector unsigned int)vec_cmpgt((vector float)zeros, x); - - vector float sbit = (vector float)(__vec_splatsi4(0x80000000)); - vector float absx = vec_andc(x, sbit); - vector float absy = vec_andc(y, sbit); - vector unsigned int oddy = vec_and(vec_ctu(absy, 0), __vec_splatsu4(0x00000001)); - negmask = vec_and(negmask, (vector unsigned int)vec_cmpgt(oddy, (vector unsigned int)zeros)); - - vector float res = _exp2f4(vec_madd(y, _log2f4(absx), (vector float)zeros)); - res = vec_sel(res, vec_or(sbit, res), negmask); - - - return vec_sel(res, (vector float)zeros, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/recipf4.h b/Extras/simdmathlibrary/ppu/simdmath/recipf4.h deleted file mode 100644 index a570986e0..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/recipf4.h +++ /dev/null @@ -1,50 +0,0 @@ -/* recipf4 - for each of four float slots, compute reciprocal. - 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 ___SIMD_MATH_RECIPF4_H___ -#define ___SIMD_MATH_RECIPF4_H___ - -#include -#include - -#include - -static inline vector float -_recipf4 (vector float x) -{ - // Reciprocal estimate and 1 Newton-Raphson iteration. - - vector float y0; - vector float ones = __vec_splatsf4(1.0f); - - y0 = vec_re( x ); - return vec_madd( vec_nmsub( x, y0, ones), y0, y0 ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/rsqrtf4.h b/Extras/simdmathlibrary/ppu/simdmath/rsqrtf4.h deleted file mode 100644 index 5fd34956f..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/rsqrtf4.h +++ /dev/null @@ -1,57 +0,0 @@ -/* sqrtf4 - - 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 ___SIMD_MATH_RSQRTF4_H___ -#define ___SIMD_MATH_RSQRTF4_H___ - -#include -#include - -#include - -// rsqrtf4 - for each of four float slots, compute reciprocal square root. -// Undefined if input < 0. - -static inline vector float -_rsqrtf4 (vector float x) -{ - // Reciprocal square root estimate and 1 Newton-Raphson iteration. - - vector float zero = __vec_splatsf4(0.0f); - vector float half = __vec_splatsf4(0.5f); - vector float one = __vec_splatsf4(1.0f); - vector float y0, y0x, y0half; - - y0 = vec_rsqrte( x ); - y0x = vec_madd( y0, x, zero ); - y0half = vec_madd( y0, half, zero ); - return vec_madd( vec_nmsub( y0, y0x, one ), y0half, y0 ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/sincosf4.h b/Extras/simdmathlibrary/ppu/simdmath/sincosf4.h deleted file mode 100644 index 0a0bc3e74..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/sincosf4.h +++ /dev/null @@ -1,113 +0,0 @@ -/* sincosf4 - - 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 ___SIMD_MATH_SINCOSF4_H___ -#define ___SIMD_MATH_SINCOSF4_H___ - -#include -#include - -#include -#include - -// -// Computes both the sine and cosine of the all four slots of x -// by using a polynomial approximation. -// -static inline void -_sincosf4 (vector float x, vector float *s, vector float *c) -{ - vector float xl,xl2,xl3; - vector signed int q; - vector signed int offsetSin, offsetCos; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000))); - q = vec_cts(xl,0); - - - // Compute the offset based on the quadrant that the angle falls in. - // Add 1 to the offset for the cosine. - // - offsetSin = vec_and(q,__vec_splatsi4((int)0x3)); - offsetCos = vec_add(__vec_splatsi4(1),offsetSin); - - // Remainder in range [-pi/4..pi/4] - // - vector float qf = vec_ctf(q,0); - vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x); - xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1); - - // Compute x^2 and x^3 - // - xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f)); - xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f)); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0),xl2,__vec_splatsf4(__SINCOSF_CC1)); - vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0),xl2,__vec_splatsf4(__SINCOSF_SC1)); - - vector float ct2 = vec_madd(ct1,xl2,__vec_splatsf4(__SINCOSF_CC2)); - vector float st2 = vec_madd(st1,xl2,__vec_splatsf4(__SINCOSF_SC2)); - - vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f)); - vector float sx = vec_madd(st2,xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vector unsigned int sinMask = - (vector unsigned int)vec_cmpeq(vec_and(offsetSin,__vec_splatsi4(0x1)),__vec_splatsi4(0)); - vector unsigned int cosMask = - (vector unsigned int)vec_cmpeq(vec_and(offsetCos,__vec_splatsi4(0x1)),__vec_splatsi4(0)); - *s = vec_sel(cx,sx,sinMask); - *c = vec_sel(cx,sx,cosMask); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - sinMask = (vector unsigned int)vec_cmpeq(vec_and(offsetSin,__vec_splatsi4(0x2)),__vec_splatsi4(0)); - cosMask = (vector unsigned int)vec_cmpeq(vec_and(offsetCos,__vec_splatsi4(0x2)),__vec_splatsi4(0)); - - *s = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)*s),*s,sinMask); - *c = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)*c),*c,cosMask); - -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/sinf4.h b/Extras/simdmathlibrary/ppu/simdmath/sinf4.h deleted file mode 100644 index 12e3ec412..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/sinf4.h +++ /dev/null @@ -1,107 +0,0 @@ -/* sinf4 - - 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 ___SIMD_MATH_SINF4_H___ -#define ___SIMD_MATH_SINF4_H___ - -#include -#include - -#include -#include -// -// Computes the sine of each of the four slots -// by using a polynomial approximation. -// - -static inline vector float -_sinf4 (vector float x) -{ - vector float xl,xl2,xl3,res; - vector signed int q; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000))); - q = vec_cts(xl,0); - - - // Compute an offset based on the quadrant that the angle falls in - // - vector signed int offset = vec_and(q,__vec_splatsi4((int)0x3)); - - // Remainder in range [-pi/4..pi/4] - // - vector float qf = vec_ctf(q,0); - vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x); - xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1); - - // Compute x^2 and x^3 - // - xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f)); - xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f)); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vector float ct1 = vec_madd(__vec_splatsf4(__SINCOSF_CC0),xl2,__vec_splatsf4(__SINCOSF_CC1)); - vector float st1 = vec_madd(__vec_splatsf4(__SINCOSF_SC0),xl2,__vec_splatsf4(__SINCOSF_SC1)); - - vector float ct2 = vec_madd(ct1,xl2,__vec_splatsf4(__SINCOSF_CC2)); - vector float st2 = vec_madd(st1,xl2,__vec_splatsf4(__SINCOSF_SC2)); - - vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f)); - vector float sx = vec_madd(st2,xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vector unsigned int mask1 = (vector unsigned int)vec_cmpeq(vec_and(offset, - __vec_splatsi4(0x1)), - __vec_splatsi4((int)(0))); - res = vec_sel(cx,sx,mask1); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - vector unsigned int mask2 = - (vector unsigned int)vec_cmpeq(vec_and(offset,__vec_splatsi4(0x2)),__vec_splatsi4((int)0)); - res = vec_sel((vector float)vec_xor(__vec_splatsu4(0x80000000U),(vector unsigned int)res),res,mask2); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/sqrtf4.h b/Extras/simdmathlibrary/ppu/simdmath/sqrtf4.h deleted file mode 100644 index 3b4a0d17c..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/sqrtf4.h +++ /dev/null @@ -1,59 +0,0 @@ -/* sqrtf4 - - 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 ___SIMD_MATH_SQRTF4_H___ -#define ___SIMD_MATH_SQRTF4_H___ - -#include -#include - -#include - -// sqrtf4 - for each of four float slots, compute square root. -// Undefined if input < 0. - -static inline vector float -_sqrtf4 (vector float x) -{ - // Reciprocal square root estimate and 1 Newton-Raphson iteration. - - vector float zero = __vec_splatsf4(0.0f); - vector float half = __vec_splatsf4(0.5f); - vector float one = __vec_splatsf4(1.0f); - vector float y0, y0x, y0xhalf; - vector unsigned int cmp_zero; - - y0 = vec_rsqrte( x ); - cmp_zero = (vector unsigned int)vec_cmpeq( x, zero ); - y0x = vec_madd( y0, x, zero ); - y0xhalf = vec_madd( y0x, half, zero ); - return vec_sel( vec_madd( vec_nmsub( y0, y0x, one ), y0xhalf, y0x ), zero, cmp_zero ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/tanf4.h b/Extras/simdmathlibrary/ppu/simdmath/tanf4.h deleted file mode 100644 index cdb692a00..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/tanf4.h +++ /dev/null @@ -1,98 +0,0 @@ -/* tanf4 - - 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 ___SIMD_MATH_TANF4_H___ -#define ___SIMD_MATH_TANF4_H___ - -#include -#include - -#include -#include - -// -// Computes the tangent of all four slots of x by using a polynomia approximation. -// -static inline vector float -_tanf4 (vector float x) -{ - vector float xl,xl2,xl3,res; - vector signed int q; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_madd(x, __vec_splatsf4(0.63661977236f),__vec_splatsf4(0.0f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(x))*sign(x)) - // - xl = vec_add(xl,vec_sel(__vec_splatsf4(0.5f),xl,__vec_splatsu4(0x80000000))); - q = vec_cts(xl,0); - - - // Remainder in range [-pi/4..pi/4] - // - vector float qf = vec_ctf(q,0); - vector float p1 = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC1),x); - xl = vec_nmsub(qf,__vec_splatsf4(__SINCOSF_KC2),p1); - - // Compute x^2 and x^3 - // - xl2 = vec_madd(xl,xl,__vec_splatsf4(0.0f)); - xl3 = vec_madd(xl2,xl,__vec_splatsf4(0.0f)); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + x2 * (C0 * x2 + C1), and - // sx = xl + x3 * S0 - // - vector float ct2 = vec_madd(__vec_splatsf4( 0.0097099364f),xl2,__vec_splatsf4(-0.4291161787f)); - - vector float cx = vec_madd(ct2,xl2,__vec_splatsf4(1.0f)); - vector float sx = vec_madd(__vec_splatsf4(-0.0957822992f),xl3,xl); - - - // Compute both cx/sx and sx/cx - // - vector float cxosx = _divf4(cx,sx); - vector float sxocx = _divf4(sx,cx); - - vector float ncxosx = (vector float)vec_xor(__vec_splatsu4(0x80000000),(vector unsigned int)cxosx); - - // For odd numbered quadrants return -cx/sx , otherwise return - // sx/cx - // - vector unsigned int mask = - (vector unsigned int)vec_cmpeq(vec_and(q,__vec_splatsi4(0x1)),__vec_splatsi4(0)); - res = vec_sel(ncxosx,sxocx,mask); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/simdmath/truncf4.h b/Extras/simdmathlibrary/ppu/simdmath/truncf4.h deleted file mode 100644 index ab0edad9e..000000000 --- a/Extras/simdmathlibrary/ppu/simdmath/truncf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* truncf4 - for each of four float slots, round towards zero to integer value. - 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 ___SIMD_MATH_TRUNCF4_H___ -#define ___SIMD_MATH_TRUNCF4_H___ - -#include -#include - - -static inline vector float -_truncf4 (vector float x) -{ - return vec_trunc( x ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/tests/Makefile b/Extras/simdmathlibrary/ppu/tests/Makefile deleted file mode 100644 index a65d05035..000000000 --- a/Extras/simdmathlibrary/ppu/tests/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# Makefile for testsuite for the PPU SIMD math library -# 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. - -topdir = ../.. -ARCH = ppu - -include $(topdir)/Make.defs - -TESTS = fabsf4 absi4 truncf4 sqrtf4 negatef4 \ - copysignf4 modff4 fminf4_fmaxf4 \ - floorf4 recipf4 ceilf4 divf4 divi4 \ - rsqrtf4 fmodf4 negatei4 - -OBJS = testutils.o - -include $(topdir)/Make.test diff --git a/Extras/simdmathlibrary/ppu/tests/absi4.c b/Extras/simdmathlibrary/ppu/tests/absi4.c deleted file mode 100644 index 926e8d932..000000000 --- a/Extras/simdmathlibrary/ppu/tests/absi4.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Testcase for absi4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" -int main() -{ - TEST_SET_START("20040908101807EJL","EJL", "abs"); - - int x0n = hide_int(0); - int x0p = hide_int(0); - int x1n = hide_int(-1); - int x1p = hide_int(1); - int x2n = hide_int(-83532); - int x2p = hide_int(83532); - - vec_int4 x0n_v = vec_splat_int(x0n); - vec_int4 x0p_v = vec_splat_int(x0p); - vec_int4 x1n_v = vec_splat_int(x1n); - vec_int4 x1p_v = vec_splat_int(x1p); - vec_int4 x2n_v = vec_splat_int(x2n); - vec_int4 x2p_v = vec_splat_int(x2p); - - vec_int4 res_v; - - TEST_START("absi4"); - res_v = absi4(x0n_v); - TEST_CHECK("20040908103824EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = absi4(x0p_v); - TEST_CHECK("20040908103903EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = absi4(x1n_v); - TEST_CHECK("20040908103905EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = absi4(x1p_v); - TEST_CHECK("20040908114003EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = absi4(x2n_v); - TEST_CHECK("20040908114714EJL", allequal_int4( res_v, x2p_v ), 0); - res_v = absi4(x2p_v); - TEST_CHECK("20040908114715EJL", allequal_int4( res_v, x2p_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/ceilf4.c b/Extras/simdmathlibrary/ppu/tests/ceilf4.c deleted file mode 100644 index e06c0f716..000000000 --- a/Extras/simdmathlibrary/ppu/tests/ceilf4.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Testcase for ceilf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040916103300EJL","EJL", "ceilf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4b000000; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(1.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = vec_splat_float(x0); - vec_float4 x0i_v = vec_splat_float(x0i); - vec_float4 x1_v = vec_splat_float(x1); - vec_float4 x1i_v = vec_splat_float(x1i); - vec_float4 x2_v = vec_splat_float(x2); - vec_float4 x2i_v = vec_splat_float(x2i); - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3i_v = vec_splat_float(x3i); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4i_v = vec_splat_float(x4i); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5i_v = vec_splat_float(x5i); - - vec_float4 res_v; - - TEST_START("ceilf4"); - res_v = ceilf4(x0_v); - TEST_CHECK("20040916103310EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = ceilf4(x1_v); - TEST_CHECK("20040916103324EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = ceilf4(x2_v); - TEST_CHECK("20040916103334EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = ceilf4(x3_v); - TEST_CHECK("20040916103341EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = ceilf4(x4_v); - TEST_CHECK("20040916103350EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = ceilf4(x5_v); - TEST_CHECK("20040916103357EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/copysignf4.c b/Extras/simdmathlibrary/ppu/tests/copysignf4.c deleted file mode 100644 index db7adcb83..000000000 --- a/Extras/simdmathlibrary/ppu/tests/copysignf4.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Testcase for copysignf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - -int main() -{ - TEST_SET_START("20040917114054EJL", "EJL", "copysignf"); - - float x0m = hide_float(1989.0f); - float x0s = hide_float(-319875.0f); - float x0c = hide_float(-1989.0f); - float x1m = hide_float(9013.0f); - float x1s = hide_float(185.0f); - float x1c = hide_float(9013.0f); - - vec_float4 x0m_v = vec_splat_float(x0m); - vec_float4 x0s_v = vec_splat_float(x0s); - vec_float4 x0c_v = vec_splat_float(x0c); - - vec_float4 x1m_v = vec_splat_float(x1m); - vec_float4 x1s_v = vec_splat_float(x1s); - vec_float4 x1c_v = vec_splat_float(x1c); - - vec_float4 res_v; - - TEST_START("copysignf4"); - res_v = copysignf4( x0m_v, x0s_v ); - TEST_CHECK("20040917114058EJL", allequal_float4( res_v, x0c_v ), 0); - res_v = copysignf4( x1m_v, x1s_v ); - TEST_CHECK("20040917114100EJL", allequal_float4( res_v, x1c_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/divf4.c b/Extras/simdmathlibrary/ppu/tests/divf4.c deleted file mode 100644 index 8816b7ed7..000000000 --- a/Extras/simdmathlibrary/ppu/tests/divf4.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Testcase for divf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040928105926EJL","EJL", "divf4"); - - unsigned int i0n = 0x75013340; - unsigned int i0d = 0x75e7753f; - unsigned int i0r = 0x3e8ee64b; - unsigned int i1n = 0x4c7fed5a; - unsigned int i1d = 0x3a0731f0; - unsigned int i1r = 0x51f24e86; - unsigned int i2n = 0x5b08b303; - unsigned int i2d = 0x562f5046; - unsigned int i2r = 0x44479d24; - unsigned int i3n = 0x748a9b87; - unsigned int i3d = 0x6b014b46; - unsigned int i3r = 0x49093864; - unsigned int i4n = 0x35dcf9d8; - unsigned int i4d = 0x6278d6e0; - unsigned int i4r = 0x12e355b5; - unsigned int i5n = 0x74d505fd; - unsigned int i5d = 0x61ef565e; - unsigned int i5r = 0x5263daa3; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = vec_splat_float(x0n); - vec_float4 x0d_v = vec_splat_float(x0d); - vec_float4 x0r_v = vec_splat_float(x0r); - - vec_float4 x1n_v = vec_splat_float(x1n); - vec_float4 x1d_v = vec_splat_float(x1d); - vec_float4 x1r_v = vec_splat_float(x1r); - - vec_float4 x2n_v = vec_splat_float(x2n); - vec_float4 x2d_v = vec_splat_float(x2d); - vec_float4 x2r_v = vec_splat_float(x2r); - - vec_float4 x3n_v = vec_splat_float(x3n); - vec_float4 x3d_v = vec_splat_float(x3d); - vec_float4 x3r_v = vec_splat_float(x3r); - - vec_float4 x4n_v = vec_splat_float(x4n); - vec_float4 x4d_v = vec_splat_float(x4d); - vec_float4 x4r_v = vec_splat_float(x4r); - - vec_float4 x5n_v = vec_splat_float(x5n); - vec_float4 x5d_v = vec_splat_float(x5d); - vec_float4 x5r_v = vec_splat_float(x5r); - - vec_float4 res_v; - - TEST_START("divf4"); - res_v = divf4(x0n_v, x0d_v); - TEST_CHECK("20040928105932EJL", allequal_ulps_float4( res_v, x0r_v, 2 ), 0); - res_v = divf4(x1n_v, x1d_v); - TEST_CHECK("20040928105934EJL", allequal_ulps_float4( res_v, x1r_v, 2 ), 0); - res_v = divf4(x2n_v, x2d_v); - TEST_CHECK("20040928105936EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0); - res_v = divf4(x3n_v, x3d_v); - TEST_CHECK("20040928105938EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = divf4(x4n_v, x4d_v); - TEST_CHECK("20040928105940EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = divf4(x5n_v, x5d_v); - TEST_CHECK("20040928105943EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/divi4.c b/Extras/simdmathlibrary/ppu/tests/divi4.c deleted file mode 100644 index 701c1ce62..000000000 --- a/Extras/simdmathlibrary/ppu/tests/divi4.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Testcase for divi4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - - -int main() -{ - TEST_SET_START("20040928161739EJL","EJL", "divi4"); - - int x0n = 0xffccb78d; - int x0d = 0x0 ; - int x0q = 0x0 ; - int x0r = 0xffccb78d; - int x1n = 0x0; - int x1d = 0xff976bb6; - int x1q = 0x0 ; - int x1r = 0x0; - int x2n = 0x0; - int x2d = 0x0; - int x2q = 0x0 ; - int x2r = 0x0; - int x3n = 0xf0e91618; - int x3d = 0xfddff7ac; - int x3q = 0x7 ; - int x3r = 0xffc95064; - - int x4n = 0xf2128d9d; - int x4d = 0xe0f76 ; - int x4q = 0xffffff03; - int x4r = 0xfff7d53b; - int x5n = 0xda1ba2ce; - int x5d = 0x4c9 ; - int x5q = 0xfff814d3; - int x5r = 0xfffffd23; - int x6n = 0xdd4426a6; - int x6d = 0xf8d245cf; - int x6q = 0x4 ; - int x6r = 0xf9fb0f6a; - int x7n = 0xd1d5ae9 ; - int x7d = 0x333ab105; - int x7q = 0x0 ; - int x7r = 0xd1d5ae9 ; - - int x8n = 0x3e0c6 ; - int x8d = 0xfff24255; - int x8q = 0x0 ; - int x8r = 0x3e0c6 ; - int x9n = 0xfd6fe27e; - int x9d = 0xf32454 ; - int x9q = 0xfffffffe; - int x9r = 0xff562b26; - int x10n =0xfb150f79; - int x10d =0xf521 ; - int x10q =0xfffffade; - int x10r =0xffff42db; - int x11n =0xfe88071f; - int x11d =0xfff937c2; - int x11q =0x37 ; - int x11r =0xfffd0c71; - - - vec_int4 x0n_v = (vec_int4){ x0n, x1n, x2n, x3n }; - vec_int4 x1n_v = (vec_int4){ x4n, x5n, x6n, x7n }; - vec_int4 x2n_v = (vec_int4){ x8n, x9n, x10n, x11n }; - - vec_int4 x0d_v = (vec_int4){ x0d, x1d, x2d, x3d }; - vec_int4 x1d_v = (vec_int4){ x4d, x5d, x6d, x7d }; - vec_int4 x2d_v = (vec_int4){ x8d, x9d, x10d, x11d }; - - vec_int4 x0q_v = (vec_int4){ x0q, x1q, x2q, x3q }; - vec_int4 x1q_v = (vec_int4){ x4q, x5q, x6q, x7q }; - vec_int4 x2q_v = (vec_int4){ x8q, x9q, x10q, x11q }; - - vec_int4 x0r_v = (vec_int4){ x0r, x1r, x2r, x3r }; - vec_int4 x1r_v = (vec_int4){ x4r, x5r, x6r, x7r }; - vec_int4 x2r_v = (vec_int4){ x8r, x9r, x10r, x11r }; - - divi4_t res; - - TEST_START("divi4"); - res = divi4(x0n_v, x0d_v); - TEST_CHECK("20040928161846EJL", allequal_int4( res.quot, x0q_v ) && allequal_int4( res.rem, x0r_v ), 0); - res = divi4(x1n_v, x1d_v); - TEST_CHECK("20040928161851EJL", allequal_int4( res.quot, x1q_v ) && allequal_int4( res.rem, x1r_v ), 0); - res = divi4(x2n_v, x2d_v); - TEST_CHECK("20040928161855EJL", allequal_int4( res.quot, x2q_v ) && allequal_int4( res.rem, x2r_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/fabsf4.c b/Extras/simdmathlibrary/ppu/tests/fabsf4.c deleted file mode 100644 index 4864e46a9..000000000 --- a/Extras/simdmathlibrary/ppu/tests/fabsf4.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Testcase for fabsf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - -int main() -{ - TEST_SET_START("20040915032605EJL","EJL", "fabsf"); - - unsigned int i3n = 0xff000000; - unsigned int i3p = 0x7f000000; - - float x0n = hide_float(-0.0f); - float x0p = hide_float(0.0f); - float x1n = hide_float(-83532.96153153f); - float x1p = hide_float(83532.96153153f); - float x2n = hide_float(-0.0000000013152f); - float x2p = hide_float(0.0000000013152f); - float x3n = hide_float(make_float(i3n)); - float x3p = hide_float(make_float(i3p)); - - vec_float4 x0n_v = vec_splat_float(x0n); - vec_float4 x0p_v = vec_splat_float(x0p); - vec_float4 x1n_v = vec_splat_float(x1n); - vec_float4 x1p_v = vec_splat_float(x1p); - vec_float4 x2n_v = vec_splat_float(x2n); - vec_float4 x2p_v = vec_splat_float(x2p); - vec_float4 x3n_v = vec_splat_float(x3n); - vec_float4 x3p_v = vec_splat_float(x3p); - - vec_float4 res_v; - - TEST_START("fabsf4"); - res_v = fabsf4(x0n_v); - TEST_CHECK("20040915032618EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = fabsf4(x0p_v); - TEST_CHECK("20040915032632EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = fabsf4(x1n_v); - TEST_CHECK("20040915032643EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = fabsf4(x1p_v); - TEST_CHECK("20040915032654EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = fabsf4(x2n_v); - TEST_CHECK("20040915032704EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = fabsf4(x2p_v); - TEST_CHECK("20040915032712EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = fabsf4(x3n_v); - TEST_CHECK("20040915032719EJL", allequal_float4( res_v, x3p_v ), 0); - res_v = fabsf4(x3p_v); - TEST_CHECK("20040915032729EJL", allequal_float4( res_v, x3p_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/floorf4.c b/Extras/simdmathlibrary/ppu/tests/floorf4.c deleted file mode 100644 index 26435ea35..000000000 --- a/Extras/simdmathlibrary/ppu/tests/floorf4.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Testcase for floorf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040916145017EJL","EJL", "floorf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(-1.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79616.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = vec_splat_float(x0); - vec_float4 x0i_v = vec_splat_float(x0i); - vec_float4 x1_v = vec_splat_float(x1); - vec_float4 x1i_v = vec_splat_float(x1i); - vec_float4 x2_v = vec_splat_float(x2); - vec_float4 x2i_v = vec_splat_float(x2i); - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3i_v = vec_splat_float(x3i); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4i_v = vec_splat_float(x4i); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5i_v = vec_splat_float(x5i); - - vec_float4 res_v; - - TEST_START("floorf4"); - res_v = floorf4(x0_v); - TEST_CHECK("20040916145022EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = floorf4(x1_v); - TEST_CHECK("20040916145024EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = floorf4(x2_v); - TEST_CHECK("20040916145027EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = floorf4(x3_v); - TEST_CHECK("20040916145029EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = floorf4(x4_v); - TEST_CHECK("20040916145032EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = floorf4(x5_v); - TEST_CHECK("20040916145034EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/fminf4_fmaxf4.c b/Extras/simdmathlibrary/ppu/tests/fminf4_fmaxf4.c deleted file mode 100644 index 5c45fa4f7..000000000 --- a/Extras/simdmathlibrary/ppu/tests/fminf4_fmaxf4.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Testcase for fminf4 and fmaxf4 - 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. - */ - -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - -int main() -{ - TEST_SET_START("20040928184342EJL","EJL", "fminf4_fmaxf4"); - - float x0min = hide_float(1760.135f); - float x0max = hide_float(19355.03f); - - float x1min = hide_float(-12351.9f); - float x1max = hide_float(-139.035f); - - float x2min = hide_float(-1.0); - float x2max = hide_float(0.0); - - vec_float4 x0min_v = vec_splat_float(x0min); - vec_float4 x0max_v = vec_splat_float(x0max); - - vec_float4 x1min_v = vec_splat_float(x1min); - vec_float4 x1max_v = vec_splat_float(x1max); - - vec_float4 x2min_v = vec_splat_float(x2min); - vec_float4 x2max_v = vec_splat_float(x2max); - - vec_float4 res_v; - - TEST_START("fminf4"); - res_v = fminf4(x0min_v, x0max_v); - TEST_CHECK("20040928184345EJL", allequal_float4( res_v, x0min_v ), 0); - res_v = fminf4(x0max_v, x0min_v); - TEST_CHECK("20040928184349EJL", allequal_float4( res_v, x0min_v ), 0); - res_v = fminf4(x1min_v, x1max_v); - TEST_CHECK("20040928184351EJL", allequal_float4( res_v, x1min_v ), 0); - res_v = fminf4(x1max_v, x1min_v); - TEST_CHECK("20040928184353EJL", allequal_float4( res_v, x1min_v ), 0); - res_v = fminf4(x2min_v, x2max_v); - TEST_CHECK("20040928184354EJL", allequal_float4( res_v, x2min_v ), 0); - res_v = fminf4(x2max_v, x2min_v); - TEST_CHECK("20040928184356EJL", allequal_float4( res_v, x2min_v ), 0); - - TEST_START("fmaxf4"); - res_v = fmaxf4(x0min_v, x0max_v); - TEST_CHECK("20040928184411EJL", allequal_float4( res_v, x0max_v ), 0); - res_v = fmaxf4(x0max_v, x0min_v); - TEST_CHECK("20040928184413EJL", allequal_float4( res_v, x0max_v ), 0); - res_v = fmaxf4(x1min_v, x1max_v); - TEST_CHECK("20040928184415EJL", allequal_float4( res_v, x1max_v ), 0); - res_v = fmaxf4(x1max_v, x1min_v); - TEST_CHECK("20040928184416EJL", allequal_float4( res_v, x1max_v ), 0); - res_v = fmaxf4(x2min_v, x2max_v); - TEST_CHECK("20040928184417EJL", allequal_float4( res_v, x2max_v ), 0); - res_v = fmaxf4(x2max_v, x2min_v); - TEST_CHECK("20040928184419EJL", allequal_float4( res_v, x2max_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/fmodf4.c b/Extras/simdmathlibrary/ppu/tests/fmodf4.c deleted file mode 100644 index 9574e88fe..000000000 --- a/Extras/simdmathlibrary/ppu/tests/fmodf4.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Testcase for fmodf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - - -int main() -{ - TEST_SET_START("20040928191240EJL","EJL", "fmodf4"); - - unsigned int i0n = 0x449edbc6; - unsigned int i0d = 0x40cf799d; - unsigned int i0r = 0x3daa7300; - unsigned int i1n = 0x6bca107a; - unsigned int i1d = 0x6c4a107a; - unsigned int i1r = 0x6bca107a; - unsigned int i2n = 0x1c123605; - unsigned int i2d = 0x1c923602; - unsigned int i2r = 0x1c123605; - unsigned int i3n = 0x2b4c50fa; - unsigned int i3d = 0x253a3ae3; - unsigned int i3r = 0x25141df9; - unsigned int i4n = 0x73addffc; - unsigned int i4d = 0x742ddffc; - unsigned int i4r = 0x73addffc; - unsigned int i5n = 0x29d4d97c; - unsigned int i5d = 0x2a546e77; - unsigned int i5r = 0x29d4d97c; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = vec_splat_float(x0n); - vec_float4 x0d_v = vec_splat_float(x0d); - vec_float4 x0r_v = vec_splat_float(x0r); - - vec_float4 x1n_v = vec_splat_float(x1n); - vec_float4 x1d_v = vec_splat_float(x1d); - vec_float4 x1r_v = vec_splat_float(x1r); - - vec_float4 x2n_v = vec_splat_float(x2n); - vec_float4 x2d_v = vec_splat_float(x2d); - vec_float4 x2r_v = vec_splat_float(x2r); - - vec_float4 x3n_v = vec_splat_float(x3n); - vec_float4 x3d_v = vec_splat_float(x3d); - vec_float4 x3r_v = vec_splat_float(x3r); - - vec_float4 x4n_v = vec_splat_float(x4n); - vec_float4 x4d_v = vec_splat_float(x4d); - vec_float4 x4r_v = vec_splat_float(x4r); - - vec_float4 x5n_v = vec_splat_float(x5n); - vec_float4 x5d_v = vec_splat_float(x5d); - vec_float4 x5r_v = vec_splat_float(x5r); - - vec_float4 res_v; - - TEST_START("fmodf4"); - res_v = fmodf4(x0n_v, x0d_v); - TEST_CHECK("20040928191245EJL", allequal_ulps_float4( res_v, x0r_v, 1 ), 0); - res_v = fmodf4(x1n_v, x1d_v); - TEST_CHECK("20040928191247EJL", allequal_ulps_float4( res_v, x1r_v, 1 ), 0); - res_v = fmodf4(x2n_v, x2d_v); - TEST_CHECK("20040928191249EJL", allequal_ulps_float4( res_v, x2r_v, 1 ), 0); - res_v = fmodf4(x3n_v, x3d_v); - TEST_CHECK("20040928191251EJL", allequal_ulps_float4( res_v, x3r_v, 1 ), 0); - res_v = fmodf4(x4n_v, x4d_v); - TEST_CHECK("20040928191253EJL", allequal_ulps_float4( res_v, x4r_v, 1 ), 0); - res_v = fmodf4(x5n_v, x5d_v); - TEST_CHECK("20040928191255EJL", allequal_ulps_float4( res_v, x5r_v, 1 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/modff4.c b/Extras/simdmathlibrary/ppu/tests/modff4.c deleted file mode 100644 index 1379fa215..000000000 --- a/Extras/simdmathlibrary/ppu/tests/modff4.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Testcase for modff4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - -int main() -{ - TEST_SET_START("20040916170642EJL", "EJL", "modff"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x0f = hide_float(0.91825f); - - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x1f = hide_float(-0.12958f); - - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x2f = hide_float(-0.1875f); - - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x3f = hide_float(0.5f); - - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x4f = hide_float(0.0f); - - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - float x5f = hide_float(0.0f); - - vec_float4 x0_v = vec_splat_float(x0); - vec_float4 x0i_v = vec_splat_float(x0i); - vec_float4 x0f_v = vec_splat_float(x0f); - vec_float4 x1_v = vec_splat_float(x1); - vec_float4 x1i_v = vec_splat_float(x1i); - vec_float4 x1f_v = vec_splat_float(x1f); - vec_float4 x2_v = vec_splat_float(x2); - vec_float4 x2i_v = vec_splat_float(x2i); - vec_float4 x2f_v = vec_splat_float(x2f); - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3i_v = vec_splat_float(x3i); - vec_float4 x3f_v = vec_splat_float(x3f); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4i_v = vec_splat_float(x4i); - vec_float4 x4f_v = vec_splat_float(x4f); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5i_v = vec_splat_float(x5i); - vec_float4 x5f_v = vec_splat_float(x5f); - - vec_float4 integer_v, fraction_v; - - TEST_START("modff4"); - fraction_v = modff4(x0_v, &integer_v); - TEST_CHECK("20040916170647EJL", allequal_float4( integer_v, x0i_v ) && allequal_float4( fraction_v, x0f_v ), 0); - fraction_v = modff4(x1_v, &integer_v); - TEST_CHECK("20040916170650EJL", allequal_float4( integer_v, x1i_v ) && allequal_float4( fraction_v, x1f_v ), 0); - fraction_v = modff4(x2_v, &integer_v); - TEST_CHECK("20040916170653EJL", allequal_float4( integer_v, x2i_v ) && allequal_float4( fraction_v, x2f_v ), 0); - fraction_v = modff4(x3_v, &integer_v); - TEST_CHECK("20040916170656EJL", allequal_float4( integer_v, x3i_v ) && allequal_float4( fraction_v, x3f_v ), 0); - fraction_v = modff4(x4_v, &integer_v); - TEST_CHECK("20040916170658EJL", allequal_float4( integer_v, x4i_v ) && allequal_float4( fraction_v, x4f_v ), 0); - fraction_v = modff4(x5_v, &integer_v); - TEST_CHECK("20040916170701EJL", allequal_float4( integer_v, x5i_v ) && allequal_float4( fraction_v, x5f_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/negatef4.c b/Extras/simdmathlibrary/ppu/tests/negatef4.c deleted file mode 100644 index c0f809f01..000000000 --- a/Extras/simdmathlibrary/ppu/tests/negatef4.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Testcase for negatef4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040930102649EJL","EJL", "negatef4"); - - unsigned int i3n = 0xff000000; - unsigned int i3p = 0x7f000000; - - float x0n = hide_float(-0.0f); - float x0p = hide_float(0.0f); - float x1n = hide_float(-83532.96153153f); - float x1p = hide_float(83532.96153153f); - float x2n = hide_float(-0.0000000013152f); - float x2p = hide_float(0.0000000013152f); - float x3n = hide_float(make_float(i3n)); - float x3p = hide_float(make_float(i3p)); - - vec_float4 x0n_v = vec_splat_float(x0n); - vec_float4 x0p_v = vec_splat_float(x0p); - vec_float4 x1n_v = vec_splat_float(x1n); - vec_float4 x1p_v = vec_splat_float(x1p); - vec_float4 x2n_v = vec_splat_float(x2n); - vec_float4 x2p_v = vec_splat_float(x2p); - vec_float4 x3n_v = vec_splat_float(x3n); - vec_float4 x3p_v = vec_splat_float(x3p); - - vec_float4 res_v; - - TEST_START("negatef4"); - res_v = negatef4(x0n_v); - TEST_CHECK("20040930102652EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = negatef4(x0p_v); - TEST_CHECK("20040930102653EJL", allequal_float4( res_v, x0n_v ), 0); - res_v = negatef4(x1n_v); - TEST_CHECK("20040930102655EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = negatef4(x1p_v); - TEST_CHECK("20040930102657EJL", allequal_float4( res_v, x1n_v ), 0); - res_v = negatef4(x2n_v); - TEST_CHECK("20040930102659EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = negatef4(x2p_v); - TEST_CHECK("20040930102701EJL", allequal_float4( res_v, x2n_v ), 0); - res_v = negatef4(x3n_v); - TEST_CHECK("20040930102703EJL", allequal_float4( res_v, x3p_v ), 0); - res_v = negatef4(x3p_v); - TEST_CHECK("20040930102705EJL", allequal_float4( res_v, x3n_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/negatei4.c b/Extras/simdmathlibrary/ppu/tests/negatei4.c deleted file mode 100644 index ad78aa9b5..000000000 --- a/Extras/simdmathlibrary/ppu/tests/negatei4.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Testcase for negatei4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040930102649EJL","EJL", "negatei4"); - - int x0n = hide_int(0); - int x0p = hide_int(0); - int x1n = hide_int(-83532); - int x1p = hide_int(83532); - int x2n = hide_int(-13152); - int x2p = hide_int(13152); - int x3n = hide_int(-1); - int x3p = hide_int(1); - - vec_int4 x0n_v = vec_splat_int(x0n); - vec_int4 x0p_v = vec_splat_int(x0p); - vec_int4 x1n_v = vec_splat_int(x1n); - vec_int4 x1p_v = vec_splat_int(x1p); - vec_int4 x2n_v = vec_splat_int(x2n); - vec_int4 x2p_v = vec_splat_int(x2p); - vec_int4 x3n_v = vec_splat_int(x3n); - vec_int4 x3p_v = vec_splat_int(x3p); - - vec_int4 res_v; - - TEST_START("negatei4"); - res_v = negatei4(x0n_v); - TEST_CHECK("20040930102652EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = negatei4(x0p_v); - TEST_CHECK("20040930102653EJL", allequal_int4( res_v, x0n_v ), 0); - res_v = negatei4(x1n_v); - TEST_CHECK("20040930102655EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = negatei4(x1p_v); - TEST_CHECK("20040930102657EJL", allequal_int4( res_v, x1n_v ), 0); - res_v = negatei4(x2n_v); - TEST_CHECK("20040930102659EJL", allequal_int4( res_v, x2p_v ), 0); - res_v = negatei4(x2p_v); - TEST_CHECK("20040930102701EJL", allequal_int4( res_v, x2n_v ), 0); - res_v = negatei4(x3n_v); - TEST_CHECK("20040930102703EJL", allequal_int4( res_v, x3p_v ), 0); - res_v = negatei4(x3p_v); - TEST_CHECK("20040930102705EJL", allequal_int4( res_v, x3n_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/recipf4.c b/Extras/simdmathlibrary/ppu/tests/recipf4.c deleted file mode 100644 index 52f1e5640..000000000 --- a/Extras/simdmathlibrary/ppu/tests/recipf4.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Testcase for recipf4 - 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. - */ - - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040920142553EJL","EJL", "recipf4"); - - unsigned int i1 = 0xff000000; // -2^127 - unsigned int i2 = 0xfe7fffff; // -2^126 - 1 ulp - unsigned int i2r = 0x80800001; - unsigned int i3 = 0x75013340; // random values - unsigned int i3r = 0x09fd9f35; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x090d9277; - unsigned int i5 = 0x4c7fed5a; - unsigned int i5r = 0x32800954; - unsigned int i6 = 0x3a0731f0; - unsigned int i6r = 0x44f2602e; - unsigned int i7 = 0x69784a07; - unsigned int i7r = 0x1583f9a3; - - float x1 = hide_float(make_float(i1)); - float x1r = hide_float(0.0f); - float x2 = hide_float(make_float(i2)); - float x2r = hide_float(make_float(i2r)); - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x1_v = vec_splat_float(x1); - vec_float4 x1r_v = vec_splat_float(x1r); - vec_float4 x2_v = vec_splat_float(x2); - vec_float4 x2r_v = vec_splat_float(x2r); - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3r_v = vec_splat_float(x3r); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4r_v = vec_splat_float(x4r); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5r_v = vec_splat_float(x5r); - vec_float4 x6_v = vec_splat_float(x6); - vec_float4 x6r_v = vec_splat_float(x6r); - vec_float4 x7_v = vec_splat_float(x7); - vec_float4 x7r_v = vec_splat_float(x7r); - - vec_float4 res_v; - - TEST_START("recipf4"); - res_v = recipf4(x1_v); - TEST_CHECK("20040920142600EJL", allequal_float4( res_v, x1r_v), 0); - res_v = recipf4(x2_v); - TEST_CHECK("20040920142602EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0); - res_v = recipf4(x3_v); - TEST_CHECK("20040920142604EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = recipf4(x4_v); - TEST_CHECK("20040920142606EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = recipf4(x5_v); - TEST_CHECK("20040920142608EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = recipf4(x6_v); - TEST_CHECK("20040920142609EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = recipf4(x7_v); - TEST_CHECK("20040920142611EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/rsqrtf4.c b/Extras/simdmathlibrary/ppu/tests/rsqrtf4.c deleted file mode 100644 index 1a8801e2c..000000000 --- a/Extras/simdmathlibrary/ppu/tests/rsqrtf4.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Testcase for rsqrtf4 - 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. - */ - - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - - - -int main() -{ - TEST_SET_START("20040928182349EJL","EJL", "rsqrtf4"); - - unsigned int i3 = 0x742c4455; - unsigned int i3r = 0x251c099a; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x243e5fe2; - unsigned int i5 = 0x4baa9e3c; - unsigned int i5r = 0x395dbbeb; - unsigned int i6 = 0x39344296; - unsigned int i6r = 0x429889eb; - unsigned int i7 = 0x68a586b0; - unsigned int i7r = 0x2ae11e67; - - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3r_v = vec_splat_float(x3r); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4r_v = vec_splat_float(x4r); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5r_v = vec_splat_float(x5r); - vec_float4 x6_v = vec_splat_float(x6); - vec_float4 x6r_v = vec_splat_float(x6r); - vec_float4 x7_v = vec_splat_float(x7); - vec_float4 x7r_v = vec_splat_float(x7r); - - vec_float4 res_v; - - TEST_START("rsqrtf4"); - res_v = rsqrtf4(x3_v); - TEST_CHECK("20040928182352EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = rsqrtf4(x4_v); - TEST_CHECK("20040928182355EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = rsqrtf4(x5_v); - TEST_CHECK("20040928182357EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = rsqrtf4(x6_v); - TEST_CHECK("20040928182358EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = rsqrtf4(x7_v); - TEST_CHECK("20040928182401EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/sqrtf4.c b/Extras/simdmathlibrary/ppu/tests/sqrtf4.c deleted file mode 100644 index 70bee97b2..000000000 --- a/Extras/simdmathlibrary/ppu/tests/sqrtf4.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Testcase for sqrtf4 - 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. - */ - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040928182549EJL","EJL", "sqrtf4"); - - unsigned int i3 = 0x742c4455; - unsigned int i3r = 0x59d20034; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x5aac1fb5; - unsigned int i5 = 0x4baa9e3c; - unsigned int i5r = 0x4593c7d8; - unsigned int i6 = 0x39344296; - unsigned int i6r = 0x3c56d14c; - unsigned int i7 = 0x68a586b0; - unsigned int i7r = 0x54118f09; - - float x0 = hide_float(0.0f); - float x0r = hide_float(0.0f); - - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x0_v = vec_splat_float(x0); - vec_float4 x0r_v = vec_splat_float(x0r); - - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3r_v = vec_splat_float(x3r); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4r_v = vec_splat_float(x4r); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5r_v = vec_splat_float(x5r); - vec_float4 x6_v = vec_splat_float(x6); - vec_float4 x6r_v = vec_splat_float(x6r); - vec_float4 x7_v = vec_splat_float(x7); - vec_float4 x7r_v = vec_splat_float(x7r); - - vec_float4 res_v; - - TEST_START("sqrtf4"); - res_v = sqrtf4(x0_v); - TEST_CHECK("20040928182551EJL", allequal_float4( res_v, x0r_v ), 0); - res_v = sqrtf4(x3_v); - TEST_CHECK("20040928182552EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = sqrtf4(x4_v); - TEST_CHECK("20040928182554EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = sqrtf4(x5_v); - TEST_CHECK("20040928182556EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = sqrtf4(x6_v); - TEST_CHECK("20040928182557EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = sqrtf4(x7_v); - TEST_CHECK("20040928182559EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/ppu/tests/testutils.c b/Extras/simdmathlibrary/ppu/tests/testutils.c deleted file mode 100644 index f5bfa3b3b..000000000 --- a/Extras/simdmathlibrary/ppu/tests/testutils.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Common part of the testsuite - 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. - */ - -unsigned int -hide_uint( unsigned int x ) -{ - return x; -} - -int -hide_int( int x ) -{ - return x; -} - -float -hide_float( float x ) -{ - return x; -} - -double -hide_double( double x ) -{ - return x; -} - -float -make_float( unsigned int x ) -{ - - union - { - unsigned int i; - float f; - }fi; - fi.i = x; - return fi.f; -} - - diff --git a/Extras/simdmathlibrary/ppu/tests/testutils.h b/Extras/simdmathlibrary/ppu/tests/testutils.h deleted file mode 100644 index 7b905edfd..000000000 --- a/Extras/simdmathlibrary/ppu/tests/testutils.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Header file for common parts of the testsuite - 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. - */ - - -/* FIXME: Don't use altivec style initializers. */ - -#ifndef _TESTUTILS_H_ - -#include -#define vec_uchar16 vector unsigned char -#define vec_char16 vector signed char -#define vec_ushort8 vector unsigned short -#define vec_short8 vector signed short -#define vec_uint4 vector unsigned int -#define vec_int4 vector signed int -#define vec_ullong2 vector unsigned long long -#define vec_llong2 vector signed long long -#define vec_float4 vector float -#define vec_double2 vector double - -extern unsigned int hide_uint( unsigned int x ); -extern int hide_int( int x ); -extern float hide_float( float x ); -extern float make_float( unsigned int x ); - -inline vec_int4 vec_splat_int( int x ) -{ - return (vec_int4){x, x, x, x}; -} - -inline vec_float4 vec_splat_float( float x ) -{ - return (vec_float4){x, x, x, x}; -} - -inline vec_uint4 bitDiff_f4(vec_float4 ref, vec_float4 vals) { - vec_int4 refi = (vec_int4)ref; - vec_int4 valsi = (vec_int4)vals; - vec_int4 diff = vec_sub( refi, valsi ); - vec_int4 negdiff = vec_sub( vec_splat_int(0), diff ); - vec_uint4 lz; - - diff = vec_sel( negdiff, diff, vec_cmpgt( diff, vec_splat_int(0) ) ); - - lz = vec_sub( (vec_uint4)vec_splat_int(158), vec_sr( (vec_uint4)vec_ctf( diff, 0 ), (vec_uint4)vec_splat_int(23) ) ); - lz = vec_sel( lz, (vec_uint4)vec_splat_int(32), vec_cmpeq( diff, vec_splat_int(0) ) ); - - return vec_sub( (vec_uint4)vec_splat_int(32), lz ); -} - -inline vec_uint4 ulpDiff_f4(vec_float4 ref, vec_float4 vals) { - vec_int4 refi = (vec_int4)ref; - vec_int4 valsi = (vec_int4)vals; - vec_int4 diff = vec_sub( refi, valsi ); - vec_int4 negdiff = vec_sub( vec_splat_int(0), diff ); - - return (vec_uint4)( vec_sel( negdiff, diff, vec_cmpgt( diff, vec_splat_int(0) ) ) ); -} - -inline int allequal_int4( vec_int4 x, vec_int4 y ) -{ - return ( vec_all_eq( x, y ) ); -} - -inline int allequal_float4( vec_float4 x, vec_float4 y ) -{ - return ( vec_all_eq( x, y ) ); -} - -inline int allequal_ulps_float4( vec_float4 x, vec_float4 y, int tolerance ) -{ - vec_uint4 vtol = (vec_uint4)vec_splat_int( tolerance ); - vec_uint4 ulps = ulpDiff_f4( x, y ); - return vec_all_le( ulps, vtol ); -} - -inline int allequal_bits_float4( vec_float4 x, vec_float4 y, int tolerance ) -{ - vec_uint4 vtol = (vec_uint4)vec_splat_int( tolerance ); - vec_uint4 bits = bitDiff_f4( x, y ); - return vec_all_le( bits, vtol ); -} - -#endif diff --git a/Extras/simdmathlibrary/ppu/tests/truncf4.c b/Extras/simdmathlibrary/ppu/tests/truncf4.c deleted file mode 100644 index 72444138f..000000000 --- a/Extras/simdmathlibrary/ppu/tests/truncf4.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Testcase for truncf4 - 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. - */ - - -#include -#include -#include -#include "common-test.h" -#include "testutils.h" -#include "simdmath.h" - - -int main() -{ - TEST_SET_START("20040916100012EJL","EJL", "truncf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = vec_splat_float(x0); - vec_float4 x0i_v = vec_splat_float(x0i); - vec_float4 x1_v = vec_splat_float(x1); - vec_float4 x1i_v = vec_splat_float(x1i); - vec_float4 x2_v = vec_splat_float(x2); - vec_float4 x2i_v = vec_splat_float(x2i); - vec_float4 x3_v = vec_splat_float(x3); - vec_float4 x3i_v = vec_splat_float(x3i); - vec_float4 x4_v = vec_splat_float(x4); - vec_float4 x4i_v = vec_splat_float(x4i); - vec_float4 x5_v = vec_splat_float(x5); - vec_float4 x5i_v = vec_splat_float(x5i); - - vec_float4 res_v; - - TEST_START("truncf4"); - res_v = truncf4(x0_v); - TEST_CHECK("20040916100023EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = truncf4(x1_v); - TEST_CHECK("20040916100034EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = truncf4(x2_v); - TEST_CHECK("20040916100043EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = truncf4(x3_v); - TEST_CHECK("20040916100054EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = truncf4(x4_v); - TEST_CHECK("20040916100103EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = truncf4(x5_v); - TEST_CHECK("20040916100111EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/simdmath.spec b/Extras/simdmathlibrary/simdmath.spec deleted file mode 100644 index 0cf0e6509..000000000 --- a/Extras/simdmathlibrary/simdmath.spec +++ /dev/null @@ -1,108 +0,0 @@ -%define lib_version 1.0.2 - -Summary: SIMD math library. -Name: simdmath -Version: %{lib_version} -Release: 1 -License: BSD -Group: System Environment/Libraries -Source0: %{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root - -%define _enable_spu 0 - -%ifarch ppc -%define _arch ppu -%define _libdir %{_exec_prefix}/lib -%define _enable_spu 1 -%endif - -%ifarch ppc64 -%define _arch ppu64 -%define _libdir %{_exec_prefix}/lib64 -%define _enable_spu 1 -%endif - -%define _spe_prefix %{_prefix}/spu -%define _spe_exec_prefix %{_exec_prefix}/spu -%define _spe_includedir %{_spe_prefix}/include -%define _spe_libdir %{_spe_exec_prefix}/lib - -%define __os_install_post %{nil} - -%package -n %{name}-devel -Summary: SIMD math library. -Group: Development/Libraries -Requires: %{name} = %{version} - -%if %{_enable_spu} -%package -n spu-%{name}-devel -Summary: SIMD math library. -Group: Development/Libraries -%endif - -%description -SIMD math library. - -%description -n %{name}-devel -SIMD math library. - -%if %{_enable_spu} -%description -n spu-%{name}-devel -SIMD math library. -%endif - -%prep -%setup -q - -%build - -make ARCH=%{_arch} - -%if %{_enable_spu} -make ARCH=spu -%endif - -%install -rm -rf %{buildroot} - -make ARCH=%{_arch} DESTDIR=%{buildroot} install - -%if %{_enable_spu} -make ARCH=spu DESTDIR=%{buildroot} install -%endif - -if [ "%{_libdir}" != /usr/lib ]; then - mv %{buildroot}/usr/lib %{buildroot}%{_libdir} -fi - -mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version} -cp README LICENSE %{buildroot}/%{_docdir}/%{name}-%{version}/ - -%clean -rm -rf %{buildroot} - -%files -%defattr(-,root,root,-) -%{_libdir}/*.so.* -%{_docdir}/* - -%files -n %{name}-devel -%defattr(-,root,root,-) -%{_includedir}/* -%{_libdir}/*.a -%{_libdir}/*.so - -%if %{_enable_spu} -%files -n spu-%{name}-devel -%defattr(-,root,root,-) -%{_spe_includedir}/* -%{_spe_libdir}/* -%endif - -%changelog -* Thu Aug 9 2007 Kazunori Asayama - 1.0.1-2 -- Add documents. - -* Fri Aug 25 2006 Kazunori Asayama - 1.0.1-1 -- Initial build. diff --git a/Extras/simdmathlibrary/spu/Makefile b/Extras/simdmathlibrary/spu/Makefile deleted file mode 100644 index 9e74faabd..000000000 --- a/Extras/simdmathlibrary/spu/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# make file to build the libsimdmath library for SPU -# 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. - -topdir = .. -ARCH = spu - -include $(topdir)/Make.defs - -# All that you do to add a file is edit OBJS, the rest will just work - -OBJS = fabsd2.o fabsf4.o truncf4.o divf4.o tanf4.o isnanf4.o isnand2.o isinff4.o isinfd2.o \ - is0denormf4.o is0denormd2.o recipd2.o divd2.o tand2.o sqrtf4.o absi4.o sqrtd2.o \ - sinf4.o isgreaterd2.o sind2.o sincosd2.o sincosf4.o rsqrtf4.o signbitf4.o signbitd2.o \ - rsqrtd2.o copysignf4.o remainderf4.o recipf4.o copysignd2.o log2f4.o \ - negatef4.o negated2.o modff4.o asinf4.o frexpf4.o frexpd2.o ldexpf4.o cbrtf4.o \ - cosd2.o cosf4.o hypotf4.o hypotd2.o ceilf4.o fmaf4.o fmaxf4.o fminf4.o floorf4.o \ - fdimf4.o fmodf4.o negatei4.o logf4.o log1pf4.o log10f4.o expm1f4.o \ - expf4.o divi4.o exp2f4.o powf4.o atanf4.o atan2f4.o acosf4.o ilogbf4.o ilogbd2.o \ - logbf4.o logbd2.o llroundd2.o llroundf4.o llrintf4.o isequalf4.o isequald2.o \ - islessgreaterf4.o islessgreaterd2.o islessf4.o islessd2.o isgreaterf4.o \ - isgreaterd2.o islessequalf4.o islessequald2.o isgreaterequalf4.o isgreaterequald2.o \ - isfinitef4.o isfinited2.o isnormalf4.o isnormald2.o isunorderedf4.o isunorderedd2.o \ - llrintd2.o roundf4.o rintf4.o irintf4.o iroundf4.o fmad2.o fmaxd2.o fmind2.o fdimd2.o \ - nextafterd2.o fpclassifyf4.o fpclassifyd2.o nearbyintd2.o nextafterf4.o nearbyintf4.o \ - llabsi2.o truncd2.o roundd2.o rintd2.o negatell2.o divu4.o modfd2.o lldivu2.o \ - ceild2.o floord2.o ldexpd2.o scalbnf4.o scalbllnd2.o lldivi2.o remquof4.o remquod2.o\ - fmodd2.o remainderd2.o - -include $(topdir)/Make.rules - -$(OBJS): ../common/simdmath.h - -# Some Objects have special header files. -sinf4.o sind2.o sincosf4.o cosd2.o: ../common/simdmath/_sincos.h -lldivu2.o lldivi2.o : simdmath/_lldiv.h diff --git a/Extras/simdmathlibrary/spu/simdmath/_lldiv.h b/Extras/simdmathlibrary/spu/simdmath/_lldiv.h deleted file mode 100644 index b3d8a2baf..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/_lldiv.h +++ /dev/null @@ -1,116 +0,0 @@ -/* Common functions for lldivi2/lldivu2 - 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 ___SIMD_MATH_LLDIV_H___ -#define ___SIMD_MATH_LLDIV_H___ - -#include - -static inline vector unsigned long long -__ll_spu_cntlz(vector unsigned long long x) -{ - vec_uint4 cnt; - - cnt = spu_cntlz((vec_uint4)x); - cnt = spu_add(cnt, spu_and(spu_cmpeq(cnt, 32), spu_rlqwbyte(cnt, 4))); - cnt = spu_shuffle(cnt, cnt, ((vec_uchar16){0x80,0x80,0x80,0x80, 0,1,2,3, 0x80,0x80,0x80,0x80, 8,9,10,11})); - - return (vec_ullong2)cnt; -} - -static inline vector unsigned long long -__ll_spu_sl(vector unsigned long long x, vector unsigned long long count) -{ - vec_ullong2 mask = (vec_ullong2){0xffffffffffffffffull, 0ull}; - vec_ullong2 x_upper, x_lower; - - // shift upper word - x_upper = spu_and(x, mask); - x_upper = spu_slqwbytebc(x_upper, spu_extract((vec_uint4)count, 1)); - x_upper = spu_slqw(x_upper, spu_extract((vec_uint4)count, 1)); - - // shift lower word - x_lower = spu_slqwbytebc(x, spu_extract((vec_uint4)count, 3)); - x_lower = spu_slqw(x_lower, spu_extract((vec_uint4)count, 3)); - - return spu_sel(x_lower, x_upper, mask); -} - -static inline vector unsigned long long -__ll_spu_rlmask(vector unsigned long long x, vector unsigned long long count) -{ - vec_ullong2 mask = (vec_ullong2){0xffffffffffffffffull, 0ull}; - vec_ullong2 x_upper, x_lower; - vec_uint4 cnt_byte; - - cnt_byte = spu_add((vec_uint4)count, 7); - - // shift upper word - x_upper = spu_rlmaskqwbytebc(x, spu_extract(cnt_byte, 1)); - x_upper = spu_rlmaskqw(x_upper, spu_extract((vec_uint4)count, 1)); - - // shift lower word - x_lower = spu_andc(x, mask); - x_lower = spu_rlmaskqwbytebc(x_lower, spu_extract(cnt_byte, 3)); - x_lower = spu_rlmaskqw(x_lower, spu_extract((vec_uint4)count, 3)); - - return spu_sel(x_lower, x_upper, mask); -} - -static inline vector unsigned long long -__ll_spu_cmpeq_zero(vector unsigned long long x) -{ - vec_uint4 cmp; - - cmp = spu_cmpeq((vec_uint4)x, 0); - return (vec_ullong2)spu_and(cmp, spu_shuffle(cmp, cmp, ((vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}))); -} - -static inline vector unsigned long long -__ll_spu_cmpgt(vector unsigned long long x, vector unsigned long long y) -{ - vec_uint4 gt; - - gt = spu_cmpgt((vec_uint4)x, (vec_uint4)y); - gt = spu_sel(gt, spu_rlqwbyte(gt, 4), spu_cmpeq((vec_uint4)x, (vec_uint4)y)); - return (vec_ullong2)spu_shuffle(gt, gt, ((vec_uchar16){0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11})); -} - -static inline vector unsigned long long -__ll_spu_sub(vector unsigned long long x, vector unsigned long long y) -{ - vec_uint4 borrow; - - borrow = spu_genb((vec_uint4)x, (vec_uint4)y); - borrow = spu_shuffle(borrow, borrow, ((vec_uchar16){4,5,6,7, 0xc0,0xc0,0xc0,0xc0, 12,13,14,15, 0xc0,0xc0,0xc0,0xc0})); - return (vec_ullong2)spu_subx((vec_uint4)x, (vec_uint4)y, borrow); -} - -#endif // __LLDIV_H__ - diff --git a/Extras/simdmathlibrary/spu/simdmath/_remainder.h b/Extras/simdmathlibrary/spu/simdmath/_remainder.h deleted file mode 100644 index b4dcbf97c..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/_remainder.h +++ /dev/null @@ -1,84 +0,0 @@ -/* A vector double is returned that contains the internal routine regarding remainder. - 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 ___SIMD_MATH__REMAINDER_H___ -#define ___SIMD_MATH__REMAINDER_H___ - -#include - -/* - * double formated x2 - */ -static inline vec_uint4 -__rem_twice_d(vec_uint4 aa) -{ - vec_uint4 norm = spu_cmpgt(aa, (vec_uint4)(spu_splats(0x000FFFFFFFFFFFFFULL))); // exp > 0 - norm = spu_shuffle(norm, norm, ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11})); - - // if denorm or zero << 1 , if norm exp + 1 - return spu_sel(spu_slqw(aa, 1), spu_add(aa, (vec_uint4)(spu_splats(0x0010000000000000ULL))), norm); // x2 -} - -/* - * subtraction function in limited confdition - */ -static inline vec_uint4 -__rem_sub_d(vec_uint4 aa, vec_uint4 bb) -{ - // which is bigger input aa or bb - vec_uint4 is_bigb = __vec_gt64(bb, aa); // bb > aa - - // need denorm calc ? - vec_uint4 norm_a, norm_b; - norm_a = spu_cmpgt(aa, (vec_uint4)(spu_splats(0x000FFFFFFFFFFFFFULL))); - norm_b = spu_cmpgt(bb, (vec_uint4)(spu_splats(0x000FFFFFFFFFFFFFULL))); - norm_a = spu_and(norm_a, norm_b); - norm_a = spu_shuffle(norm_a, norm_a,((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11})); - - // calc (aa - bb) and (bb - aa) - vec_uint4 res_a, res_b, res; - vec_uint4 borrow_a, borrow_b; - vec_uchar16 mask_b = ((vec_uchar16){4,5,6,7,192,192,192,192,12,13,14,15,192,192,192,192}); - borrow_a = spu_genb(aa, bb); - borrow_b = spu_genb(bb, aa); - borrow_a = spu_shuffle(borrow_a, borrow_a, mask_b); - borrow_b = spu_shuffle(borrow_b, borrow_b, mask_b); - res_a = spu_subx(aa, bb, borrow_a); - res_b = spu_subx(bb, aa, borrow_b); - res_b = spu_or(res_b, ((vec_uint4){0x80000000,0,0x80000000,0})); // set sign - - res = spu_sel(res_a, res_b, is_bigb); // select (aa - bb) or (bb - aa) - // select normal calc or special - res = spu_sel(res, (vec_uint4)spu_sub((vec_double2)aa, (vec_double2)bb), norm_a); - - return res; -} - -#endif - diff --git a/Extras/simdmathlibrary/spu/simdmath/_vec_utils.h b/Extras/simdmathlibrary/spu/simdmath/_vec_utils.h deleted file mode 100644 index 037eeec3d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/_vec_utils.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Common types for SPU SIMD Math Library - 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 ___SIMD_MATH__VEC_UTILS_H___ -#define ___SIMD_MATH__VEC_UTILS_H___ - -/* - * extend spu_cmpgt function to 64bit data - */ -static inline vec_uint4 -__vec_gt64_half(vec_uint4 aa, vec_uint4 bb) -{ - vec_uint4 gt = spu_cmpgt(aa, bb); // aa > bb - vec_uint4 eq = spu_cmpeq(aa, bb); // aa = bb - return spu_or(gt, spu_and(eq, spu_rlqwbyte(gt, 4))); // only higher is right -} -static inline vec_uint4 -__vec_gt64(vec_uint4 aa, vec_uint4 bb) -{ - vec_uint4 gt_hi = __vec_gt64_half(aa, bb); // only higher is right - return spu_shuffle(gt_hi, gt_hi, ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11})); -} - -static inline vec_uint4 -__vec_eq64_half(vec_uint4 aa, vec_uint4 bb) -{ - vec_uint4 eq = spu_cmpeq(aa, bb); - return spu_and(eq, spu_shuffle(eq, eq, ((vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}))); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/absi4.h b/Extras/simdmathlibrary/spu/simdmath/absi4.h deleted file mode 100644 index 813041c6f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/absi4.h +++ /dev/null @@ -1,44 +0,0 @@ -/* absi4 - for each of four integer slots, compute absolute value. - 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 ___SIMD_MATH_ABSI4_H___ -#define ___SIMD_MATH_ABSI4_H___ - -#include -#include - -static inline vector signed int -_absi4 (vector signed int x) -{ - vec_int4 neg; - neg = spu_sub( 0, x ); - return spu_sel( neg, x, spu_cmpgt( x, -1 ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/acosf4.h b/Extras/simdmathlibrary/spu/simdmath/acosf4.h deleted file mode 100644 index c492d53cb..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/acosf4.h +++ /dev/null @@ -1,82 +0,0 @@ -/* acosf4 - - 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 ___SIMD_MATH_ACOSF4_H___ -#define ___SIMD_MATH_ACOSF4_H___ - -#include -#include - -#include - -// -// Computes the inverse cosine of all four slots of x -// -static inline vector float -_acosf4 (vector float x) -{ - vec_float4 result, xabs; - vec_float4 t1; - vec_float4 xabs2, xabs4; - vec_float4 hi, lo; - vec_float4 neg, pos; - vec_uint4 select; - - xabs = (vec_float4)(spu_rlmask(spu_sl((vec_uint4)(x), 1), -1)); - select = (vec_uint4)(spu_rlmaska((vector signed int)(x), -31)); - - t1 = _sqrtf4(spu_sub( spu_splats(1.0f), xabs)); - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - xabs2 = spu_mul(xabs, xabs); - xabs4 = spu_mul(xabs2, xabs2); - hi = spu_madd(spu_splats(-0.0012624911f), xabs, spu_splats(0.0066700901f)); - hi = spu_madd(hi, xabs, spu_splats(-0.0170881256f)); - hi = spu_madd(hi, xabs, spu_splats( 0.0308918810f)); - lo = spu_madd(spu_splats(-0.0501743046f), xabs, spu_splats(0.0889789874f)); - lo = spu_madd(lo, xabs, spu_splats(-0.2145988016f)); - lo = spu_madd(lo, xabs, spu_splats( 1.5707963050f)); - - result = spu_madd(hi, xabs4, lo); - - /* Adjust the result if x is negactive. - */ - neg = spu_nmsub(t1, result, spu_splats(3.1415926535898f)); - pos = spu_mul(t1, result); - - result = spu_sel(pos, neg, select); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/asinf4.h b/Extras/simdmathlibrary/spu/simdmath/asinf4.h deleted file mode 100644 index eb6273121..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/asinf4.h +++ /dev/null @@ -1,92 +0,0 @@ -/* asinf4 - Computes the inverse sine of all four slots of x - 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 ___SIMD_MATH_ASINF4_H___ -#define ___SIMD_MATH_ASINF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_asinf4 (vector float x) -{ - // positive = (x > 0) - // - vec_uint4 positive = spu_cmpgt(x,spu_splats(0.0f)); - - // gtHalf = (|x| > 0.5) - // - vec_uint4 gtHalf = spu_cmpabsgt(x,spu_splats(0.5f)); - - // x = absf(x) - // - x = (vec_float4)spu_and((vec_int4)x,spu_splats((int)0x7fffffff)); - - - // if (x > 0.5) - // g = 0.5 - 0.5*x - // x = -2 * sqrtf(g) - // else - // g = x * x - // - vec_float4 g = spu_sel(spu_mul(x,x),spu_madd(spu_splats(-0.5f),x,spu_splats(0.5f)),gtHalf); - - x = spu_sel(x,spu_mul(spu_splats(-2.0f),_sqrtf4(g)),gtHalf); - - // Compute the polynomials and take their ratio - // denom = (1.0f*g + -0.554846723e+1f)*g + 5.603603363f - // num = x * g * (-0.504400557f * g + 0.933933258f) - // - vec_float4 denom = spu_add(g,spu_splats(-5.54846723f)); - vec_float4 num = spu_madd(spu_splats(-0.504400557f),g,spu_splats(0.933933258f)); - denom = spu_madd(denom,g,spu_splats(5.603603363f)); - num = spu_mul(spu_mul(x,g),num); - - - // x = x + num / denom - // - x = spu_add(x,_divf4(num,denom)); - - // if (x > 0.5) - // x = x + M_PI_2 - // - x = spu_sel(x,spu_add(x,spu_splats(1.57079632679489661923f)),gtHalf); - - - // if (!positive) x = -x - // - x = spu_sel((vec_float4)spu_xor(spu_splats((int)0x80000000),(vec_int4)x),x,positive); - - return x; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/atan2f4.h b/Extras/simdmathlibrary/spu/simdmath/atan2f4.h deleted file mode 100644 index d17993ee2..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/atan2f4.h +++ /dev/null @@ -1,66 +0,0 @@ -/* atan2f4 - - 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 ___SIMD_MATH_ATAN2F4_H___ -#define ___SIMD_MATH_ATAN2F4_H___ - -#include -#include - -#include -#include - -// -// Inverse tangent function of two variables -// -static inline vector float -_atan2f4 (vector float y, vector float x) -{ - vec_float4 res = _atanf4(_divf4(y,x)); - - // Use the arguments to determine the quadrant of the result: - // if (x < 0) - // if (y < 0) - // res = -PI + res - // else - // res = PI + res - // - vec_uint4 yNeg = spu_cmpgt(spu_splats(0.0f),y); - vec_uint4 xNeg = spu_cmpgt(spu_splats(0.0f),x); - - vec_float4 bias = spu_sel(spu_splats(3.14159265358979323846f),spu_splats(-3.14159265358979323846f),yNeg); - - vec_float4 newRes = spu_add(bias, res); - - res = spu_sel(res,newRes,xNeg); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/atanf4.h b/Extras/simdmathlibrary/spu/simdmath/atanf4.h deleted file mode 100644 index 49c8bee45..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/atanf4.h +++ /dev/null @@ -1,81 +0,0 @@ -/* atanf4 - - 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 ___SIMD_MATH_ATANF4_H___ -#define ___SIMD_MATH_ATANF4_H___ - -#include -#include - -#include - -// -// Computes the inverse tangent of all four slots of x. -// -static inline vector float -_atanf4 (vector float x) -{ - vec_float4 bias; - vec_float4 x2, x3, x4, x8, x9; - vec_float4 hi, lo; - vec_float4 result; - vec_float4 inv_x; - vec_uint4 sign; - vec_uint4 select; - - sign = spu_sl(spu_rlmask((vec_uint4)x, -31), 31); - inv_x = _recipf4(x); - inv_x = (vec_float4)spu_xor((vec_uint4)inv_x, spu_splats(0x80000000u)); - - select = (vec_uint4)spu_cmpabsgt(x, spu_splats(1.0f)); - bias = (vec_float4)spu_or(sign, (vec_uint4)(spu_splats(1.57079632679489661923f))); - bias = (vec_float4)spu_and((vec_uint4)bias, select); - - x = spu_sel(x, inv_x, select); - - bias = spu_add(bias, x); - x2 = spu_mul(x, x); - x3 = spu_mul(x2, x); - x4 = spu_mul(x2, x2); - x8 = spu_mul(x4, x4); - x9 = spu_mul(x8, x); - hi = spu_madd(spu_splats(0.0028662257f), x2, spu_splats(-0.0161657367f)); - hi = spu_madd(hi, x2, spu_splats(0.0429096138f)); - hi = spu_madd(hi, x2, spu_splats(-0.0752896400f)); - hi = spu_madd(hi, x2, spu_splats(0.1065626393f)); - lo = spu_madd(spu_splats(-0.1420889944f), x2, spu_splats(0.1999355085f)); - lo = spu_madd(lo, x2, spu_splats(-0.3333314528f)); - lo = spu_madd(lo, x3, bias); - - result = spu_madd(hi, x9, lo); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/cbrtf4.h b/Extras/simdmathlibrary/spu/simdmath/cbrtf4.h deleted file mode 100644 index c44aa2f3d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/cbrtf4.h +++ /dev/null @@ -1,95 +0,0 @@ -/* cbrtf4 - - 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 ___SIMD_MATH_CBRTF4_H___ -#define ___SIMD_MATH_CBRTF4_H___ - -#include -#include - -#include -#include -#include - -static inline vec_int4 -__cbrtf4_calc_quot(vec_int4 n) -{ - vec_int4 quot; - vec_uint4 negxexpmask = spu_cmpgt(spu_splats(0), n); - n = spu_sel(n, spu_add(n,2), negxexpmask); - - quot = spu_add(spu_rlmaska(n,-2), spu_rlmaska(n,-4)); - quot = spu_add(quot, spu_rlmaska(quot, -4)); - quot = spu_add(quot, spu_rlmaska(quot, -8)); - quot = spu_add(quot, spu_rlmaska(quot,-16)); - vec_int4 r = spu_sub(spu_sub(n,quot), spu_sl(quot,1)); - quot = spu_add(quot, spu_rlmaska(spu_add(spu_add(r,5), spu_sl (r,2)), -4)); - return quot; -} - -#define __CBRTF_cbrt2 1.2599210498948731648 // 2^(1/3) -#define __CBRTF_sqr_cbrt2 1.5874010519681994748 // 2^(2/3) - -static inline vector float -_cbrtf4 (vector float x) -{ - vec_float4 zeros = spu_splats(0.0f); - vec_uint4 zeromask = spu_cmpeq(x, zeros); - vec_int4 xexp; - vec_float4 sgnmask = (vec_float4)spu_splats(0x7FFFFFFF); - vec_uint4 negmask = spu_cmpgt(spu_splats(0.0f), x); - x = spu_and(x, sgnmask); - - x = _frexpf4(x, &xexp); - vec_float4 p = spu_madd( - spu_madd(x, spu_splats(-0.191502161678719066f), spu_splats(0.697570460207922770f)), - x, - spu_splats(0.492659620528969547f) - ); - vec_float4 p3 = spu_mul(p, spu_mul(p, p)); - vec_int4 quot = __cbrtf4_calc_quot(xexp); - vec_int4 modval = spu_sub(spu_sub(xexp,quot), spu_sl(quot,1)); // mod = xexp - 3*quotient - vec_float4 factor = spu_splats((float)(1.0/__CBRTF_sqr_cbrt2)); - factor = spu_sel(factor, spu_splats((float)(1.0/__CBRTF_cbrt2)), spu_cmpeq(modval,-1)); - factor = spu_sel(factor, spu_splats((float)( 1.0)), spu_cmpeq(modval, 0)); - factor = spu_sel(factor, spu_splats((float)( __CBRTF_cbrt2)), spu_cmpeq(modval, 1)); - factor = spu_sel(factor, spu_splats((float)(__CBRTF_sqr_cbrt2)), spu_cmpeq(modval, 2)); - - vec_float4 pre = spu_mul(p, factor); - vec_float4 numr = spu_madd(x , spu_splats(2.0f), p3); - vec_float4 denr = spu_madd(p3, spu_splats(2.0f), x ); - vec_float4 res = spu_mul(pre, _divf4(numr, denr)); - res = _ldexpf4(res, quot); - - return spu_sel(spu_sel(res, spu_orc(res,sgnmask), negmask), - zeros, - zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ceild2.h b/Extras/simdmathlibrary/spu/simdmath/ceild2.h deleted file mode 100644 index a2d7d3f9b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ceild2.h +++ /dev/null @@ -1,99 +0,0 @@ -/* ceild2 - for each of two doule slots, round up to smallest integer not less than the value. - 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 ___SIMD_MATH_CEILD2_H___ -#define ___SIMD_MATH_CEILD2_H___ - -#include -#include - -static inline vector double -_ceild2(vector double in) -{ - vec_uchar16 swap_words = ((vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}); - vec_uchar16 splat_hi = ((vec_uchar16){0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_uint4 one = ((vec_uint4){0, 1, 0, 1}); - vec_int4 exp, shift; - vec_uint4 mask, mask_1, frac_mask, addend, insert, pos, equal0, e_0, e_00, e_sign, exp_ge0; - vec_ullong2 sign = spu_splats(0x8000000000000000ULL); - vec_double2 in_hi, out; - vec_double2 one_d = spu_splats((double)1.0); - vec_uint4 zero = spu_splats((unsigned int)0x0); - - /* This function generates the following component - * based upon the inputs. - * - * mask = bits of the input that need to be replaced. - * insert = value of the bits that need to be replaced - * addend = value to be added to perform function. - * - * These are applied as follows:. - * - * out = ((in & mask) | insert) + addend - */ - - in_hi = spu_shuffle(in, in, splat_hi); - exp = spu_and(spu_rlmask((vec_int4)in_hi, -20), 0x7FF); - shift = spu_sub(((vec_int4){1023, 1043, 1023, 1043}), exp); - - /* clamp shift to the range 0 to -31. - */ - shift = spu_sel(spu_splats((int)-32), spu_andc(shift, (vec_int4)spu_cmpgt(shift, 0)), spu_cmpgt(shift, -32)); - frac_mask = spu_rlmask(((vec_uint4){0xFFFFF, -1, 0xFFFFF, -1}), shift); - exp_ge0 = spu_cmpgt(exp, 0x3FE); - mask = spu_orc(frac_mask, exp_ge0); - - /* addend = ((in & mask) && (in >= 0)) ? mask+1 : 0 - */ - mask_1 = spu_addx(mask, one, spu_rlqwbyte(spu_genc(mask, one), 4)); - pos = spu_cmpgt((vec_int4)in_hi, -1); - //pos = spu_cmpgt((vec_int4)in_hi, 0x0); //it is also work - equal0 = spu_cmpeq(spu_and((vec_uint4)in, mask), 0); - addend = spu_andc(spu_and(mask_1, pos), spu_and(equal0, spu_shuffle(equal0, equal0, swap_words))); - - /* insert - */ - e_0 = spu_cmpeq(spu_andc((vec_uint4)in, (vec_uint4)sign), zero); - e_00 = spu_and(e_0, spu_shuffle(e_0, e_0, swap_words)); - // e_sign = spu_sel(spu_splats((unsigned int)0x0), (vec_uint4)one_d, spu_cmpeq( spu_and((vec_uint4)in_hi, spu_splats((unsigned int)0x80000000)), zero)); - e_sign = spu_and( (vec_uint4)one_d, spu_cmpeq( spu_and((vec_uint4)in_hi,spu_splats((unsigned int)0x80000000)), zero)); - insert =spu_andc(spu_andc(e_sign, e_00), exp_ge0); - - /* replace insert - */ - in = spu_sel(in, (vec_double2)insert, spu_andc((vec_ullong2)mask, sign)); - - /* in + addend - */ - out = (vec_double2)spu_addx((vec_uint4)in, addend, spu_rlqwbyte(spu_genc((vec_uint4)in, addend), 4)); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ceilf4.h b/Extras/simdmathlibrary/spu/simdmath/ceilf4.h deleted file mode 100644 index 06468a2d8..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ceilf4.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ceilf4 - for each of four float slots, round up to smallest integer not less than the value. - 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 ___SIMD_MATH_CEILF4_H___ -#define ___SIMD_MATH_CEILF4_H___ - -#include -#include - -static inline vector float -_ceilf4 (vector float x) -{ - vec_int4 xi, xi1; - vec_uint4 inrange; - vec_float4 truncated, truncated1; - - // Find truncated value and one greater. - - inrange = spu_cmpabsgt( (vec_float4)spu_splats(0x4b000000), x ); - - xi = spu_convts( x, 0 ); - xi1 = spu_add( xi, 1 ); - - truncated = spu_sel( x, spu_convtf( xi, 0 ), inrange ); - truncated1 = spu_sel( x, spu_convtf( xi1, 0 ), inrange ); - - // If truncated value is less than input, add one. - - return spu_sel( truncated, truncated1, spu_cmpgt( x, truncated ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/copysignd2.h b/Extras/simdmathlibrary/spu/simdmath/copysignd2.h deleted file mode 100644 index be4137ad4..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/copysignd2.h +++ /dev/null @@ -1,43 +0,0 @@ -/* copysignd2 - for each of two double slots, return value with magnitude from x and sign from y. - 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 ___SIMD_MATH_COPYSIGND2_H___ -#define ___SIMD_MATH_COPYSIGND2_H___ - -#include -#include - - -static inline vector double -_copysignd2 (vector double x, vector double y) -{ - return spu_sel( x, y, spu_splats(0x8000000000000000ull) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/copysignf4.h b/Extras/simdmathlibrary/spu/simdmath/copysignf4.h deleted file mode 100644 index 1871a4bbb..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/copysignf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* copysignf4 - for each of four float slots, return value with magnitude from x and sign from y. - 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 ___SIMD_MATH_COPYSIGNF4_H___ -#define ___SIMD_MATH_COPYSIGNF4_H___ - -#include -#include - - -static inline vector float -_copysignf4 (vector float x, vector float y) -{ - return spu_sel( x, y, spu_splats(0x80000000) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/cosd2.h b/Extras/simdmathlibrary/spu/simdmath/cosd2.h deleted file mode 100644 index 5fd6bf0df..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/cosd2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* cosd2 - Computes the cosine of the each of two double slots. - 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 ___SIMD_MATH_COSD2_H___ -#define ___SIMD_MATH_COSD2_H___ - -#include -#include - -#include - -static inline vector double -_cosd2 (vector double x) -{ - vec_double2 s, c; - _sincosd2(x, &s, &c); - return c; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/cosf4.h b/Extras/simdmathlibrary/spu/simdmath/cosf4.h deleted file mode 100644 index c3d2be5bf..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/cosf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* cosf4 - Computes the cosine of each of the four slots by using a polynomial approximation - 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 ___SIMD_MATH_COSF4_H___ -#define ___SIMD_MATH_COSF4_H___ - -#include -#include - -#include - -static inline vector float -_cosf4 (vector float x) -{ - vec_float4 s, c; - _sincosf4(x, &s, &c); - return c; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/divd2.h b/Extras/simdmathlibrary/spu/simdmath/divd2.h deleted file mode 100644 index 35cfe6e5d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/divd2.h +++ /dev/null @@ -1,47 +0,0 @@ -/* divd2 - for each of two double slots, divide numer by denom. - 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 ___SIMD_MATH_DIVD2_H___ -#define ___SIMD_MATH_DIVD2_H___ - -// Equal to numer * recipd2(denom) -// See recipd2 for results of special values. - -#include -#include - -#include - -static inline vector double -_divd2 (vector double numer, vector double denom) -{ - return spu_mul( numer, _recipd2( denom ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/divf4.h b/Extras/simdmathlibrary/spu/simdmath/divf4.h deleted file mode 100644 index 6edfab1c8..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/divf4.h +++ /dev/null @@ -1,50 +0,0 @@ -/* divf4 - for each of four float slots, divide numer by denom. - 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 ___SIMD_MATH_DIVF4_H___ -#define ___SIMD_MATH_DIVF4_H___ - -#include -#include - -static inline vector float -_divf4 (vector float numer, vector float denom) -{ - // Reciprocal estimate and 1 Newton-Raphson iteration. - // Uses constant of 1.0 + 1 ulp to improve accuracy. - - vector float y0, y0numer; - vector float oneish = (vector float)spu_splats(0x3f800001); - - y0 = spu_re( denom ); - y0numer = spu_mul( numer, y0 ); - return spu_madd( spu_nmsub( denom, y0, oneish ), y0numer, y0numer ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/divi4.h b/Extras/simdmathlibrary/spu/simdmath/divi4.h deleted file mode 100644 index f4f7e9668..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/divi4.h +++ /dev/null @@ -1,67 +0,0 @@ -/* divi4 - - 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 ___SIMD_MATH_DIVI4_H___ -#define ___SIMD_MATH_DIVI4_H___ - -#include -#include - -#include - -// divi4 - for each of four integer slots, compute quotient and remainder of numer/denom -// and store in divi4_t struct. Divide by zero produces quotient = 0, remainder = numerator. - -static inline divi4_t -_divi4 (vector signed int numer, vector signed int denom) -{ - divu4_t resAbs; - divi4_t res; - vec_uint4 numerPos, denomPos, quotNeg; - vec_uint4 numerAbs, denomAbs; - - // Determine whether result needs sign change - - numerPos = spu_cmpgt( numer, -1 ); - denomPos = spu_cmpgt( denom, -1 ); - quotNeg = spu_xor( numerPos, denomPos ); - - // Use absolute values of numerator, denominator - - numerAbs = (vec_uint4)spu_sel( spu_sub( 0, numer ), numer, numerPos ); - denomAbs = (vec_uint4)spu_sel( spu_sub( 0, denom ), denom, denomPos ); - - resAbs = _divu4(numerAbs, denomAbs); - - res.quot = spu_sel( (vec_int4)resAbs.quot, spu_sub( 0, (vec_int4)resAbs.quot ), quotNeg ); - res.rem = spu_sel( spu_sub( 0, (vec_int4)resAbs.rem ), (vec_int4)resAbs.rem, numerPos ); - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/divu4.h b/Extras/simdmathlibrary/spu/simdmath/divu4.h deleted file mode 100644 index f28c09dc6..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/divu4.h +++ /dev/null @@ -1,102 +0,0 @@ -/* divu4 - - 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 ___SIMD_MATH_DIVU4_H___ -#define ___SIMD_MATH_DIVU4_H___ - -#include -#include - -// divu4 - for each of four unsigned integer slots, compute quotient and remainder of numer/denom -// and store in divu4_t struct. Divide by zero produces quotient = 0, remainder = numerator. - -static inline divu4_t -_divu4 (vector unsigned int numer, vector unsigned int denom) -{ - divu4_t res; - vec_int4 shift; - vec_uint4 quot, newQuot; - vec_uint4 denomZeros, numerZeros, denomLeft, oneLeft, denomShifted, oneShifted; - vec_uint4 newNum, skip, cont; - int anyCont; - - // Get difference of leading zeros. - // Any possible negative value will be interpreted as a shift > 31 - - denomZeros = spu_cntlz( denom ); - numerZeros = spu_cntlz( numer ); - - shift = (vec_int4)spu_sub( denomZeros, numerZeros ); - - // Shift denom to align leading one with numerator's - - denomShifted = spu_sl( denom, (vec_uint4)shift ); - oneShifted = spu_sl( spu_splats(1U), (vec_uint4)shift ); - oneShifted = spu_sel( oneShifted, spu_splats(0U), spu_cmpeq( denom, 0 ) ); - - // Shift left all leading zeros. - - denomLeft = spu_sl( denom, denomZeros ); - oneLeft = spu_sl( spu_splats(1U), denomZeros ); - - quot = spu_splats(0U); - - do - { - cont = spu_cmpgt( oneShifted, 0U ); - anyCont = spu_extract( spu_gather( cont ), 0 ); - - newQuot = spu_or( quot, oneShifted ); - - // Subtract shifted denominator from remaining numerator - // when denominator is not greater. - - skip = spu_cmpgt( denomShifted, numer ); - newNum = spu_sub( numer, denomShifted ); - - // If denominator is greater, next shift is one more, otherwise - // next shift is number of leading zeros of remaining numerator. - - numerZeros = spu_sel( spu_cntlz( newNum ), numerZeros, skip ); - shift = (vec_int4)spu_sub( skip, numerZeros ); - - oneShifted = spu_rlmask( oneLeft, shift ); - denomShifted = spu_rlmask( denomLeft, shift ); - - quot = spu_sel( newQuot, quot, skip ); - numer = spu_sel( newNum, numer, spu_orc(skip,cont) ); - } - while ( anyCont ); - - res.quot = quot; - res.rem = numer; - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/exp2f4.h b/Extras/simdmathlibrary/spu/simdmath/exp2f4.h deleted file mode 100644 index 4e8a9ab7e..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/exp2f4.h +++ /dev/null @@ -1,135 +0,0 @@ -/* exp2f4 - - 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 ___SIMD_MATH_EXP2F4_H___ -#define ___SIMD_MATH_EXP2F4_H___ - -#include -#include - - -/* - * FUNCTION - * vec_float4 _exp2_v(vec_float4 x) - * - * DESCRIPTION - * _exp2_v computes 2 raised to the input vector x. Computation is - * performed by observing the 2^(a+b) = 2^a * 2^b. - * We decompose x into a and b (above) by letting. - * a = ceil(x), b = x - a; - * - * 2^a is easilty computed by placing a into the exponent - * or a floating point number whose mantissa is all zeros. - * - * 2^b is computed using the following polynomial approximation. - * (C. Hastings, Jr, 1955). - * - * __7__ - * \ - * \ - * 2^(-x) = / Ci*x^i - * /____ - * i=1 - * - * for x in the range 0.0 to 1.0 - * - * C0 = 1.0 - * C1 = -0.9999999995 - * C2 = 0.4999999206 - * C3 = -0.1666653019 - * C4 = 0.0416573475 - * C5 = -0.0083013598 - * C6 = 0.0013298820 - * C7 = -0.0001413161 - * - * This function does not handle out of range conditions. It - * assumes that x is in the range (-128.0, 127.0]. Values outside - * this range will produce undefined results. - */ - - -#define __EXP2F_LN2 0.69314718055995f /* ln(2) */ - -static inline vector float -_exp2f4 (vector float x) -{ - vec_int4 ix; - vec_uint4 overflow, underflow; - vec_float4 frac, frac2, frac4; - vec_float4 exp_int, exp_frac; - vec_float4 result; - vec_float4 hi, lo; - - vec_float4 bias; - /* Break in the input x into two parts ceil(x), x - ceil(x). - */ - bias = (vec_float4)(spu_rlmaska((vec_int4)(x), -31)); - bias = (vec_float4)(spu_andc(spu_splats(0x3F7FFFFFu), (vec_uint4)bias)); - ix = spu_convts(spu_add(x, bias), 0); - frac = spu_sub(spu_convtf(ix, 0), x); - frac = spu_mul(frac, spu_splats(__EXP2F_LN2)); - - // !!! HRD Changing weird un-understandable and incorrect overflow handling code - //overflow = spu_sel((vec_uint4)spu_splats(0x7FFFFFFF), (vec_uint4)x, (vec_uchar16)spu_splats(0x80000000)); - overflow = spu_cmpgt(x, (vec_float4)spu_splats(0x4300FFFFu)); // !!! Biggest possible exponent to fit in range. - underflow = spu_cmpgt(spu_splats(-126.0f), x); - - //exp_int = (vec_float4)(spu_sl(spu_add(ix, 127), 23)); // !!! HRD <- changing this to correct for - // !!! overflow (x >= 127.999999f) - exp_int = (vec_float4)(spu_sl(spu_add(ix, 126), 23)); // !!! HRD <- add with saturation - exp_int = spu_add(exp_int, exp_int); // !!! HRD - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - frac2 = spu_mul(frac, frac); - frac4 = spu_mul(frac2, frac2); - - hi = spu_madd(frac, spu_splats(-0.0001413161f), spu_splats(0.0013298820f)); - hi = spu_madd(frac, hi, spu_splats(-0.0083013598f)); - hi = spu_madd(frac, hi, spu_splats(0.0416573475f)); - lo = spu_madd(frac, spu_splats(-0.1666653019f), spu_splats(0.4999999206f)); - lo = spu_madd(frac, lo, spu_splats(-0.9999999995f)); - lo = spu_madd(frac, lo, spu_splats(1.0f)); - - exp_frac = spu_madd(frac4, hi, lo); - ix = spu_add(ix, spu_rlmask((vec_int4)(exp_frac), -23)); - result = spu_mul(exp_frac, exp_int); - - /* Handle overflow */ - result = spu_sel(result, (vec_float4)spu_splats(0x7FFFFFFF), overflow); - result = spu_sel(result, (vec_float4)spu_splats(0), underflow); - //result = spu_sel(result, (vec_float4)(overflow), spu_cmpgt((vec_uint4)(ix), 255)); - - return (result); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/expf4.h b/Extras/simdmathlibrary/spu/simdmath/expf4.h deleted file mode 100644 index d870d8243..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/expf4.h +++ /dev/null @@ -1,70 +0,0 @@ -/* expm1f4 - - 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 ___SIMD_MATH_EXPF4_H___ -#define ___SIMD_MATH_EXPF4_H___ - -#include -#include - -#include -#include - -#define __EXPF_C1 -0.6931470632553101f -#define __EXPF_C2 -1.1730463525082e-7f - -#define __EXPF_INVLN2 1.4426950408889634f - -static inline vector float -_expf4 (vector float x) -{ - vec_uint4 xnegmask = spu_cmpgt(spu_splats(0.0f), x); - vec_float4 goffset = spu_sel(spu_splats(0.5f),spu_splats(-0.5f),xnegmask); - vec_float4 g = spu_mul(x, spu_splats(__EXPF_INVLN2)); - vec_int4 xexp = spu_convts(spu_add(g, goffset),0); - - g = spu_convtf(xexp, 0); - g = spu_madd(g, spu_splats(__EXPF_C2), spu_madd(g, spu_splats(__EXPF_C1), x)); - vec_float4 z = spu_mul(g, g); - vec_float4 a = spu_mul(z, spu_splats(0.0999748594f)); - vec_float4 b = spu_mul(g, - spu_madd(z, - spu_splats(0.0083208258f), - spu_splats(0.4999999992f) - ) - ); - - vec_float4 foo = _divf4(spu_add(spu_splats(1.0f), spu_add(a, b)), - spu_add(spu_splats(1.0f), spu_sub(a, b))); - - return _ldexpf4(foo, xexp); - -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/expm1f4.h b/Extras/simdmathlibrary/spu/simdmath/expm1f4.h deleted file mode 100644 index 78e63abfd..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/expm1f4.h +++ /dev/null @@ -1,62 +0,0 @@ -/* expm1f4 - - 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 ___SIMD_MATH_EXPMLF4_H___ -#define ___SIMD_MATH_EXPMLF4_H___ - -#include -#include - -#include -#include - -#define __EXPM1F_ln1by2 -0.6931471805599f -#define __EXPM1F_ln3by2 0.4054651081082f - -static inline vector float -_expm1f4 (vector float x) -{ - vec_uint4 nearzeromask = spu_and(spu_cmpgt(x, spu_splats(__EXPM1F_ln1by2)), - spu_cmpgt(spu_splats(__EXPM1F_ln3by2), x)); - vec_float4 x2 = spu_mul(x,x); - vec_float4 d0, d1, n0, n1; - - d0 = spu_madd(x , spu_splats(-0.3203561199f), spu_splats(0.9483177697f)); - d1 = spu_madd(x2, spu_splats(0.0326527809f), d0); - - n0 = spu_madd(x , spu_splats(0.1538026623f), spu_splats(0.9483177732f)); - n1 = spu_madd(x , spu_splats(0.0024490478f), spu_splats(0.0305274668f)); - n1 = spu_madd(x2, n1, n0); - - return spu_sel(spu_sub(_expf4(x), spu_splats(1.0f)), - spu_mul(x, _divf4(n1, d1)), - nearzeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fabsd2.h b/Extras/simdmathlibrary/spu/simdmath/fabsd2.h deleted file mode 100644 index 3ba4e39ea..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fabsd2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fabsd2 - for each of two double slots, compute absolute value. - 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 ___SIMD_MATH_FABSD2_H___ -#define ___SIMD_MATH_FABSD2_H___ - -#include -#include - -static inline vector double -_fabsd2 (vector double x) -{ - return (vec_double2)spu_andc( (vec_ullong2)x, spu_splats(0x8000000000000000ull) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fabsf4.h b/Extras/simdmathlibrary/spu/simdmath/fabsf4.h deleted file mode 100644 index bad63e5b1..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fabsf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fabsf4 - for each of 4 float slots, compute absolute value. - 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 ___SIMD_MATH_FABSF4_H___ -#define ___SIMD_MATH_FABSF4_H___ - -#include -#include - -static inline vector float -_fabsf4 (vector float x) -{ - return (vec_float4)spu_andc( (vec_uint4)x, spu_splats(0x80000000) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fdimd2.h b/Extras/simdmathlibrary/spu/simdmath/fdimd2.h deleted file mode 100644 index 5cbb1a3ff..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fdimd2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* fdimd2 - 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 ___SIMD_MATH_FDIMD2_H___ -#define ___SIMD_MATH_FDIMD2_H___ - -#include -#include - -/* fdim_v - compute the positive difference of x and y. - */ -static inline vector double -_fdimd2 (vector double x, vector double y) -{ - vec_double2 v; - vec_uint4 mask; - - v = spu_sub(x, y); - mask = (vec_uint4)spu_shuffle(v, v, ((vec_uchar16){0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8})); - v = spu_andc(v, (vec_double2)spu_rlmaska(mask, -31)); - - return (v); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fdimf4.h b/Extras/simdmathlibrary/spu/simdmath/fdimf4.h deleted file mode 100644 index f81482f1c..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fdimf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* fdimf4 - - 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 ___SIMD_MATH_FDIMF4_H___ -#define ___SIMD_MATH_FDIMF4_H___ - -#include -#include - -static inline vector float -_fdimf4 (vector float x, vector float y) -{ - vec_float4 diff = spu_sub(x,y); - return spu_sel(spu_splats(0.0f),diff, spu_cmpgt(x,y)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/floord2.h b/Extras/simdmathlibrary/spu/simdmath/floord2.h deleted file mode 100644 index e2499883f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/floord2.h +++ /dev/null @@ -1,99 +0,0 @@ -/* floord2 - for each of two doule slots, round up to smallest integer not more than the value. - 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 ___SIMD_MATH_FLOORD2_H___ -#define ___SIMD_MATH_FLOORD2_H___ - -#include -#include - -static inline vector double -_floord2(vector double in) -{ - vec_uchar16 swap_words = ((vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}); - vec_uchar16 splat_hi = ((vec_uchar16){0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_uint4 one = ((vec_uint4){0, 1, 0, 1}); - vec_int4 exp, shift; - vec_uint4 mask, mask_1, frac_mask, addend, insert, pos, equal0, e_0, e_00, e_sign, exp_ge0; - vec_ullong2 sign = spu_splats(0x8000000000000000ULL); - vec_double2 in_hi, out; - vec_double2 one_d = spu_splats((double)1.0); - vec_uint4 zero = spu_splats((unsigned int)0x0); - - /* This function generates the following component - * based upon the inputs. - * - * mask = bits of the input that need to be replaced. - * insert = value of the bits that need to be replaced - * addend = value to be added to perform function. - * - * These are applied as follows:. - * - * out = ((in & mask) | insert) + addend - */ - - in_hi = spu_shuffle(in, in, splat_hi); - exp = spu_and(spu_rlmask((vec_int4)in_hi, -20), 0x7FF); - shift = spu_sub(((vec_int4){1023, 1043, 1023, 1043}), exp); - - /* clamp shift to the range 0 to -31. - */ - shift = spu_sel(spu_splats((int)-32), spu_andc(shift, (vec_int4)spu_cmpgt(shift, 0)), spu_cmpgt(shift, -32)); - frac_mask = spu_rlmask(((vec_uint4){0xFFFFF, -1, 0xFFFFF, -1}), shift); - exp_ge0 = spu_cmpgt(exp, 0x3FE); - mask = spu_orc(frac_mask, exp_ge0); - - /* addend = ((in & mask) && (in >= 0)) ? mask+1 : 0 - */ - mask_1 = spu_addx(mask, one, spu_rlqwbyte(spu_genc(mask, one), 4)); - pos = spu_cmpgt((vec_int4)in_hi, -1); - //pos = spu_cmpgt((vec_int4)in_hi, 0x0); //it is also work - equal0 = spu_cmpeq(spu_and((vec_uint4)in, mask), 0); - addend = spu_andc(spu_andc(mask_1, pos), spu_and(equal0, spu_shuffle(equal0, equal0, swap_words))); - - /* insert - */ - e_0 = spu_cmpeq(spu_andc((vec_uint4)in, (vec_uint4)sign), zero); - e_00 = spu_and(e_0, spu_shuffle(e_0, e_0, swap_words)); - // e_sign = spu_sel((vec_uint4)one_d, zero, spu_cmpeq( spu_and((vec_uint4)in_hi, spu_splats((unsigned int)0x80000000)), zero)); - e_sign = spu_andc( (vec_uint4)one_d, spu_cmpeq( spu_and((vec_uint4)in_hi,spu_splats((unsigned int)0x80000000)), zero)); - insert =spu_andc(spu_andc(e_sign, e_00), exp_ge0); - - /* replace insert - */ - in = spu_sel(in, (vec_double2)insert, spu_andc((vec_ullong2)mask, sign)); - - /* in + addend - */ - out = (vec_double2)spu_addx((vec_uint4)in, addend, spu_rlqwbyte(spu_genc((vec_uint4)in, addend), 4)); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/floorf4.h b/Extras/simdmathlibrary/spu/simdmath/floorf4.h deleted file mode 100644 index 2e8f62508..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/floorf4.h +++ /dev/null @@ -1,58 +0,0 @@ -/* floorf4 - for each of four float slots, round down to largest integer not greater than the value. - 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 ___SIMD_MATH_FLOORF4_H___ -#define ___SIMD_MATH_FLOORF4_H___ - -#include -#include - -static inline vector float -_floorf4 (vector float x) -{ - vec_int4 xi, xi1; - vec_uint4 inrange; - vec_float4 truncated, truncated1; - - // Find truncated value and one less. - - inrange = spu_cmpabsgt( (vec_float4)spu_splats(0x4b000000), x ); - - xi = spu_convts( x, 0 ); - xi1 = spu_add( xi, -1 ); - - truncated = spu_sel( x, spu_convtf( xi, 0 ), inrange ); - truncated1 = spu_sel( x, spu_convtf( xi1, 0 ), inrange ); - - // If truncated value is greater than input, subtract one. - - return spu_sel( truncated, truncated1, spu_cmpgt( truncated, x ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmad2.h b/Extras/simdmathlibrary/spu/simdmath/fmad2.h deleted file mode 100644 index b1047cde8..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmad2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fmad2 - 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 ___SIMD_MATH_FMAD2_H___ -#define ___SIMD_MATH_FMAD2_H___ - -#include -#include - -static inline vector double -_fmad2 (vector double x, vector double y, vector double z) -{ - return spu_madd(x,y,z); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmaf4.h b/Extras/simdmathlibrary/spu/simdmath/fmaf4.h deleted file mode 100644 index 7dd344f16..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmaf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* fmaf4 - 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 ___SIMD_MATH_FMAF4_H___ -#define ___SIMD_MATH_FMAF4_H___ - -#include -#include - -static inline vector float -_fmaf4 (vector float x, vector float y, vector float z) -{ - return spu_madd(x,y,z); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmaxd2.h b/Extras/simdmathlibrary/spu/simdmath/fmaxd2.h deleted file mode 100644 index 944881fc9..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmaxd2.h +++ /dev/null @@ -1,71 +0,0 @@ -/* fmaxd2 - for each of two double slots, compute maximum of x and y - 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 ___SIMD_MATH_FMAXD2_H___ -#define ___SIMD_MATH_FMAXD2_H___ - -#include -#include - -/* Return the maximum numeric value of their arguments. If one argument - * is a NaN, fmax returns the other value. If both are NaNs, then a NaN - * is returned. - */ - -static inline vector double -_fmaxd2 (vector double x, vector double y) -{ - vec_ullong2 selector, denorm; - vec_double2 x_offset, y_offset, diff; - vec_uint4 nan_x, abs_x, gt, eq; - vec_uint4 sign = (vec_uint4){0x80000000, 0, 0x80000000, 0}; - vec_uint4 infinity = (vec_uint4){0x7FF00000, 0, 0x7FF00000, 0}; - vec_uint4 exp0 = (vec_uint4){0x3FF00000, 0, 0x3FF00000, 0}; - - /* If both x and y are denorm or zero, then set 0x3ff to exponent - */ - denorm = (vec_ullong2)spu_cmpeq(spu_and((vec_uint4)spu_or(x, y), infinity), 0); - x_offset = spu_sel(x, spu_or(x, (vec_double2)exp0), denorm); - y_offset = spu_sel(y, spu_or(y, (vec_double2)exp0), denorm); - - /* If x is a NaN, then select y as max - */ - abs_x = spu_andc((vec_uint4)x, sign); - gt = spu_cmpgt(abs_x, infinity); - eq = spu_cmpeq(abs_x, infinity); - nan_x = spu_or(gt, spu_and(eq, spu_rlqwbyte(gt, 4))); - - diff = spu_sub(x_offset, y_offset); - selector = (vec_ullong2)spu_orc(nan_x, spu_cmpgt((vec_int4)diff, -1)); - selector = spu_shuffle(selector, selector, ((vec_uchar16){0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11})); - - return spu_sel(x, y, selector); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmaxf4.h b/Extras/simdmathlibrary/spu/simdmath/fmaxf4.h deleted file mode 100644 index cdaecdc94..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmaxf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* fmaxf4 - for each of four float slots, compute maximum of x and y - 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 ___SIMD_MATH_FMAXF4_H___ -#define ___SIMD_MATH_FMAXF4_H___ - -#include -#include - - -static inline vector float -_fmaxf4 (vector float x, vector float y) -{ - return spu_sel( x, y, spu_cmpgt( y, x ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmind2.h b/Extras/simdmathlibrary/spu/simdmath/fmind2.h deleted file mode 100644 index df641c04d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmind2.h +++ /dev/null @@ -1,71 +0,0 @@ -/* fmind2 - for each of two double slots, compute minimum of x and y - 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 ___SIMD_MATH_FMIND2_H___ -#define ___SIMD_MATH_FMIND2_H___ - -#include -#include - -/* Return the minimum numeric value of their arguments. If one argument - * is a NaN, fmin returns the other value. If both are NaNs, then a NaN - * is returned. - */ - -static inline vector double -_fmind2 (vector double x, vector double y) -{ - vec_ullong2 selector, denorm; - vec_double2 x_offset, y_offset, diff; - vec_uint4 nan_x, abs_x, gt, eq; - vec_uint4 sign = (vec_uint4){0x80000000, 0, 0x80000000, 0}; - vec_uint4 infinity = (vec_uint4){0x7FF00000, 0, 0x7FF00000, 0}; - vec_uint4 exp0 = (vec_uint4){0x3FF00000, 0, 0x3FF00000, 0}; - - /* If both x and y are denorm or zero, then set 0x3ff to exponent - */ - denorm = (vec_ullong2)spu_cmpeq(spu_and((vec_uint4)spu_or(x, y), infinity), 0); - x_offset = spu_sel(x, spu_or(x, (vec_double2)exp0), denorm); - y_offset = spu_sel(y, spu_or(y, (vec_double2)exp0), denorm); - - /* If x is a NaN, then select y as min - */ - abs_x = spu_andc((vec_uint4)x, sign); - gt = spu_cmpgt(abs_x, infinity); - eq = spu_cmpeq(abs_x, infinity); - nan_x = spu_or(gt, spu_and(eq, spu_rlqwbyte(gt, 4))); - - diff = spu_sub(y_offset, x_offset); - selector = (vec_ullong2)spu_orc(nan_x, spu_cmpgt((vec_int4)diff, -1)); - selector = spu_shuffle(selector, selector, ((vec_uchar16){0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11})); - - return spu_sel(x, y, selector); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fminf4.h b/Extras/simdmathlibrary/spu/simdmath/fminf4.h deleted file mode 100644 index c422e6010..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fminf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* fminf4 - for each of four float slots, compute minimum of x and y - 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 ___SIMD_MATH_FMINF4_H___ -#define ___SIMD_MATH_FMINF4_H___ - -#include -#include - - -static inline vector float -_fminf4 (vector float x, vector float y) -{ - return spu_sel( x, y, spu_cmpgt( x, y ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmodd2.h b/Extras/simdmathlibrary/spu/simdmath/fmodd2.h deleted file mode 100644 index cf7b71722..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmodd2.h +++ /dev/null @@ -1,282 +0,0 @@ -/* fmodd2 - - 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 ___SIMD_MATH_FMODD2_H___ -#define ___SIMD_MATH_FMODD2_H___ - -#include -#include - -#include - -/* - * a vector is returned that contains the remainder of xi/yi, - * for coresponding elements of vector double x and vector double y, - * as described below: - * if yi is 0, the result is 0 - * otherwise, the funciton determines the unique signed integer value i - * such that the returned element is xi - i * yi with the same sign as xi and - * magnitude less than |yi| - */ - -static inline vector double -_fmodd2(vector double x, vector double y) -{ - int shift0, shift1; - vec_uchar16 swap_words = (vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}; - vec_uchar16 propagate = (vec_uchar16){4,5,6,7, 192,192,192,192, 12,13,14,15, 192,192,192,192}; - vec_uchar16 splat_hi = (vec_uchar16){0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}; - vec_uchar16 merge = (vec_uchar16){8,9,10,11,12,13,14,15, 24,25,26,27,28,29,30,31}; - vec_int4 n, shift, power; - vec_uint4 z; - vec_uint4 x_hi, y_hi; - vec_uint4 abs_x, abs_y; - vec_uint4 exp_x, exp_y; - vec_uint4 zero_x, zero_y; - vec_uint4 mant_x, mant_x0, mant_x1, mant_y ; - vec_uint4 norm, denorm, norm0, norm1, denorm0, denorm1; - vec_uint4 result, result0, resultx, cnt, sign, borrow, mask; - vec_uint4 x_7ff, x_inf, x_nan, y_7ff, y_inf, y_nan, is_normal; - vec_uint4 x_is_norm, y_is_norm, frac_x, frac_y, cnt_x, cnt_y, mant_x_norm, mant_y_norm; - vec_uint4 mant_x_denorm0, mant_x_denorm1, mant_x_denorm; - vec_uint4 mant_y_denorm0, mant_y_denorm1, mant_y_denorm; - vec_uint4 lsb = (vec_uint4)(spu_splats(0x0000000000000001ULL)); - vec_uint4 sign_mask = (vec_uint4)(spu_splats(0x8000000000000000ULL)); - vec_uint4 implied_1 = (vec_uint4)(spu_splats(0x0010000000000000ULL)); - vec_uint4 mant_mask = (vec_uint4)(spu_splats(0x000FFFFFFFFFFFFFULL)); - - sign = spu_and((vec_uint4)x, sign_mask); - - abs_x = spu_andc((vec_uint4)x, sign_mask); - abs_y = spu_andc((vec_uint4)y, sign_mask); - - x_hi = spu_shuffle(abs_x, abs_x, splat_hi); - y_hi = spu_shuffle(abs_y, abs_y, splat_hi); - - exp_x = spu_rlmask(x_hi, -20); - exp_y = spu_rlmask(y_hi, -20); - - // y>x - resultx = __vec_gt64(abs_y, abs_x); - - //is Inf, is Nan - x_7ff = spu_cmpgt(x_hi, spu_splats((unsigned int)0x7fefffff)); - x_inf = __vec_eq64_half(abs_x, ((vec_uint4){0x7ff00000,0x0,0x7ff00000,0x0})); - x_nan = spu_andc(x_7ff, x_inf); - - y_7ff = spu_cmpgt(y_hi, spu_splats((unsigned int)0x7fefffff)); - y_inf = __vec_eq64_half(abs_y, ((vec_uint4){0x7ff00000,0x0,0x7ff00000,0x0})); - y_nan = spu_andc(y_7ff, y_inf); - - // is zero - zero_x = __vec_eq64_half(abs_x, spu_splats((unsigned int)0x0)); - zero_y = __vec_eq64_half(abs_y, spu_splats((unsigned int)0x0)); - - - /* Determine ilogb of abs_x and abs_y and - * extract the mantissas (mant_x, mant_y) - */ - /* change form*/ - // 0 -> ! is_normal - // 0 don't care (because (x=0, y!=0)match xx || y<=x - result = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), - (vec_uint4)x, resultx); - //y=+-inf => 0 - result = spu_sel(result, (vec_uint4)x, y_inf); - //x=+-inf => NaN - result = spu_sel(result, ((vec_uint4){0x7ff80000, 0x0, 0x7ff80000, 0x0}), x_inf); - //y=0 => 0 - result = spu_andc(result, zero_y); - - //x=NaN or y=NaN => 0 - result = spu_sel(result, (vec_uint4)x, x_nan); - result = spu_sel(result, (vec_uint4)y, y_nan); - - return ((vec_double2)result); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fmodf4.h b/Extras/simdmathlibrary/spu/simdmath/fmodf4.h deleted file mode 100644 index 61b5473c8..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fmodf4.h +++ /dev/null @@ -1,94 +0,0 @@ -/* fmodf4 - for each of four float slots, compute remainder of x/y defined as x - truncated_integer(x/y) * y. - 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 ___SIMD_MATH_FMODF4_H___ -#define ___SIMD_MATH_FMODF4_H___ - -#include -#include - -#include -#include -#include - -// -// This returns an accurate result when |divf4(x,y)| < 2^20 and |x| < 2^128, and otherwise returns zero. -// If x == 0, the result is 0. -// If x != 0 and y == 0, the result is undefined. - -static inline vector float -_fmodf4 (vector float x, vector float y) -{ - vec_float4 q, xabs, yabs, qabs, xabs2; - vec_int4 qi0, qi1, qi2; - vec_float4 i0, i1, i2, r1, r2, i; - vec_uint4 inrange; - - // Find i = truncated_integer(|x/y|) - - // If |divf4(x,y)| < 2^20, the quotient is at most off by 1.0. - // Thus i is either the truncated quotient, one less, or one greater. - - q = _divf4( x, y ); - xabs = _fabsf4( x ); - yabs = _fabsf4( y ); - qabs = _fabsf4( q ); - xabs2 = spu_add( xabs, xabs ); - - inrange = spu_cmpabsgt( (vec_float4)spu_splats(0x49800000), q ); - inrange = spu_and( inrange, spu_cmpabsgt( (vec_float4)spu_splats(0x7f800000), x ) ); - - qi1 = spu_convts( qabs, 0 ); - qi0 = spu_add( qi1, -1 ); - qi2 = spu_add( qi1, 1 ); - - i0 = spu_convtf( qi0, 0 ); - i1 = spu_convtf( qi1, 0 ); - i2 = spu_convtf( qi2, 0 ); - - // Correct i will be the largest one such that |x| - i*|y| >= 0. Can test instead as - // 2*|x| - i*|y| >= |x|: - // - // With exact inputs, the negative-multiply-subtract gives the exact result rounded towards zero. - // Thus |x| - i*|y| may be < 0 but still round to zero. However, if 2*|x| - i*|y| < |x|, the computed - // answer will be rounded down to < |x|. 2*|x| can be represented exactly provided |x| < 2^128. - - r1 = spu_nmsub( i1, yabs, xabs2 ); - r2 = spu_nmsub( i2, yabs, xabs2 ); - - i = i0; - i = spu_sel( i1, i, spu_cmpgt( xabs, r1 ) ); - i = spu_sel( i2, i, spu_cmpgt( xabs, r2 ) ); - - i = _copysignf4( i, q ); - - return spu_sel( spu_splats(0.0f), spu_nmsub( i, y, x ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fpclassifyd2.h b/Extras/simdmathlibrary/spu/simdmath/fpclassifyd2.h deleted file mode 100644 index bbccbfc57..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fpclassifyd2.h +++ /dev/null @@ -1,83 +0,0 @@ -/* fpclassifyd2 - for each element of vector x, return classification of x': FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO - 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 ___SIMD_MATH_FPCLASSIFYD2_H___ -#define ___SIMD_MATH_FPCLASSIFYD2_H___ - -#include -#include -#include - -static inline vector signed long long -_fpclassifyd2 (vector double x) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 signexpn = spu_splats(0xfff0000000000000ull); - vec_ullong2 zero = spu_splats(0x0000000000000000ull); - - vec_ullong2 mask; - vec_llong2 classtype; - vec_uint4 cmpgt, cmpeq; - - //FP_NORMAL: normal unless nan, infinity, zero, or denorm - classtype = spu_splats((long long)FP_NORMAL); - - //FP_NAN: all-ones exponent and non-zero mantissa - cmpgt = spu_cmpgt( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)signexpn ); - cmpeq = spu_cmpeq( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)signexpn ); - mask = (vec_ullong2)spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - classtype = spu_sel( classtype, spu_splats((long long)FP_NAN), mask ); - - //FP_INFINITE: all-ones exponent and zero mantissa - mask = (vec_ullong2)spu_and( cmpeq, spu_shuffle( cmpeq, cmpeq, swapEvenOdd ) ); - classtype = spu_sel( classtype, spu_splats((long long)FP_INFINITE), mask ); - - //FP_ZERO: zero exponent and zero mantissa - cmpeq = spu_cmpeq( (vec_uint4)spu_andc( (vec_ullong2)x, sign ), (vec_uint4)zero ); - mask = (vec_ullong2)spu_and( cmpeq, spu_shuffle( cmpeq, cmpeq, swapEvenOdd ) ); - classtype = spu_sel( classtype, spu_splats((long long)FP_ZERO), mask ); - - //FP_SUBNORMAL: zero exponent and non-zero mantissa - cmpeq = spu_cmpeq( (vec_uint4)spu_and( (vec_ullong2)x, expn ), (vec_uint4)zero ); - cmpgt = spu_cmpgt( (vec_uint4)spu_andc( (vec_ullong2)x, signexpn ), (vec_uint4)zero ); - mask = (vec_ullong2)spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_or( cmpgt, spu_shuffle( cmpgt, cmpgt, swapEvenOdd ) ) ); - classtype = spu_sel( classtype, spu_splats((long long)FP_SUBNORMAL), mask ); - - return classtype; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/fpclassifyf4.h b/Extras/simdmathlibrary/spu/simdmath/fpclassifyf4.h deleted file mode 100644 index fc251f998..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/fpclassifyf4.h +++ /dev/null @@ -1,67 +0,0 @@ -/* fpclassifyf4 - for each element of vector x, return classification of x': FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO - 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 ___SIMD_MATH_FPCLASSIFYF4_H___ -#define ___SIMD_MATH_FPCLASSIFYF4_H___ - -#include -#include -#include - -static inline vector signed int -_fpclassifyf4 (vector float x) -{ - vec_uint4 zero = spu_splats((unsigned int)0x00000000); - - vec_uint4 mask; - vec_uint4 unclassified = spu_splats((unsigned int)0xffffffff); - vec_int4 classtype = (vec_int4)zero; - - //FP_NAN: NaN not supported on SPU, never return FP_NAN - - //FP_INFINITE: Inf not supported on SPU, never return FP_INFINITE - - //FP_ZERO: zero exponent and zero mantissa - mask = spu_cmpeq( spu_andc( (vec_uint4)x, spu_splats((unsigned int)0x80000000)), zero ); - classtype = spu_sel( classtype, spu_splats((int)FP_ZERO), mask ); - unclassified = spu_andc( unclassified, mask ); - - //FP_SUBNORMAL: zero exponent and non-zero mantissa - mask = spu_and( spu_cmpeq( spu_and( (vec_uint4)x, spu_splats((unsigned int)0x7f800000)), zero ), - spu_cmpgt( spu_and( (vec_uint4)x, spu_splats((unsigned int)0x007fffff)), zero ) ); - classtype = spu_sel( classtype, spu_splats((int)FP_SUBNORMAL), mask ); - unclassified = spu_andc( unclassified, mask ); - - //FP_NORMAL: none of the above - classtype = spu_sel( classtype, spu_splats((int)FP_NORMAL), unclassified ); - - return classtype; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/frexpd2.h b/Extras/simdmathlibrary/spu/simdmath/frexpd2.h deleted file mode 100644 index 956412953..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/frexpd2.h +++ /dev/null @@ -1,98 +0,0 @@ -/* frexpd2 - for each element of vector x, return the normalized fraction and store the exponent of x' - 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 ___SIMD_MATH_FREXPD2_H___ -#define ___SIMD_MATH_FREXPD2_H___ - -#include -#include -#include - -#define __FREXPD_DBL_NAN 0x7FF8000000000000ull - -static inline vector double -_frexpd2 (vector double x, vector signed long long *pexp) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - - vec_ullong2 maskdw = (vec_ullong2){0xffffffffffffffffull, 0ull}; - - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 zero = spu_splats(0x0000000000000000ull); - - vec_ullong2 isnan, isinf, iszero; - vec_ullong2 e0, x0, x1; - vec_uint4 cmpgt, cmpeq, cmpzr; - vec_int4 lz, lz0, sh, ex; - vec_double2 fr, frac = (vec_double2)zero; - - //NAN: x is NaN (all-ones exponent and non-zero mantissa) - cmpgt = spu_cmpgt( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - cmpeq = spu_cmpeq( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - isnan = (vec_ullong2)spu_or( cmpgt, spu_and( cmpeq, spu_rlqwbyte( cmpgt, -4 ) ) ); - isnan = (vec_ullong2)spu_shuffle( isnan, isnan, even ); - frac = spu_sel( frac, (vec_double2)spu_splats(__FREXPD_DBL_NAN), isnan ); - - //INF: x is infinite (all-ones exponent and zero mantissa) - isinf = (vec_ullong2)spu_and( cmpeq, spu_shuffle( cmpeq, cmpeq, swapEvenOdd ) ); - frac = spu_sel( frac, x , isinf ); - - //x is zero (zero exponent and zero mantissa) - cmpzr = spu_cmpeq( (vec_uint4)spu_andc( (vec_ullong2)x, sign ), (vec_uint4)zero ); - iszero = (vec_ullong2)spu_and( cmpzr, spu_shuffle( cmpzr, cmpzr, swapEvenOdd ) ); - - frac = spu_sel( frac, (vec_double2)zero , iszero ); - *pexp = spu_sel( *pexp, (vec_llong2)zero , iszero ); - - //Integer Exponent: if x is normal or subnormal - - //...shift left to normalize fraction, zero shift if normal - lz = (vec_int4)spu_cntlz( (vec_uint4)spu_andc( (vec_ullong2)x, sign) ); - lz0 = (vec_int4)spu_shuffle( lz, lz, even ); - sh = spu_sel( (vec_int4)zero, spu_sub( lz0, spu_splats((int)11) ), spu_cmpgt( lz0, (int)11 ) ); - sh = spu_sel( sh, spu_add( sh, lz ), spu_cmpeq( lz0, (int)32 ) ); - - x0 = spu_slqw( spu_slqwbytebc( spu_and( (vec_ullong2)x, maskdw ), spu_extract(sh, 1) ), spu_extract(sh, 1) ); - x1 = spu_slqw( spu_slqwbytebc( (vec_ullong2)x, spu_extract(sh, 3) ), spu_extract(sh, 3) ); - fr = (vec_double2)spu_sel( x1, x0, maskdw ); - fr = spu_sel( fr, (vec_double2)spu_splats(0x3FE0000000000000ull), expn ); - fr = spu_sel( fr, x, sign ); - - e0 = spu_rlmaskqw( spu_rlmaskqwbyte(spu_and( (vec_ullong2)x, expn ),-6), -4 ); - ex = spu_sel( spu_sub( (vec_int4)e0, spu_splats((int)1022) ), spu_sub( spu_splats((int)-1021), sh ), spu_cmpgt( sh, (int)0 ) ); - - frac = spu_sel( frac, fr, spu_nor( isnan, spu_or( isinf, iszero ) ) ); - *pexp = spu_sel( *pexp, spu_extend( ex ), spu_nor( isnan, spu_or( isinf, iszero ) ) ); - - return frac; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/frexpf4.h b/Extras/simdmathlibrary/spu/simdmath/frexpf4.h deleted file mode 100644 index 698f79028..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/frexpf4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* frexpf4 - for each element of vector x, return the normalized fraction and store the exponent of x' - 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 ___SIMD_MATH_FREXPF4_H___ -#define ___SIMD_MATH_FREXPF4_H___ - -#include -#include - -static inline vector float -_frexpf4 (vector float x, vector signed int *pexp) -{ - vec_int4 zeros = spu_splats((int)0); - vec_uint4 zeromask = spu_cmpeq(x, (vec_float4)zeros); - - vec_uint4 expmask = spu_splats(0x7F800000U); - vec_int4 e1 = spu_and((vec_int4)x, (vec_int4)expmask); - vec_int4 e2 = spu_sub(spu_rlmask(e1,-23), spu_splats((int)126)); - *pexp = spu_sel(e2, zeros, zeromask); - - vec_float4 m2 = spu_sel(x, (vec_float4)spu_splats((int)0x3F000000), expmask); - - return spu_sel(m2, (vec_float4)zeros, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/hypotd2.h b/Extras/simdmathlibrary/spu/simdmath/hypotd2.h deleted file mode 100644 index e2676d4b5..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/hypotd2.h +++ /dev/null @@ -1,47 +0,0 @@ -/* hypotd2 - for each element of vector x and y, return the square root of (x')^2 + (y')^2 - 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 ___SIMD_MATH_HYPOTD2_H___ -#define ___SIMD_MATH_HYPOTD2_H___ - -#include -#include - -#include - -static inline vector double -_hypotd2 (vector double x, vector double y) -{ - vec_double2 sum = spu_mul(x,x); - sum = spu_madd(y,y,sum); - - return _sqrtd2(sum); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/hypotf4.h b/Extras/simdmathlibrary/spu/simdmath/hypotf4.h deleted file mode 100644 index b607a847e..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/hypotf4.h +++ /dev/null @@ -1,47 +0,0 @@ -/* hypotf4 - for each element of vector x and y, return the square root of (x')^2 + (y')^2 - 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 ___SIMD_MATH_HYPOTF4_H___ -#define ___SIMD_MATH_HYPOTF4_H___ - -#include -#include - -#include - -static inline vector float -_hypotf4 (vector float x, vector float y) -{ - vec_float4 sum = spu_mul(x,x); - sum = spu_madd(y,y,sum); - - return _sqrtf4(sum); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ilogbd2.h b/Extras/simdmathlibrary/spu/simdmath/ilogbd2.h deleted file mode 100644 index 91039259e..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ilogbd2.h +++ /dev/null @@ -1,83 +0,0 @@ -/* ilogbd2 - for each element of vector x, return integer exponent of normalized double x', FP_ILOGBNAN, or FP_ILOGB0 - 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 ___SIMD_MATH_ILOGBD2_H___ -#define ___SIMD_MATH_ILOGBD2_H___ - -#include -#include -#include -#include - -static inline vector signed long long -_ilogbd2 (vector double x) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 zero = spu_splats(0x0000000000000000ull); - - vec_ullong2 isnan, iszeroinf; - vec_llong2 ilogb = (vec_llong2)zero; - vec_llong2 e1, e2; - vec_uint4 cmpgt, cmpeq, cmpzr; - vec_int4 lz, lz0, lz1; - - //FP_ILOGBNAN: x is NaN (all-ones exponent and non-zero mantissa) - cmpgt = spu_cmpgt( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - cmpeq = spu_cmpeq( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - isnan = (vec_ullong2)spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - ilogb = spu_sel( ilogb, spu_splats((long long)FP_ILOGBNAN), isnan ); - - //FP_ILOGB0: x is zero (zero exponent and zero mantissa) or infinity (all-ones exponent and zero mantissa) - cmpzr = spu_cmpeq( (vec_uint4)spu_andc( (vec_ullong2)x, sign ), (vec_uint4)zero ); - iszeroinf = (vec_ullong2)spu_or( spu_and( cmpzr, spu_shuffle( cmpzr, cmpzr, swapEvenOdd ) ), - spu_and( cmpeq, spu_shuffle( cmpeq, cmpeq, swapEvenOdd ) ) ); - ilogb = spu_sel( ilogb, spu_splats((long long)FP_ILOGB0), iszeroinf ); - - //Integer Exponent: if x is normal or subnormal, return unbiased exponent of normalized double x - e1 = (vec_llong2)spu_and( (vec_llong2)x, (vec_llong2)expn ); - e2 = (vec_llong2)spu_rlmaskqw( spu_rlmaskqwbyte(e1,-6), -4 ); - - lz = (vec_int4)spu_cntlz( (vec_uint4)spu_andc( (vec_ullong2)x, sign) ); - lz0 = (vec_int4)spu_shuffle( lz, lz, even ); - lz0 = spu_sel( (vec_int4)zero, spu_sub( lz0, spu_splats((int)12) ), spu_cmpgt( lz0, (int)11 ) ); - lz1 = spu_sel( (vec_int4)zero, spu_shuffle( lz, lz, odd), spu_cmpeq( lz0, (int)20 ) ); - - ilogb = spu_sel( ilogb, spu_extend( spu_sub( spu_sub( (vec_int4)e2, spu_splats((int)1023)), spu_add( lz0, lz1 ) ) ), spu_nor( isnan, iszeroinf ) ); - - return ilogb; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ilogbf4.h b/Extras/simdmathlibrary/spu/simdmath/ilogbf4.h deleted file mode 100644 index 6ebd88a83..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ilogbf4.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ilogbf4 - for each element of vector x, return integer exponent of x', FP_ILOGBNAN, or FP_ILOGB0 - 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 ___SIMD_MATH_ILOGBF4_H___ -#define ___SIMD_MATH_ILOGBF4_H___ - -#include -#include -#include -#include - -static inline vector signed int -_ilogbf4 (vector float x) -{ - vec_int4 minus127 = spu_splats((int)-127); - - vec_int4 e1 = spu_and((vec_int4)x, spu_splats((int)0x7F800000)); - vec_uint4 zeromask = spu_cmpeq(e1, 0); - vec_int4 e2 = spu_add(spu_rlmask(e1,-23), minus127); - - return spu_sel(e2, (vec_int4)spu_splats(FP_ILOGB0), zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/irintf4.h b/Extras/simdmathlibrary/spu/simdmath/irintf4.h deleted file mode 100644 index 4c56db686..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/irintf4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* irintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model. - On SPU, the rounding mode for float is always towards zero. - vector singned int is returned. - 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 ___SIMD_MATH_IRINTF4_H___ -#define ___SIMD_MATH_IRINTF4_H___ - -#include -#include - -static inline vector signed int -_irintf4(vector float in) -{ - return spu_convts(in,0); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/iroundf4.h b/Extras/simdmathlibrary/spu/simdmath/iroundf4.h deleted file mode 100644 index c2cc36cf4..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/iroundf4.h +++ /dev/null @@ -1,61 +0,0 @@ -/* iroundf4 - for each of four float slots, round to the nearest integer, - halfway cases are rounded away form zero. - - 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 ___SIMD_MATH_IROUNDF4_H___ -#define ___SIMD_MATH_IROUNDF4_H___ - -#include -#include - -static inline vector signed int -_iroundf4(vector float in) -{ - vec_int4 exp, out; - vec_uint4 addend; - - /* Add 0.5 (fixed precision to eliminate rounding issues - */ - exp = spu_sub(125, spu_and(spu_rlmask((vec_int4)in, -23), 0xFF)); - - addend = spu_and(spu_rlmask( spu_splats((unsigned int)0x1000000), exp), - spu_cmpgt((vec_uint4)exp, -31)); - - in = (vec_float4)spu_add((vec_uint4)in, addend); - - - /* Truncate the result. - */ - out = spu_convts(in,0); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/is0denormd2.h b/Extras/simdmathlibrary/spu/simdmath/is0denormd2.h deleted file mode 100644 index fcc76ce08..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/is0denormd2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* is0denormd2 - for each of two double slots, if input equals 0 or denorm return mask of ones, else 0 - 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 ___SIMD_MATH_IS0DENORMD2_H___ -#define ___SIMD_MATH_IS0DENORMD2_H___ - -#include -#include - - -static inline vector unsigned long long -_is0denormd2 (vector double x) -{ - vec_double2 xexp; - vec_ullong2 cmp; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - - xexp = (vec_double2)spu_and( (vec_ullong2)x, spu_splats(0x7ff0000000000000ull) ); - cmp = (vec_ullong2)spu_cmpeq( (vec_uint4)xexp, (vec_uint4)spu_splats(0) ); - cmp = spu_shuffle( cmp, cmp, even ); - - return cmp; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/is0denormf4.h b/Extras/simdmathlibrary/spu/simdmath/is0denormf4.h deleted file mode 100644 index 97549d7ed..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/is0denormf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* is0denormf4 - for each element of vector x, return a mask of ones if x' is zero or denorm, zero otherwise - 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 ___SIMD_MATH_IS0DENORMF4_H___ -#define ___SIMD_MATH_IS0DENORMF4_H___ - -#include -#include - -static inline vector unsigned int -_is0denormf4 (vector float x) -{ - return spu_cmpeq( (vec_uint4)spu_and( (vec_uint4)x, spu_splats((unsigned int)0x7f800000) ), (vec_uint4)spu_splats(0x00000000) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isequald2.h b/Extras/simdmathlibrary/spu/simdmath/isequald2.h deleted file mode 100644 index edf48c43d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isequald2.h +++ /dev/null @@ -1,61 +0,0 @@ -/* isequald2 - for each of two double slots, if x = y return a mask of ones, else zero - 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 ___SIMD_MATH_ISEQUALD2_H___ -#define ___SIMD_MATH_ISEQUALD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_isequald2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpeq_i, cmpeq_i_even, cmpeq_i_odd; - vec_ullong2 bothzero; - - cmpeq_i = spu_cmpeq( (vec_int4)x, (vec_int4)y ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpeq_i_odd = spu_shuffle( cmpeq_i, cmpeq_i, odd ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - return spu_andc( spu_or( (vec_ullong2)spu_and( cmpeq_i_even, cmpeq_i_odd), bothzero), - spu_or( _isnand2( x ), _isnand2( y ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isequalf4.h b/Extras/simdmathlibrary/spu/simdmath/isequalf4.h deleted file mode 100644 index 8af4d7042..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isequalf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* isequalf4 - for each element of vector x and y, return a mask of ones if x' is equal to y', zero otherwise - 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 ___SIMD_MATH_ISEQUALF4_H___ -#define ___SIMD_MATH_ISEQUALF4_H___ - -#include -#include - -static inline vector unsigned int -_isequalf4 (vector float x, vector float y) -{ - return spu_cmpeq(x, y); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isfinited2.h b/Extras/simdmathlibrary/spu/simdmath/isfinited2.h deleted file mode 100644 index 4efc9c802..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isfinited2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* isfinited2 - for each element of vector x, return a mask of ones if x' is finite, zero otherwise - 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 ___SIMD_MATH_ISFINITED2_H___ -#define ___SIMD_MATH_ISFINITED2_H___ - -#include -#include - -static inline vector unsigned long long -_isfinited2 (vector double x) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 cmpr; - - //Finite unless NaN or Inf, check for 'not all-ones exponent' - - cmpr = (vec_ullong2)spu_cmpgt( (vec_uint4)expn, (vec_uint4)spu_and( (vec_ullong2)x, expn ) ); - cmpr = spu_shuffle( cmpr, cmpr, even); - - return cmpr; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isfinitef4.h b/Extras/simdmathlibrary/spu/simdmath/isfinitef4.h deleted file mode 100644 index 7846f2e51..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isfinitef4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* isfinitef4 - for each element of vector x, return a mask of ones if x' is finite, zero otherwise - 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 ___SIMD_MATH_ISFINITEF4_H___ -#define ___SIMD_MATH_ISFINITEF4_H___ - -#include -#include - -static inline vector unsigned int -_isfinitef4 (vector float x) -{ - (void)x; - - // NaN, INF not supported on SPU, result always a mask of ones - return spu_splats((unsigned int)0xffffffff); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isgreaterd2.h b/Extras/simdmathlibrary/spu/simdmath/isgreaterd2.h deleted file mode 100644 index d4fa0c7ca..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isgreaterd2.h +++ /dev/null @@ -1,71 +0,0 @@ -/* isgreaterd2 - for each of two double slots, if x > y return mask of ones, else 0 - 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 ___SIMD_MATH_ISGREATERD2_H___ -#define ___SIMD_MATH_ISGREATERD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_isgreaterd2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpgt_i, cmpgt_ui, cmpeq_i, cmpeq_i_even; - vec_ullong2 cmpgt_ll, cmplt_ll, cmpeq_ll; - vec_ullong2 bothneg, bothzero; - - cmpgt_i = spu_cmpgt( (vec_int4)x, (vec_int4)y ); - cmpeq_i = spu_cmpeq( (vec_int4)x, (vec_int4)y ); - cmpgt_ui = spu_cmpgt( (vec_uint4)x, (vec_uint4)y ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpgt_ll = (vec_ullong2)spu_or( spu_shuffle( cmpgt_i, cmpgt_i, even ), - spu_and( cmpeq_i_even, spu_shuffle( cmpgt_ui, cmpgt_ui, odd ) ) ); - cmpeq_ll = (vec_ullong2)spu_and( cmpeq_i_even, spu_shuffle( cmpeq_i, cmpeq_i, odd ) ); - cmplt_ll = spu_nor( cmpeq_ll, cmpgt_ll ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - bothneg = spu_and( (vec_ullong2)x, (vec_ullong2)y ); - bothneg = (vec_ullong2)spu_cmpgt( spu_splats(0), (vec_int4)bothneg ); - bothneg = spu_shuffle( bothneg, bothneg, even ); - - return spu_andc( spu_sel( cmpgt_ll, cmplt_ll, bothneg ), - spu_or( bothzero, spu_or( _isnand2 ( x ), _isnand2 ( y ) ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isgreaterequald2.h b/Extras/simdmathlibrary/spu/simdmath/isgreaterequald2.h deleted file mode 100644 index 5f1498841..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isgreaterequald2.h +++ /dev/null @@ -1,73 +0,0 @@ -/* isgreaterequald2 - for each of two double slots, if x is greater or equal to y return a mask of ones, else zero - 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 ___SIMD_MATH_ISGREATEREQUALD2_H___ -#define ___SIMD_MATH_ISGREATEREQUALD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_isgreaterequald2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpgt_i, cmpgt_ui, cmpeq_i, cmpeq_i_even; - vec_ullong2 cmpgt_ll, cmplt_ll, cmpeq_ll; - vec_ullong2 bothneg, bothzero; - - cmpgt_i = spu_cmpgt( (vec_int4)x, (vec_int4)y ); - cmpeq_i = spu_cmpeq( (vec_int4)x, (vec_int4)y ); - cmpgt_ui = spu_cmpgt( (vec_uint4)x, (vec_uint4)y ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpgt_ll = (vec_ullong2)spu_or( spu_shuffle( cmpgt_i, cmpgt_i, even ), - spu_and( cmpeq_i_even, spu_shuffle( cmpgt_ui, cmpgt_ui, odd ) ) ); - cmpeq_ll = (vec_ullong2)spu_and( cmpeq_i_even, spu_shuffle( cmpeq_i, cmpeq_i, odd ) ); - cmplt_ll = spu_nor( cmpeq_ll, cmpgt_ll ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - cmpeq_ll = spu_or( cmpeq_ll, bothzero); - - bothneg = spu_and( (vec_ullong2)x, (vec_ullong2)y ); - bothneg = (vec_ullong2)spu_cmpgt( spu_splats(0), (vec_int4)bothneg ); - bothneg = spu_shuffle( bothneg, bothneg, even ); - - return spu_andc( spu_or( spu_sel ( cmpgt_ll, cmplt_ll, bothneg ), cmpeq_ll ), - spu_or( _isnand2 ( x ), _isnand2 ( y ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isgreaterequalf4.h b/Extras/simdmathlibrary/spu/simdmath/isgreaterequalf4.h deleted file mode 100644 index c95233499..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isgreaterequalf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* isgreaterequalf4 - for each element of vector x and y, return a mask of ones if x' is greater than or equal to y', zero otherwise - 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 ___SIMD_MATH_ISGREATEREQUALF4_H___ -#define ___SIMD_MATH_ISGREATEREQUALF4_H___ - -#include -#include - -static inline vector unsigned int -_isgreaterequalf4 (vector float x, vector float y) -{ - vec_uint4 var; - - var = spu_cmpgt(y, x); - - return spu_nor(var, var); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isgreaterf4.h b/Extras/simdmathlibrary/spu/simdmath/isgreaterf4.h deleted file mode 100644 index 13c4c00c3..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isgreaterf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* isgreaterf4 - for each element of vector x and y, return a mask of ones if x' is greater than y', zero otherwise - 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 ___SIMD_MATH_ISGREATERF4_H___ -#define ___SIMD_MATH_ISGREATERF4_H___ - -#include -#include - -static inline vector unsigned int -_isgreaterf4 (vector float x, vector float y) -{ - return spu_cmpgt(x, y); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isinfd2.h b/Extras/simdmathlibrary/spu/simdmath/isinfd2.h deleted file mode 100644 index ba4d608a7..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isinfd2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* isinfd2 - for each of two double slots, if input equals +Inf or -Inf return mask of ones, else 0 - 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 ___SIMD_MATH_ISINFD2_H___ -#define ___SIMD_MATH_ISINFD2_H___ - -#include -#include - - -static inline vector unsigned long long -_isinfd2 (vector double x) -{ - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_double2 xabs; - vec_ullong2 cmp; - - xabs = (vec_double2)spu_andc( (vec_ullong2)x, spu_splats(0x8000000000000000ull) ); - cmp = (vec_ullong2)spu_cmpeq( (vec_uint4)xabs, (vec_uint4)spu_splats(0x7ff0000000000000ull) ); - cmp = spu_and( cmp, spu_shuffle( cmp, cmp, swapEvenOdd ) ); - - return cmp; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isinff4.h b/Extras/simdmathlibrary/spu/simdmath/isinff4.h deleted file mode 100644 index a3872d768..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isinff4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* isinff4 - for each element of vector x, return a mask of ones if x' is INF, zero otherwise - 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 ___SIMD_MATH_ISINFF4_H___ -#define ___SIMD_MATH_ISINFF4_H___ - -#include -#include - -static inline vector unsigned int -_isinff4 (vector float x) -{ - (void)x; - - // INF not supported on SPU, result always zero - return spu_splats((unsigned int)0x00000000); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessd2.h b/Extras/simdmathlibrary/spu/simdmath/islessd2.h deleted file mode 100644 index 9278e0e4e..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessd2.h +++ /dev/null @@ -1,71 +0,0 @@ -/* islessd2 - for each of two double slots, if x < y return a mask of ones, else zero - 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 ___SIMD_MATH_ISLESSD2_H___ -#define ___SIMD_MATH_ISLESSD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_islessd2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpgt_i, cmpgt_ui, cmpeq_i, cmpeq_i_even; - vec_ullong2 cmpgt_ll, cmplt_ll, cmpeq_ll; - vec_ullong2 bothneg, bothzero; - - cmpgt_i = spu_cmpgt( (vec_int4)y, (vec_int4)x ); - cmpeq_i = spu_cmpeq( (vec_int4)y, (vec_int4)x ); - cmpgt_ui = spu_cmpgt( (vec_uint4)y, (vec_uint4)x ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpgt_ll = (vec_ullong2)spu_or( spu_shuffle( cmpgt_i, cmpgt_i, even ), - spu_and( cmpeq_i_even, spu_shuffle( cmpgt_ui, cmpgt_ui, odd ) ) ); - cmpeq_ll = (vec_ullong2)spu_and( cmpeq_i_even, spu_shuffle( cmpeq_i, cmpeq_i, odd ) ); - cmplt_ll = spu_nor( cmpeq_ll, cmpgt_ll ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - bothneg = spu_and( (vec_ullong2)x, (vec_ullong2)y ); - bothneg = (vec_ullong2)spu_cmpgt( spu_splats(0), (vec_int4)bothneg ); - bothneg = spu_shuffle( bothneg, bothneg, even ); - - return spu_andc( spu_sel( cmpgt_ll, cmplt_ll, bothneg ), - spu_or( bothzero, spu_or( _isnand2 ( x ), _isnand2 ( y ) ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessequald2.h b/Extras/simdmathlibrary/spu/simdmath/islessequald2.h deleted file mode 100644 index 51148cb1f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessequald2.h +++ /dev/null @@ -1,73 +0,0 @@ -/* islessequald2 - for each of two double slots, if x <= y return mask of ones, else 0 - 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 ___SIMD_MATH_ISLESSEQUALD2_H___ -#define ___SIMD_MATH_ISLESSEQUALD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_islessequald2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpgt_i, cmpgt_ui, cmpeq_i, cmpeq_i_even; - vec_ullong2 cmpgt_ll, cmplt_ll, cmpeq_ll; - vec_ullong2 bothneg, bothzero; - - cmpgt_i = spu_cmpgt( (vec_int4)x, (vec_int4)y ); - cmpeq_i = spu_cmpeq( (vec_int4)x, (vec_int4)y ); - cmpgt_ui = spu_cmpgt( (vec_uint4)x, (vec_uint4)y ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpgt_ll = (vec_ullong2)spu_or( spu_shuffle( cmpgt_i, cmpgt_i, even ), - spu_and( cmpeq_i_even, spu_shuffle( cmpgt_ui, cmpgt_ui, odd ) ) ); - cmpeq_ll = (vec_ullong2)spu_and( cmpeq_i_even, spu_shuffle( cmpeq_i, cmpeq_i, odd ) ); - cmplt_ll = spu_nor( cmpeq_ll, cmpgt_ll ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - cmpeq_ll = spu_or( cmpeq_ll, bothzero); - - bothneg = spu_and( (vec_ullong2)x, (vec_ullong2)y ); - bothneg = (vec_ullong2)spu_cmpgt( spu_splats(0), (vec_int4)bothneg ); - bothneg = spu_shuffle( bothneg, bothneg, even ); - - return spu_andc( spu_or( spu_sel( cmplt_ll, cmpgt_ll, bothneg ), cmpeq_ll), - spu_or( _isnand2 ( x ), _isnand2 ( y ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessequalf4.h b/Extras/simdmathlibrary/spu/simdmath/islessequalf4.h deleted file mode 100644 index 5e6b5f50b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessequalf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* islessequalf4 - for each element of vector x and y, return a mask of ones if x' is less than or equal to y', zero otherwise - 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 ___SIMD_MATH_ISLESSEQUALF4_H___ -#define ___SIMD_MATH_ISLESSEQUALF4_H___ - -#include -#include - -static inline vector unsigned int -_islessequalf4 (vector float x, vector float y) -{ - vec_uint4 var; - - var = spu_cmpgt(x, y); - - return spu_nor(var, var); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessf4.h b/Extras/simdmathlibrary/spu/simdmath/islessf4.h deleted file mode 100644 index ca84fae93..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* islessf4 - for each element of vector x and y, return a mask of ones if x' is less than y', zero otherwise - 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 ___SIMD_MATH_ISLESSF4_H___ -#define ___SIMD_MATH_ISLESSF4_H___ - -#include -#include - -static inline vector unsigned int -_islessf4 (vector float x, vector float y) -{ - return spu_cmpgt(y, x); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessgreaterd2.h b/Extras/simdmathlibrary/spu/simdmath/islessgreaterd2.h deleted file mode 100644 index 7c23c8bdb..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessgreaterd2.h +++ /dev/null @@ -1,61 +0,0 @@ -/* islessgreaterd2 - for each of two double slots, if x is less or greater than y return a mask of ones, else zero - 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 ___SIMD_MATH_ISLESSGREATERD2_H___ -#define ___SIMD_MATH_ISLESSGREATERD2_H___ - -#include -#include - -#include - -static inline vector unsigned long long -_islessgreaterd2 (vector double x, vector double y) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_uint4 cmpeq_i, cmpeq_i_even, cmpeq_i_odd; - vec_ullong2 bothzero; - - cmpeq_i = spu_cmpeq( (vec_int4)x, (vec_int4)y ); - - cmpeq_i_even = spu_shuffle( cmpeq_i, cmpeq_i, even ); - cmpeq_i_odd = spu_shuffle( cmpeq_i, cmpeq_i, odd ); - - bothzero = spu_andc( spu_or( (vec_ullong2)x, (vec_ullong2)y ), sign ); - bothzero = (vec_ullong2)spu_cmpeq( (vec_uint4)bothzero, 0U ); - bothzero = spu_and( bothzero, spu_shuffle( bothzero, bothzero, swapEvenOdd ) ); - - return spu_andc( (vec_ullong2)spu_nand( cmpeq_i_even, cmpeq_i_odd), - spu_or( bothzero, spu_or( _isnand2 ( x ), _isnand2 ( y ) ) ) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/islessgreaterf4.h b/Extras/simdmathlibrary/spu/simdmath/islessgreaterf4.h deleted file mode 100644 index 0143b49df..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/islessgreaterf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* islessgreaterf4 - for each element of vector x and y, return a mask of ones if x' is less than or greater than y', zero otherwise - 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 ___SIMD_MATH_ISLESSGREATERF4_H___ -#define ___SIMD_MATH_ISLESSGREATERF4_H___ - -#include -#include - -static inline vector unsigned int -_islessgreaterf4 (vector float x, vector float y) -{ - vec_uint4 var; - - var = spu_cmpeq(x, y); - - return spu_nor(var, var); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isnand2.h b/Extras/simdmathlibrary/spu/simdmath/isnand2.h deleted file mode 100644 index eabb20c53..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isnand2.h +++ /dev/null @@ -1,56 +0,0 @@ -/* isnand2 - for each of two double slots, if input is any type of NaN return mask of ones, else 0 - 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 ___SIMD_MATH_ISNAND2_H___ -#define ___SIMD_MATH_ISNAND2_H___ - -#include -#include - -static inline vector unsigned long long -_isnand2 (vector double x) -{ - vec_double2 xneg; - vec_ullong2 cmpgt, cmpeq, cmpnan; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uint4 expmask = (vec_uint4)spu_splats(0xfff0000000000000ull); - - xneg = (vec_double2)spu_or( (vec_ullong2)x, spu_splats(0x8000000000000000ull) ); - cmpgt = (vec_ullong2)spu_cmpgt( (vec_uint4)xneg, expmask ); - cmpeq = (vec_ullong2)spu_cmpeq( (vec_uint4)xneg, expmask ); - - cmpnan = spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - - return cmpnan; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isnanf4.h b/Extras/simdmathlibrary/spu/simdmath/isnanf4.h deleted file mode 100644 index 6dabfd0a6..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isnanf4.h +++ /dev/null @@ -1,45 +0,0 @@ -/* isnanf4 - for each element of vector x, return a mask of ones if x' is NaN, zero otherwise - 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 ___SIMD_MATH_ISNANF4_H___ -#define ___SIMD_MATH_ISNANF4_H___ - -#include -#include - -static inline vector unsigned int -_isnanf4 (vector float x) -{ - (void)x; - - // NaN not supported on SPU, result always zero - return spu_splats((unsigned int)0x00000000); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isnormald2.h b/Extras/simdmathlibrary/spu/simdmath/isnormald2.h deleted file mode 100644 index 72d6c4d51..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isnormald2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* isnormald2 - for each element of vector x, return a mask of ones if x' is normal, not a NaN or INF, zero otherwise - 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 ___SIMD_MATH_ISNORMALD2_H___ -#define ___SIMD_MATH_ISNORMALD2_H___ - -#include -#include - -static inline vector unsigned long long -_isnormald2 (vector double x) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 cmpr; - - //Normal unless nan, infinite, denorm, or zero - - //Check for 'not zero or all-ones exponent' - cmpr = (vec_ullong2)spu_and( spu_cmpgt( (vec_uint4)spu_and( (vec_ullong2)x, expn ), (vec_uint4)spu_splats(0x0000000000000000ull) ), - spu_cmpgt( (vec_uint4)expn, (vec_uint4)spu_and( (vec_ullong2)x, expn ) ) ); - cmpr = spu_shuffle( cmpr, cmpr, even); - - return cmpr; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isnormalf4.h b/Extras/simdmathlibrary/spu/simdmath/isnormalf4.h deleted file mode 100644 index b0420d56d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isnormalf4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* isnormalf4 - for each element of vector x, return a mask of ones if x' is normal, not a NaN or INF, zero otherwise - 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 ___SIMD_MATH_ISNORMALF4_H___ -#define ___SIMD_MATH_ISNORMALF4_H___ - -#include -#include - -static inline vector unsigned int -_isnormalf4 (vector float x) -{ - // NaN, INF not supported on SPU; normal unless zero - return spu_cmpabsgt(x, (vector float)spu_splats(0x00000000)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isunorderedd2.h b/Extras/simdmathlibrary/spu/simdmath/isunorderedd2.h deleted file mode 100644 index f5bd7b471..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isunorderedd2.h +++ /dev/null @@ -1,67 +0,0 @@ -/* isunorderedd2 - for each element of vector x and y, return a mask of ones if x' is unordered to y', zero otherwise - 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 ___SIMD_MATH_ISUNORDEREDD2_H___ -#define ___SIMD_MATH_ISUNORDEREDD2_H___ - -#include -#include - -static inline vector unsigned long long -_isunorderedd2 (vector double x, vector double y) -{ - vec_double2 neg; - vec_ullong2 cmpgt, cmpeq, cmpnanx, cmpnany; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_ullong2 expn = (vec_ullong2)spu_splats(0xfff0000000000000ull); - vec_ullong2 sign = (vec_ullong2)spu_splats(0x8000000000000000ull); - - //Check if x is nan - neg = (vec_double2)spu_or( (vec_ullong2)x, sign ); - cmpgt = (vec_ullong2)spu_cmpgt( (vec_uint4)neg, (vec_uint4)expn ); - cmpeq = (vec_ullong2)spu_cmpeq( (vec_uint4)neg, (vec_uint4)expn ); - - cmpnanx = spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - - //Check if y is nan - neg = (vec_double2)spu_or( (vec_ullong2)y, sign ); - cmpgt = (vec_ullong2)spu_cmpgt( (vec_uint4)neg, (vec_uint4)expn ); - cmpeq = (vec_ullong2)spu_cmpeq( (vec_uint4)neg, (vec_uint4)expn ); - - cmpnany = spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - - return spu_or( cmpnanx, cmpnany ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/isunorderedf4.h b/Extras/simdmathlibrary/spu/simdmath/isunorderedf4.h deleted file mode 100644 index 917bf4ad9..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/isunorderedf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* isunorderedf4 - for each element of vector x and y, return a mask of ones if x' is unordered to y', zero otherwise - 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 ___SIMD_MATH_ISUNORDEREDF4_H___ -#define ___SIMD_MATH_ISUNORDEREDF4_H___ - -#include -#include - -static inline vector unsigned int -_isunorderedf4 (vector float x, vector float y) -{ - (void)x; - (void)y; - - // NaN not supported on SPU, result always zero - return spu_splats((unsigned int)0x00000000); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ldexpd2.h b/Extras/simdmathlibrary/spu/simdmath/ldexpd2.h deleted file mode 100644 index a5d9a0e9b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ldexpd2.h +++ /dev/null @@ -1,266 +0,0 @@ -/* ldexpd2 - Multiply Double by 2 Raised to its Power - For large elements of ex (overflow), returns HUGE_VALF - For small elements of ex (underflow), returns 0. - 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 ___SIMD_MATH_LDEXPD2_H___ -#define ___SIMD_MATH_LDEXPD2_H___ - -#include -#include - -static inline vector double -_ldexpd2(vector double x, vector signed long long ex) -{ - vec_int4 e1, e2; - vec_int4 min = spu_splats(-2099); - // vec_int4 min = spu_splats(-2044); - vec_int4 max = spu_splats( 2098); - // vec_int4 max = spu_splats( 2046); - vec_uint4 cmp_min, cmp_max; - vec_uint4 shift = ((vec_uint4){20, 32, 20, 32}); - vec_double2 f1, f2; - vec_double2 out; - vec_double2 in = x; - vec_int4 exp_in; - - // check input data range - vec_int4 exp0 = spu_shuffle( (vec_int4)ex, (vec_int4)ex, ((vec_uchar16){4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15})); - vec_int4 dmy = spu_shuffle( (vec_int4)spu_splats(0x10000), (vec_int4)ex, ((vec_uchar16){16,1,2,3, 16,1,2,3, 24,1,2,3,24,1,2,3})); - // (-)0xFFFFFFFF80000000 or (+)0x000000007FFFFFFF - vec_int4 msk_range = ((vec_int4){0,0x80000000, 0,0x80000000}); - vec_int4 inrange = spu_addx( (vec_int4)ex, msk_range, spu_rlqwbyte(spu_genc((vec_int4)ex, msk_range), 4)); - inrange = (vec_int4)spu_cmpeq( inrange, 0 ); - inrange = spu_shuffle(inrange,inrange,((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - // select dummy over ranged data or input data - vec_int4 exp = spu_sel( dmy, exp0, (vec_uint4)inrange); - exp_in = exp; - /* Clamp the specified exponent to the range -2044 to 2046. - */ - cmp_min = spu_cmpgt(exp, min); - cmp_max = spu_cmpgt(exp, max); - exp = spu_sel(min, exp, cmp_min); - exp = spu_sel(exp, max, cmp_max); - - /* Generate the factors f1 = 2^e1 and f2 = 2^e2 - */ - e1 = spu_rlmaska(exp, -1); - e2 = spu_sub(exp, e1); - - f1 = (vec_double2)spu_sl(spu_add(e1, 1023), shift); - - vec_double2 otmp = spu_mul(x, f1); - vec_uint4 fpscr1 = spu_mffpscr(); - - f2 = (vec_double2)spu_sl(spu_add(e2, 1023), shift); - - out = spu_mul(otmp, f2); - vec_uint4 fpscr2 = spu_mffpscr(); - - /* Compute the product x * 2^e1 * 2^e2 - */ - // out = spu_mul(spu_mul(x, f1), f2); - - // check floating point register DENORM bit - vec_uint4 fpscr0, fpscr; - fpscr0 = spu_or(fpscr1, fpscr2); - fpscr = spu_shuffle(fpscr0, fpscr0, ((vec_uchar16){0x80,0x80,0x80,0x80,0x80,0x80,10,0x80,0x80,0x80,6,0x80,0x80,0x80,0x80,0x80})); - fpscr = spu_or(fpscr0, fpscr); - if ( __builtin_expect(spu_extract(fpscr, 1) == 0, 1) ) return out; - - - ////////////////////// - // Denormalized calc// - ////////////////////// - - vec_uchar16 splat_msb = { 0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8}; - vec_uint4 signmask = ((vec_uint4){0x80000000,0,0x80000000,0}); - vec_int4 zeros = spu_splats(0); - vec_uchar16 msk_64_eq = ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}); - - //check input was zero - vec_uint4 x_body = spu_and( (vec_uint4)x, ((vec_uint4){0x7FFFFFFF,-1,0x7FFFFFFF,-1})); - vec_uint4 x_zero = spu_cmpeq( x_body, (vec_uint4)zeros ); - x_zero = spu_and( x_zero, spu_shuffle(x_zero,x_zero,msk_64_eq)); - - // check Denormalized input - vec_int4 cnt_zero = (vec_int4)spu_cntlz(x_body); - vec_uint4 is_den = (vec_uint4)spu_cmpgt(cnt_zero, 11); // Denormalized data 000XXXXX XXXXXXXX - is_den = spu_shuffle( is_den, is_den, splat_msb); - is_den = spu_sel(is_den, (vec_uint4)zeros, x_zero); // exclude zero from denormalized - - // count 0bits for 64bit - vec_uint4 cnt_ex = (vec_uint4)spu_cmpgt(cnt_zero, 31); // Denormalized data 00000000 XXXXXXXX - vec_int4 cnt_z = spu_shuffle( cnt_zero, cnt_zero, ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11})); - cnt_zero = spu_add(cnt_zero, spu_sel(zeros, cnt_z, cnt_ex)); - cnt_zero = spu_shuffle(cnt_zero, cnt_zero, ((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - // extract each 64bit data - x_body = spu_and( (vec_uint4)x, ((vec_uint4){0x000FFFFF,-1,0x000FFFFF,-1})); - vec_uint4 mant0 = spu_shuffle(x_body, x_body, ((vec_uchar16){0,1, 2, 3, 4, 5, 6, 7,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 mant1 = spu_shuffle(x_body, x_body, ((vec_uchar16){8,9,10,11,12,13,14,15,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 sign = (vec_uint4)spu_rlmaska((vec_int4)exp_in, -31); - sign = spu_shuffle(sign, sign, splat_msb); - - // set max shift count - vec_int4 sht = spu_add( cnt_zero, ((vec_int4){-11,-64,-11,-64})); - - // denorm & exp+ shift left - vec_uint4 cmp = spu_cmpgt( sht, exp_in); - vec_int4 sht_l = spu_sel(sht, exp_in, cmp); - int shtl0 = spu_extract(sht_l, 0); - int shtl1 = spu_extract(sht_l, 2); - vec_uint4 mant0l = spu_slqwbytebc( spu_slqw(mant0, shtl0), shtl0 ); - vec_uint4 mant1l = spu_slqwbytebc( spu_slqw(mant1, shtl1), shtl1 ); - vec_int4 expp = spu_shuffle(spu_sub(exp_in, sht_l), zeros, ((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - exp0 = spu_sel( expp, exp_in, sign ); // select plus or minus caluc - vec_uint4 mantl = spu_shuffle( mant0l, mant1l, ((vec_uchar16){0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23})); - vec_uint4 mant = spu_sel( mantl, (vec_uint4)x, sign); - exp = spu_sel( exp_in, exp0, is_den ); // select denormalized - x = (vec_double2)spu_sel( (vec_uint4)x, mant, is_den); - - - ////////////////////////////////////////////////////////////////////////// - // from ldexpf4 - vec_int4 expmask = ((vec_int4){0x7FF00000, 0, 0x7FF00000, 0}); - e1 = spu_and((vec_int4)x, expmask); - e2 = spu_rlmask(e1,-20); - - vec_uchar16 maxmask = (vec_uchar16)spu_cmpgt(exp, 2046); - vec_uchar16 minmask = (vec_uchar16)spu_cmpgt(spu_splats(-2044), exp); - minmask = spu_or (minmask, (vec_uchar16)x_zero); - - vec_int4 esum = spu_add(e2, exp); - - maxmask = spu_or (maxmask, (vec_uchar16)spu_cmpgt(esum, 2046)); - maxmask = spu_shuffle(maxmask, maxmask, splat_msb); - // maxmask = spu_and(maxmask, ((vec_uchar16)spu_splats((long long)0x7FFFFFFFFFFFFFFFLL))); - minmask = spu_or (minmask, (vec_uchar16)spu_cmpgt(zeros, esum)); - minmask = spu_shuffle(minmask, minmask, splat_msb); - - // check denorm - vec_uint4 mxmask = spu_and(spu_cmpgt(e2, 0), ((vec_uint4){0x00100000,0,0x00100000,0})); // not denorm - vec_int4 esum2 = spu_sub(esum, (vec_int4)spu_rlmask(mxmask, -20)); // reverse to norm - vec_uint4 mrange = spu_and(spu_cmpgt(zeros, esum2), spu_cmpgt(esum2, -55)); // denorm range - mrange = spu_shuffle(mrange, mrange, splat_msb); - - vec_int4 sht_r = spu_sel(spu_splats(-54), esum2, spu_cmpgt(esum2, spu_splats(-54)) ); - vec_int4 sht_rh = spu_add( sht_r, ((vec_int4){7,7,7,7})); - - x_body = spu_or( x_body, mxmask ); - mant0 = spu_shuffle(x_body, x_body, ((vec_uchar16){0,1, 2, 3, 4, 5, 6, 7,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - mant1 = spu_shuffle(x_body, x_body, ((vec_uchar16){8,9,10,11,12,13,14,15,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 mant0r = spu_rlmaskqwbytebc( spu_rlmaskqw(mant0, spu_extract(sht_r, 0)), spu_extract(sht_rh,0) ); - vec_uint4 mant1r = spu_rlmaskqwbytebc( spu_rlmaskqw(mant1, spu_extract(sht_r, 2)), spu_extract(sht_rh,2) ); - -#ifdef LDEXPD2_ROUND - // check current round mode - fpscr = spu_shuffle(fpscr2, fpscr2, ((vec_uchar16){0x80,0x80,0x80,0x80,0,1,2,3,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - fpscr0 = spu_and(fpscr, ((vec_uint4){0,0xc00,0,0})); - fpscr1 = spu_and(fpscr, ((vec_uint4){0,0x300,0,0})); - - // prepare round data - vec_uint4 rnd0 = spu_slqwbytebc( spu_slqw( mant0r, 31), 31); - vec_uint4 rnd1 = spu_slqwbytebc( spu_slqw( mant1r, 31), 31); - vec_uint4 rnd0w = (vec_uint4)spu_cntb( (vec_uchar16)rnd0 ); - vec_uint4 rnd1w = (vec_uint4)spu_cntb( (vec_uchar16)rnd1 ); - rnd0w = spu_or( spu_slqwbyte(rnd0w,4), spu_slqwbyte(rnd0w,8)); - rnd1w = spu_or( spu_slqwbyte(rnd1w,4), spu_slqwbyte(rnd1w,8)); - rnd0 = spu_or( rnd0, rnd0w); - rnd1 = spu_or( rnd1, rnd1w); - - // nearest - // check half - vec_uint4 hit0 = spu_cmpeq(rnd0, ((vec_uint4){0,0xc0000000,0,0})); //odd + round out - vec_uint4 hit1 = spu_cmpeq(rnd1, ((vec_uint4){0,0xc0000000,0,0})); //odd + round out - vec_uint4 add0 = spu_sel((vec_uint4)zeros, ((vec_uint4){0,1,0,0}), hit0); - vec_uint4 add1 = spu_sel((vec_uint4)zeros, ((vec_uint4){0,1,0,0}), hit1); - // check greater than half - rnd0 = spu_and( rnd0, ((vec_uint4){0,0x7FFFFFFF,0,0})); - rnd1 = spu_and( rnd1, ((vec_uint4){0,0x7FFFFFFF,0,0})); - hit0 = spu_cmpgt(rnd0, ((vec_uint4){0,0x40000000,0,0})); - hit1 = spu_cmpgt(rnd1, ((vec_uint4){0,0x40000000,0,0})); - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - // select if fp0 - add0 = spu_sel((vec_uint4)zeros, add0, spu_cmpeq(fpscr0, (vec_uint4)zeros)); - add1 = spu_sel((vec_uint4)zeros, add1, spu_cmpeq(fpscr1, (vec_uint4)zeros)); - - // toward zero do nothing - // upward - sign = spu_rlmaska((vec_uint4)in, -31); - vec_uint4 sign0 = spu_shuffle(sign, sign, ((vec_uchar16){0x80,0x80,0x80,0x80,0,0,0,0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 sign1 = spu_shuffle(sign, sign, ((vec_uchar16){0x80,0x80,0x80,0x80,8,8,8,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 hit0w = spu_cmpgt(rnd0, ((vec_uint4){0,0,0,0})); - vec_uint4 hit1w = spu_cmpgt(rnd1, ((vec_uint4){0,0,0,0})); - - hit0 = spu_andc(hit0w, sign0); - hit1 = spu_andc(hit1w, sign1); - hit0 = spu_and(hit0, spu_cmpeq(fpscr0, ((vec_uint4){0,0x800,0,0}))); - hit1 = spu_and(hit1, spu_cmpeq(fpscr1, ((vec_uint4){0,0x200,0,0}))); - // select if fp2 - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - - // downward - hit0 = spu_and(hit0w, sign0); - hit1 = spu_and(hit1w, sign1); - hit0 = spu_and(hit0, spu_cmpeq(fpscr0, ((vec_uint4){0,0xc00,0,0}))); - hit1 = spu_and(hit1, spu_cmpeq(fpscr1, ((vec_uint4){0,0x300,0,0}))); - // select if fp3 - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - - // calc round - mant0r = spu_addx(mant0r, add0, spu_rlqwbyte(spu_genc(mant0r, add0), 4)); - mant1r = spu_addx(mant1r, add1, spu_rlqwbyte(spu_genc(mant1r, add1), 4)); - -#endif // LDEXPD2_ROUND - - vec_uint4 mantr = spu_shuffle( mant0r, mant1r, ((vec_uchar16){0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23})); - - // select right answer - x = spu_sel(x, (vec_double2)spu_sl(esum,20), (vec_ullong2)expmask); - x = spu_sel(x, (vec_double2)zeros, (vec_ullong2)minmask); - x = spu_sel(x, (vec_double2)spu_splats((long long)0x7FEFFFFFFFFFFFFFLL), (vec_ullong2)maxmask); - - out = (vec_double2)spu_sel((vec_uint4)x , mantr, mrange); - - // check Infinity,NaN - vec_uint4 is_inf = spu_cmpeq(e1, expmask); - is_inf = spu_and( is_inf, spu_shuffle(is_inf,is_inf,msk_64_eq)); - out = (vec_double2)spu_sel((vec_uint4)out , (vec_uint4)in, is_inf); - - out = spu_sel(out, in, (vec_ullong2)signmask); - return out; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/ldexpf4.h b/Extras/simdmathlibrary/spu/simdmath/ldexpf4.h deleted file mode 100644 index d6984575b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/ldexpf4.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ldexpf4 - 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 ___SIMD_MATH_LDEXPF4_H___ -#define ___SIMD_MATH_LDEXPF4_H___ - -#include -#include - -static inline vector float -_ldexpf4 (vector float x, vector signed int exp) -{ - vec_int4 zeros = spu_splats(0); - - vec_uint4 expmask = spu_splats(0x7F800000U); - vec_int4 e1 = spu_and((vec_int4)x, (vec_int4)expmask); - vec_int4 e2 = spu_rlmask(e1,-23); - - vec_uint4 maxmask = spu_cmpgt(exp, 255); - vec_uint4 minmask = spu_cmpgt(spu_splats(-255), exp); - minmask = spu_or (minmask, spu_cmpeq(x, (vec_float4)zeros)); - - vec_int4 esum = spu_add(e2, exp); - - maxmask = spu_or (maxmask, spu_cmpgt(esum, 255)); - maxmask = spu_and(maxmask, spu_splats(0x7FFFFFFFU)); - minmask = spu_or (minmask, spu_cmpgt(zeros, esum)); - - x = spu_sel(x, (vec_float4)spu_sl(esum,23), expmask); - x = spu_sel(x, (vec_float4)zeros, minmask); - //x = spu_sel(x, (vec_float4)spu_splats((int)0xFFFFFFFF), maxmask); - x = spu_sel(x, (vec_float4)maxmask, maxmask); - return x; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/llabsi2.h b/Extras/simdmathlibrary/spu/simdmath/llabsi2.h deleted file mode 100644 index 304198887..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/llabsi2.h +++ /dev/null @@ -1,50 +0,0 @@ -/* llabsi2 - returns absolute value of input. - 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 ___SIMD_MATH_LLABSI2_H___ -#define ___SIMD_MATH_LLABSI2_H___ - -#include -#include - -static inline vector signed long long -_llabsi2 (vector signed long long in) -{ - vec_uint4 sign = (vec_uint4)spu_rlmaska((vec_int4)in, -31); - sign = spu_shuffle(sign, sign, ((vec_uchar16){ 0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8})); - - vec_uint4 add_1 = ((vec_uint4){0,1,0,1}); - vec_uint4 res = spu_nor((vec_uint4)in, (vec_uint4)in); - res = spu_addx( res, add_1, spu_slqwbyte(spu_genc(res, add_1), 4)); - res = spu_sel( (vec_uint4)in, res, sign); - - return ((vec_llong2)(res)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/lldivi2.h b/Extras/simdmathlibrary/spu/simdmath/lldivi2.h deleted file mode 100644 index c0a8ca2ae..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/lldivi2.h +++ /dev/null @@ -1,85 +0,0 @@ -/* lldivi2 - - 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 ___SIMD_MATH_LLDIVI2_H___ -#define ___SIMD_MATH_LLDIVI2_H___ - -#include -#include - -#include -#include - -static inline vector signed long long -__lldivi2_negatell2 (vector signed long long x) -{ - vector signed int zero = (vector signed int){0,0,0,0}; - vector signed int borrow; - - borrow = spu_genb(zero, (vec_int4)x); - borrow = spu_shuffle(borrow, borrow, ((vec_uchar16){4,5,6,7, 0xc0,0xc0,0xc0,0xc0, 12,13,14,15, 0xc0,0xc0,0xc0,0xc0})); - return (vec_llong2)spu_subx(zero, (vec_int4)x, borrow); -} - -// lldivi2 - for each of two signed long long interger slots, compute quotient and remainder of -// numer/denom and store in lldivi2_t struct. Divide by zero produces quotient = 0, remainder = numerator. - -static inline lldivi2_t -_lldivi2 (vector signed long long numer, vector signed long long denom) -{ - lldivi2_t res; - lldivu2_t resAbs; - vec_ullong2 numerAbs, denomAbs; - vec_uint4 numerPos, denomPos, quotNeg; - - // Determine whether result needs sign change - - numerPos = spu_cmpgt((vec_int4)numer, -1); - numerPos = spu_shuffle(numerPos, numerPos, ((vec_uchar16){0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8})); - denomPos = spu_cmpgt((vec_int4)denom, -1); - denomPos = spu_shuffle(denomPos, denomPos, ((vec_uchar16){0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8})); - quotNeg = spu_xor( numerPos, denomPos ); - - // Use absolute values of numerator, denominator - - numerAbs = (vec_ullong2)spu_sel(__lldivi2_negatell2(numer), numer, (vec_ullong2)numerPos); - denomAbs = (vec_ullong2)spu_sel(__lldivi2_negatell2(denom), denom, (vec_ullong2)denomPos); - - // Get difference of leading zeros. - - resAbs = _lldivu2(numerAbs, denomAbs); - res.quot = spu_sel((vec_llong2)resAbs.quot, __lldivi2_negatell2((vec_llong2)resAbs.quot), - (vec_ullong2)quotNeg); - res.rem = spu_sel(__lldivi2_negatell2((vec_llong2)resAbs.rem), (vec_llong2)resAbs.rem, - (vec_ullong2)numerPos); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/lldivu2.h b/Extras/simdmathlibrary/spu/simdmath/lldivu2.h deleted file mode 100644 index f58c30510..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/lldivu2.h +++ /dev/null @@ -1,104 +0,0 @@ -/* lldivu2 - - 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 ___SIMD_MATH_LLDIVU2_H___ -#define ___SIMD_MATH_LLDIVU2_H___ - -#include -#include - -#include - -// lldivu2 - for each of two unsigned long long interger slots, compute quotient and remainder of -// numer/denom and store in lldivu2_t struct. Divide by zero produces quotient = 0, remainder = numerator. - -static inline lldivu2_t -_lldivu2 (vector unsigned long long numer, vector unsigned long long denom) -{ - lldivu2_t res; - vec_uint4 denomZeros, numerZeros; - vec_int4 shift; - vec_ullong2 denomShifted, oneShifted, denomLeft, oneLeft; - vec_ullong2 quot, newQuot; - vec_ullong2 newNum, skip, cont; - int anyCont; - - // Get difference of leading zeros. - - denomZeros = (vec_uint4)__ll_spu_cntlz( denom ); - numerZeros = (vec_uint4)__ll_spu_cntlz( numer ); - - shift = (vec_int4)spu_sub( denomZeros, numerZeros ); - - // Shift denom to align leading one with numerator's - - denomShifted = __ll_spu_sl( denom, (vec_ullong2)shift ); - oneShifted = __ll_spu_sl( spu_splats(1ull), (vec_ullong2)shift ); - oneShifted = spu_sel( oneShifted, spu_splats(0ull), __ll_spu_cmpeq_zero( denom ) ); - - // Shift left all leading zeros. - - denomLeft = __ll_spu_sl( denom, (vec_ullong2)denomZeros ); - oneLeft = __ll_spu_sl( spu_splats(1ull), (vec_ullong2)denomZeros ); - - quot = spu_splats(0ull); - - do - { - cont = __ll_spu_cmpgt( oneShifted, spu_splats(0ull) ); - anyCont = spu_extract( spu_gather((vec_uint4)cont ), 0 ); - - newQuot = spu_or( quot, oneShifted ); - - // Subtract shifted denominator from remaining numerator - // when denominator is not greater. - - skip = __ll_spu_cmpgt( denomShifted, numer ); - newNum = __ll_spu_sub( numer, denomShifted ); - - // If denominator is greater, next shift is one more, otherwise - // next shift is number of leading zeros of remaining numerator. - - numerZeros = (vec_uint4)spu_sel( __ll_spu_cntlz( newNum ), (vec_ullong2)numerZeros, skip ); - shift = (vec_int4)spu_sub( (vec_uint4)skip, numerZeros ); - - oneShifted = __ll_spu_rlmask( oneLeft, (vec_ullong2)shift ); - denomShifted = __ll_spu_rlmask( denomLeft, (vec_ullong2)shift ); - - quot = spu_sel( newQuot, quot, skip ); - numer = spu_sel( newNum, numer, spu_orc(skip,cont) ); - } - while ( anyCont ); - - res.quot = quot; - res.rem = numer; - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/llrintd2.h b/Extras/simdmathlibrary/spu/simdmath/llrintd2.h deleted file mode 100644 index 02ebacdc2..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/llrintd2.h +++ /dev/null @@ -1,115 +0,0 @@ -/* llrintd2 - rounds two doubles in to two nearest 64bit integer. - consistent with the current rounding mode. - 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 ___SIMD_MATH_LLRINTD2_H___ -#define ___SIMD_MATH_LLRINTD2_H___ - -#include -#include - -// -// Handles no exception -// over flow will return unspecified data - -static inline vector signed long long -_llrintd2 (vector double in) -{ - int shift0, shift1; - vec_uchar16 splat_msb = ((vec_uchar16){0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8}); - vec_int4 exp; - vec_uint4 mant, mant0, mant1, sign, mask, borrow; - vec_uint4 implied_one = ((vec_uint4){ 0, 0, 0x00100000, 0}); - vec_uint4 exp_mask = ((vec_uint4){-1,-1, 0xFFF00000, 0}); - vec_double2 bias; - - vec_uint4 vec_zero = ((vec_uint4){0,0,0,0}); - // check denormalized - vec_uint4 exp_in = spu_and( (vec_uint4)in, 0x7FF00000 ); - vec_uint4 is_denorm = spu_cmpeq( exp_in, 0 ); - vec_uint4 ofs = spu_and( ((vec_uint4){0x00100000,0,0x00100000,0}), is_denorm); - - // check zero - vec_uint4 abs_x = spu_and((vec_uint4)in, ((vec_uint4){0x7FFFFFFF,-1,0x7FFFFFFF,-1})); - vec_uint4 is_zerox = spu_cmpeq( abs_x, vec_zero); - is_zerox = spu_and( is_zerox, spu_shuffle(is_zerox,is_zerox, ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}))); - ofs = spu_sel( ofs, vec_zero, is_zerox); - - vec_double2 xx = (vec_double2)spu_or( (vec_uint4)in, ofs ); - - /* Round the input according to the current rounding mode. - */ - vec_uint4 is_large = spu_cmpgt( exp_in, 0x43200000 ); - is_large = spu_shuffle(is_large,is_large,((vec_uchar16){0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8})); - bias = spu_sel((vec_double2)((vec_ullong2){0x4330000000000000ULL,0x4330000000000000ULL}), ((vec_double2){0.0,0.0}), (vec_ullong2)is_large); - bias = spu_sel(bias, xx, (vec_ullong2)spu_splats(0x8000000000000000ULL)); - - // bias = spu_sel((vec_double2)((vec_ullong2)spu_splats(0x4330000000000000ULL)), xx, - // (vec_ullong2)spu_splats(0x8000000000000000ULL)); - mant = (vec_uint4)(spu_sub(spu_add(xx, bias), bias)); - - /* Determine how many bits to shift the mantissa to correctly - * align it into long long element 0. - */ - exp = spu_and(spu_rlmask((vec_int4)mant, -20), 0x7FF); - exp = spu_add(exp, -1011); - shift0 = spu_extract(exp, 0); - shift1 = spu_extract(exp, 2); - - mask = spu_cmpgt(exp, 0); - mask = spu_shuffle(mask, mask, splat_msb); - - /* Algn mantissa bits - */ - mant0 = spu_sel(spu_rlmaskqwbyte(mant, -8), implied_one, exp_mask); - mant1 = spu_sel(mant, implied_one, exp_mask); - - mant0 = spu_slqwbytebc(spu_slqw(mant0, shift0), shift0); - mant1 = spu_slqwbytebc(spu_slqw(mant1, shift1), shift1); - - mant = spu_shuffle(mant0, mant1, ((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - mant = spu_and(mant, mask); - - /* Compute the two's complement of the mantissa if the - * input is negative. - */ - sign = (vec_uint4)spu_rlmaska((vec_int4)xx, -31); - sign = spu_shuffle(sign, sign, splat_msb); - - mant = spu_xor(mant, sign); - borrow = spu_genb(mant, sign); - borrow = spu_shuffle(borrow, borrow, ((vec_uchar16){ - 4,5,6,7, 192,192,192,192, - 12,13,14,15, 192,192,192,192})); - mant = spu_subx(mant, sign, borrow); - - return ((vec_llong2)(mant)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/llrintf4.h b/Extras/simdmathlibrary/spu/simdmath/llrintf4.h deleted file mode 100644 index d00279b7a..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/llrintf4.h +++ /dev/null @@ -1,107 +0,0 @@ -/* llrintf4 - rounds four floats in to four nearest 64bit integer. - On SPU the rounding mode for floats is always towards 0. - 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 ___SIMD_MATH_LLRINTF4_H___ -#define ___SIMD_MATH_LLRINTF4_H___ - -#include -#include - -// -// Handles no exception -// over flow will return unspecified data - -static inline llroundf4_t -_llrintf4 (vector float in) -{ - llroundf4_t res; - vec_int4 exp; - vec_uint4 mant0, mant1, mant2, mant3; - vec_uint4 mask, mask0, mask1; - vec_uint4 sign, sign0, sign1; - vec_uint4 borrow0, borrow1; - vec_uint4 res0, res1; - int shift0, shift1, shift2, shift3; - - /* Place mantissa bits (including implied most signficant - * bit) into the most significant bits of element 3. Elements - * 0, 1, and 2 are zeroed. - */ - mant0 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in,-11), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant1 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in, -7), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant2 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in, -3), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant3 = spu_sel( spu_rlqwbyte((vec_uint4)in, 1), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - - /* Determine how many bits to shift the mantissa to correctly - * align it into long long element 0. - */ - exp = spu_and(spu_rlmask((vec_int4)in, -23), 0xFF); - exp = spu_add(exp, -94); - shift0 = spu_extract(exp, 0); - shift1 = spu_extract(exp, 1); - shift2 = spu_extract(exp, 2); - shift3 = spu_extract(exp, 3); - - /* Algn mantissa bits - */ - mant0 = spu_slqwbytebc(spu_slqw(mant0, shift0), shift0); - mant1 = spu_slqwbytebc(spu_slqw(mant1, shift1), shift1); - mant2 = spu_slqwbytebc(spu_slqw(mant2, shift2), shift2); - mant3 = spu_slqwbytebc(spu_slqw(mant3, shift3), shift3); - - mask = spu_cmpgt(exp, 0); - mask0 = spu_shuffle(mask, mask, ((vec_uchar16){0,0,0,0,0,0,0,0, 4, 4, 4, 4, 4, 4, 4, 4})); - mask1 = spu_shuffle(mask, mask, ((vec_uchar16){8,8,8,8,8,8,8,8, 12,12,12,12,12,12,12,12})); - - res0 = spu_shuffle(mant0, mant1,((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - res1 = spu_shuffle(mant2, mant3,((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - res0 = spu_and(res0, mask0); - res1 = spu_and(res1, mask1); - - /* Compute the two's complement of the mantissa if the - * input is negative. - */ - sign = (vec_uint4)spu_rlmaska((vec_int4)in, -31); - sign0 = spu_shuffle(sign, sign, ((vec_uchar16){0,0,0,0,0,0,0,0, 4, 4, 4, 4, 4, 4, 4, 4})); - sign1 = spu_shuffle(sign, sign, ((vec_uchar16){8,8,8,8,8,8,8,8, 12,12,12,12,12,12,12,12})); - - res0 = spu_xor(res0, sign0); - res1 = spu_xor(res1, sign1); - borrow0 = spu_genb(res0, sign0); - borrow1 = spu_genb(res1, sign1); - borrow0 = spu_shuffle(borrow0, borrow0, ((vec_uchar16){4,5,6,7,0xc0,0xc0,0xc0,0xc0, 12,13,14,15,0xc0,0xc0,0xc0,0xc0})); - borrow1 = spu_shuffle(borrow1, borrow1, ((vec_uchar16){4,5,6,7,0xc0,0xc0,0xc0,0xc0, 12,13,14,15,0xc0,0xc0,0xc0,0xc0})); - res.vll[0] = (vec_llong2)spu_subx(res0, sign0, borrow0); - res.vll[1] = (vec_llong2)spu_subx(res1, sign1, borrow1); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/llroundd2.h b/Extras/simdmathlibrary/spu/simdmath/llroundd2.h deleted file mode 100644 index 0efd4724b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/llroundd2.h +++ /dev/null @@ -1,97 +0,0 @@ -/* llroundd2 - rounds two doubles in to two nearest 64bit integer. - 0.5 will be rounded to far from 0 - 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 ___SIMD_MATH_LLROUNDD2_H___ -#define ___SIMD_MATH_LLROUNDD2_H___ - -#include -#include - -// -// Handles no exception -// over flow will return unspecified data - -static inline vector signed long long -_llroundd2 (vector double in) -{ - int shift0, shift1; - vec_uchar16 splat_msb = { 0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8}; - vec_int4 exp; - vec_uint4 mant, mant0, mant1, sign, mask, borrow, addend; - vec_uint4 implied_one = { 0, 0, 0x00100000, 0}; - vec_uint4 exp_mask = { -1, -1,0xFFF00000, 0}; - - /* Determine how many bits to shift the mantissa to correctly - * align it into long long element 0. - */ - exp = spu_and(spu_rlmask((vec_int4)in, -20), 0x7FF); - exp = spu_add(exp, -1011); - shift0 = spu_extract(exp, 0); - shift1 = spu_extract(exp, 2); - - mask = spu_cmpgt(exp, 0); - mask = spu_shuffle(mask, mask, splat_msb); - - /* Algn mantissa bits - */ - mant0 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in, -8), implied_one, exp_mask); - mant1 = spu_sel((vec_uint4)in, implied_one, exp_mask); - - mant0 = spu_slqwbytebc(spu_slqw(mant0, shift0), shift0); - mant1 = spu_slqwbytebc(spu_slqw(mant1, shift1), shift1); - - mant = spu_shuffle(mant0, mant1, ((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - mant = spu_and(mant, mask); - - /* Perform round by adding 1 if the fraction bits are - * greater than or equal to .5 - */ - addend = spu_shuffle(mant0, mant1, ((vec_uchar16){0x80,0x80,0x80,0x80,0x80,0x80,0x80,8, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,24})); - addend = spu_rlmask(addend, -7); - // addend = spu_and(spu_rlqw(mant, 1), ((vec_uint4){ 0,1,0,1})); - mant = spu_addx(mant, addend, spu_rlqwbyte(spu_genc(mant, addend), 4)); - - /* Compute the two's complement of the mantissa if the - * input is negative. - */ - sign = (vec_uint4)spu_rlmaska((vec_int4)in, -31); - sign = spu_shuffle(sign, sign, splat_msb); - - mant = spu_xor(mant, sign); - borrow = spu_genb(mant, sign); - borrow = spu_shuffle(borrow, borrow, ((vec_uchar16){ - 4,5,6,7, 192,192,192,192, - 12,13,14,15, 192,192,192,192})); - mant = spu_subx(mant, sign, borrow); - - return ((vec_llong2)(mant)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/llroundf4.h b/Extras/simdmathlibrary/spu/simdmath/llroundf4.h deleted file mode 100644 index 77345d869..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/llroundf4.h +++ /dev/null @@ -1,120 +0,0 @@ -/* llroundf4 - rounds four floats in to four nearest 64bit integer. - 0.5 will be rounded to far from 0 - 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 ___SIMD_MATH_LLROUNDF4_H___ -#define ___SIMD_MATH_LLROUNDF4_H___ - -#include -#include - -// -// Handles no exception -// over flow will return unspecified data - -static inline llroundf4_t -_llroundf4 (vector float in) -{ - llroundf4_t res; - vec_int4 exp; - vec_uint4 mant0, mant1, mant2, mant3; - vec_uint4 mask, mask0, mask1; - vec_uint4 sign, sign0, sign1; - vec_uint4 addend0, addend1; - vec_uint4 borrow0, borrow1; - vec_uint4 res0, res1; - int shift0, shift1, shift2, shift3; - - /* Place mantissa bits (including implied most signficant - * bit) into the most significant bits of element 3. Elements - * 0, 1, and 2 are zeroed. - */ - mant0 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in,-11), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant1 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in, -7), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant2 = spu_sel(spu_rlmaskqwbyte((vec_uint4)in, -3), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - mant3 = spu_sel( spu_rlqwbyte((vec_uint4)in, 1), ((vec_uint4){0, 0, 0, 0x80000000}), ((vec_uint4){-1, -1, -1, 0x800000FF})); - - /* Determine how many bits to shift the mantissa to correctly - * align it into long long element 0. - */ - exp = spu_and(spu_rlmask((vec_int4)in, -23), 0xFF); - exp = spu_add(exp, -94); - shift0 = spu_extract(exp, 0); - shift1 = spu_extract(exp, 1); - shift2 = spu_extract(exp, 2); - shift3 = spu_extract(exp, 3); - - /* Algn mantissa bits - */ - mant0 = spu_slqwbytebc(spu_slqw(mant0, shift0), shift0); - mant1 = spu_slqwbytebc(spu_slqw(mant1, shift1), shift1); - mant2 = spu_slqwbytebc(spu_slqw(mant2, shift2), shift2); - mant3 = spu_slqwbytebc(spu_slqw(mant3, shift3), shift3); - - mask = spu_cmpgt(exp, 0); - mask0 = spu_shuffle(mask, mask, ((vec_uchar16){0,0,0,0,0,0,0,0, 4, 4, 4, 4, 4, 4, 4, 4})); - mask1 = spu_shuffle(mask, mask, ((vec_uchar16){8,8,8,8,8,8,8,8, 12,12,12,12,12,12,12,12})); - - res0 = spu_shuffle(mant0, mant1,((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - res1 = spu_shuffle(mant2, mant3,((vec_uchar16){0,1,2,3,4,5,6,7, 16,17,18,19,20,21,22,23})); - res0 = spu_and(res0, mask0); - res1 = spu_and(res1, mask1); - - /* Perform round by adding 1 if the fraction bits are - * greater than or equal to .5 - */ - addend0 = spu_shuffle(mant0, mant1, ((vec_uchar16){0x80,0x80,0x80,0x80,0x80,0x80,0x80,8, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,24})); - addend1 = spu_shuffle(mant2, mant3, ((vec_uchar16){0x80,0x80,0x80,0x80,0x80,0x80,0x80,8, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,24})); - addend0 = spu_rlmask(addend0, -7); - addend1 = spu_rlmask(addend1, -7); - // addend0 = spu_and(spu_rlqw(res0, 1), ((vec_uint4){ 0,1,0,1})); - // addend1 = spu_and(spu_rlqw(res1, 1), ((vec_uint4){ 0,1,0,1})); - res0 = spu_addx(res0, addend0, spu_rlqwbyte(spu_genc(res0, addend0), 4)); - res1 = spu_addx(res1, addend1, spu_rlqwbyte(spu_genc(res1, addend1), 4)); - - /* Compute the two's complement of the mantissa if the - * input is negative. - */ - sign = (vec_uint4)spu_rlmaska((vec_int4)in, -31); - sign0 = spu_shuffle(sign, sign, ((vec_uchar16){0,0,0,0,0,0,0,0, 4, 4, 4, 4, 4, 4, 4, 4})); - sign1 = spu_shuffle(sign, sign, ((vec_uchar16){8,8,8,8,8,8,8,8, 12,12,12,12,12,12,12,12})); - - res0 = spu_xor(res0, sign0); - res1 = spu_xor(res1, sign1); - borrow0 = spu_genb(res0, sign0); - borrow1 = spu_genb(res1, sign1); - borrow0 = spu_shuffle(borrow0, borrow0, ((vec_uchar16){4,5,6,7,0xc0,0xc0,0xc0,0xc0, 12,13,14,15,0xc0,0xc0,0xc0,0xc0})); - borrow1 = spu_shuffle(borrow1, borrow1, ((vec_uchar16){4,5,6,7,0xc0,0xc0,0xc0,0xc0, 12,13,14,15,0xc0,0xc0,0xc0,0xc0})); - res.vll[0] = (vec_llong2)spu_subx(res0, sign0, borrow0); - res.vll[1] = (vec_llong2)spu_subx(res1, sign1, borrow1); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/log10f4.h b/Extras/simdmathlibrary/spu/simdmath/log10f4.h deleted file mode 100644 index 9f28103f4..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/log10f4.h +++ /dev/null @@ -1,83 +0,0 @@ -/* log10f4 - - 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 ___SIMD_MATH_LOG10F4_H___ -#define ___SIMD_MATH_LOG10F4_H___ - -#include -#include - -#include - -#define __LOG10F_loga2msb 0.3010299205780f -#define __LOG10F_loga2lsb 7.5085978266e-8f -#define __LOG10F_logaemsb 0.4342944622040f -#define __LOG10F_logaelsb 1.9699272335e-8f -#define __LOG10F_logae 0.4342944819033f - -#define __LOG10F_c0 0.2988439998f -#define __LOG10F_c1 0.3997655209f -#define __LOG10F_c2 0.6666679125f - -static inline vector float -_log10f4 (vector float x) -{ - vec_int4 zeros = spu_splats((int)0); - vec_float4 ones = spu_splats(1.0f); - vec_uint4 zeromask = spu_cmpeq(x, (vec_float4)zeros); - - vec_uint4 expmask = spu_splats(0x7F800000U); - vec_int4 xexp = spu_add( spu_rlmask(spu_and((vec_int4)x, (vec_int4)expmask), -23), -126 ); - x = spu_sel(x, (vec_float4)spu_splats((int)0x3F000000), expmask); - - vec_uint4 mask = spu_cmpgt(spu_splats(0.7071067811865f), x); - x = spu_sel(x , spu_add(x, x) , mask); - xexp = spu_sel(xexp, spu_sub(xexp,spu_splats((int)1)), mask); - - vec_float4 x1 = spu_sub(x , ones); - vec_float4 z = _divf4 (x1, spu_add(x, ones)); - vec_float4 w = spu_mul(z , z); - vec_float4 polyw; - polyw = spu_madd(spu_splats(__LOG10F_c0), w, spu_splats(__LOG10F_c1)); - polyw = spu_madd(polyw , w, spu_splats(__LOG10F_c2)); - - vec_float4 yneg = spu_mul(z, spu_msub(polyw, w, x1)); - vec_float4 wnew = spu_convtf(xexp,0); - - vec_float4 zz1 = spu_madd(spu_splats(__LOG10F_logaemsb), x1, - spu_mul(spu_splats(__LOG10F_loga2msb),wnew)); - vec_float4 zz2 = spu_madd(spu_splats(__LOG10F_logaelsb), x1, - spu_madd(spu_splats(__LOG10F_loga2lsb), wnew, - spu_mul(spu_splats(__LOG10F_logae), yneg)) - ); - - return spu_sel(spu_add(zz1,zz2), (vec_float4)zeromask, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/log1pf4.h b/Extras/simdmathlibrary/spu/simdmath/log1pf4.h deleted file mode 100644 index 6715aa4df..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/log1pf4.h +++ /dev/null @@ -1,60 +0,0 @@ -/* log1pf4 - - 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 ___SIMD_MATH_LOG1PF4_H___ -#define ___SIMD_MATH_LOG1PF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_log1pf4 (vector float x) -{ - vec_uint4 nearzeromask = spu_and(spu_cmpgt(x, spu_splats(-0.5f)), - spu_cmpgt(spu_splats(0.5f), x)); - vec_float4 x2 = spu_mul(x,x); - vec_float4 d0, d1, n0, n1; - - d0 = spu_madd(x , spu_splats(1.5934420741f), spu_splats(0.8952856868f)); - d1 = spu_madd(x , spu_splats(0.1198195734f), spu_splats(0.8377145063f)); - d1 = spu_madd(x2, d1, d0); - - n0 = spu_madd(x , spu_splats(1.1457993413f), spu_splats(0.8952856678f)); - n1 = spu_madd(x , spu_splats(0.0082862580f), spu_splats(0.3394238808f)); - n1 = spu_madd(x2, n1, n0); - - return spu_sel(_logf4(spu_add(x, spu_splats(1.0f))), - spu_mul(x, _divf4(n1, d1)), - nearzeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/log2f4.h b/Extras/simdmathlibrary/spu/simdmath/log2f4.h deleted file mode 100644 index 43d2dfc6f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/log2f4.h +++ /dev/null @@ -1,78 +0,0 @@ -/* log2f4 - 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 ___SIMD_MATH_LOG2F4_H___ -#define ___SIMD_MATH_LOG2F4_H___ - -#include -#include - -#include - -#define __LOG2F_l2emsb 1.4426950216293f -#define __LOG2F_l2elsb 1.9259629911e-8f -#define __LOG2F_l2e 1.4426950408890f - -#define __LOG2F_c0 0.2988439998f -#define __LOG2F_c1 0.3997655209f -#define __LOG2F_c2 0.6666679125f - -static inline vector float -_log2f4 (vector float x) -{ - vec_int4 zeros = spu_splats((int)0); - vec_float4 ones = spu_splats(1.0f); - vec_uint4 zeromask = spu_cmpeq(x, (vec_float4)zeros); - - vec_int4 expmask = spu_splats((int)0x7F800000); - vec_int4 xexp = spu_add( spu_rlmask(spu_and((vec_int4)x, expmask), -23), -126 ); - x = spu_sel(x, (vec_float4)spu_splats((int)0x3F000000), (vec_uint4)expmask); - - - vec_uint4 mask = spu_cmpgt(spu_splats(0.7071067811865f), x); - x = spu_sel(x , spu_add(x, x) , mask); - xexp = spu_sel(xexp, spu_sub(xexp,spu_splats((int)1)), mask); - - vec_float4 x1 = spu_sub(x , ones); - vec_float4 z = _divf4(x1, spu_add(x, ones)); - vec_float4 w = spu_mul(z , z); - vec_float4 polyw; - polyw = spu_madd(spu_splats(__LOG2F_c0), w, spu_splats(__LOG2F_c1)); - polyw = spu_madd(polyw , w, spu_splats(__LOG2F_c2)); - - vec_float4 yneg = spu_mul(z, spu_msub(polyw, w, x1)); - vec_float4 zz1 = spu_madd(spu_splats(__LOG2F_l2emsb), x1, spu_convtf(xexp,0)); - vec_float4 zz2 = spu_madd(spu_splats(__LOG2F_l2elsb), x1, - spu_mul(spu_splats(__LOG2F_l2e), yneg) - ); - - return spu_sel(spu_add(zz1,zz2), (vec_float4)zeromask, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/logbd2.h b/Extras/simdmathlibrary/spu/simdmath/logbd2.h deleted file mode 100644 index 55bfdc8e8..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/logbd2.h +++ /dev/null @@ -1,86 +0,0 @@ -/* logbd2 - for each element of vector x, return the exponent of normalized double x' as floating point value - 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 ___SIMD_MATH_LOGBD2_H___ -#define ___SIMD_MATH_LOGBD2_H___ - -#include -#include -#include - -static inline vector double -_logbd2 (vector double x) -{ - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - vec_uchar16 swapEvenOdd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x00010203, 0x0c0d0e0f, 0x08090a0b }; - - vec_ullong2 sign = spu_splats(0x8000000000000000ull); - vec_ullong2 expn = spu_splats(0x7ff0000000000000ull); - vec_ullong2 zero = spu_splats(0x0000000000000000ull); - - vec_ullong2 isnan, isinf, iszero; - vec_double2 logb = (vec_double2)zero; - vec_llong2 e1, e2; - vec_uint4 cmpgt, cmpeq, cmpzr; - vec_int4 lz, lz0, lz1; - - //NAN: x is NaN (all-ones exponent and non-zero mantissa) - cmpgt = spu_cmpgt( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - cmpeq = spu_cmpeq( (vec_uint4)spu_or( (vec_ullong2)x, sign ), (vec_uint4)spu_or(sign, expn) ); - isnan = (vec_ullong2)spu_or( spu_shuffle( cmpgt, cmpgt, even ), - spu_and( spu_shuffle( cmpeq, cmpeq, even ), - spu_shuffle( cmpgt, cmpgt, odd ) ) ); - logb = spu_sel( logb, (vec_double2)spu_splats(0x7FF8000000000000ll), isnan ); - - //INF: x is infinite (all-ones exponent and zero mantissa) - isinf = (vec_ullong2)spu_and( cmpeq, spu_shuffle( cmpeq, cmpeq, swapEvenOdd ) ); - logb = spu_sel( logb, (vec_double2)spu_splats(__builtin_huge_val()), isinf ); - - //HUGE_VAL: x is zero (zero exponent and zero mantissa) - cmpzr = spu_cmpeq( (vec_uint4)spu_andc( (vec_ullong2)x, sign ), (vec_uint4)zero ); - iszero = (vec_ullong2)spu_and( cmpzr, spu_shuffle( cmpzr, cmpzr, swapEvenOdd ) ); - logb = spu_sel( logb, (vec_double2)spu_splats(-__builtin_huge_val()), iszero ); - - //Integer Exponent: if x is normal or subnormal, return unbiased exponent of normalized double x - e1 = (vec_llong2)spu_and( (vec_llong2)x, (vec_llong2)expn ); - e2 = (vec_llong2)spu_rlmask((vec_uint4)e1, -20); - - lz = (vec_int4)spu_cntlz( (vec_uint4)spu_andc( (vec_ullong2)x, sign) ); - lz0 = (vec_int4)spu_shuffle( lz, lz, even ); - lz0 = spu_sel( (vec_int4)zero, spu_sub( lz0, spu_splats((int)12) ), spu_cmpgt( lz0, (int)11 ) ); - lz1 = spu_sel( (vec_int4)zero, spu_shuffle( lz, lz, odd), spu_cmpeq( lz0, (int)20 ) ); - - logb = spu_sel( logb, spu_extend( spu_convtf( spu_sub( spu_sub( (vec_int4)e2, spu_splats((int)1023) ), spu_add( lz0, lz1 ) ), 0 ) ), - spu_nor( isnan, spu_or( isinf, iszero ) ) ); - - return logb; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/logbf4.h b/Extras/simdmathlibrary/spu/simdmath/logbf4.h deleted file mode 100644 index 40e0d7a71..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/logbf4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* logbf4 - for each element of vector x, return the exponent of x' as floating point value - 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 ___SIMD_MATH_LOGBF4_H___ -#define ___SIMD_MATH_LOGBF4_H___ - -#include -#include -#include - -static inline vector float -_logbf4 (vector float x) -{ - vec_int4 e1 = spu_and((vec_int4)x, spu_splats((int)0x7F800000)); - vec_uint4 zeromask = spu_cmpeq(e1, 0); - e1 = spu_sub(e1, spu_splats((int)0x3F800000)); - return spu_sel(spu_convtf(e1,23), (vec_float4)spu_splats(-HUGE_VALF), zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/logf4.h b/Extras/simdmathlibrary/spu/simdmath/logf4.h deleted file mode 100644 index 2b901a544..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/logf4.h +++ /dev/null @@ -1,76 +0,0 @@ -/* logf4 - for each of four slots, calculate the natural log - 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 ___SIMD_MATH_LOGF4_H___ -#define ___SIMD_MATH_LOGF4_H___ - -#include -#include - -#include - -#define __LOGF_ln2msb 0.6931470632553f -#define __LOGF_ln2lsb 1.1730463525e-7f - -#define __LOGF_c0 0.2988439998f -#define __LOGF_c1 0.3997655209f -#define __LOGF_c2 0.6666679125f - -static inline vector float -_logf4 (vector float x) -{ - vec_int4 zeros = spu_splats((int)0); - vec_float4 ones = spu_splats(1.0f); - vec_uint4 zeromask = spu_cmpeq(x, (vec_float4)zeros); - - vec_uint4 expmask = spu_splats(0x7F800000U); - vec_int4 xexp = spu_add( spu_rlmask(spu_and((vec_int4)x, (vec_int4)expmask), -23), -126 ); - x = spu_sel(x, (vec_float4)spu_splats((int)0x3F000000), expmask); - - - vec_uint4 mask = spu_cmpgt(spu_splats(0.7071067811865f), x); - x = spu_sel(x , spu_add(x, x) , mask); - xexp = spu_sel(xexp, spu_sub(xexp,spu_splats((int)1)), mask); - - vec_float4 x1 = spu_sub(x , ones); - vec_float4 z = _divf4 (x1, spu_add(x, ones)); - vec_float4 w = spu_mul(z , z); - vec_float4 polyw; - polyw = spu_madd(spu_splats(__LOGF_c0), w, spu_splats(__LOGF_c1)); - polyw = spu_madd(polyw , w, spu_splats(__LOGF_c2)); - - vec_float4 yneg = spu_mul(z, spu_msub(polyw, w, x1)); - vec_float4 wnew = spu_convtf(xexp,0); - vec_float4 zz1 = spu_madd(spu_splats(__LOGF_ln2msb), wnew, x1); - vec_float4 zz2 = spu_madd(spu_splats(__LOGF_ln2lsb), wnew, yneg); - - return spu_sel(spu_add(zz1,zz2), (vec_float4)zeromask, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/modfd2.h b/Extras/simdmathlibrary/spu/simdmath/modfd2.h deleted file mode 100644 index cb9f52501..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/modfd2.h +++ /dev/null @@ -1,59 +0,0 @@ -/* modfd2 - for each of two double slots, compute fractional and integral parts. - 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 ___SIMD_MATH_MODFD2_H___ -#define ___SIMD_MATH_MODFD2_H___ - -#include -#include - -#include - -// Returns fractional part and stores integral part in *iptr. - -static inline vector double -_modfd2 (vector double x, vector double *iptr) -{ - vec_double2 integral, fraction; - vec_uint4 iszero; - vec_uint4 sign = (vec_uint4){0x80000000, 0, 0x80000000, 0}; - vec_uchar16 pattern = (vec_uchar16){4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11}; - - integral = _truncd2( x ); - - // if integral is zero, then fraction is x. - iszero = spu_cmpeq(spu_andc((vec_uint4)integral, sign), 0); - iszero = spu_and(iszero, spu_shuffle(iszero, iszero, pattern)); - fraction = spu_sel(spu_sub( x, integral ), x, (vec_ullong2)iszero); - - *iptr = integral; - return fraction; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/modff4.h b/Extras/simdmathlibrary/spu/simdmath/modff4.h deleted file mode 100644 index e18cb5967..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/modff4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* modff4 - for each of four float slots, compute fractional and integral parts. - 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 ___SIMD_MATH_MODFF4_H___ -#define ___SIMD_MATH_MODFF4_H___ - -#include -#include - -#include - -// Returns fractional part and stores integral part in *iptr. - -static inline vector float -_modff4 (vector float x, vector float *iptr) -{ - vec_float4 integral, fraction; - - integral = _truncf4( x ); - fraction = spu_sub( x, integral ); - - *iptr = integral; - return fraction; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/nearbyintd2.h b/Extras/simdmathlibrary/spu/simdmath/nearbyintd2.h deleted file mode 100644 index 111bb01b4..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/nearbyintd2.h +++ /dev/null @@ -1,76 +0,0 @@ -/* nearbyintd2 - Round the input to the nearest integer according to - the current rounding mode without raising an inexact exception. - 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 ___SIMD_MATH_NEARBYINTD2_H___ -#define ___SIMD_MATH_NEARBYINTD2_H___ - -#include -#include - -static inline vector double -_nearbyintd2(vector double in) -{ - vec_uint4 fpscr; - vec_ullong2 sign = ((vec_ullong2){0x8000000000000000ULL,0x8000000000000000ULL}); - vec_double2 out, addend; - vec_uint4 vec_zero = ((vec_uint4){0,0,0,0}); - - fpscr = spu_mffpscr(); - - // check denormalized - vec_uint4 exp = spu_and( (vec_uint4)in, 0x7FF00000 ); - vec_uint4 is_denorm = spu_cmpeq( exp, 0 ); - vec_uint4 ofs = spu_and( ((vec_uint4){0x00100000,0,0x00100000,0}), is_denorm); - - // check zero - vec_uint4 abs_x = spu_and((vec_uint4)in, ((vec_uint4){0x7FFFFFFF,-1,0x7FFFFFFF,-1})); - vec_uint4 is_zerox = spu_cmpeq( abs_x, vec_zero); - is_zerox = spu_and( is_zerox, spu_shuffle(is_zerox,is_zerox, ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}))); - ofs = spu_sel( ofs, vec_zero, is_zerox); - - vec_double2 xx = (vec_double2)spu_or( (vec_uint4)in, ofs ); - - /* Add 2^53 and then subtract 2^53 to affect a round to be performed by the - * hardware. Also preserve the input sign so that negative inputs that - * round to zero generate a -0.0. - */ - vec_uint4 is_large = spu_cmpgt( exp, 0x43200000 ); - is_large = spu_shuffle(is_large,is_large,((vec_uchar16){0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8})); - addend = spu_sel((vec_double2)((vec_ullong2){0x4330000000000000ULL,0x4330000000000000ULL}), ((vec_double2){0.0,0.0}), (vec_ullong2)is_large); - addend = spu_sel(addend, xx, sign); - - out = spu_sel(spu_sub(spu_add(xx, addend), addend), xx, sign); - - spu_mtfpscr(fpscr); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/nearbyintf4.h b/Extras/simdmathlibrary/spu/simdmath/nearbyintf4.h deleted file mode 100644 index 99d31dfe7..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/nearbyintf4.h +++ /dev/null @@ -1,55 +0,0 @@ -/* nearbyintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model, - without raising an inexact floating-point exception. - On SPU, the rounding mode for float is always towards zero. - 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 ___SIMD_MATH_NEARBYINTF4_H___ -#define ___SIMD_MATH_NEARBYINTF4_H___ - -#include -#include - -static inline vector float -_nearbyintf4(vector float x) -{ - vector signed int xi; - vector unsigned int inrange; - - // Can convert to and from signed integer to truncate values in range [-2^31, 2^31). - // However, no truncation needed if exponent > 22. - - inrange = spu_cmpabsgt( (vector float)spu_splats(0x4b000000), x ); - - xi = spu_convts( x, 0 ); - - return spu_sel( x, spu_convtf( xi, 0 ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/negated2.h b/Extras/simdmathlibrary/spu/simdmath/negated2.h deleted file mode 100644 index 19c90287f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/negated2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* negated2 - for each of two double slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATED2_H___ -#define ___SIMD_MATH_NEGATED2_H___ - -#include -#include - -static inline vector double -_negated2 (vector double x) -{ - return (vec_double2)spu_xor( (vec_ullong2)x, spu_splats(0x8000000000000000ull) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/negatef4.h b/Extras/simdmathlibrary/spu/simdmath/negatef4.h deleted file mode 100644 index 52dd3a1bb..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/negatef4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* negatef4 - for each of four float slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATEF4_H___ -#define ___SIMD_MATH_NEGATEF4_H___ - -#include -#include - - -static inline vector float -_negatef4 (vector float x) -{ - return (vec_float4)spu_xor( (vec_uint4)x, spu_splats(0x80000000) ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/negatei4.h b/Extras/simdmathlibrary/spu/simdmath/negatei4.h deleted file mode 100644 index 3b29c50ba..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/negatei4.h +++ /dev/null @@ -1,43 +0,0 @@ -/* negatei4 - for each of 4 signed int slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATEI4_H___ -#define ___SIMD_MATH_NEGATEI4_H___ - -#include -#include - -static inline vector signed int -_negatei4 (vector signed int x) -{ - vector signed int zero = (vector signed int){0,0,0,0}; - return spu_sub (zero, x); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/negatell2.h b/Extras/simdmathlibrary/spu/simdmath/negatell2.h deleted file mode 100644 index b618e11da..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/negatell2.h +++ /dev/null @@ -1,47 +0,0 @@ -/* negatell2 - for each of 2 signed long long slots, negate the sign bit. - 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 ___SIMD_MATH_NEGATELL2_H___ -#define ___SIMD_MATH_NEGATELL2_H___ - -#include -#include - -static inline vector signed long long -_negatell2 (vector signed long long x) -{ - vector signed int zero = (vector signed int){0,0,0,0}; - vector signed int borrow; - - borrow = spu_genb(zero, (vec_int4)x); - borrow = spu_shuffle(borrow, borrow, ((vec_uchar16){4,5,6,7, 0xC0,0xC0,0xC0,0xC0, 12,13,14,15, 0xC0,0xC0,0xC0,0xC0})); - return (vec_llong2)spu_subx(zero, (vec_int4)x, borrow); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/nextafterd2.h b/Extras/simdmathlibrary/spu/simdmath/nextafterd2.h deleted file mode 100644 index 2fcd98f54..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/nextafterd2.h +++ /dev/null @@ -1,97 +0,0 @@ -/* nextafterd2 - find next representable floating-point value towards 2nd param. - 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 ___SIMD_MATH_NEXTAFTERD2_H___ -#define ___SIMD_MATH_NEXTAFTERD2_H___ - -#include -#include - -static inline vector double -_nextafterd2 (vector double xx, vector double yy) -{ - vec_uint4 abs_x, abs_y, sign_x, abs_dif; - vec_uint4 is_sub, is_zerox, is_zeroy; - vec_uint4 is_equal, is_infy, is_nany; - vec_uint4 res0, res1, res; - vec_uint4 vec_zero = ((vec_uint4){0,0,0,0}); - vec_uint4 vec_one = ((vec_uint4){0,1,0,1}); - vec_uint4 vec_m1 = ((vec_uint4){0x80000000,1,0x80000000,1}); - vec_uint4 msk_exp = ((vec_uint4){0x7FF00000,0,0x7FF00000,0}); - vec_uint4 msk_abs = ((vec_uint4){0x7FFFFFFF,-1,0x7FFFFFFF,-1}); - vec_uchar16 msk_all_eq = ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}); - - // mask sign bit - abs_x = spu_and( (vec_uint4)xx, msk_abs); - abs_y = spu_and( (vec_uint4)yy, msk_abs); - - is_zerox = spu_cmpeq( abs_x, vec_zero); - is_zerox = spu_and( is_zerox, spu_shuffle(is_zerox,is_zerox,msk_all_eq)); - - // -0 exception - sign_x = spu_and((vec_uint4)xx, ((vec_uint4){0x80000000,0,0x80000000,0})); - sign_x = spu_sel(sign_x, vec_zero, is_zerox); - - // if same sign |y| < |x| -> decrease - abs_dif = spu_subx(abs_y, abs_x, spu_rlqwbyte(spu_genb(abs_y, abs_x), 4)); - is_sub = spu_xor((vec_uint4)yy, sign_x); // not same sign -> decrease - is_sub = spu_or(is_sub, abs_dif); - is_sub = spu_rlmaska(is_sub, -31); - is_sub = spu_shuffle(is_sub,is_sub,((vec_uchar16){0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8})); - - res0 = spu_addx( abs_x, vec_one, spu_rlqwbyte(spu_genc(abs_x,vec_one),4)); // calc increase - res1 = spu_subx( abs_x, vec_one, spu_rlqwbyte(spu_genb(abs_x,vec_one),4)); // calc decrease - res = spu_sel( res0, res1, is_sub); // select increase or decrease - res = spu_or( res, sign_x); // set sign - - // check exception - // 0 -> -1 - res = spu_sel(res, vec_m1, spu_and(is_zerox, is_sub)); - - // check equal (include 0,-0) - is_zeroy = spu_cmpeq( abs_y, vec_zero); - is_zeroy = spu_and( is_zeroy, spu_shuffle(is_zeroy,is_zeroy,msk_all_eq)); - is_equal = spu_cmpeq((vec_uint4)xx, (vec_uint4)yy); - is_equal = spu_and(is_equal, spu_shuffle(is_equal,is_equal,msk_all_eq)); - is_equal = spu_or(is_equal, spu_and(is_zeroy, is_zerox)); - res = spu_sel(res, (vec_uint4)yy, is_equal); - - // check nan - is_infy = spu_cmpeq( abs_y, msk_exp); - is_infy = spu_and( is_infy, spu_shuffle(is_infy,is_infy,msk_all_eq)); - is_nany = spu_and( abs_y, msk_exp); - is_nany = spu_cmpeq( is_nany, msk_exp); - is_nany = spu_and( is_nany, spu_shuffle(is_nany,is_nany,msk_all_eq)); - is_nany = spu_sel( is_nany, vec_zero, is_infy); - res = spu_sel(res, (vec_uint4)yy, is_nany); - - return (vec_double2)res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/nextafterf4.h b/Extras/simdmathlibrary/spu/simdmath/nextafterf4.h deleted file mode 100644 index cf32a4fcd..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/nextafterf4.h +++ /dev/null @@ -1,72 +0,0 @@ -/* nextafterf4 - for each of four float slots, - return the the next representable value after x in the direction fo y, - if x is euqal to y, the result is y. - 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 ___SIMD_MATH_NEXTAFTERF4_H___ -#define ___SIMD_MATH_NEXTAFTERF4_H___ - -#include -#include - - -static inline vector float -_nextafterf4(vector float x, vector float y) -{ - vec_float4 x_not_dec, lala_inc, lala_dec; - vec_uint4 abs_inc_number, abs_dec_number; - - vec_uint4 A, B; - - //abs_inc, abs_dec - abs_inc_number = spu_sel(spu_splats((unsigned int)0x800000), spu_add((vec_uint4)x, spu_splats((unsigned int)0x1)), spu_cmpabsgt(x, spu_splats(0.0f))); - abs_dec_number = (vec_uint4)spu_add((vec_float4)spu_sub((vec_uint4)x, spu_splats((unsigned int)0x1)), spu_splats(0.0f)); - - //x<= y - A= spu_andc(abs_inc_number, spu_splats((unsigned int)0x80000000)); - // in < 0 - B= abs_dec_number; - - lala_inc = spu_sel((vec_float4)A, (vec_float4)B, spu_cmpgt(spu_splats(0.0f), x)); - - // in <=0, abs_inc ( if in==0, set result's sign to -) - //A= spu_or(spu_splats((unsigned int)0x80000000), spu_andc(abs_inc_number, spu_splats((unsigned int)0x80000000))); - A= spu_or(abs_inc_number, spu_splats((unsigned int)0x80000000)); - // in > 0 - B = abs_dec_number; - lala_dec = spu_sel((vec_float4)A, (vec_float4)B, spu_cmpgt(x, spu_splats(0.0f))); - - - x_not_dec = spu_sel(y, lala_inc, spu_cmpgt(y, x)); - - // (x <= y) || (x > y) - return spu_sel(x_not_dec, lala_dec, spu_cmpgt(x, y)); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/powf4.h b/Extras/simdmathlibrary/spu/simdmath/powf4.h deleted file mode 100644 index aacb61ee6..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/powf4.h +++ /dev/null @@ -1,60 +0,0 @@ -/* powf4 - - 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 ___SIMD_MATH_POWF4_H___ -#define ___SIMD_MATH_POWF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_powf4 (vector float x, vector float y) -{ - vec_int4 zeros = spu_splats((int)0); - vec_uint4 zeromask = spu_cmpeq((vec_float4)zeros, x); - - vec_uint4 negmask = spu_cmpgt(spu_splats(0.0f), x); - - vec_float4 sbit = (vec_float4)spu_splats((int)0x80000000); - vec_float4 absx = spu_andc(x, sbit); - vec_float4 absy = spu_andc(y, sbit); - vec_uint4 oddy = spu_and(spu_convtu(absy, 0), spu_splats(0x00000001U)); - negmask = spu_and(negmask, spu_cmpgt(oddy, (vec_uint4)zeros)); - - vec_float4 res = _exp2f4(spu_mul(y, _log2f4(absx))); - res = spu_sel(res, spu_or(sbit, res), negmask); - - - return spu_sel(res, (vec_float4)zeros, zeromask); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/recipd2.h b/Extras/simdmathlibrary/spu/simdmath/recipd2.h deleted file mode 100644 index 906ca336f..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/recipd2.h +++ /dev/null @@ -1,88 +0,0 @@ -/* recipd2 - for each of two double slots, compute reciprocal. - 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 ___SIMD_MATH_RECIPD2_H___ -#define ___SIMD_MATH_RECIPD2_H___ - -#include -#include - -#include -#include -#include - -// Handles exceptional values as follows: -// NaN -> NaN -// (+,-)Inf -> (+,-)0 -// (+,-)0 -> (+,-)Inf -// Denormal inputs are treated as zero. - -static inline vector double -_recipd2 (vector double x) -{ - vec_ullong2 expmask, signmask; - vec_double2 one, man, exp, nexp, y1, y2, y3, zero, inf, result; - vec_float4 onef, manf, y0f, y1f; - - expmask = spu_splats(0x7ff0000000000000ull); - signmask = spu_splats(0x8000000000000000ull); - onef = spu_splats(1.0f); - one = spu_extend( onef ); - - // Factor ( mantissa x 2^exponent ) into ( mantissa x 2 ) and ( 2^(exponent-1) ). - // Invert exponent part with subtraction. - - exp = spu_and( x, (vec_double2)expmask ); - nexp = (vec_double2)spu_sub( (vec_uint4)expmask, (vec_uint4)exp ); - man = spu_sel( x, (vec_double2)spu_splats(0x40000000), expmask ); - - // Compute mantissa part with single and double precision Newton-Raphson steps. - // Then multiply with 2^(1-exponent). - - manf = spu_roundtf( man ); - y0f = spu_re( manf ); - y1f = spu_madd( spu_nmsub( manf, y0f, onef ), y0f, y0f ); - y1 = spu_extend( y1f ); - y2 = spu_madd( spu_nmsub( man, y1, one ), y1, y1 ); - y3 = spu_madd( spu_nmsub( man, y2, one ), y2, y2 ); - y3 = spu_mul( y3, nexp ); - - // Choose iterated result or special value. - - zero = spu_and( x, (vec_double2)signmask ); - inf = spu_sel( (vec_double2)expmask, x, signmask ); - - result = spu_sel( y3, zero, _isinfd2 ( x ) ); - result = spu_sel( result, inf, _is0denormd2 ( x ) ); - result = spu_sel( result, x, _isnand2( x ) ); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/recipf4.h b/Extras/simdmathlibrary/spu/simdmath/recipf4.h deleted file mode 100644 index e7dfd8651..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/recipf4.h +++ /dev/null @@ -1,50 +0,0 @@ -/* recipf4 - for each of four float slots, compute reciprocal. - 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 ___SIMD_MATH_RECIPF4_H___ -#define ___SIMD_MATH_RECIPF4_H___ - -#include -#include - -static inline vector float -_recipf4 (vector float x) -{ - // Reciprocal estimate and 1 Newton-Raphson iteration. - // A constant of 1.0 + 1 ulp in the Newton-Raphson step results in exact - // answers for powers of 2, and a slightly smaller relative error bound. - - vec_float4 y0; - vec_float4 oneish = (vec_float4)spu_splats(0x3f800001); - - y0 = spu_re( x ); - return spu_madd( spu_nmsub( x, y0, oneish ), y0, y0 ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/remainderd2.h b/Extras/simdmathlibrary/spu/simdmath/remainderd2.h deleted file mode 100644 index 3bdc67ee1..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/remainderd2.h +++ /dev/null @@ -1,110 +0,0 @@ -/* A vector double is returned that contains the remainder xi REM yi, - for the corresponding elements of vector double x and vector double y. - 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 ___SIMD_MATH_REMAINDERD2_H___ -#define ___SIMD_MATH_REMAINDERD2_H___ - -#include -#include - -#include -#include - - -static inline vector double -_remainderd2(vector double x, vector double yy) -{ - vec_uchar16 splat_hi = ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_uint4 y_hi; - vec_uint4 abs_x, abs_yy, abs_2x, abs_2y; - vec_uint4 bias; - vec_uint4 nan_out, overflow; - vec_uint4 result; - vec_uint4 half_smax = spu_splats((unsigned int)0x7FEFFFFF); - vec_uint4 sign_mask = (vec_uint4)(spu_splats(0x8000000000000000ULL)); - vec_uint4 exp_mask = (vec_uint4)(spu_splats(0x7FF0000000000000ULL)); - vec_uint4 val_nan = (vec_uint4)(spu_splats(0x7FF8000000000000ULL)); - vec_uint4 vec_zero = spu_splats((unsigned int)0); - vec_uint4 is_zeroy; - - // cut sign - abs_x = spu_andc((vec_uint4)x, sign_mask); - abs_yy = spu_andc((vec_uint4)yy, sign_mask); - y_hi = spu_shuffle(abs_yy, abs_yy, splat_hi); - - - // check nan out - is_zeroy = spu_cmpeq(abs_yy, vec_zero); - is_zeroy = spu_and(is_zeroy, spu_rlqwbyte(is_zeroy, 4)); - nan_out = __vec_gt64_half(abs_yy, exp_mask); // y > 7FF00000 - nan_out = spu_or(nan_out, spu_cmpgt(abs_x, half_smax)); // x >= 7FF0000000000000 - nan_out = spu_or(nan_out, is_zeroy); // y = 0 - nan_out = spu_shuffle(nan_out, nan_out, splat_hi); - - - // make y x2 - abs_2y = __rem_twice_d(abs_yy); // 2 x y - - result = (vec_uint4)_fmodd2((vec_double2)abs_x, (vec_double2)abs_2y); - - // abs_x = spu_sel(spu_andc(result, sign_mask), abs_x, spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FBFFFFF))); - abs_x = spu_sel(result, abs_x, spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FEFFFFF))); - - /* if (2*x > y) - * x -= y - * if (2*x >= y) x -= y - */ - overflow = spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FEFFFFF)); - // make x2 - abs_2x = __rem_twice_d(abs_x); // 2 x x - - bias = __vec_gt64(abs_2x, abs_yy); // abs_2x > abs_yy - bias = spu_andc(bias, overflow); - - abs_x = spu_sel(abs_x, __rem_sub_d(abs_x, abs_yy), bias); - - - overflow = spu_or(overflow, spu_shuffle(spu_rlmaska(abs_x, -31), vec_zero, splat_hi)); // minous - - // make x2 - abs_2x = __rem_twice_d(spu_andc(abs_x, sign_mask)); // 2 x x unsupport minous - bias = spu_andc(bias, spu_rlmaska(__rem_sub_d(abs_2x, abs_yy), -31)); - bias = spu_andc(spu_shuffle(bias, bias, splat_hi), overflow); - abs_x = spu_sel(abs_x, __rem_sub_d(abs_x, abs_yy), bias); - - /* select final answer - */ - result = spu_xor(abs_x, spu_and((vec_uint4)x, sign_mask)); // set sign - result = spu_sel(result, val_nan, nan_out); // if nan - - return ((vec_double2)result); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/remainderf4.h b/Extras/simdmathlibrary/spu/simdmath/remainderf4.h deleted file mode 100644 index 32d5cfaee..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/remainderf4.h +++ /dev/null @@ -1,115 +0,0 @@ -/* remainderf4 - for each of four float slots, compute remainder of x/y defined as x - nearest_integer(x/y) * y. - 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 ___SIMD_MATH_REMAINDERF4_H___ -#define ___SIMD_MATH_REMAINDERF4_H___ - -#include -#include - -#include -#include -#include - -// -// This returns an accurate result when |divf4(x,y)| < 2^20 and |x| < 2^128, and otherwise returns zero. -// If x == 0, the result is 0. -// If x != 0 and y == 0, the result is undefined. -static inline vector float -_remainderf4 (vector float x, vector float y) -{ - vec_float4 q, xabs, yabs, qabs, xabs2, yabshalf; - vec_int4 qi0, qi1, qi2; - vec_float4 i0, i1, i2, i, rem; - vec_uint4 inrange, odd0, odd1, odd2, cmp1, cmp2, odd; - - // Find i = truncated_integer(|x/y|) - - // By the error bounds of divf4, if |x/y| is < 2^20, the quotient is at most off by 1.0. - // Thus the exact truncation is either the truncated quotient, one less, or one greater. - - q = _divf4( x, y ); - xabs = _fabsf4( x ); - yabs = _fabsf4( y ); - qabs = _fabsf4( q ); - xabs2 = spu_add( xabs, xabs ); - - inrange = spu_cmpabsgt( (vec_float4)spu_splats(0x49800000), q ); - inrange = spu_and( inrange, spu_cmpabsgt( (vec_float4)spu_splats(0x7f800000), x ) ); - - qi1 = spu_convts( qabs, 0 ); - qi0 = spu_add( qi1, -1 ); - qi2 = spu_add( qi1, 1 ); - - odd1 = spu_cmpeq( spu_and( qi1, 1 ), 1 ); - odd0 = odd2 = spu_nor( odd1, odd1 ); - - i0 = spu_convtf( qi0, 0 ); - i1 = spu_convtf( qi1, 0 ); - i2 = spu_convtf( qi2, 0 ); - - // Correct i will be the largest one such that |x| - i*|y| >= 0. Can test instead as - // 2*|x| - i*|y| >= |x|: - // - // With exact inputs, the negative-multiply-subtract gives the exact result rounded towards zero. - // Thus |x| - i*|y| may be < 0 but still round to zero. However, if 2*|x| - i*|y| < |x|, the computed - // answer will be rounded down to < |x|. 2*|x| can be represented exactly provided |x| < 2^128. - - cmp1 = spu_cmpgt( xabs, spu_nmsub( i1, yabs, xabs2 ) ); - cmp2 = spu_cmpgt( xabs, spu_nmsub( i2, yabs, xabs2 ) ); - - i = i0; - i = spu_sel( i1, i, cmp1 ); - i = spu_sel( i2, i, cmp2 ); - - odd = odd0; - odd = spu_sel( odd1, odd, cmp1 ); - odd = spu_sel( odd2, odd, cmp2 ); - - rem = spu_nmsub( i, yabs, xabs ); - - // Test whether i or i+1 = nearest_integer(|x/y|) - // - // i+1 is correct if: - // - // rem > 0.5*|y| - // or - // rem = 0.5*|y| and i is odd - - yabshalf = spu_mul( yabs, spu_splats(0.5f) ); - cmp1 = spu_cmpgt( rem, yabshalf ); - cmp2 = spu_and( spu_cmpeq( rem, yabshalf ), odd ); - - i = spu_sel( i, spu_add( i, spu_splats(1.0f) ), spu_or( cmp1, cmp2 ) ); - i = _copysignf4( i, q ); - - return spu_sel( spu_splats(0.0f), spu_nmsub( i, y, x ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/remquod2.h b/Extras/simdmathlibrary/spu/simdmath/remquod2.h deleted file mode 100644 index ef1ea7810..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/remquod2.h +++ /dev/null @@ -1,155 +0,0 @@ -/* remquod2 - - 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 ___SIMD_MATH_REMQUOD2_H___ -#define ___SIMD_MATH_REMQUOD2_H___ - -#include -#include - -#include -#include - -/* - * This function returns the same vector double result as remainderd2(). - * In addition a vector signed long long is storedin *pquo, - * that contains the corresponding element values whose sign is - * the sign of xi / yi and whose magnitude is congruent modulo 2n to - * the magnitude of the integral quotient of xi / yi, where n is - * an implementation-defined integer greater than or equal to 3. - */ - -static inline vector double -_remquod2(vector double x, vector double yy, vector signed long long *quo) -{ - vec_uchar16 splat_hi = ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_int4 quotient, quotient0; - vec_uint4 y_hi; - vec_uint4 abs_x, abs_yy, abs_2x, abs_8y, abs_4y, abs_2y; - vec_uint4 bias; - vec_uint4 nan_out, not_ge, quo_pos, overflow; - vec_uint4 result; - vec_uint4 half_smax = spu_splats((unsigned int)0x7FEFFFFF); - vec_uint4 sign_mask = (vec_uint4)(spu_splats(0x8000000000000000ULL)); - vec_uint4 exp_mask = (vec_uint4)(spu_splats(0x7FF0000000000000ULL)); - vec_uint4 val_nan = (vec_uint4)(spu_splats(0x7FF8000000000000ULL)); - vec_uint4 vec_zero = spu_splats((unsigned int)0); - vec_uint4 is_zeroy; - - // cut sign - abs_x = spu_andc((vec_uint4)x, sign_mask); - abs_yy = spu_andc((vec_uint4)yy, sign_mask); - y_hi = spu_shuffle(abs_yy, abs_yy, splat_hi); - - quo_pos = spu_cmpgt((vec_int4)spu_and((vec_uint4)spu_xor(x, yy), sign_mask), -1); - quo_pos = spu_shuffle(quo_pos, quo_pos, splat_hi); - - // check nan out - is_zeroy = spu_cmpeq(abs_yy, vec_zero); - is_zeroy = spu_and(is_zeroy, spu_rlqwbyte(is_zeroy, 4)); - nan_out = __vec_gt64_half(abs_yy, exp_mask); // y > 7FF00000 - nan_out = spu_or(nan_out, spu_cmpgt(abs_x, half_smax)); // x >= 7FF0000000000000 - nan_out = spu_or(nan_out, is_zeroy); // y = 0 - nan_out = spu_shuffle(nan_out, nan_out, splat_hi); - - - // make y x8 - abs_2y = __rem_twice_d(abs_yy); // 2 x y - abs_4y = __rem_twice_d(abs_2y); // 4 x y - abs_8y = __rem_twice_d(abs_4y); // 2 x y - - result = (vec_uint4)_fmodd2((vec_double2)abs_x, (vec_double2)abs_8y); - - // if y (x8->exp+3 7FF-7FC) overflow - // abs_x = spu_sel(spu_andc(result, sign_mask), abs_x, spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FBFFFFF))); - abs_x = spu_sel(result, abs_x, spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FBFFFFF))); - - /* if (x >= 4*y) - * x -= 4*y - * quotient = 4 - * else - * quotient = 0 - */ - overflow = spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FCFFFFF)); - - not_ge = __vec_gt64(abs_4y, abs_x); - not_ge = spu_or(not_ge, overflow); - abs_x = spu_sel(__rem_sub_d(abs_x, abs_4y), abs_x, not_ge); - quotient = spu_andc(spu_splats((int)4), (vec_int4)not_ge); - - /* if (x >= 2*y - * x -= 2*y - * quotient += 2 - */ - overflow = spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FDFFFFF)); - - not_ge = __vec_gt64(abs_2y, abs_x); // abs_2y > abs_x - not_ge = spu_or(not_ge, overflow); - - abs_x = spu_sel(__rem_sub_d(abs_x, abs_2y), abs_x, not_ge); - quotient = spu_sel(spu_add(quotient, 2), quotient, not_ge); - - /* if (2*x > y) - * x -= y - * if (2*x >= y) x -= y - */ - overflow = spu_cmpgt(y_hi, spu_splats((unsigned int)0x7FEFFFFF)); - // make x2 - abs_2x = __rem_twice_d(abs_x); // 2 x x - - bias = __vec_gt64(abs_2x, abs_yy); // abs_2x > abs_yy - bias = spu_andc(bias, overflow); - - abs_x = spu_sel(abs_x, __rem_sub_d(abs_x, abs_yy), bias); - quotient = spu_sub(quotient, (vec_int4)bias); - - overflow = spu_or(overflow, spu_shuffle(spu_rlmaska(abs_x, -31), vec_zero, splat_hi)); // minous - - // make x2 - abs_2x = __rem_twice_d(spu_andc(abs_x, sign_mask)); // 2 x x unsupport minous - bias = spu_andc(bias, spu_rlmaska(__rem_sub_d(abs_2x, abs_yy), -31)); - bias = spu_andc(spu_shuffle(bias, bias, splat_hi), overflow); - abs_x = spu_sel(abs_x, __rem_sub_d(abs_x, abs_yy), bias); - quotient = spu_sub(quotient, (vec_int4)bias); - - /* select final answer - */ - result = spu_xor(abs_x, spu_and((vec_uint4)x, sign_mask)); // set sign - result = spu_sel(result, val_nan, nan_out); // if nan - - quotient = spu_and(quotient, ((vec_int4){0,7,0,7})); // limit to 3bit - quotient0 = spu_subx( (vec_int4)vec_zero, quotient, spu_rlqwbyte(spu_genb((vec_int4)vec_zero,quotient),4)); - quotient = spu_sel(quotient0, quotient, quo_pos); - - *quo = (vec_llong2)quotient; - - return ((vec_double2)result); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/remquof4.h b/Extras/simdmathlibrary/spu/simdmath/remquof4.h deleted file mode 100644 index 734df87da..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/remquof4.h +++ /dev/null @@ -1,191 +0,0 @@ -/* remquof4 - - 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. - */ -/* remquof4 - This function returns the same vector float result as - * remainderf4(). In addition a vector signed int is stored in - * *pquo, that contains the corresponding element values whose sign is - * the sign of xi / yi and whose magnitude is congruent modulo 2n to - * the magnitude of the integral quotient of xi / yi, where n is an - * implementation-defined integer - * greater than or equal to 3. - */ - -#ifndef ___SIMD_MATH_REMQUODF4_H___ -#define ___SIMD_MATH_REMQUODF4_H___ - -#include -#include - -static inline vector float -_remquof4(vector float x, vector float y, vector signed int *quo) -{ - vec_int4 n; - vec_int4 quotient; - vec_uint4 z, y2, y4; - vec_uint4 abs_x, abs_y, abs_2x, abs_8y; - vec_uint4 exp_x, exp_y; - vec_uint4 zero_x, zero_y; - // vec_uint4 logb_x, logb_y; - vec_uint4 mant_x, mant_y; - vec_uint4 not_ge, overflow, quo_pos, mask; - vec_uint4 result, result0, resultx, cnt, sign, bias; - vec_uint4 sign_mask = spu_splats((unsigned int)0x80000000); - vec_uint4 implied_1 = spu_splats((unsigned int)0x00800000); - vec_uint4 mant_mask = spu_splats((unsigned int)0x007FFFFF); - - abs_x = spu_andc((vec_uint4)x, sign_mask); - abs_y = spu_andc((vec_uint4)y, sign_mask); - - abs_8y = spu_add(abs_y, spu_splats((unsigned int)0x01800000)); /* abs_8y = (2^3) * abs_y */ - - sign = spu_and((vec_uint4)x, sign_mask); - - quo_pos = spu_cmpgt((vec_int4)spu_and(spu_xor((vec_uint4)x, (vec_uint4)y), sign_mask), -1); - - /* Compute abs_x = fmodf(abs_x, 8*abs_y). If y is greater than 0.125*SMAX - * (SMAX is the maximum representable float), then return abs_x. - */ - { - /* Determine ilogb of abs_x and abs_8y and - * extract the mantissas (mant_x, mant_y) - */ - exp_x = spu_rlmask(abs_x, -23); - exp_y = spu_rlmask(abs_8y, -23); - - resultx = spu_or(spu_cmpgt(abs_8y, abs_x), spu_cmpgt(abs_y, spu_splats((unsigned int)0x7E7FFFFF))); - - zero_x = spu_cmpeq(exp_x, 0); - // zero_y = spu_cmpeq(exp_y, 0); - zero_y = spu_cmpgt(implied_1, abs_y ); - - // logb_x = spu_add(exp_x, -127); - // logb_y = spu_add(exp_y, -127); - - mant_x = spu_andc(spu_sel(implied_1, abs_x, mant_mask), zero_x); - mant_y = spu_andc(spu_sel(implied_1, abs_8y, mant_mask), zero_y); - - /* Compute fixed point fmod of mant_x and mant_y. Set the flag, - * result0, to all ones if we detect that the final result is - * ever 0. - */ - result0 = spu_or(zero_x, zero_y); - - // n = spu_sub((vec_int4)logb_x, (vec_int4)logb_y); - n = spu_sub((vec_int4)exp_x, (vec_int4)exp_y); // (exp_x-127)-(exp_y-127)=exp_x-exp_y - mask = spu_cmpgt(n, 0); - - while (spu_extract(spu_gather(mask), 0)) { - z = spu_sub(mant_x, mant_y); - - result0 = spu_or(spu_and(spu_cmpeq(z, 0), mask), result0); - - mant_x = spu_sel(mant_x, - spu_sel(spu_add(mant_x, mant_x), - spu_add(z, z), - spu_cmpgt((vec_int4)z, -1)), - mask); - - n = spu_add(n, -1); - mask = spu_cmpgt(n, 0); - } - - z = spu_sub(mant_x, mant_y); - mant_x = spu_sel(mant_x, z, spu_cmpgt((vec_int4)z, -1)); - - result0 = spu_or(spu_cmpeq(mant_x, 0), result0); - - /* Convert the result back to floating point and restore - * the sign. If we flagged the result to be zero (result0), - * zero it. If we flagged the result to equal its input x, - * (resultx) then return x. - */ - cnt = spu_add(spu_cntlz(mant_x), -8); - - // hide hidden bit and shift left side zero - mant_x = spu_rl(spu_andc(mant_x, implied_1), (vec_int4)cnt); - - exp_y = spu_sub(exp_y, cnt); //adjust exponent - result0 = spu_orc(result0, spu_cmpgt((vec_int4)exp_y, 0)); /* zero denorm results */ - exp_y = spu_rl(exp_y, 23); - - result = spu_sel(exp_y, mant_x, mant_mask); - abs_x = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), abs_x, resultx); - result0 = spu_andc(result0, resultx); - } - - /* if (x >= 4*y) - * x -= 4*y - * quotient = 4 - * else - * quotient = 0 - */ - y4 = spu_andc(spu_add(abs_y, spu_splats((unsigned int)0x01000000)), zero_y); - - overflow = spu_cmpgt(abs_y, spu_splats((unsigned int)0x7EFFFFFF)); - not_ge = spu_or(spu_cmpgt(y4, abs_x), overflow); - - abs_x = spu_sel((vec_uint4)spu_sub((vec_float4)abs_x, (vec_float4)y4), abs_x, not_ge); - quotient = spu_andc(spu_splats((int)4), (vec_int4)not_ge); - - /* if (x >= 2*y - * x -= 2*y - * quotient += 2 - */ - y2 = spu_andc(spu_add(abs_y, implied_1), zero_y); - not_ge = spu_cmpgt(y2, abs_x); - - abs_x = spu_sel((vec_uint4)spu_sub((vec_float4)abs_x, (vec_float4)y2), abs_x, not_ge); - quotient = spu_sel(spu_add(quotient, 2), quotient, not_ge); - - /* if (2*x > y) - * x -= y - * if (2*x >= y) x -= y - */ - abs_2x = spu_add(abs_x, implied_1); - bias = spu_cmpgt(abs_2x, abs_y); - abs_x = spu_sel(abs_x, (vec_uint4)spu_sub((vec_float4)abs_x, (vec_float4)abs_y), bias); - quotient = spu_sub(quotient, (vec_int4)bias); - - bias = spu_andc(bias, spu_rlmaska((vec_uint4)spu_msub((vec_float4)abs_x, spu_splats(2.0f), (vec_float4)abs_y), -31)); - abs_x = spu_sel(abs_x, (vec_uint4)spu_sub((vec_float4)abs_x, (vec_float4)abs_y), bias); - quotient = spu_sub(quotient, (vec_int4)bias); - - /* Generate a correct final sign - */ - result = spu_sel(abs_x, ((vec_uint4){0,0,0,0}), result0); // reminder 0 - result = spu_xor(result, sign); // set sign - - quotient = spu_and(quotient, 7); - quotient = spu_sel(spu_sub(0, quotient), quotient, quo_pos); - - *quo = quotient; - - return ((vec_float4)result); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/rintd2.h b/Extras/simdmathlibrary/spu/simdmath/rintd2.h deleted file mode 100644 index 286b41690..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/rintd2.h +++ /dev/null @@ -1,72 +0,0 @@ -/* rintd2 - Round the input to the nearest integer according to - the current rounding mode. - 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 ___SIMD_MATH_RINTD2_H___ -#define ___SIMD_MATH_RINTD2_H___ - -#include -#include - -static inline vector double -_rintd2(vector double in) -{ - vec_ullong2 sign = ((vec_ullong2){0x8000000000000000ULL,0x8000000000000000ULL}); - vec_uint4 vec_norm = ((vec_uint4){0x00100000,0,0x00100000,0}); - vec_uint4 vec_bias = ((vec_uint4){0x43300000,0,0x43300000,0}); - vec_double2 addend, xx; - vec_uint4 abs_x; - vec_uint4 is_zerox; - vec_uint4 is_denorm; - vec_uint4 ofs; - - abs_x = spu_andc((vec_uint4)in, (vec_uint4)sign); - - // check denormalized - is_zerox = spu_cmpeq( abs_x, 0); - is_denorm = spu_cmpgt( vec_norm, abs_x ); - is_zerox = spu_and( is_zerox, spu_shuffle(is_zerox,is_zerox, ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}))); - is_denorm = spu_andc(is_denorm, is_zerox); - ofs = spu_and( vec_norm, is_denorm); - - xx = spu_or( in, (vec_double2)ofs ); - - /* Add 2^53 and then subtract 2^53 to affect a round to be performed by the - * hardware. Also preserve the input sign so that negative inputs that - * round to zero generate a -0.0. - */ - addend = (vec_double2)spu_and(vec_bias, spu_cmpgt( vec_bias, abs_x )); - addend = spu_sel(addend, in, sign); - - return spu_sel(spu_sub(spu_add(xx, addend), addend), in, sign); - - -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/rintf4.h b/Extras/simdmathlibrary/spu/simdmath/rintf4.h deleted file mode 100644 index db8fdccd0..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/rintf4.h +++ /dev/null @@ -1,54 +0,0 @@ -/* rintf4 - for each of four float slots, round to the nearest integer, - consistent with the current rounding model. - On SPU, the rounding mode for float is always towards zero. - 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 ___SIMD_MATH_RINTF4_H___ -#define ___SIMD_MATH_RINTF4_H___ - -#include -#include - -static inline vector float -_rintf4(vector float x) -{ - vector signed int xi; - vector unsigned int inrange; - - // Can convert to and from signed integer to truncate values in range [-2^31, 2^31). - // However, no truncation needed if exponent > 22. - - inrange = spu_cmpabsgt( (vector float)spu_splats(0x4b000000), x ); - - xi = spu_convts( x, 0 ); - - return spu_sel( x, spu_convtf( xi, 0 ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/roundd2.h b/Extras/simdmathlibrary/spu/simdmath/roundd2.h deleted file mode 100644 index fdd9bd586..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/roundd2.h +++ /dev/null @@ -1,78 +0,0 @@ -/* roundd2 - rounds to nearest integer value in floating point format. - 0.5 will be rounded to far from 0 - 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 ___SIMD_MATH_ROUNDD2_H___ -#define ___SIMD_MATH_ROUNDD2_H___ - -#include -#include - - -static inline vector double -_roundd2 (vector double in) -{ - vec_uchar16 splat_hi = ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_int4 exp, shift; - vec_uint4 sign = ((vec_uint4){ 0x80000000, 0, 0x80000000, 0}); - vec_uint4 or_mask, and_mask, mask, addend; - vec_double2 in_hi, out; - - /* Add 0.5 (fixed precision to eliminate rounding issues) - */ - in_hi = spu_shuffle(in, in, splat_hi); - exp = spu_and(spu_rlmask((vec_int4)in_hi, -20), 0x7FF); - - shift = spu_sub(((vec_int4){ 1022, 1043, 1022, 1043}), exp); - - addend = spu_and(spu_rlmask(((vec_uint4){ 0x100000, 0x80000000, 0x100000, 0x80000000}), shift), - spu_cmpgt((vec_uint4)spu_add(shift, -1), -33)); - - in = (vec_double2)spu_addx((vec_uint4)in, addend, spu_rlqwbyte(spu_genc((vec_uint4)in, addend), 4)); - - /* Truncate the result. - */ - in_hi = spu_shuffle(in, in, splat_hi); - exp = spu_and(spu_rlmask((vec_int4)in_hi, -20), 0x7FF); - - shift = spu_sub(((vec_int4){ 1023, 1043, 1023, 1043}), exp); - or_mask = spu_andc(spu_cmpgt(shift, 0), sign); - - and_mask = spu_rlmask(((vec_uint4){ 0xFFFFF, -1, 0xFFFFF, -1}), shift); - // mask = spu_or(spu_and(and_mask, spu_cmpgt(shift, -31)), or_mask); - mask = spu_or(spu_and(and_mask, spu_cmpgt(shift, -32)), or_mask); - - /* Apply the mask and return the result. - */ - out = spu_andc(in, (vec_double2)(mask)); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/roundf4.h b/Extras/simdmathlibrary/spu/simdmath/roundf4.h deleted file mode 100644 index b0f85fdb6..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/roundf4.h +++ /dev/null @@ -1,69 +0,0 @@ -/* roundf4 - for each of four float slots, round to the nearest integer, - halfway cases are rounded away form zero. - 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 ___SIMD_MATH_ROUNDF4_H___ -#define ___SIMD_MATH_ROUNDF4_H___ - -#include -#include - -static inline vector float -_roundf4(vector float in) -{ - vec_int4 exp; - vec_uint4 or_mask, and_mask, mask, addend; - vec_float4 out; - - /* Add 0.5 (fixed precision to eliminate rounding issues - */ - exp = spu_sub(125, spu_and(spu_rlmask((vec_int4)in, -23), 0xFF)); - - addend = spu_and(spu_rlmask( spu_splats((unsigned int)0x1000000), exp), - spu_cmpgt((vec_uint4)exp, -31)); - - in = (vec_float4)spu_add((vec_uint4)in, addend); - - - /* Truncate the result. - */ - exp = spu_sub(127, spu_and(spu_rlmask((vec_int4)in, -23), 0xFF)); - - or_mask = spu_cmpgt(exp, 0); - - and_mask = spu_rlmask(spu_splats((unsigned int)0x7FFFFF), exp); - - mask = spu_or(spu_and(and_mask, spu_cmpgt(exp, -31)), or_mask); - - out = spu_andc(in, (vec_float4)(mask)); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/rsqrtd2.h b/Extras/simdmathlibrary/spu/simdmath/rsqrtd2.h deleted file mode 100644 index 6c4dd3130..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/rsqrtd2.h +++ /dev/null @@ -1,105 +0,0 @@ -/* rsqrtd2 - for each of two double slots, compute reciprocal square root. - 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 ___SIMD_MATH_RSQRTD2_H___ -#define ___SIMD_MATH_RSQRTD2_H___ - -#include -#include - -#include -#include -#include - -// -// Handles exceptional values as follows: -// NaN -> NaN -// (+,-)0 -> (+,-)Inf -// +Inf -> +0 -// -Inf -> Nan -// -Finite -> Nan -// Denormal inputs are treated as zero. - -static inline vector double -_rsqrtd2 (vector double x) -{ - vec_ullong2 expmask, onemask, signmask, evenexp; - vec_double2 half, one, man, exp, nexp, y1, y2, y3, zero, inf, nan, result; - vec_float4 halff, onef, manf, y0f, y1f; - - expmask = spu_splats(0x7ff0000000000000ull); - onemask = spu_splats(0x0010000000000000ull); - signmask = spu_splats(0x8000000000000000ull); - onef = spu_splats(1.0f); - one = spu_extend( onef ); - halff = spu_splats(0.5f); - half = spu_extend( halff ); - - // Factor input ( mantissa x 2^exponent ) into ( mantissa x 2^(-i) ) and ( 2^(exponent+i) ) - // where i = 0 when exponent is even and i = 1 when exponent is odd. - // - // Compute reciprocal-square-root of second factor by finding -(exponent+i)/2: - // - // biased_exp = 1023 + exponent - // new_biased_exp = 1023 - (exponent+i)/2 - // = 1023 - (biased_exp-1023+i)/2 - // = (3069 - (biased_exp+i)) / 2 - - evenexp = spu_and( (vec_ullong2)x, onemask ); - man = spu_sel( x, (vec_double2)spu_add( spu_splats(0x3fe00000u), (vec_uint4)evenexp ), expmask ); - - exp = spu_and( x, (vec_double2)expmask ); - nexp = spu_or( exp, (vec_double2)onemask ); - nexp = (vec_double2)spu_rlmask( spu_sub( (vec_uint4)spu_splats(0xbfd0000000000000ull), (vec_uint4)nexp ), -1 ); - - // Compute mantissa part in single precision. - // Convert back to double and multiply with 2^(-(exponent+i)/2), then - // do two Newton-Raphson steps for full precision. - - manf = spu_roundtf( man ); - y0f = spu_rsqrte( manf ); - y1f = spu_madd( spu_mul( y0f, halff ), spu_nmsub( y0f, spu_mul( y0f, manf ), onef ), y0f ); - y1 = spu_mul( spu_extend( y1f ), nexp ); - y2 = spu_madd( spu_mul( y1, half ), spu_nmsub( y1, spu_mul( y1, x ), one ), y1 ); - y3 = spu_madd( spu_mul( y2, half ), spu_nmsub( y2, spu_mul( y2, x ), one ), y2 ); - - // Choose iterated result or special value. - - zero = spu_and( x, (vec_double2)signmask ); - inf = spu_sel( (vec_double2)expmask, x, signmask ); - nan = (vec_double2)spu_splats(0x7ff8000000000000ull); - - result = spu_sel( y3, zero, _isinfd2 ( x ) ); - result = spu_sel( result, nan, _signbitd2 ( x ) ); - result = spu_sel( result, inf, _is0denormd2 ( x ) ); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/rsqrtf4.h b/Extras/simdmathlibrary/spu/simdmath/rsqrtf4.h deleted file mode 100644 index 605a479db..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/rsqrtf4.h +++ /dev/null @@ -1,51 +0,0 @@ -/* rsqrtf4 - for each of four float slots, compute reciprocal square root. - 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. - */ -// Undefined if input < 0. - -#ifndef ___SIMD_MATH_RSQRTF4_H___ -#define ___SIMD_MATH_RSQRTF4_H___ - -#include -#include - -static inline vector float -_rsqrtf4 (vector float x) -{ - // Reciprocal square root estimate and 1 Newton-Raphson iteration. - - vec_float4 y0, y0x, y0half; - vec_float4 oneish = (vec_float4)spu_splats(0x3f800001); - - y0 = spu_rsqrte( x ); - y0x = spu_mul( y0, x ); - y0half = spu_mul( y0, spu_splats(0.5f) ); - return spu_madd( spu_nmsub( y0, y0x, oneish ), y0half, y0 ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/scalbllnd2.h b/Extras/simdmathlibrary/spu/simdmath/scalbllnd2.h deleted file mode 100644 index b51063e0e..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/scalbllnd2.h +++ /dev/null @@ -1,268 +0,0 @@ -/* scalbllnd2 - Multiply Double by 2 Raised to its Power - For large elements of ex (overflow), returns HUGE_VALF - For small elements of ex (underflow), returns 0. - 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 ___SIMD_MATH_SCALBLLND2_H___ -#define ___SIMD_MATH_SCALBLLND2_H___ - -#undef _SCALBLLND2_ROUND - -#include -#include - -static inline vector double -_scalbllnd2(vector double x, vector signed long long ex) -{ - vec_int4 e1, e2; - vec_int4 min = spu_splats(-2099); - // vec_int4 min = spu_splats(-2044); - vec_int4 max = spu_splats( 2098); - // vec_int4 max = spu_splats( 2046); - vec_uint4 cmp_min, cmp_max; - vec_uint4 shift = ((vec_uint4){20, 32, 20, 32}); - vec_double2 f1, f2; - vec_double2 out; - vec_double2 in = x; - vec_int4 exp_in; - - // check input data range - vec_int4 exp0 = spu_shuffle( (vec_int4)ex, (vec_int4)ex, ((vec_uchar16){4,5,6,7, 4,5,6,7, 12,13,14,15, 12,13,14,15})); - vec_int4 dmy = spu_shuffle( (vec_int4)spu_splats(0x10000), (vec_int4)ex, ((vec_uchar16){16,1,2,3, 16,1,2,3, 24,1,2,3,24,1,2,3})); - // (-)0xFFFFFFFF80000000 or (+)0x000000007FFFFFFF - vec_int4 msk_range = ((vec_int4){0,0x80000000, 0,0x80000000}); - vec_int4 inrange = spu_addx( (vec_int4)ex, msk_range, spu_rlqwbyte(spu_genc((vec_int4)ex, msk_range), 4)); - inrange = (vec_int4)spu_cmpeq( inrange, 0 ); - inrange = spu_shuffle(inrange,inrange,((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - // select dummy over ranged data or input data - vec_int4 exp = spu_sel( dmy, exp0, (vec_uint4)inrange); - exp_in = exp; - /* Clamp the specified exponent to the range -2044 to 2046. - */ - cmp_min = spu_cmpgt(exp, min); - cmp_max = spu_cmpgt(exp, max); - exp = spu_sel(min, exp, cmp_min); - exp = spu_sel(exp, max, cmp_max); - - /* Generate the factors f1 = 2^e1 and f2 = 2^e2 - */ - e1 = spu_rlmaska(exp, -1); - e2 = spu_sub(exp, e1); - - f1 = (vec_double2)spu_sl(spu_add(e1, 1023), shift); - - vec_double2 otmp = spu_mul(x, f1); - vec_uint4 fpscr1 = spu_mffpscr(); - - f2 = (vec_double2)spu_sl(spu_add(e2, 1023), shift); - - out = spu_mul(otmp, f2); - vec_uint4 fpscr2 = spu_mffpscr(); - - /* Compute the product x * 2^e1 * 2^e2 - */ - // out = spu_mul(spu_mul(x, f1), f2); - - // check floating point register DENORM bit - vec_uint4 fpscr0, fpscr; - fpscr0 = spu_or(fpscr1, fpscr2); - fpscr = spu_shuffle(fpscr0, fpscr0, ((vec_uchar16){0x80,0x80,0x80,0x80,0x80,0x80,10,0x80,0x80,0x80,6,0x80,0x80,0x80,0x80,0x80})); - fpscr = spu_or(fpscr0, fpscr); - if ( __builtin_expect(spu_extract(fpscr, 1) == 0, 1) ) return out; - - - ////////////////////// - // Denormalized calc// - ////////////////////// - - vec_uchar16 splat_msb = { 0,0,0,0,0,0,0,0, 8,8,8,8,8,8,8,8}; - vec_uint4 signmask = ((vec_uint4){0x80000000,0,0x80000000,0}); - vec_int4 zeros = spu_splats(0); - vec_uchar16 msk_64_eq = ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}); - - //check input was zero - vec_uint4 x_body = spu_and( (vec_uint4)x, ((vec_uint4){0x7FFFFFFF,-1,0x7FFFFFFF,-1})); - vec_uint4 x_zero = spu_cmpeq( x_body, (vec_uint4)zeros ); - x_zero = spu_and( x_zero, spu_shuffle(x_zero,x_zero,msk_64_eq)); - - // check Denormalized input - vec_int4 cnt_zero = (vec_int4)spu_cntlz(x_body); - vec_uint4 is_den = (vec_uint4)spu_cmpgt(cnt_zero, 11); // Denormalized data 000XXXXX XXXXXXXX - is_den = spu_shuffle( is_den, is_den, splat_msb); - is_den = spu_sel(is_den, (vec_uint4)zeros, x_zero); // exclude zero from denormalized - - // count 0bits for 64bit - vec_uint4 cnt_ex = (vec_uint4)spu_cmpgt(cnt_zero, 31); // Denormalized data 00000000 XXXXXXXX - vec_int4 cnt_z = spu_shuffle( cnt_zero, cnt_zero, ((vec_uchar16){4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11})); - cnt_zero = spu_add(cnt_zero, spu_sel(zeros, cnt_z, cnt_ex)); - cnt_zero = spu_shuffle(cnt_zero, cnt_zero, ((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - // extract each 64bit data - x_body = spu_and( (vec_uint4)x, ((vec_uint4){0x000FFFFF,-1,0x000FFFFF,-1})); - vec_uint4 mant0 = spu_shuffle(x_body, x_body, ((vec_uchar16){0,1, 2, 3, 4, 5, 6, 7,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 mant1 = spu_shuffle(x_body, x_body, ((vec_uchar16){8,9,10,11,12,13,14,15,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 sign = (vec_uint4)spu_rlmaska((vec_int4)exp_in, -31); - sign = spu_shuffle(sign, sign, splat_msb); - - // set max shift count - vec_int4 sht = spu_add( cnt_zero, ((vec_int4){-11,-64,-11,-64})); - - // denorm & exp+ shift left - vec_uint4 cmp = spu_cmpgt( sht, exp_in); - vec_int4 sht_l = spu_sel(sht, exp_in, cmp); - int shtl0 = spu_extract(sht_l, 0); - int shtl1 = spu_extract(sht_l, 2); - vec_uint4 mant0l = spu_slqwbytebc( spu_slqw(mant0, shtl0), shtl0 ); - vec_uint4 mant1l = spu_slqwbytebc( spu_slqw(mant1, shtl1), shtl1 ); - vec_int4 expp = spu_shuffle(spu_sub(exp_in, sht_l), zeros, ((vec_uchar16){0,1,2,3,0,1,2,3,8,9,10,11,8,9,10,11})); - - exp0 = spu_sel( expp, exp_in, sign ); // select plus or minus caluc - vec_uint4 mantl = spu_shuffle( mant0l, mant1l, ((vec_uchar16){0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23})); - vec_uint4 mant = spu_sel( mantl, (vec_uint4)x, sign); - exp = spu_sel( exp_in, exp0, is_den ); // select denormalized - x = (vec_double2)spu_sel( (vec_uint4)x, mant, is_den); - - - ////////////////////////////////////////////////////////////////////////// - // from ldexpf4 - vec_int4 expmask = ((vec_int4){0x7FF00000, 0, 0x7FF00000, 0}); - e1 = spu_and((vec_int4)x, expmask); - e2 = spu_rlmask(e1,-20); - - vec_uchar16 maxmask = (vec_uchar16)spu_cmpgt(exp, 2046); - vec_uchar16 minmask = (vec_uchar16)spu_cmpgt(spu_splats(-2044), exp); - minmask = spu_or (minmask, (vec_uchar16)x_zero); - - vec_int4 esum = spu_add(e2, exp); - - maxmask = spu_or (maxmask, (vec_uchar16)spu_cmpgt(esum, 2046)); - maxmask = spu_shuffle(maxmask, maxmask, splat_msb); - // maxmask = spu_and(maxmask, ((vec_uchar16)spu_splats((long long)0x7FFFFFFFFFFFFFFFLL))); - minmask = spu_or (minmask, (vec_uchar16)spu_cmpgt(zeros, esum)); - minmask = spu_shuffle(minmask, minmask, splat_msb); - - // check denorm - vec_uint4 mxmask = spu_and(spu_cmpgt(e2, 0), ((vec_uint4){0x00100000,0,0x00100000,0})); // not denorm - vec_int4 esum2 = spu_sub(esum, (vec_int4)spu_rlmask(mxmask, -20)); // reverse to norm - vec_uint4 mrange = spu_and(spu_cmpgt(zeros, esum2), spu_cmpgt(esum2, -55)); // denorm range - mrange = spu_shuffle(mrange, mrange, splat_msb); - - vec_int4 sht_r = spu_sel(spu_splats(-54), esum2, spu_cmpgt(esum2, spu_splats(-54)) ); - vec_int4 sht_rh = spu_add( sht_r, ((vec_int4){7,7,7,7})); - - x_body = spu_or( x_body, mxmask ); - mant0 = spu_shuffle(x_body, x_body, ((vec_uchar16){0,1, 2, 3, 4, 5, 6, 7,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - mant1 = spu_shuffle(x_body, x_body, ((vec_uchar16){8,9,10,11,12,13,14,15,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 mant0r = spu_rlmaskqwbytebc( spu_rlmaskqw(mant0, spu_extract(sht_r, 0)), spu_extract(sht_rh,0) ); - vec_uint4 mant1r = spu_rlmaskqwbytebc( spu_rlmaskqw(mant1, spu_extract(sht_r, 2)), spu_extract(sht_rh,2) ); - -#ifdef _SCALBLLND2_ROUND - // check current round mode - fpscr = spu_shuffle(fpscr2, fpscr2, ((vec_uchar16){0x80,0x80,0x80,0x80,0,1,2,3,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - fpscr0 = spu_and(fpscr, ((vec_uint4){0,0xc00,0,0})); - fpscr1 = spu_and(fpscr, ((vec_uint4){0,0x300,0,0})); - - // prepare round data - vec_uint4 rnd0 = spu_slqwbytebc( spu_slqw( mant0r, 31), 31); - vec_uint4 rnd1 = spu_slqwbytebc( spu_slqw( mant1r, 31), 31); - vec_uint4 rnd0w = (vec_uint4)spu_cntb( (vec_uchar16)rnd0 ); - vec_uint4 rnd1w = (vec_uint4)spu_cntb( (vec_uchar16)rnd1 ); - rnd0w = spu_or( spu_slqwbyte(rnd0w,4), spu_slqwbyte(rnd0w,8)); - rnd1w = spu_or( spu_slqwbyte(rnd1w,4), spu_slqwbyte(rnd1w,8)); - rnd0 = spu_or( rnd0, rnd0w); - rnd1 = spu_or( rnd1, rnd1w); - - // nearest - // check half - vec_uint4 hit0 = spu_cmpeq(rnd0, ((vec_uint4){0,0xc0000000,0,0})); //odd + round out - vec_uint4 hit1 = spu_cmpeq(rnd1, ((vec_uint4){0,0xc0000000,0,0})); //odd + round out - vec_uint4 add0 = spu_sel((vec_uint4)zeros, ((vec_uint4){0,1,0,0}), hit0); - vec_uint4 add1 = spu_sel((vec_uint4)zeros, ((vec_uint4){0,1,0,0}), hit1); - // check greater than half - rnd0 = spu_and( rnd0, ((vec_uint4){0,0x7FFFFFFF,0,0})); - rnd1 = spu_and( rnd1, ((vec_uint4){0,0x7FFFFFFF,0,0})); - hit0 = spu_cmpgt(rnd0, ((vec_uint4){0,0x40000000,0,0})); - hit1 = spu_cmpgt(rnd1, ((vec_uint4){0,0x40000000,0,0})); - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - // select if fp0 - add0 = spu_sel((vec_uint4)zeros, add0, spu_cmpeq(fpscr0, (vec_uint4)zeros)); - add1 = spu_sel((vec_uint4)zeros, add1, spu_cmpeq(fpscr1, (vec_uint4)zeros)); - - // toward zero do nothing - // upward - sign = spu_rlmaska((vec_uint4)in, -31); - vec_uint4 sign0 = spu_shuffle(sign, sign, ((vec_uchar16){0x80,0x80,0x80,0x80,0,0,0,0,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 sign1 = spu_shuffle(sign, sign, ((vec_uchar16){0x80,0x80,0x80,0x80,8,8,8,8,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80})); - vec_uint4 hit0w = spu_cmpgt(rnd0, ((vec_uint4){0,0,0,0})); - vec_uint4 hit1w = spu_cmpgt(rnd1, ((vec_uint4){0,0,0,0})); - - hit0 = spu_and(hit0w, spu_nor(sign0, sign0)); - hit1 = spu_and(hit1w, spu_nor(sign1, sign1)); - hit0 = spu_and(hit0, spu_cmpeq(fpscr0, ((vec_uint4){0,0x800,0,0}))); - hit1 = spu_and(hit1, spu_cmpeq(fpscr1, ((vec_uint4){0,0x200,0,0}))); - // select if fp2 - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - - // downward - hit0 = spu_and(hit0w, sign0); - hit1 = spu_and(hit1w, sign1); - hit0 = spu_and(hit0, spu_cmpeq(fpscr0, ((vec_uint4){0,0xc00,0,0}))); - hit1 = spu_and(hit1, spu_cmpeq(fpscr1, ((vec_uint4){0,0x300,0,0}))); - // select if fp3 - add0 = spu_sel(add0, ((vec_uint4){0,1,0,0}), hit0); - add1 = spu_sel(add1, ((vec_uint4){0,1,0,0}), hit1); - - // calc round - mant0r = spu_addx(mant0r, add0, spu_rlqwbyte(spu_genc(mant0r, add0), 4)); - mant1r = spu_addx(mant1r, add1, spu_rlqwbyte(spu_genc(mant1r, add1), 4)); - -#endif // _SCALBLLND2_ROUND - - vec_uint4 mantr = spu_shuffle( mant0r, mant1r, ((vec_uchar16){0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23})); - - // select right answer - x = spu_sel(x, (vec_double2)spu_sl(esum,20), (vec_ullong2)expmask); - x = spu_sel(x, (vec_double2)zeros, (vec_ullong2)minmask); - x = spu_sel(x, (vec_double2)spu_splats((long long)0x7FEFFFFFFFFFFFFFLL), (vec_ullong2)maxmask); - - out = (vec_double2)spu_sel((vec_uint4)x , mantr, mrange); - - // check Infinity,NaN - vec_uint4 is_inf = spu_cmpeq(e1, expmask); - is_inf = spu_and( is_inf, spu_shuffle(is_inf,is_inf,msk_64_eq)); - out = (vec_double2)spu_sel((vec_uint4)out , (vec_uint4)in, is_inf); - - out = spu_sel(out, in, (vec_ullong2)signmask); - return out; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/scalbnf4.h b/Extras/simdmathlibrary/spu/simdmath/scalbnf4.h deleted file mode 100644 index f13826675..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/scalbnf4.h +++ /dev/null @@ -1,75 +0,0 @@ -/* scalbnf4 computes x * 2^exp. This function is computed without - the assistence of any floating point operations and as such does - not set any floating point exceptions. - 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 ___SIMD_MATH_SCALBNF4_H___ -#define ___SIMD_MATH_SCALBNF4_H___ - -#include -#include - -static inline vector float -_scalbnf4(vector float x, vector signed int n) -{ - vec_int4 x_exp; - vec_uint4 zero, overflow; - vec_uint4 exp_mask = spu_splats((unsigned int)0x7F800000); - vec_float4 out; - - /* Extract exponent from x. If the exponent is 0, then - * x is either 0 or a denorm and x*2^exp is a zero. - */ - x_exp = spu_and(spu_rlmask((vec_int4)x, -23), 0xFF); - - zero = spu_cmpeq(x_exp, 0); - - /* Compute the expected exponent and determine if the - * result is within range. - */ - x_exp = spu_add(n, x_exp); - - zero = spu_orc(zero, spu_cmpgt(x_exp, 0)); - - // overflow = spu_rlmask(spu_cmpgt(x_exp, 255), -1); - overflow = spu_cmpgt(x_exp, 255); - - /* Merge the expect exponent with x's mantissa. Zero the - * result if underflow and force to max if overflow. - */ - out = spu_sel(x, (vec_float4)spu_rl(x_exp, 23), exp_mask); - out = spu_andc(out, (vec_float4)zero); - out = spu_or(out, (vec_float4)overflow); - // add sign bit - out = spu_sel(out, x, spu_splats((unsigned int)0x80000000)); - - return out; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/signbitd2.h b/Extras/simdmathlibrary/spu/simdmath/signbitd2.h deleted file mode 100644 index 7cdbb84c3..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/signbitd2.h +++ /dev/null @@ -1,48 +0,0 @@ -/* signbitd2 - for each of two double slots, if input has negative sign bit return mask of ones, else 0 - 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 ___SIMD_MATH_SIGNBITD2_H___ -#define ___SIMD_MATH_SIGNBITD2_H___ - -#include -#include - -static inline vector unsigned long long -_signbitd2 (vector double x) -{ - vec_ullong2 cmp; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - - cmp = (vec_ullong2)spu_cmpgt( spu_splats(0), (vec_int4)x ); - cmp = spu_shuffle( cmp, cmp, even ); - - return cmp; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/signbitf4.h b/Extras/simdmathlibrary/spu/simdmath/signbitf4.h deleted file mode 100644 index 7fbda7a02..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/signbitf4.h +++ /dev/null @@ -1,42 +0,0 @@ -/* signbitf4 - for each element of vector x, return a mask of ones if x' has signbit one, zero otherwise - 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 ___SIMD_MATH_SIGNBITF4_H___ -#define ___SIMD_MATH_SIGNBITF4_H___ - -#include -#include - -static inline vector unsigned int -_signbitf4 (vector float x) -{ - return spu_cmpgt( spu_splats(0), (vec_int4)x ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sincosd2.h b/Extras/simdmathlibrary/spu/simdmath/sincosd2.h deleted file mode 100644 index f8482cde3..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sincosd2.h +++ /dev/null @@ -1,149 +0,0 @@ -/* sind2 and cosd2 - 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 ___SIMD_MATH__SINCOSD2_H___ -#define ___SIMD_MATH__SINCOSD2_H___ - -#include -#include - -#include -#include -#include -#include - -// -// Computes the sine of the each of two double slots. -// -static inline void -_sincosd2(vector double x, vec_double2 *s, vec_double2 *c) -{ - vec_double2 xl,xl2,xl3; - vec_double2 nan = (vec_double2)spu_splats(0x7ff8000000000000ull); - vec_uchar16 copyEven = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_double2 tiny = (vec_double2)spu_splats(0x3e40000000000000ull); - vec_double2 ts, tc; - - // Range reduction using : x = angle * TwoOverPi; - // - xl = spu_mul(x, spu_splats(0.63661977236758134307553505349005744)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(x))*sign(x)) - // - xl = spu_add(xl,spu_sel(spu_splats(0.5),xl,spu_splats(0x8000000000000000ull))); - vec_float4 xf = spu_roundtf(xl); - vec_int4 q = spu_convts(xf,0); - q = spu_shuffle(q,q,copyEven); - - - // Compute an offset based on the quadrant that the angle falls in - // - vec_int4 offsetSin = spu_and(q,spu_splats(0x3)); - vec_int4 offsetCos = spu_add(spu_splats(1),offsetSin); - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = spu_convtf(q,0); - vec_double2 qd = spu_extend(qf); - vec_double2 p1 = spu_nmsub(qd,spu_splats(__SINCOSD_KC1),x); - xl = spu_nmsub(qd,spu_splats(__SINCOSD_KC2),p1); - - // Check if |xl| is a really small number - // - vec_double2 absXl = (vec_double2)spu_andc((vec_ullong2)xl, spu_splats(0x8000000000000000ull)); - vec_ullong2 isTiny = (vec_ullong2)_isgreaterd2(tiny,absXl); - - // Compute x^2 and x^3 - // - xl2 = spu_mul(xl,xl); - xl3 = spu_mul(xl2,xl); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((((((c0 * xl2 + c1) * xl2 + c2) * xl2 + c3) * xl2 + c4) * xl2 + c5), and - // sx = xl + xl3 * (((((s0 * xl2 + s1) * xl2 + s2) * xl2 + s3) * xl2 + s4) * xl2 + s5) - // - - vec_double2 ct0 = spu_mul(xl2,xl2); - vec_double2 ct1 = spu_madd(spu_splats(__SINCOSD_CC0),xl2,spu_splats(__SINCOSD_CC1)); - vec_double2 ct2 = spu_madd(spu_splats(__SINCOSD_CC2),xl2,spu_splats(__SINCOSD_CC3)); - vec_double2 ct3 = spu_madd(spu_splats(__SINCOSD_CC4),xl2,spu_splats(__SINCOSD_CC5)); - vec_double2 st1 = spu_madd(spu_splats(__SINCOSD_SC0),xl2,spu_splats(__SINCOSD_SC1)); - vec_double2 st2 = spu_madd(spu_splats(__SINCOSD_SC2),xl2,spu_splats(__SINCOSD_SC3)); - vec_double2 st3 = spu_madd(spu_splats(__SINCOSD_SC4),xl2,spu_splats(__SINCOSD_SC5)); - vec_double2 ct4 = spu_madd(ct2,ct0,ct3); - vec_double2 st4 = spu_madd(st2,ct0,st3); - vec_double2 ct5 = spu_mul(ct0,ct0); - - vec_double2 ct6 = spu_madd(ct5,ct1,ct4); - vec_double2 st6 = spu_madd(ct5,st1,st4); - - vec_double2 cx = spu_madd(ct6,xl2,spu_splats(1.0)); - vec_double2 sx = spu_madd(st6,xl3,xl); - - // Small angle approximation: sin(tiny) = tiny, cos(tiny) = 1.0 - // - sx = spu_sel(sx,xl,isTiny); - cx = spu_sel(cx,spu_splats(1.0),isTiny); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vec_ullong2 sinMask = (vec_ullong2)spu_cmpeq(spu_and(offsetSin,(int)0x1),spu_splats((int)0)); - vec_ullong2 cosMask = (vec_ullong2)spu_cmpeq(spu_and(offsetCos,(int)0x1),spu_splats((int)0)); - ts = spu_sel(cx,sx,sinMask); - tc = spu_sel(cx,sx,cosMask); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - sinMask = (vec_ullong2)spu_cmpeq(spu_and(offsetSin,(int)0x2),spu_splats((int)0)); - sinMask = spu_shuffle(sinMask,sinMask,copyEven); - ts = spu_sel((vec_double2)spu_xor(spu_splats(0x8000000000000000ull),(vec_ullong2)ts),ts,sinMask); - - cosMask = (vec_ullong2)spu_cmpeq(spu_and(offsetCos,(int)0x2),spu_splats((int)0)); - cosMask = spu_shuffle(cosMask,cosMask,copyEven); - tc = spu_sel((vec_double2)spu_xor(spu_splats(0x8000000000000000ull),(vec_ullong2)tc),tc,cosMask); - - // if input = +/-Inf return NAN - // - ts = spu_sel(ts, nan, _isnand2 (x)); - tc = spu_sel(tc, nan, _isnand2 (x)); - - // if input = 0 or denorm return 'result0' - // - vec_ullong2 zeroMask = _is0denormd2 (x); - ts = spu_sel(ts,x,zeroMask); - tc = spu_sel(tc,spu_splats(1.0),zeroMask); - - *s = ts; - *c = tc; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sincosf4.h b/Extras/simdmathlibrary/spu/simdmath/sincosf4.h deleted file mode 100644 index db9cf8df9..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sincosf4.h +++ /dev/null @@ -1,113 +0,0 @@ -/* sincosf4 - 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 ___SIMD_MATH_SINCOSF4_H___ -#define ___SIMD_MATH_SINCOSF4_H___ - -#include -#include - -#include - -// -// Computes both the sine and cosine of the all four slots of x -// by using a polynomial approximation. -// -static inline void -_sincosf4 (vector float x, vector float *s, vector float *c) -{ - vec_float4 xl,xl2,xl3; - vec_int4 q; - vec_int4 offsetSin, offsetCos; - vec_float4 ts, tc; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = spu_mul(x, spu_splats(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - xl = spu_add(xl,spu_sel(spu_splats(0.5f),xl,spu_splats(0x80000000))); - q = spu_convts(xl,0); - - - // Compute the offset based on the quadrant that the angle falls in. - // Add 1 to the offset for the cosine. - // - offsetSin = spu_and(q,spu_splats((int)0x3)); - offsetCos = spu_add(spu_splats(1),offsetSin); - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = spu_convtf(q,0); - vec_float4 p1 = spu_nmsub(qf,spu_splats(__SINCOSF_KC1),x); - xl = spu_nmsub(qf,spu_splats(__SINCOSF_KC2),p1); - - // Compute x^2 and x^3 - // - xl2 = spu_mul(xl,xl); - xl3 = spu_mul(xl2,xl); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vec_float4 ct1 = spu_madd(spu_splats(__SINCOSF_CC0),xl2,spu_splats(__SINCOSF_CC1)); - vec_float4 st1 = spu_madd(spu_splats(__SINCOSF_SC0),xl2,spu_splats(__SINCOSF_SC1)); - - vec_float4 ct2 = spu_madd(ct1,xl2,spu_splats(__SINCOSF_CC2)); - vec_float4 st2 = spu_madd(st1,xl2,spu_splats(__SINCOSF_SC2)); - - vec_float4 cx = spu_madd(ct2,xl2,spu_splats(1.0f)); - vec_float4 sx = spu_madd(st2,xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vec_uint4 sinMask = spu_cmpeq(spu_and(offsetSin,(int)0x1),spu_splats((int)0)); - vec_uint4 cosMask = spu_cmpeq(spu_and(offsetCos,(int)0x1),spu_splats((int)0)); - ts = spu_sel(cx,sx,sinMask); - tc = spu_sel(cx,sx,cosMask); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - sinMask = spu_cmpeq(spu_and(offsetSin,(int)0x2),spu_splats((int)0)); - cosMask = spu_cmpeq(spu_and(offsetCos,(int)0x2),spu_splats((int)0)); - - ts = spu_sel((vec_float4)spu_xor(spu_splats(0x80000000),(vec_uint4)ts),ts,sinMask); - tc = spu_sel((vec_float4)spu_xor(spu_splats(0x80000000),(vec_uint4)tc),tc,cosMask); - - *s = ts; - *c = tc; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sind2.h b/Extras/simdmathlibrary/spu/simdmath/sind2.h deleted file mode 100644 index a2f4a17b2..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sind2.h +++ /dev/null @@ -1,49 +0,0 @@ -/* sind2 - 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 ___SIMD_MATH_SIND2_H___ -#define ___SIMD_MATH_SIND2_H___ - -#include -#include - -#include - -// -// Computes the sine of the each of two double slots. -// -static inline vector double -_sind2 (vector double x) -{ - vec_double2 s, c; - _sincosd2(x, &s, &c); - return s; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sinf4.h b/Extras/simdmathlibrary/spu/simdmath/sinf4.h deleted file mode 100644 index b2f1aac0b..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sinf4.h +++ /dev/null @@ -1,49 +0,0 @@ -/* sinf4 - 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 ___SIMD_MATH_SINF4_H___ -#define ___SIMD_MATH_SINF4_H___ - -#include -#include - -#include - -// -// Computes the sine of each of the four slots by using a polynomia approximation -// -static inline vector float -_sinf4 (vector float x) -{ - vec_float4 s, c; - _sincosf4(x, &s, &c); - return s; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sqrtd2.h b/Extras/simdmathlibrary/spu/simdmath/sqrtd2.h deleted file mode 100644 index 60a17d23d..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sqrtd2.h +++ /dev/null @@ -1,113 +0,0 @@ -/* sqrtd2 - for each of two double slots, compute square root. - 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 ___SIMD_MATH_SQRTD2_H___ -#define ___SIMD_MATH_SQRTD2_H___ - -#include -#include - -#include -#include -#include - -// -// Handles exceptional values as follows: -// NaN -> NaN -// -Inf -> Nan -// -Finite -> Nan -// Denormal inputs are treated as zero. - -static inline vector double -_sqrtd2 (vector double x) -{ - vec_ullong2 expmask, onemask, signmask, evenexp; - vec_double2 half, one, man, exp, nexp, y1, y2, y3, zero, inf, nan, neg, result; - vec_float4 halff, onef, manf, y0f, y1f; - - expmask = spu_splats(0x7ff0000000000000ull); - onemask = spu_splats(0x0010000000000000ull); - signmask = spu_splats(0x8000000000000000ull); - onef = spu_splats(1.0f); - one = spu_extend( onef ); - halff = spu_splats(0.5f); - half = spu_extend( halff ); - - // First compute reciprocal square root. - // Factor input ( mantissa x 2^exponent ) into ( mantissa x 2^(-i) ) and ( 2^(exponent+i) ) - // where i = 0 when exponent is even and i = 1 when exponent is odd. - // - // Compute reciprocal-square-root of second factor by finding -(exponent+i)/2: - // - // biased_exp = 1023 + exponent - // new_biased_exp = 1023 - (exponent+i)/2 - // = 1023 - (biased_exp-1023+i)/2 - // = (3069 - (biased_exp+i)) / 2 - - evenexp = spu_and( (vec_ullong2)x, onemask ); - man = spu_sel( x, (vec_double2)spu_add( spu_splats(0x3fe00000u), (vec_uint4)evenexp ), expmask ); - - exp = spu_and( x, (vec_double2)expmask ); - nexp = spu_or( exp, (vec_double2)onemask ); - nexp = (vec_double2)spu_rlmask( spu_sub( (vec_uint4)spu_splats(0xbfd0000000000000ull), (vec_uint4)nexp ), -1 ); - - // Compute mantissa part in single precision. - // Convert back to double and multiply with 2^(-(exponent+i)/2), then - // do two Newton-Raphson steps for full precision. - - manf = spu_roundtf( man ); - y0f = spu_rsqrte( manf ); - y1f = spu_madd( spu_mul( y0f, halff ), spu_nmsub( y0f, spu_mul( y0f, manf ), onef ), y0f ); - y1 = spu_mul( spu_extend( y1f ), nexp ); - y2 = spu_madd( spu_mul( y1, half ), spu_nmsub( y1, spu_mul( y1, x ), one ), y1 ); - y3 = spu_madd( spu_mul( y2, half ), spu_nmsub( y2, spu_mul( y2, x ), one ), y2 ); - - // Multiply by input to get square root. - - y3 = spu_mul( y3, x ); - - // Choose iterated result or special value. - - zero = spu_and( x, (vec_double2)signmask ); - inf = (vec_double2)expmask; - nan = (vec_double2)spu_splats(0x7ff8000000000000ull); - - neg = spu_and(x, (vec_double2)spu_splats(0x8000000000000000ull)); - neg = spu_shuffle(neg, neg, ((vec_uchar16){0,0,0,0,0,0,0,0,8,8,8,8,8,8,8,8})); - neg = (vec_double2)spu_rlmaska((vec_int4)neg, -31); - - result = spu_sel( y3, inf, _isinfd2 ( x ) ); - result = spu_sel( result, nan, _isnand2 ( x ) ); - result = spu_sel( result, nan, (vec_ullong2)neg ); - result = spu_sel( result, zero, _is0denormd2 ( x ) ); - - return result; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/sqrtf4.h b/Extras/simdmathlibrary/spu/simdmath/sqrtf4.h deleted file mode 100644 index ae3f8f629..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/sqrtf4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* sqrtf4 - for each of four float slots, compute square root. - 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. - */ - -// Undefined if input < 0. - -#ifndef ___SIMD_MATH_SQRTF4_H___ -#define ___SIMD_MATH_SQRTF4_H___ - -#include -#include - -static inline vector float -_sqrtf4 (vector float x) -{ - // Reciprocal square root estimate and 1 Newton-Raphson iteration. - - vec_float4 y0, y0x, y0xhalf; - vec_float4 oneish = (vec_float4)spu_splats(0x3f800001); - - y0 = spu_rsqrte( x ); - y0x = spu_mul( y0, x ); - y0xhalf = spu_mul( y0x, spu_splats(0.5f) ); - return spu_madd( spu_nmsub( y0, y0x, oneish ), y0xhalf, y0x ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/tand2.h b/Extras/simdmathlibrary/spu/simdmath/tand2.h deleted file mode 100644 index c96907a21..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/tand2.h +++ /dev/null @@ -1,125 +0,0 @@ -/* tand2 - 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 ___SIMD_MATH_TAND2_H___ -#define ___SIMD_MATH_TAND2_H___ - -#include -#include - -#include -#include -#include -#include - -#define __TAND_CC0 -0.00020844956382258822 -#define __TAND_CC1 0.02334489464693293380 -#define __TAND_CC2 -0.46161689768996201755 -#define __TAND_SC0 -0.00000748373924372997 -#define __TAND_SC1 0.00280592875035233052 -#define __TAND_SC2 -0.12828356435663158978 - -/* - * Computes the tangent of the given angles by first reducing the - * range to [-pi/4..pi/4] and performing the appropriate sin/cos ratio - */ -static inline vector double -_tand2 (vector double x) -{ - vec_double2 xl,x2,x3,res; - vec_double2 nan = (vec_double2)spu_splats(0x7ff8000000000000ull); - vec_uchar16 copyEven = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = spu_mul(x, spu_splats(0.63661977236758134307553505349005744)); - - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - xl = spu_add(xl,spu_sel(spu_splats(0.5),xl,spu_splats(0x8000000000000000ull))); - vec_float4 xf = spu_roundtf(xl); - vec_int4 q = spu_convts(xf,0); - q = spu_shuffle(q,q,copyEven); - - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = spu_convtf(q,0); - vec_double2 qd = spu_extend(qf); - vec_double2 p1 = spu_nmsub(qd,spu_splats(__SINCOSD_KC1),x); - xl = spu_nmsub(qd,spu_splats(__SINCOSD_KC2),p1); - - // Compute x^2 and x^3 - // - x2 = spu_mul(xl,xl); - x3 = spu_mul(x2,xl); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + x2 * ((C0 * x2 + C1) * x2 + C2), and - // sx = x + x3 * ((S0 * x2 + S1) * x2 + S2) - // - vec_double2 ct1 = spu_madd(spu_splats(__TAND_CC0),x2,spu_splats(__TAND_CC1)); - vec_double2 st1 = spu_madd(spu_splats(__TAND_SC0),x2,spu_splats(__TAND_SC1)); - - vec_double2 ct2 = spu_madd(ct1,x2,spu_splats(__TAND_CC2)); - vec_double2 st2 = spu_madd(st1,x2,spu_splats(__TAND_SC2)); - - vec_double2 cx = spu_madd(ct2,x2,spu_splats(1.0)); - vec_double2 sx = spu_madd(st2,x3,xl); - - - // Compute both cx/sx and sx/cx - // - vec_double2 cxosx = _divd2(cx,sx); - vec_double2 sxocx = _divd2(sx,cx); - - vec_double2 ncxosx = (vec_double2)spu_xor(spu_splats(0x8000000000000000ull),(vec_ullong2)cxosx); - - // For odd numbered quadrants return -cx/sx , otherwise return - // sx/cx - // - vec_ullong2 mask = (vec_ullong2)spu_cmpeq(spu_and(q,(int)0x1),spu_splats((int)0)); - res = spu_sel(ncxosx,sxocx,mask); - - // If input = +/-Inf return NAN - // - res = spu_sel(res,nan,_isinfd2 (x)); - - // If input =0 or denorm return input - // - res = spu_sel(res,x, _is0denormd2 (x)); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/tanf4.h b/Extras/simdmathlibrary/spu/simdmath/tanf4.h deleted file mode 100644 index 889466989..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/tanf4.h +++ /dev/null @@ -1,95 +0,0 @@ -/* tanf4 - for each of four float slots, compute the tangent by using a polynomial approximation. - 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 ___SIMD_MATH_TANF4_H___ -#define ___SIMD_MATH_TANF4_H___ - -#include -#include - -#include -#include - -static inline vector float -_tanf4 (vector float x) -{ - vector float xl,x2,x3,res; - vector signed int q; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = spu_mul(x, spu_splats(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(x))*sign(x)) - // - xl = spu_add(xl,spu_sel(spu_splats(0.5f),xl,spu_splats(0x80000000))); - q = spu_convts(xl,0); - - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = spu_convtf(q,0); - vec_float4 p1 = spu_nmsub(qf,spu_splats(__SINCOSF_KC1),x); - xl = spu_nmsub(qf,spu_splats(__SINCOSF_KC2),p1); - - // Compute x^2 and x^3 - // - x2 = spu_mul(xl,xl); - x3 = spu_mul(x2,xl); - - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + x2 * (C0 * x2 + C1), and - // sx = xl + x3 * S0 - // - vec_float4 ct2 = spu_madd(spu_splats( 0.0097099364f),x2,spu_splats(-0.4291161787f)); - - vec_float4 cx = spu_madd(ct2,x2,spu_splats(1.0f)); - vec_float4 sx = spu_madd(spu_splats(-0.0957822992f),x3,xl); - - - // Compute both cx/sx and sx/cx - // - vec_float4 cxosx = _divf4(cx,sx); - vec_float4 sxocx = _divf4(sx,cx); - - vec_float4 ncxosx = (vec_float4)spu_xor(spu_splats(0x80000000),(vec_uint4)cxosx); - - // For odd numbered quadrants return -cx/sx , otherwise return - // sx/cx - // - vec_uint4 mask = spu_cmpeq(spu_and(q,(int)0x1),spu_splats((int)0)); - res = spu_sel(ncxosx,sxocx,mask); - - return res; -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/truncd2.h b/Extras/simdmathlibrary/spu/simdmath/truncd2.h deleted file mode 100644 index a5201ab43..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/truncd2.h +++ /dev/null @@ -1,66 +0,0 @@ -/* truncd2 - Round the input to the nearest integer. - Always rounds towards 0. - 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 ___SIMD_MATH_TRUNCD2_H___ -#define ___SIMD_MATH_TRUNCD2_H___ - -#include -#include - -static inline vector double -_truncd2(vector double in) -{ - vec_uchar16 splat_hi = ((vec_uchar16){ 0,1,2,3,0,1,2,3, 8,9,10,11, 8,9,10,11}); - vec_int4 exp, shift; - vec_uint4 sign = ((vec_uint4){ 0x80000000, 0, 0x80000000, 0}); - vec_uint4 or_mask, and_mask, mask; - vec_double2 in_hi, out; - - /* Construct a mask to remove the fraction bits. The mask - * depends on the exponent of the floating point - * input value. - */ - in_hi = spu_shuffle(in, in, splat_hi); - exp = spu_and(spu_rlmask((vec_int4)in_hi, -20), 0x7FF); - - shift = spu_sub(((vec_int4){ 1023, 1043, 1023, 1043}), exp); - or_mask = spu_andc(spu_cmpgt(shift, 0), sign); - - and_mask = spu_rlmask(((vec_uint4){ 0xFFFFF, -1, 0xFFFFF, -1}), shift); - mask = spu_or(spu_and(and_mask, spu_cmpgt(shift, -32)), or_mask); - - /* Apply the mask and return the result. - */ - out = spu_andc(in, (vec_double2)(mask)); - - return (out); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/simdmath/truncf4.h b/Extras/simdmathlibrary/spu/simdmath/truncf4.h deleted file mode 100644 index b51916014..000000000 --- a/Extras/simdmathlibrary/spu/simdmath/truncf4.h +++ /dev/null @@ -1,52 +0,0 @@ -/* truncf4 - for each of four float slots, round towards zero to integer value. - 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 ___SIMD_MATH_TRUNCF4_H___ -#define ___SIMD_MATH_TRUNCF4_H___ - -#include -#include - -static inline vector float -_truncf4 (vector float x) -{ - vector signed int xi; - vector unsigned int inrange; - - // Can convert to and from signed integer to truncate values in range [-2^31, 2^31). - // However, no truncation needed if exponent > 22. - - inrange = spu_cmpabsgt( (vector float)spu_splats(0x4b000000), x ); - - xi = spu_convts( x, 0 ); - - return spu_sel( x, spu_convtf( xi, 0 ), inrange ); -} - -#endif diff --git a/Extras/simdmathlibrary/spu/tests/Makefile b/Extras/simdmathlibrary/spu/tests/Makefile deleted file mode 100644 index 57c5f61f5..000000000 --- a/Extras/simdmathlibrary/spu/tests/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# Makefile for testsuite for the SPU SIMD math library -# 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. - -topdir = ../.. -ARCH = spu - -include $(topdir)/Make.defs - -TESTS = fabsd2 fabsf4 truncf4 divf4 recipd2 divd2 sqrtf4 \ - absi4 sqrtd2 rsqrtf4 rsqrtd2 copysignf4 remainderf4 \ - recipf4 copysignd2 negatef4 negated2 modff4 ceilf4 \ - fminf4_fmaxf4 floorf4 negatei4 divi4 llroundd2 llroundf4 \ - llrintf4 isequalf4 isequald2 islessgreaterf4 islessgreaterd2 \ - islessf4 islessd2 isgreaterf4 isgreaterd2 islessequalf4 islessequald2 \ - isgreaterequalf4 isgreaterequald2 isnanf4 isnand2 isinff4 isinfd2 \ - isfinitef4 isfinited2 isnormalf4 isnormald2 isunorderedf4 isunorderedd2 \ - is0denormf4 is0denormd2 signbitf4 signbitd2 llrintd2 \ - roundf4 iroundf4 rintf4 irintf4 fmind2_fmaxd2 fdimd2 \ - fmad2 nextafterd2 nextafterf4 fpclassifyf4 fpclassifyd2 nearbyintd2 nearbyintf4 \ - llabsi2 truncd2 roundd2 rintd2 negatell2 hypotf4 hypotd2 divu4 modfd2 \ - lldivu2 ceild2 floord2 ldexpd2 ilogbd2 ilogbf4 logbf4 logbd2 scalbnf4 \ - scalbllnd2 lldivi2 frexpf4 frexpd2 remquof4 remquod2 fmodd2 remainderd2 - -OBJS = testutils.o - -include $(topdir)/Make.test diff --git a/Extras/simdmathlibrary/spu/tests/absi4.c b/Extras/simdmathlibrary/spu/tests/absi4.c deleted file mode 100644 index bd150e4e1..000000000 --- a/Extras/simdmathlibrary/spu/tests/absi4.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Test absi4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040908101807EJL","EJL", "abs"); - - int x0n = hide_int(0); - int x0p = hide_int(0); - int x1n = hide_int(-1); - int x1p = hide_int(1); - int x2n = hide_int(-83532); - int x2p = hide_int(83532); - - vec_int4 x0n_v = spu_splats(x0n); - vec_int4 x0p_v = spu_splats(x0p); - vec_int4 x1n_v = spu_splats(x1n); - vec_int4 x1p_v = spu_splats(x1p); - vec_int4 x2n_v = spu_splats(x2n); - vec_int4 x2p_v = spu_splats(x2p); - - int res; - vec_int4 res_v; - - TEST_START("absi4"); - res_v = absi4(x0n_v); - TEST_CHECK("20040908103824EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = absi4(x0p_v); - TEST_CHECK("20040908103903EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = absi4(x1n_v); - TEST_CHECK("20040908103905EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = absi4(x1p_v); - TEST_CHECK("20040908114003EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = absi4(x2n_v); - TEST_CHECK("20040908114714EJL", allequal_int4( res_v, x2p_v ), 0); - res_v = absi4(x2p_v); - TEST_CHECK("20040908114715EJL", allequal_int4( res_v, x2p_v ), 0); - - TEST_START("abs"); - res = abs(x0n); - TEST_CHECK("20040908114718EJL", res == x0p, 0); - res = abs(x0p); - TEST_CHECK("20040908114719EJL", res == x0p, 0); - res = abs(x1n); - TEST_CHECK("20040908114720EJL", res == x1p, 0); - res = abs(x1p); - TEST_CHECK("20040908114721EJL", res == x1p, 0); - res = abs(x2n); - TEST_CHECK("20040908114722EJL", res == x2p, 0); - res = abs(x2p); - TEST_CHECK("20040908114723EJL", res == x2p, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/ceild2.c b/Extras/simdmathlibrary/spu/tests/ceild2.c deleted file mode 100644 index 7712c5b1c..000000000 --- a/Extras/simdmathlibrary/spu/tests/ceild2.c +++ /dev/null @@ -1,156 +0,0 @@ -/* Test roundd2 for SPU - 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. - */ -/** - * - *@@ ceild2for each of two doule slots, - * round up to smallest integer not less than the value. - * - *@brief - * boundary test for ceild2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef union { - struct { - double xxx[2]; - double ans[2]; - } dbl; - struct { - unsigned long long xxx[2]; - unsigned long long ans[2]; - } ull; -} TestVec_Roundd2; - -int main() -{ - TestVec_Roundd2 test_a[] = { - { - ull:{ - // 0 -> 0 , -0 -> -0 - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // -Inf -> -Inf , Inf -> Inf - {0xFFF0000000000000ULL,0x7FF0000000000000ULL}, - {0xFFF0000000000000ULL,0x7FF0000000000000ULL} - } - },{ - ull:{ - // MAX -> MAX , MIN -> MIN - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x0000000000000001ULL,0x8000000000000010ULL}, - {0x3ff0000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x800FFFFFFFFFFFFFULL,0x000FFFFFFFFFFFFFULL}, - {0x8000000000000000ULL,0x3ff0000000000000ULL} - } - },{ - ull:{ - // border - {0x4320000000000001ULL,0xC320000000000001ULL}, - {0x4320000000000002ULL,0xC320000000000000ULL} - } - },{ - dbl:{ - {1.0, -1.0}, - {1.0, -1.0} - } - },{ - dbl:{ - {0.5, -0.5}, - {1.0, -0.0} - } - },{ - dbl:{ - {-2.75, 3.2}, - {-2.0, 4.0} - } - },{ - ull:{ - // Nan - {0xFFF0000000000001ULL,0x7FF0000000000001ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL} - } - },{ - ull:{ - {0ULL,0ULL}, - {0ULL,0ULL} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - //vec_double2 input; - - TEST_SET_START("51651906100000NM","CED", "ceild2"); - - TEST_START("ceild2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ull.xxx[0] == 0) && (test_a[ii].ull.xxx[1] == 0) ) break; - //input = *((vec_double2 *)&test_a[ii].dbl.xxx[0]); - res_v = ceild2 (*((vec_double2 *)&test_a[ii].dbl.xxx[0]) ); - sprintf(msg,"5165190610%04dCED", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, (vec_llong2)*((vec_double2 *)&test_a[ii].dbl.ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/ceilf4.c b/Extras/simdmathlibrary/spu/tests/ceilf4.c deleted file mode 100644 index d130176e2..000000000 --- a/Extras/simdmathlibrary/spu/tests/ceilf4.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Test ceilf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040916103300EJL","EJL", "ceilf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4b000000; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(1.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 x0i_v = spu_splats(x0i); - vec_float4 x1_v = spu_splats(x1); - vec_float4 x1i_v = spu_splats(x1i); - vec_float4 x2_v = spu_splats(x2); - vec_float4 x2i_v = spu_splats(x2i); - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3i_v = spu_splats(x3i); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4i_v = spu_splats(x4i); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5i_v = spu_splats(x5i); - - float res; - vec_float4 res_v; - - TEST_START("ceilf4"); - res_v = ceilf4(x0_v); - TEST_CHECK("20040916103310EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = ceilf4(x1_v); - TEST_CHECK("20040916103324EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = ceilf4(x2_v); - TEST_CHECK("20040916103334EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = ceilf4(x3_v); - TEST_CHECK("20040916103341EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = ceilf4(x4_v); - TEST_CHECK("20040916103350EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = ceilf4(x5_v); - TEST_CHECK("20040916103357EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_START("ceilf"); - res = ceilf(x0); - TEST_CHECK("20040916103407EJL", res == x0i, 0); - res = ceilf(x1); - TEST_CHECK("20040916103418EJL", res == x1i, 0); - res = ceilf(x2); - TEST_CHECK("20040916103428EJL", res == x2i, 0); - res = ceilf(x3); - TEST_CHECK("20040916103437EJL", res == x3i, 0); - res = ceilf(x4); - TEST_CHECK("20040916103448EJL", res == x4i, 0); - res = ceilf(x5); - TEST_CHECK("20040916103457EJL", res == x5i, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/copysignd2.c b/Extras/simdmathlibrary/spu/tests/copysignd2.c deleted file mode 100644 index 0aa8312c3..000000000 --- a/Extras/simdmathlibrary/spu/tests/copysignd2.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Test copysignd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" -int main() -{ - TEST_SET_START("20040928185245EJL","EJL", "copysign"); - - double x0m = hide_double(1989.0); - double x0s = hide_double(-319875.0); - double x0c = hide_double(-1989.0); - double x1m = hide_double(9013.0); - double x1s = hide_double(185.0); - double x1c = hide_double(9013.0); - - vec_double2 x0m_v = spu_splats(x0m); - vec_double2 x0s_v = spu_splats(x0s); - vec_double2 x0c_v = spu_splats(x0c); - - vec_double2 x1m_v = spu_splats(x1m); - vec_double2 x1s_v = spu_splats(x1s); - vec_double2 x1c_v = spu_splats(x1c); - - double res; - vec_double2 res_v; - - TEST_START("copysignd2"); - res_v = copysignd2( x0m_v, x0s_v ); - TEST_CHECK("20040928185248EJL", allequal_double2( res_v, x0c_v ), 0); - res_v = copysignd2( x1m_v, x1s_v ); - TEST_CHECK("20040928185251EJL", allequal_double2( res_v, x1c_v ), 0); - - TEST_START("copysign"); - res = copysign( x0m, x0s ); - TEST_CHECK("20040928185253EJL", res == x0c, 0); - res = copysign( x1m, x1s ); - TEST_CHECK("20040928185256EJL", res == x1c, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/copysignf4.c b/Extras/simdmathlibrary/spu/tests/copysignf4.c deleted file mode 100644 index 148ecca5b..000000000 --- a/Extras/simdmathlibrary/spu/tests/copysignf4.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Test copysignf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040917114054EJL", "EJL", "copysignf"); - - float x0m = hide_float(1989.0f); - float x0s = hide_float(-319875.0f); - float x0c = hide_float(-1989.0f); - float x1m = hide_float(9013.0f); - float x1s = hide_float(185.0f); - float x1c = hide_float(9013.0f); - - vec_float4 x0m_v = spu_splats(x0m); - vec_float4 x0s_v = spu_splats(x0s); - vec_float4 x0c_v = spu_splats(x0c); - - vec_float4 x1m_v = spu_splats(x1m); - vec_float4 x1s_v = spu_splats(x1s); - vec_float4 x1c_v = spu_splats(x1c); - - float res; - vec_float4 res_v; - - TEST_START("copysignf4"); - res_v = copysignf4( x0m_v, x0s_v ); - TEST_CHECK("20040917114058EJL", allequal_float4( res_v, x0c_v ), 0); - res_v = copysignf4( x1m_v, x1s_v ); - TEST_CHECK("20040917114100EJL", allequal_float4( res_v, x1c_v ), 0); - - TEST_START("copysignf"); - res = copysignf( x0m, x0s ); - TEST_CHECK("20040917114102EJL", res == x0c, 0); - res = copysignf( x1m, x1s ); - TEST_CHECK("20040917114104EJL", res == x1c, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/divd2.c b/Extras/simdmathlibrary/spu/tests/divd2.c deleted file mode 100644 index 66a6dca63..000000000 --- a/Extras/simdmathlibrary/spu/tests/divd2.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Test divd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040927182952EJL","EJL", "divd2"); - - unsigned long long i3n = 0x747f7fefa0c3274aull; - unsigned long long i3d = 0x7606a4533cf5605eull; - unsigned long long i3r = 0x3e66426af0ec01b0ull; - unsigned long long i4n = 0x4c042c295376566eull; - unsigned long long i4d = 0x39b3720562510408ull; - unsigned long long i4r = 0x52409928d3244077ull; - unsigned long long i5n = 0x6911a64538a389aeull; - unsigned long long i5d = 0x1ac4d062d451c99dull; - unsigned long long i5r = 0x7ff0000000000000ull; - unsigned long long i6n = 0x5b112f9d39e7de27ull; - unsigned long long i6d = 0x5659f8dbe4993d7cull; - unsigned long long i6r = 0x44a52cb9b9d2b2cdull; - unsigned long long i7n = 0x7410065c772e25daull; - unsigned long long i7d = 0x6a576b936e5f1034ull; - unsigned long long i7r = 0x49a5e53936c1b556ull; - unsigned long long i8n = 0x3605d9b2916be0f5ull; - unsigned long long i8d = 0x61f25e39867b0a9eull; - unsigned long long i8r = 0x1403088aa08482f2ull; - - double x0n = hide_double(-HUGE_VAL); // -Inf/ Inf == NaN - double x0d = hide_double(HUGE_VAL); - - double x1n = hide_double(0.0); // 0 / 0 == NaN - double x1d = hide_double(-0.0); - - double x2n = hide_double(nan("")); // NaN / 2 == NaN - double x2d = hide_double(2.0); - - double x3n = hide_double(make_double(i3n)); - double x3d = hide_double(make_double(i3d)); - double x3r = hide_double(make_double(i3r)); - - double x4n = hide_double(make_double(i4n)); - double x4d = hide_double(make_double(i4d)); - double x4r = hide_double(make_double(i4r)); - - double x5n = hide_double(make_double(i5n)); - double x5d = hide_double(make_double(i5d)); - double x5r = hide_double(make_double(i5r)); - - double x6n = hide_double(make_double(i6n)); - double x6d = hide_double(make_double(i6d)); - double x6r = hide_double(make_double(i6r)); - - double x7n = hide_double(make_double(i7n)); - double x7d = hide_double(make_double(i7d)); - double x7r = hide_double(make_double(i7r)); - - double x8n = hide_double(make_double(i8n)); - double x8d = hide_double(make_double(i8d)); - double x8r = hide_double(make_double(i8r)); - - vec_double2 x0n_v = spu_splats(x0n); - vec_double2 x0d_v = spu_splats(x0d); - - vec_double2 x1n_v = spu_splats(x1n); - vec_double2 x1d_v = spu_splats(x1d); - - vec_double2 x2n_v = spu_splats(x2n); - vec_double2 x2d_v = spu_splats(x2d); - - vec_double2 x3n_v = spu_splats(x3n); - vec_double2 x3d_v = spu_splats(x3d); - vec_double2 x3r_v = spu_splats(x3r); - - vec_double2 x4n_v = spu_splats(x4n); - vec_double2 x4d_v = spu_splats(x4d); - vec_double2 x4r_v = spu_splats(x4r); - - vec_double2 x5n_v = spu_splats(x5n); - vec_double2 x5d_v = spu_splats(x5d); - vec_double2 x5r_v = spu_splats(x5r); - - vec_double2 x6n_v = spu_splats(x6n); - vec_double2 x6d_v = spu_splats(x6d); - vec_double2 x6r_v = spu_splats(x6r); - - vec_double2 x7n_v = spu_splats(x7n); - vec_double2 x7d_v = spu_splats(x7d); - vec_double2 x7r_v = spu_splats(x7r); - - vec_double2 x8n_v = spu_splats(x8n); - vec_double2 x8d_v = spu_splats(x8d); - vec_double2 x8r_v = spu_splats(x8r); - - vec_double2 res_v; - - TEST_START("divd2"); - res_v = divd2(x0n_v, x0d_v); - TEST_CHECK("20040927183001EJL", allnan_double2( res_v ), 0); - res_v = divd2(x1n_v, x1d_v); - TEST_CHECK("20040927183003EJL", allnan_double2( res_v ), 0); - res_v = divd2(x2n_v, x2d_v); - TEST_CHECK("20040927183006EJL", allnan_double2( res_v ), 0); - res_v = divd2(x3n_v, x3d_v); - TEST_CHECK("20040927183008EJL", allequal_ulps_double2( res_v, x3r_v, 1 ), 0 ); - res_v = divd2(x4n_v, x4d_v); - TEST_CHECK("20040927183010EJL", allequal_ulps_double2( res_v, x4r_v, 1 ), 0 ); - res_v = divd2(x5n_v, x5d_v); - TEST_CHECK("20040927183012EJL", allequal_ulps_double2( res_v, x5r_v, 1 ), 0 ); - res_v = divd2(x6n_v, x6d_v); - TEST_CHECK("20040927183014EJL", allequal_ulps_double2( res_v, x6r_v, 1 ), 0 ); - res_v = divd2(x7n_v, x7d_v); - TEST_CHECK("20040927183016EJL", allequal_ulps_double2( res_v, x7r_v, 1 ), 0 ); - res_v = divd2(x8n_v, x8d_v); - TEST_CHECK("20040927183018EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0 ); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/divf4.c b/Extras/simdmathlibrary/spu/tests/divf4.c deleted file mode 100644 index e60b668db..000000000 --- a/Extras/simdmathlibrary/spu/tests/divf4.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Test divf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040928105926EJL","EJL", "divf4"); - - unsigned int i0n = 0x75013340; - unsigned int i0d = 0x75e7753f; - unsigned int i0r = 0x3e8ee64b; - unsigned int i1n = 0x4c7fed5a; - unsigned int i1d = 0x3a0731f0; - unsigned int i1r = 0x51f24e86; - unsigned int i2n = 0x5b08b303; - unsigned int i2d = 0x562f5046; - unsigned int i2r = 0x44479d24; - unsigned int i3n = 0x748a9b87; - unsigned int i3d = 0x6b014b46; - unsigned int i3r = 0x49093864; - unsigned int i4n = 0x35dcf9d8; - unsigned int i4d = 0x6278d6e0; - unsigned int i4r = 0x12e355b5; - unsigned int i5n = 0x74d505fd; - unsigned int i5d = 0x61ef565e; - unsigned int i5r = 0x5263daa3; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0d_v = spu_splats(x0d); - vec_float4 x0r_v = spu_splats(x0r); - - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1d_v = spu_splats(x1d); - vec_float4 x1r_v = spu_splats(x1r); - - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2d_v = spu_splats(x2d); - vec_float4 x2r_v = spu_splats(x2r); - - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3d_v = spu_splats(x3d); - vec_float4 x3r_v = spu_splats(x3r); - - vec_float4 x4n_v = spu_splats(x4n); - vec_float4 x4d_v = spu_splats(x4d); - vec_float4 x4r_v = spu_splats(x4r); - - vec_float4 x5n_v = spu_splats(x5n); - vec_float4 x5d_v = spu_splats(x5d); - vec_float4 x5r_v = spu_splats(x5r); - - vec_float4 res_v; - - TEST_START("divf4"); - res_v = divf4(x0n_v, x0d_v); - TEST_CHECK("20040928105932EJL", allequal_ulps_float4( res_v, x0r_v, 2 ), 0); - res_v = divf4(x1n_v, x1d_v); - TEST_CHECK("20040928105934EJL", allequal_ulps_float4( res_v, x1r_v, 2 ), 0); - res_v = divf4(x2n_v, x2d_v); - TEST_CHECK("20040928105936EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0); - res_v = divf4(x3n_v, x3d_v); - TEST_CHECK("20040928105938EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = divf4(x4n_v, x4d_v); - TEST_CHECK("20040928105940EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = divf4(x5n_v, x5d_v); - TEST_CHECK("20040928105943EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/divi4.c b/Extras/simdmathlibrary/spu/tests/divi4.c deleted file mode 100644 index a56239b23..000000000 --- a/Extras/simdmathlibrary/spu/tests/divi4.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Test divi4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040928161739EJL","EJL", "divi4"); - - int x0n = 0xffccb78d; - int x0d = 0x0 ; - int x0q = 0x0 ; - int x0r = 0xffccb78d; - int x1n = 0xff978333; - int x1d = 0xff976bb6; - int x1q = 0x0 ; - int x1r = 0xff978333; - int x2n = 0x5e146 ; - int x2d = 0xd14ebe0e; - int x2q = 0x0 ; - int x2r = 0x5e146 ; - int x3n = 0xf0e91618; - int x3d = 0xfddff7ac; - int x3q = 0x7 ; - int x3r = 0xffc95064; - - int x4n = 0xf2128d9d; - int x4d = 0xe0f76 ; - int x4q = 0xffffff03; - int x4r = 0xfff7d53b; - int x5n = 0xda1ba2ce; - int x5d = 0x4c9 ; - int x5q = 0xfff814d3; - int x5r = 0xfffffd23; - int x6n = 0xdd4426a6; - int x6d = 0xf8d245cf; - int x6q = 0x4 ; - int x6r = 0xf9fb0f6a; - int x7n = 0xd1d5ae9 ; - int x7d = 0x333ab105; - int x7q = 0x0 ; - int x7r = 0xd1d5ae9 ; - - int x8n = 0x3e0c6 ; - int x8d = 0xfff24255; - int x8q = 0x0 ; - int x8r = 0x3e0c6 ; - int x9n = 0xfd6fe27e; - int x9d = 0xf32454 ; - int x9q = 0xfffffffe; - int x9r = 0xff562b26; - int x10n =0xfb150f79; - int x10d =0xf521 ; - int x10q =0xfffffade; - int x10r =0xffff42db; - int x11n =0xfe88071f; - int x11d =0xfff937c2; - int x11q =0x37 ; - int x11r =0xfffd0c71; - - - vec_int4 x0n_v = (vec_int4){ x0n, x1n, x2n, x3n }; - vec_int4 x1n_v = (vec_int4){ x4n, x5n, x6n, x7n }; - vec_int4 x2n_v = (vec_int4){ x8n, x9n, x10n, x11n }; - - vec_int4 x0d_v = (vec_int4){ x0d, x1d, x2d, x3d }; - vec_int4 x1d_v = (vec_int4){ x4d, x5d, x6d, x7d }; - vec_int4 x2d_v = (vec_int4){ x8d, x9d, x10d, x11d }; - - vec_int4 x0q_v = (vec_int4){ x0q, x1q, x2q, x3q }; - vec_int4 x1q_v = (vec_int4){ x4q, x5q, x6q, x7q }; - vec_int4 x2q_v = (vec_int4){ x8q, x9q, x10q, x11q }; - - vec_int4 x0r_v = (vec_int4){ x0r, x1r, x2r, x3r }; - vec_int4 x1r_v = (vec_int4){ x4r, x5r, x6r, x7r }; - vec_int4 x2r_v = (vec_int4){ x8r, x9r, x10r, x11r }; - - divi4_t res; - - TEST_START("divi4"); - res = divi4(x0n_v, x0d_v); - TEST_CHECK("20040928161846EJL", allequal_int4( res.quot, x0q_v ) && allequal_int4( res.rem, x0r_v ), 0); - res = divi4(x1n_v, x1d_v); - TEST_CHECK("20040928161851EJL", allequal_int4( res.quot, x1q_v ) && allequal_int4( res.rem, x1r_v ), 0); - res = divi4(x2n_v, x2d_v); - TEST_CHECK("20040928161855EJL", allequal_int4( res.quot, x2q_v ) && allequal_int4( res.rem, x2r_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/divu4.c b/Extras/simdmathlibrary/spu/tests/divu4.c deleted file mode 100644 index a5fff1d42..000000000 --- a/Extras/simdmathlibrary/spu/tests/divu4.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Test divu4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060901150000MH","MH", "divu4"); - - unsigned int x0n = 0xffccb78d; - unsigned int x0d = 0x0 ; - unsigned int x0q = 0x0 ; - unsigned int x0r = 0xffccb78d; - unsigned int x1n = 0xff978333; - unsigned int x1d = 0xff976bb6; - unsigned int x1q = 0x1 ; - unsigned int x1r = 0x177d ; - unsigned int x2n = 0x5e146 ; - unsigned int x2d = 0xd14ebe0e; - unsigned int x2q = 0x0 ; - unsigned int x2r = 0x5e146 ; - unsigned int x3n = 0xf0e91618; - unsigned int x3d = 0xfddff7ac; - unsigned int x3q = 0x0 ; - unsigned int x3r = 0xf0e91618; - - unsigned int x4n = 0xf2128d9d; - unsigned int x4d = 0xe0f76 ; - unsigned int x4q = 0x1137 ; - unsigned int x4r = 0x66543 ; - unsigned int x5n = 0xda1ba2ce; - unsigned int x5d = 0x4c9 ; - unsigned int x5q = 0x2d9482 ; - unsigned int x5r = 0xbc ; - unsigned int x6n = 0xdd4426a6; - unsigned int x6d = 0xf8d245cf; - unsigned int x6q = 0x0 ; - unsigned int x6r = 0xdd4426a6; - unsigned int x7n = 0xd1d5ae9 ; - unsigned int x7d = 0x333ab105; - unsigned int x7q = 0x0 ; - unsigned int x7r = 0xd1d5ae9 ; - - unsigned int x8n = 0x3e0c6 ; - unsigned int x8d = 0xfff24255; - unsigned int x8q = 0x0 ; - unsigned int x8r = 0x3e0c6 ; - unsigned int x9n = 0xfd6fe27e; - unsigned int x9d = 0xf32454 ; - unsigned int x9q = 0x10a ; - unsigned int x9r = 0xcc2336 ; - unsigned int x10n =0xfb150f79; - unsigned int x10d =0xf521 ; - unsigned int x10q =0x10637 ; - unsigned int x10r =0x9f62 ; - unsigned int x11n =0xfe88071f; - unsigned int x11d =0xfff937c2; - unsigned int x11q =0x0 ; - unsigned int x11r =0xfe88071f; - - unsigned int x12n =0xc374fa4 ; - unsigned int x12d =0x1234 ; - unsigned int x12q =0xabcd ; - unsigned int x12r =0x0 ; - unsigned int x13n =0xffffffff; - unsigned int x13d =0x2 ; - unsigned int x13q =0x7fffffff; - unsigned int x13r =0x1 ; - unsigned int x14n =0x0 ; - unsigned int x14d =0x12345678; - unsigned int x14q =0x0 ; - unsigned int x14r =0x0 ; - unsigned int x15n =0xffffffff; - unsigned int x15d =0x1 ; - unsigned int x15q =0xffffffff; - unsigned int x15r =0x0 ; - - vec_uint4 x0n_v = (vec_uint4){ x0n, x1n, x2n, x3n }; - vec_uint4 x1n_v = (vec_uint4){ x4n, x5n, x6n, x7n }; - vec_uint4 x2n_v = (vec_uint4){ x8n, x9n, x10n, x11n }; - vec_uint4 x3n_v = (vec_uint4){ x12n, x13n, x14n, x15n }; - - vec_uint4 x0d_v = (vec_uint4){ x0d, x1d, x2d, x3d }; - vec_uint4 x1d_v = (vec_uint4){ x4d, x5d, x6d, x7d }; - vec_uint4 x2d_v = (vec_uint4){ x8d, x9d, x10d, x11d }; - vec_uint4 x3d_v = (vec_uint4){ x12d, x13d, x14d, x15d }; - - vec_uint4 x0q_v = (vec_uint4){ x0q, x1q, x2q, x3q }; - vec_uint4 x1q_v = (vec_uint4){ x4q, x5q, x6q, x7q }; - vec_uint4 x2q_v = (vec_uint4){ x8q, x9q, x10q, x11q }; - vec_uint4 x3q_v = (vec_uint4){ x12q, x13q, x14q, x15q }; - - vec_uint4 x0r_v = (vec_uint4){ x0r, x1r, x2r, x3r }; - vec_uint4 x1r_v = (vec_uint4){ x4r, x5r, x6r, x7r }; - vec_uint4 x2r_v = (vec_uint4){ x8r, x9r, x10r, x11r }; - vec_uint4 x3r_v = (vec_uint4){ x12r, x13r, x14r, x15r }; - - divu4_t res; - - TEST_START("divu4"); - res = divu4(x0n_v, x0d_v); - TEST_CHECK("20060901150001MH", allequal_uint4( res.quot, x0q_v ) && allequal_uint4( res.rem, x0r_v ), 0); - res = divu4(x1n_v, x1d_v); - TEST_CHECK("20060901150002MH", allequal_uint4( res.quot, x1q_v ) && allequal_uint4( res.rem, x1r_v ), 0); - res = divu4(x2n_v, x2d_v); - TEST_CHECK("20060901150003MH", allequal_uint4( res.quot, x2q_v ) && allequal_uint4( res.rem, x2r_v ), 0); - res = divu4(x3n_v, x3d_v); - TEST_CHECK("20060901150004MH", allequal_uint4( res.quot, x3q_v ) && allequal_uint4( res.rem, x3r_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fabsd2.c b/Extras/simdmathlibrary/spu/tests/fabsd2.c deleted file mode 100644 index 11e366dd4..000000000 --- a/Extras/simdmathlibrary/spu/tests/fabsd2.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Test fabsd2 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040908022501EJL","EJL", "fabs"); - - double x0n = hide_double(-0.0); - double x0p = hide_double(0.0); - double x1n = hide_double(-83532.96153153); - double x1p = hide_double(83532.96153153); - double x2n = hide_double(-0.0000000013152); - double x2p = hide_double(0.0000000013152); - double x3n = hide_double(-HUGE_VAL); - double x3p = hide_double(HUGE_VAL); - - vec_double2 x0n_v = spu_splats(x0n); - vec_double2 x0p_v = spu_splats(x0p); - vec_double2 x1n_v = spu_splats(x1n); - vec_double2 x1p_v = spu_splats(x1p); - vec_double2 x2n_v = spu_splats(x2n); - vec_double2 x2p_v = spu_splats(x2p); - vec_double2 x3n_v = spu_splats(x3n); - vec_double2 x3p_v = spu_splats(x3p); - - double res; - vec_double2 res_v; - - TEST_START("fabsd2"); - res_v = fabsd2(x0n_v); - TEST_CHECK("20040908022502EJL", allequal_double2( res_v, x0p_v ), 0); - res_v = fabsd2(x0p_v); - TEST_CHECK("20040908022503EJL", allequal_double2( res_v, x0p_v ), 0); - res_v = fabsd2(x1n_v); - TEST_CHECK("20040908022504EJL", allequal_double2( res_v, x1p_v ), 0); - res_v = fabsd2(x1p_v); - TEST_CHECK("20040908022505EJL", allequal_double2( res_v, x1p_v ), 0); - res_v = fabsd2(x2n_v); - TEST_CHECK("20040908022506EJL", allequal_double2( res_v, x2p_v ), 0); - res_v = fabsd2(x2p_v); - TEST_CHECK("20040908022507EJL", allequal_double2( res_v, x2p_v ), 0); - res_v = fabsd2(x3n_v); - TEST_CHECK("20040908022508EJL", allposinf_double2( res_v ), 0); - res_v = fabsd2(x3p_v); - TEST_CHECK("20040908022509EJL", allposinf_double2( res_v ), 0); - - TEST_START("fabs"); - res = fabs( x0n ); - TEST_CHECK("20040908022510EJL", res == x0p, 0); - res = fabs( x0p ); - TEST_CHECK("20040908022511EJL", res == x0p, 0); - res = fabs( x1n ); - TEST_CHECK("20040908022512EJL", res == x1p, 0); - res = fabs( x1p ); - TEST_CHECK("20040908022513EJL", res == x1p, 0); - res = fabs( x2n ); - TEST_CHECK("20040908022514EJL", res == x2p, 0); - res = fabs( x2p ); - TEST_CHECK("20040908022515EJL", res == x2p, 0); - res = fabs( x3n ); - TEST_CHECK("20040908022516EJL", isinf(res) == 1, 0); - res = fabs( x3p ); - TEST_CHECK("20040908022517EJL", isinf(res) == 1, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fabsf4.c b/Extras/simdmathlibrary/spu/tests/fabsf4.c deleted file mode 100644 index 4d62074e2..000000000 --- a/Extras/simdmathlibrary/spu/tests/fabsf4.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Test fabsf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040915032605EJL","EJL", "fabsf"); - - unsigned int i3n = 0xffffffff; - unsigned int i3p = 0x7fffffff; - - float x0n = hide_float(-0.0f); - float x0p = hide_float(0.0f); - float x1n = hide_float(-83532.96153153f); - float x1p = hide_float(83532.96153153f); - float x2n = hide_float(-0.0000000013152f); - float x2p = hide_float(0.0000000013152f); - float x3n = hide_float(make_float(i3n)); - float x3p = hide_float(make_float(i3p)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0p_v = spu_splats(x0p); - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1p_v = spu_splats(x1p); - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2p_v = spu_splats(x2p); - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3p_v = spu_splats(x3p); - - float res; - vec_float4 res_v; - - TEST_START("fabsf4"); - res_v = fabsf4(x0n_v); - TEST_CHECK("20040915032618EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = fabsf4(x0p_v); - TEST_CHECK("20040915032632EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = fabsf4(x1n_v); - TEST_CHECK("20040915032643EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = fabsf4(x1p_v); - TEST_CHECK("20040915032654EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = fabsf4(x2n_v); - TEST_CHECK("20040915032704EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = fabsf4(x2p_v); - TEST_CHECK("20040915032712EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = fabsf4(x3n_v); - TEST_CHECK("20040915032719EJL", allequal_float4( res_v, x3p_v ), 0); - res_v = fabsf4(x3p_v); - TEST_CHECK("20040915032729EJL", allequal_float4( res_v, x3p_v ), 0); - - TEST_START("fabsf"); - res = fabsf( x0n ); - TEST_CHECK("20040915032739EJL", res == x0p, 0); - res = fabsf( x0p ); - TEST_CHECK("20040915032747EJL", res == x0p, 0); - res = fabsf( x1n ); - TEST_CHECK("20040915032755EJL", res == x1p, 0); - res = fabsf( x1p ); - TEST_CHECK("20040915032806EJL", res == x1p, 0); - res = fabsf( x2n ); - TEST_CHECK("20040915032814EJL", res == x2p, 0); - res = fabsf( x2p ); - TEST_CHECK("20040915032826EJL", res == x2p, 0); - res = fabsf( x3n ); - TEST_CHECK("20040915032834EJL", res == x3p, 0); - res = fabsf( x3p ); - TEST_CHECK("20040915032841EJL", res == x3p, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fdimd2.c b/Extras/simdmathlibrary/spu/tests/fdimd2.c deleted file mode 100644 index d71a48ef2..000000000 --- a/Extras/simdmathlibrary/spu/tests/fdimd2.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Test fdimd2 for SPU - 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. - */ -/** - * - *@@ fdimd2 - compute positive difference. - * - *@brief - * boundary test for fdimd2. - * - *@pre - * - *@criteria - * when both of two values are denormalized, it may not work correctly. - * - *@note - * source of fdimd2.c was modified from IBM SDK1.1 math library - * - **/ - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20060824151500MH","MH", "fdimd2"); - - double x0min = hide_double(1760.135); - double x0max = hide_double(19355.03); - double x0dim = hide_double(19355.03 - 1760.135); - - double x1min = hide_double(-12351.9); - double x1max = hide_double(-139.035); - double x1dim = hide_double((-139.035) - (-12351.9)); - - double x2min = hide_double(-1.0); - double x2max = hide_double(0.0); - double x2dim = hide_double(1.0); - - double x3min = hide_double(nan("")); - double x3max = hide_double(-1.0); - - double x4min = hide_double(-0.0); - double x4max = hide_double(0.0); - - double x5min = hide_double(5.0e-324); - double x5max = hide_double(1.0e-323); - double x5dim = hide_double(1.0e-323) - hide_double(5.0e-324); - - double x6min = hide_double(DBL_MAX); - double x6max = hide_double(HUGE_VAL); - - double x7min = hide_double(-HUGE_VAL); - double x7max = hide_double(19355.03); - - double x8min = hide_double(-HUGE_VAL); - double x8max = hide_double(HUGE_VAL); - - vec_double2 x0min_v = spu_splats(x0min); - vec_double2 x0max_v = spu_splats(x0max); - vec_double2 x0dim_v = spu_splats(x0dim); - - vec_double2 x1min_v = spu_splats(x1min); - vec_double2 x1max_v = spu_splats(x1max); - vec_double2 x1dim_v = spu_splats(x1dim); - - vec_double2 x2min_v = spu_splats(x2min); - vec_double2 x2max_v = spu_splats(x2max); - vec_double2 x2dim_v = spu_splats(x2dim); - - vec_double2 x3min_v = spu_splats(x3min); - vec_double2 x3max_v = spu_splats(x3max); - - vec_double2 x4min_v = spu_splats(x4min); - vec_double2 x4max_v = spu_splats(x4max); - - vec_double2 x5min_v = spu_splats(x5min); - vec_double2 x5max_v = spu_splats(x5max); - vec_double2 x5dim_v = spu_splats(x5dim); - - vec_double2 x6min_v = spu_splats(x6min); - vec_double2 x6max_v = spu_splats(x6max); - - vec_double2 x7min_v = spu_splats(x7min); - vec_double2 x7max_v = spu_splats(x7max); - - vec_double2 x8min_v = spu_splats(x8min); - vec_double2 x8max_v = spu_splats(x8max); - - vec_double2 x9minmax_v = (vec_double2){x0min, x1max}; - vec_double2 x9maxmin_v = (vec_double2){x0max, x1min}; - vec_double2 x9dim1_v = (vec_double2){x0dim, 0.0}; - vec_double2 x9dim2_v = (vec_double2){0.0, x1dim}; - - vec_double2 res_v; - - TEST_START("fdimd2"); - res_v = fdimd2(x0min_v, x0max_v); - TEST_CHECK("20060824151501MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x0max_v, x0min_v); - TEST_CHECK("20060824151502MH", allequal_double2( res_v, x0dim_v ), 0); - res_v = fdimd2(x1min_v, x1max_v); - TEST_CHECK("20060824151503MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x1max_v, x1min_v); - TEST_CHECK("20060824151504MH", allequal_double2( res_v, x1dim_v ), 0); - res_v = fdimd2(x2min_v, x2max_v); - TEST_CHECK("20060824151505MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x2max_v, x2min_v); - TEST_CHECK("20060824151506MH", allequal_double2( res_v, x2dim_v ), 0); - res_v = fdimd2(x3min_v, x3max_v); - TEST_CHECK("20060824151507MH", allnan_double2( res_v ), 0); - res_v = fdimd2(x3max_v, x3min_v); - TEST_CHECK("20060824151508MH", allnan_double2( res_v ), 0); - res_v = fdimd2(x4min_v, x4max_v); - TEST_CHECK("20060824151509MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x4max_v, x4min_v); - TEST_CHECK("20060824151510MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x5min_v, x5max_v); - TEST_CHECK("20060824151511MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x5max_v, x5min_v); - TEST_CHECK("20060824151512MH", allequal_double2( res_v, x5dim_v ), 0); - res_v = fdimd2(x6min_v, x6max_v); - TEST_CHECK("20060824151513MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x6max_v, x6min_v); - TEST_CHECK("20060824151514MH", allposinf_double2( res_v ), 0); - res_v = fdimd2(x7min_v, x7max_v); - TEST_CHECK("20060824151515MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x7max_v, x7min_v); - TEST_CHECK("20060824151516MH", allposinf_double2( res_v ), 0); - res_v = fdimd2(x8min_v, x8max_v); - TEST_CHECK("20060824151517MH", allposzero_double2( res_v ), 0); - res_v = fdimd2(x8max_v, x8min_v); - TEST_CHECK("20060824151518MH", allposinf_double2( res_v ), 0); - res_v = fdimd2(x9minmax_v, x9maxmin_v); - TEST_CHECK("20060824151519MH", allequal_double2( res_v, x9dim2_v ), 0); - res_v = fdimd2(x9maxmin_v, x9minmax_v); - TEST_CHECK("20060824151520MH", allequal_double2( res_v, x9dim1_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/floord2.c b/Extras/simdmathlibrary/spu/tests/floord2.c deleted file mode 100644 index 01ad0e1a7..000000000 --- a/Extras/simdmathlibrary/spu/tests/floord2.c +++ /dev/null @@ -1,157 +0,0 @@ -/* Test roundd2 for SPU - 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. - */ -/** - * - *@@ floord2 - for each of two doule slots, - * round up to smallest integer not more than the value. - * - *@brief - * boundary test for floord2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -typedef union { - struct { - double xxx[2]; - double ans[2]; - } dbl; - struct { - unsigned long long xxx[2]; - unsigned long long ans[2]; - } ull; -} TestVec_Roundd2; - -int main() -{ - TestVec_Roundd2 test_a[] = { - { - ull:{ - // 0 -> 0 , -0 -> -0 - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // -Inf -> -Inf , Inf -> Inf - {0xFFF0000000000000ULL,0x7FF0000000000000ULL}, - {0xFFF0000000000000ULL,0x7FF0000000000000ULL} - } - },{ - ull:{ - // MAX -> MAX , MIN -> MIN - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - } - },{ - ull:{ - // +Denormalize -> 0, -Denormalize -> -1.0 - {0x0000000000000001ULL,0x8000000000000010ULL}, - {0x0000000000000000ULL,0xbff0000000000000ULL} - } - },{ - ull:{ - // +Denormalize -> 0, -Denormalize -> -1.0 - {0x000FFFFFFFFFFFFFULL,0x800FFFFFFFFFFFFFULL}, - {0x0000000000000000ULL,0xbff0000000000000ULL} - } - },{ - ull:{ - // border - {0x4320000000000001ULL,0xC320000000000001ULL}, - {0x4320000000000000ULL,0xC320000000000002ULL} - } - },{ - dbl:{ - {1.0, -1.0}, - {1.0, -1.0} - } - },{ - dbl:{ - {0.5, -0.5}, - {0.0, -1.0} - } - },{ - dbl:{ - {-2.75, 3.25}, - {-3.0, 3.0} - } - },{ - ull:{ - // Nan - {0xFFF0000000000001ULL,0x7FF0000000000001ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL} - } - },{ - ull:{ - {0ULL,0ULL}, - {0ULL,0ULL} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - //vec_double2 input; - - TEST_SET_START("96743652190000NM","FLR", "floord2"); - - TEST_START("floord2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ull.xxx[0] == 0) && (test_a[ii].ull.xxx[1] == 0) ) break; - //input = *((vec_double2 *)&test_a[ii].dbl.xxx[0]); - res_v = floord2 (*((vec_double2 *)&test_a[ii].dbl.xxx[0]) ); - sprintf(msg,"9674365219%04dFLR", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, (vec_llong2)*((vec_double2 *)&test_a[ii].dbl.ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/floorf4.c b/Extras/simdmathlibrary/spu/tests/floorf4.c deleted file mode 100644 index fa514ed8b..000000000 --- a/Extras/simdmathlibrary/spu/tests/floorf4.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Test floorf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040916145017EJL","EJL", "floorf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(-1.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79616.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 x0i_v = spu_splats(x0i); - vec_float4 x1_v = spu_splats(x1); - vec_float4 x1i_v = spu_splats(x1i); - vec_float4 x2_v = spu_splats(x2); - vec_float4 x2i_v = spu_splats(x2i); - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3i_v = spu_splats(x3i); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4i_v = spu_splats(x4i); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5i_v = spu_splats(x5i); - - float res; - vec_float4 res_v; - - TEST_START("floorf4"); - res_v = floorf4(x0_v); - TEST_CHECK("20040916145022EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = floorf4(x1_v); - TEST_CHECK("20040916145024EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = floorf4(x2_v); - TEST_CHECK("20040916145027EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = floorf4(x3_v); - TEST_CHECK("20040916145029EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = floorf4(x4_v); - TEST_CHECK("20040916145032EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = floorf4(x5_v); - TEST_CHECK("20040916145034EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_START("floorf"); - res = floorf(x0); - TEST_CHECK("20040916155814EJL", res == x0i, 0); - res = floorf(x1); - TEST_CHECK("20040916155818EJL", res == x1i, 0); - res = floorf(x2); - TEST_CHECK("20040916155822EJL", res == x2i, 0); - res = floorf(x3); - TEST_CHECK("20040916155825EJL", res == x3i, 0); - res = floorf(x4); - TEST_CHECK("20040916155827EJL", res == x4i, 0); - res = floorf(x5); - TEST_CHECK("20040916155830EJL", res == x5i, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fmad2.c b/Extras/simdmathlibrary/spu/tests/fmad2.c deleted file mode 100644 index 2c3ea6a49..000000000 --- a/Extras/simdmathlibrary/spu/tests/fmad2.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Test fmad2 for SPU - 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. - */ - -/** - * - *@@ fmad2 - multiply and add (double). - * - *@brief - * boundary test for fmad2. - * - *@pre - * - *@criteria - * if input parameters are denorm, it may not work correctly. - * - *@note - * - **/ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060828114000MH","MH", "fmad2"); - -// double denorm_min = hide_double(make_double(0x0000000000000001ull)); - double denorm_max = hide_double(make_double(0x000fffffffffffffull)); -// double norm_min = hide_double(make_double(0x0010000000000000ull)); - double norm_max = hide_double(make_double(0x7fefffffffffffffull)); - - double x0 = hide_double(1760.135); - double y0 = hide_double(19355.03); - double z0 = hide_double(-12351.9); - double a0 = hide_double(34055113.82905); - - double x1 = hide_double(-139.035); - double y1 = hide_double(0.0); - double z1 = hide_double(-1.0); - - double x2 = hide_double(nan("")); - double y2 = hide_double(-1.0); - double z2 = hide_double(-0.0); - - double x3 = hide_double(1.0); - double y3 = hide_double(HUGE_VAL); - double z3 = hide_double(-1.0); - - double x4 = norm_max; - double y4 = norm_max; - double z4 = hide_double(0.0); - - double x5 = hide_double(100.0); - double y5 = denorm_max; - double z5 = hide_double(0.0); - double a5 = hide_double(make_double(0x0078fffffffffffeull)); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_double2 z0_v = spu_splats(z0); - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_double2 z1_v = spu_splats(z1); - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_double2 z2_v = spu_splats(z2); - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_double2 z3_v = spu_splats(z3); - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_double2 z4_v = spu_splats(z4); - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_double2 z5_v = spu_splats(z5); - - vec_double2 a0_v = spu_splats(a0); - vec_double2 a1_v = spu_splats(z1); - vec_double2 a5_v = spu_splats(a5); - - vec_double2 res_v; - - TEST_START("fmad2"); - res_v = fmad2(x0_v, y0_v, z0_v); - TEST_CHECK("20060828114001MH", allequal_ulps_double2( res_v, a0_v, 1 ), 0); - res_v = fmad2(y0_v, x0_v, z0_v); - TEST_CHECK("20060828114002MH", allequal_ulps_double2( res_v, a0_v, 1 ), 0); - res_v = fmad2(x1_v, y1_v, z1_v); - TEST_CHECK("20060828114003MH", allequal_ulps_double2( res_v, a1_v, 1 ), 0); - res_v = fmad2(y1_v, x1_v, z1_v); - TEST_CHECK("20060828114004MH", allequal_ulps_double2( res_v, a1_v, 1 ), 0); - res_v = fmad2(x2_v, y2_v, z2_v); - TEST_CHECK("20060828114005MH", allnan_double2( res_v ), 0); - res_v = fmad2(y2_v, x2_v, z2_v); - TEST_CHECK("20060828114006MH", allnan_double2( res_v ), 0); - res_v = fmad2(x3_v, y3_v, z3_v); - TEST_CHECK("20060828114007MH", allposinf_double2( res_v ), 0); - res_v = fmad2(y3_v, x3_v, z3_v); - TEST_CHECK("20060828114008MH", allposinf_double2( res_v ), 0); - res_v = fmad2(x4_v, y4_v, z4_v); - TEST_CHECK("20060828114009MH", allposinf_double2( res_v ), 0); - res_v = fmad2(y4_v, x4_v, z4_v); - TEST_CHECK("20060828114010MH", allposinf_double2( res_v ), 0); - res_v = fmad2(x5_v, y5_v, z5_v); - TEST_CHECK("20060828114011MH", allequal_ulps_double2( res_v, a5_v, 1 ), 0); - res_v = fmad2(y5_v, x5_v, z5_v); - TEST_CHECK("20060828114012MH", allequal_ulps_double2( res_v, a5_v, 1 ), 0); -//printf("res:%.10le, a5:%.10le\n", spu_extract(res_v, 0), spu_extract(a5_v, 0)); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fmind2_fmaxd2.c b/Extras/simdmathlibrary/spu/tests/fmind2_fmaxd2.c deleted file mode 100644 index bfaed2067..000000000 --- a/Extras/simdmathlibrary/spu/tests/fmind2_fmaxd2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test fmind2 and fmaxd2 for SPU - 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. - */ - -/** - * - *@@ fmind2_fmaxd2 - find minimum/maximum value. - * - *@brief - * boundary test for fmind2/fmaxd2. - * - *@pre - * - *@criteria - * - *@note - * - **/ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20060824103000MH","MH", "fmind2_fmaxd2"); - - double denorm_min = hide_double(make_double(0x0000000000000001ull)); - double denorm_max = hide_double(make_double(0x000fffffffffffffull)); - double norm_min = hide_double(make_double(0x0010000000000000ull)); - double norm_max = hide_double(make_double(0x7fefffffffffffffull)); - - double x0min = hide_double(1760.135); - double x0max = hide_double(19355.03); - - double x1min = hide_double(-12351.9); - double x1max = hide_double(-139.035); - - double x2min = hide_double(-1.0); - double x2max = hide_double(0.0); - - double x3min = hide_double(nan("")); - double x3max = hide_double(-1.0); - - double x4min = hide_double(-0.0); - double x4max = hide_double(0.0); - - double x5min = denorm_min; - double x5max = hide_double(1.0e-323); - - double x6min = norm_max; - double x6max = hide_double(HUGE_VAL); - - double x7min = hide_double(-HUGE_VAL); - double x7max = hide_double(19355.03); - - double x8min = hide_double(-HUGE_VAL); - double x8max = hide_double(HUGE_VAL); - - double x9min = denorm_max; - double x9max = norm_min; - - vec_double2 x0min_v = spu_splats(x0min); - vec_double2 x0max_v = spu_splats(x0max); - - vec_double2 x1min_v = spu_splats(x1min); - vec_double2 x1max_v = spu_splats(x1max); - - vec_double2 x2min_v = spu_splats(x2min); - vec_double2 x2max_v = spu_splats(x2max); - - vec_double2 x3min_v = spu_splats(x3min); - vec_double2 x3max_v = spu_splats(x3max); - - vec_double2 x4min_v = spu_splats(x4min); - vec_double2 x4max_v = spu_splats(x4max); - - vec_double2 x5min_v = spu_splats(x5min); - vec_double2 x5max_v = spu_splats(x5max); - - vec_double2 x6min_v = spu_splats(x6min); - vec_double2 x6max_v = spu_splats(x6max); - - vec_double2 x7min_v = spu_splats(x7min); - vec_double2 x7max_v = spu_splats(x7max); - - vec_double2 x8min_v = spu_splats(x8min); - vec_double2 x8max_v = spu_splats(x8max); - - vec_double2 x9min_v = spu_splats(x9min); - vec_double2 x9max_v = spu_splats(x9max); - - vec_double2 x51min_v = (vec_double2){x5min, x1min}; - vec_double2 x51max_v = (vec_double2){x5max, x1max}; - - vec_double2 res_v; - - TEST_START("fmind2"); - res_v = fmind2(x0min_v, x0max_v); - TEST_CHECK("20060824103001MH", allequal_double2( res_v, x0min_v ), 0); - res_v = fmind2(x0max_v, x0min_v); - TEST_CHECK("20060824103002MH", allequal_double2( res_v, x0min_v ), 0); - res_v = fmind2(x1min_v, x1max_v); - TEST_CHECK("20060824103003MH", allequal_double2( res_v, x1min_v ), 0); - res_v = fmind2(x1max_v, x1min_v); - TEST_CHECK("20060824103004MH", allequal_double2( res_v, x1min_v ), 0); - res_v = fmind2(x2min_v, x2max_v); - TEST_CHECK("20060824103005MH", allequal_double2( res_v, x2min_v ), 0); - res_v = fmind2(x2max_v, x2min_v); - TEST_CHECK("20060824103006MH", allequal_double2( res_v, x2min_v ), 0); - res_v = fmind2(x3min_v, x3max_v); - TEST_CHECK("20060824103007MH", allequal_double2( res_v, x3max_v ), 0); - res_v = fmind2(x3max_v, x3min_v); - TEST_CHECK("20060824103008MH", allequal_double2( res_v, x3max_v ), 0); - res_v = fmind2(x4min_v, x4max_v); - TEST_CHECK("20060824103009MH", allequal_double2( res_v, x4min_v ), 0); - res_v = fmind2(x4max_v, x4min_v); - TEST_CHECK("20060824103010MH", allequal_double2( res_v, x4min_v ), 0); - res_v = fmind2(x5min_v, x5max_v); - TEST_CHECK("20060824103011MH", allequal_double2( res_v, x5min_v ), 0); - res_v = fmind2(x5max_v, x5min_v); - TEST_CHECK("20060824103012MH", allequal_double2( res_v, x5min_v ), 0); - res_v = fmind2(x6min_v, x6max_v); - TEST_CHECK("20060824103013MH", allequal_double2( res_v, x6min_v ), 0); - res_v = fmind2(x6max_v, x6min_v); - TEST_CHECK("20060824103014MH", allequal_double2( res_v, x6min_v ), 0); - res_v = fmind2(x7min_v, x7max_v); - TEST_CHECK("20060824103015MH", allequal_double2( res_v, x7min_v ), 0); - res_v = fmind2(x7max_v, x7min_v); - TEST_CHECK("20060824103016MH", allequal_double2( res_v, x7min_v ), 0); - res_v = fmind2(x8min_v, x8max_v); - TEST_CHECK("20060824103017MH", allequal_double2( res_v, x8min_v ), 0); - res_v = fmind2(x8max_v, x8min_v); - TEST_CHECK("20060824103018MH", allequal_double2( res_v, x8min_v ), 0); - res_v = fmind2(x9min_v, x9max_v); - TEST_CHECK("20060824103019MH", allequal_double2( res_v, x9min_v ), 0); - res_v = fmind2(x9max_v, x9min_v); - TEST_CHECK("20060824103020MH", allequal_double2( res_v, x9min_v ), 0); - res_v = fmind2(x51min_v, x51max_v); - TEST_CHECK("20060824103021MH", allequal_double2( res_v, x51min_v ), 0); - res_v = fmind2(x51max_v, x51min_v); - TEST_CHECK("20060824103022MH", allequal_double2( res_v, x51min_v ), 0); - - TEST_START("fmaxd2"); - res_v = fmaxd2(x0min_v, x0max_v); - TEST_CHECK("20060824103101MH", allequal_double2( res_v, x0max_v ), 0); - res_v = fmaxd2(x0max_v, x0min_v); - TEST_CHECK("20060824103102MH", allequal_double2( res_v, x0max_v ), 0); - res_v = fmaxd2(x1min_v, x1max_v); - TEST_CHECK("20060824103103MH", allequal_double2( res_v, x1max_v ), 0); - res_v = fmaxd2(x1max_v, x1min_v); - TEST_CHECK("20060824103104MH", allequal_double2( res_v, x1max_v ), 0); - res_v = fmaxd2(x2min_v, x2max_v); - TEST_CHECK("20060824103105MH", allequal_double2( res_v, x2max_v ), 0); - res_v = fmaxd2(x2max_v, x2min_v); - TEST_CHECK("20060824103106MH", allequal_double2( res_v, x2max_v ), 0); - res_v = fmaxd2(x3min_v, x3max_v); - TEST_CHECK("20060824103107MH", allequal_double2( res_v, x3max_v ), 0); - res_v = fmaxd2(x3max_v, x3min_v); - TEST_CHECK("20060824103108MH", allequal_double2( res_v, x3max_v ), 0); - res_v = fmaxd2(x4min_v, x4max_v); - TEST_CHECK("20060824103109MH", allequal_double2( res_v, x4max_v ), 0); - res_v = fmaxd2(x4max_v, x4min_v); - TEST_CHECK("20060824103110MH", allequal_double2( res_v, x4max_v ), 0); - res_v = fmaxd2(x5min_v, x5max_v); - TEST_CHECK("20060824103111MH", allequal_double2( res_v, x5max_v ), 0); - res_v = fmaxd2(x5max_v, x5min_v); - TEST_CHECK("20060824103112MH", allequal_double2( res_v, x5max_v ), 0); - res_v = fmaxd2(x6min_v, x6max_v); - TEST_CHECK("20060824103113MH", allequal_double2( res_v, x6max_v ), 0); - res_v = fmaxd2(x6max_v, x6min_v); - TEST_CHECK("20060824103114MH", allequal_double2( res_v, x6max_v ), 0); - res_v = fmaxd2(x7min_v, x7max_v); - TEST_CHECK("20060824103115MH", allequal_double2( res_v, x7max_v ), 0); - res_v = fmaxd2(x7max_v, x7min_v); - TEST_CHECK("20060824103116MH", allequal_double2( res_v, x7max_v ), 0); - res_v = fmaxd2(x8min_v, x8max_v); - TEST_CHECK("20060824103117MH", allequal_double2( res_v, x8max_v ), 0); - res_v = fmaxd2(x8max_v, x8min_v); - TEST_CHECK("20060824103118MH", allequal_double2( res_v, x8max_v ), 0); - res_v = fmaxd2(x9min_v, x9max_v); - TEST_CHECK("20060824103119MH", allequal_double2( res_v, x9max_v ), 0); - res_v = fmaxd2(x9max_v, x9min_v); - TEST_CHECK("20060824103120MH", allequal_double2( res_v, x9max_v ), 0); - res_v = fmaxd2(x51min_v, x51max_v); - TEST_CHECK("20060824103121MH", allequal_double2( res_v, x51max_v ), 0); - res_v = fmaxd2(x51max_v, x51min_v); - TEST_CHECK("20060824103122MH", allequal_double2( res_v, x51max_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fminf4_fmaxf4.c b/Extras/simdmathlibrary/spu/tests/fminf4_fmaxf4.c deleted file mode 100644 index dd0bcd4a3..000000000 --- a/Extras/simdmathlibrary/spu/tests/fminf4_fmaxf4.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Test fminf4 and fmaxf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040928184342EJL","EJL", "fminf4_fmaxf4"); - - float x0min = hide_float(1760.135f); - float x0max = hide_float(19355.03f); - - float x1min = hide_float(-12351.9f); - float x1max = hide_float(-139.035f); - - float x2min = hide_float(-1.0); - float x2max = hide_float(0.0); - - vec_float4 x0min_v = spu_splats(x0min); - vec_float4 x0max_v = spu_splats(x0max); - - vec_float4 x1min_v = spu_splats(x1min); - vec_float4 x1max_v = spu_splats(x1max); - - vec_float4 x2min_v = spu_splats(x2min); - vec_float4 x2max_v = spu_splats(x2max); - - float res; - vec_float4 res_v; - - TEST_START("fminf4"); - res_v = fminf4(x0min_v, x0max_v); - TEST_CHECK("20040928184345EJL", allequal_float4( res_v, x0min_v ), 0); - res_v = fminf4(x0max_v, x0min_v); - TEST_CHECK("20040928184349EJL", allequal_float4( res_v, x0min_v ), 0); - res_v = fminf4(x1min_v, x1max_v); - TEST_CHECK("20040928184351EJL", allequal_float4( res_v, x1min_v ), 0); - res_v = fminf4(x1max_v, x1min_v); - TEST_CHECK("20040928184353EJL", allequal_float4( res_v, x1min_v ), 0); - res_v = fminf4(x2min_v, x2max_v); - TEST_CHECK("20040928184354EJL", allequal_float4( res_v, x2min_v ), 0); - res_v = fminf4(x2max_v, x2min_v); - TEST_CHECK("20040928184356EJL", allequal_float4( res_v, x2min_v ), 0); - - TEST_START("fminf"); - res = fminf(x0min, x0max); - TEST_CHECK("20040928184358EJL", res == x0min, 0); - res = fminf(x0max, x0min); - TEST_CHECK("20040928184400EJL", res == x0min, 0); - res = fminf(x1min, x1max); - TEST_CHECK("20040928184401EJL", res == x1min, 0); - res = fminf(x1max, x1min); - TEST_CHECK("20040928184403EJL", res == x1min, 0); - res = fminf(x2min, x2max); - TEST_CHECK("20040928184405EJL", res == x2min, 0); - res = fminf(x2max, x2min); - TEST_CHECK("20040928184406EJL", res == x2min, 0); - - TEST_START("fmaxf4"); - res_v = fmaxf4(x0min_v, x0max_v); - TEST_CHECK("20040928184411EJL", allequal_float4( res_v, x0max_v ), 0); - res_v = fmaxf4(x0max_v, x0min_v); - TEST_CHECK("20040928184413EJL", allequal_float4( res_v, x0max_v ), 0); - res_v = fmaxf4(x1min_v, x1max_v); - TEST_CHECK("20040928184415EJL", allequal_float4( res_v, x1max_v ), 0); - res_v = fmaxf4(x1max_v, x1min_v); - TEST_CHECK("20040928184416EJL", allequal_float4( res_v, x1max_v ), 0); - res_v = fmaxf4(x2min_v, x2max_v); - TEST_CHECK("20040928184417EJL", allequal_float4( res_v, x2max_v ), 0); - res_v = fmaxf4(x2max_v, x2min_v); - TEST_CHECK("20040928184419EJL", allequal_float4( res_v, x2max_v ), 0); - - TEST_START("fmaxf"); - res = fmaxf(x0min, x0max); - TEST_CHECK("20040928184420EJL", res == x0max, 0); - res = fmaxf(x0max, x0min); - TEST_CHECK("20040928184422EJL", res == x0max, 0); - res = fmaxf(x1min, x1max); - TEST_CHECK("20040928184423EJL", res == x1max, 0); - res = fmaxf(x1max, x1min); - TEST_CHECK("20040928184424EJL", res == x1max, 0); - res = fmaxf(x2min, x2max); - TEST_CHECK("20040928184426EJL", res == x2max, 0); - res = fmaxf(x2max, x2min); - TEST_CHECK("20040928184428EJL", res == x2max, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fmodd2.c b/Extras/simdmathlibrary/spu/tests/fmodd2.c deleted file mode 100644 index 6e1b842e2..000000000 --- a/Extras/simdmathlibrary/spu/tests/fmodd2.c +++ /dev/null @@ -1,364 +0,0 @@ -/* Test roundd2 for SPU - 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. - */ -/** - * - *@@ fmodd2 - - * - *@brief - * boundary test for fmodd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -typedef union { - struct { - double xxx[2]; - double yyy[2]; - double rrr[2]; - } dbl; - struct { - unsigned long long xxx[2]; - unsigned long long yyy[2]; - unsigned long long rrr[2]; - } ull; -} TestVec_Roundd2; - -int main() -{ - TestVec_Roundd2 test_a[] = { -{ -ull:{ -// 1.00...11 / 1.0...0 -> 0.00...11, 1.00...1 /1.0...0 -> 0.0...1 -{0x3ff0000000000003ULL,0x3ff0000000000001ULL}, -{0x3fe0000000000000ULL,0x3fe0000000000000ULL}, -{0x3cc8000000000000ULL,0x3cb0000000000000ULL} -} -},{ -ull:{ -// 1.00...1111 / 0.10...0 -> 0.00...11, 1.00...1 /0.10...0 -> 0.0...1 -{0x3ff000000000000fULL,0x3ff0000000000001ULL}, -{0x3fe0000000000000ULL,0x3fe0000000000000ULL}, -{0x3cee000000000000ULL,0x3cb0000000000000ULL} -} -}, - -{ -ull:{ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0x0000000000000000ULL, 0x7aa0000000000000ULL},/*(0.000000 4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0x7ff0000000000000ULL, 0x0000000000000001ULL},/*(inf 0.000000)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0xfff0000000000000ULL, 0x7fffffffeffffffeULL},/*(-inf nan)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x0000000000000000ULL, 0x7aa0000000000000ULL},/*(0.000000 4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0x0000000000000001ULL},/*(inf 0.000000)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0xfff0000000000000ULL, 0x7fffffffeffffffeULL},/*(-inf nan)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL},/*(nan nan)*/ -{0x7fffffffeffffffeULL, 0x7fffffffeffffffeULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x0000000000000000ULL, 0x7aa0000000000000ULL},/*(0.000000 4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL},/*(0.000000 0.000000)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0x0000000000000001ULL},/*(inf 0.000000)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL},/*(0.000000 0.000000)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0xfff0000000000000ULL, 0x7fffffffeffffffeULL},/*(-inf nan)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL},/*(0.000000 0.000000)*/ -{0x0000000000000000ULL, 0x7fffffffeffffffeULL}/*(0.000000, nan)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0x7ff0000000000000ULL},/*(inf inf)*/ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x7ff8000000000000ULL, 0x7ff8000000000000ULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0xfff0000000000000ULL, 0xfff0000000000000ULL},/*(-inf -inf)*/ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x7ff8000000000000ULL, 0x7ff8000000000000ULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x7aa0000000000000ULL, 0x7aa0000000000000ULL},/*(4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000 4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000)*/ -{0x7ff8000000000000ULL, 0x7ff8000000000000ULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x0000000000000001ULL, 0x0000000000000001ULL},/*(0.000000 0.000000)*/ -{0x7ff8000000000000ULL, 0x7ff8000000000000ULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x7aa0000000000000ULL, 0x0000000000000001ULL},/*(4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000 0.000000)*/ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x7aa0000000000000ULL, 0x0000000000000001ULL}/*(4646927838993072071243945306718439250410188130185607684549287060362314553626263667328650982800488595593121011844353040782670578892327830336846345565944983205571783876398312106070895030732180427719497486819848241268961714708993375275490934188589556509412640954544199727574266715045888.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0000000000000000ULL, 0x0000000000000000ULL},/*(0.000000 0.000000)*/ -{0x7ff0000000000000ULL, 0xfff0000000000000ULL},/*(inf -inf)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x7fefffffffffffffULL, 0x7fefffffffffffffULL},/*(179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0x7feffffffffffffeULL, 0x7feeffffffffffffULL},/*(179769313486231550856124328384506240234343437157459335924404872448581845754556114388470639943126220321960804027157371570809852884964511743044087662767600909594331927728237078876188760579532563768698654064825262115771015791463983014857704008123419459386245141723703148097529108423358883457665451722744025579520.000000 174151522439786833602873345010488654505514389466650288559122786766978114661106633662692418716441642670880455394768401421807484146614013663315566064496053950599244663907024235661361045727850388502842959666202477512028391028080020983119748774627722497113443122745251401348739825745341808746724299140883367854080.000000)*/ -{0x7ca0000000000000ULL, 0x7fa0000000000000ULL}/*(19958403095347198116563727130368385660674512604354575415025472424372118918689640657849579654926357010893424468441924952439724379883935936607391717982848314203200056729510856765175377214443629871826533567445439239933308104551208703888888552684480441575071209068757560416423584952303440099278848.000000, 5617791046444737211654078721215702292556178059194708039794690036179146118921905097897139916325235500660003558745981042426837180275450519452901482207483566386805246669527046414884444362538940441232908842252656430276192208823201965046059784704400851161354703458893321819998351435577491134526104885300757004288.000000)*/ -} -}, -{ -ull:{ -{0x0008000000000000ULL, 0x7fefffffffffffffULL},/*(0.000000 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0x7ff0000000000000ULL, 0x7ff0000000000000ULL},/*(inf inf)*/ -{0x0008000000000000ULL, 0x7fefffffffffffffULL}/*(0.000000, 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -} -}, -{ -ull:{ -{0x7fefffffffffffffULL, 0x0010000000000000ULL},/*(179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 0.000000)*/ -{0x7fdfffffffffffffULL, 0x0008000000000003ULL},/*(89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184.000000 0.000000)*/ -{0x0000000000000000ULL, 0x0007fffffffffffdULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x7ff0000000000000ULL, 0x7fefffffffffffffULL},/*(inf 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0x7fefffffffffffffULL, 0x0000000000000003ULL},/*(179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 0.000000)*/ -{0x7ff8000000000000ULL, 0x0000000000000002ULL}/*(nan, 0.000000)*/ -} -}, -{ -ull:{ -{0xffe0000000000000ULL, 0x7fefffffffffffffULL},/*(-89884656743115795386465259539451236680898848947115328636715040578866337902750481566354238661203768010560056939935696678829394884407208311246423715319737062188883946712432742638151109800623047059726541476042502884419075341171231440736956555270413618581675255342293149119973622969239858152417678164812112068608.000000 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0x0008000000000000ULL, 0x0010000000000000ULL},/*(0.000000 0.000000)*/ -{0x8000000000000000ULL, 0x0000000000000000ULL}/*(-0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x4004000000000000ULL, 0x403d000000000000ULL},/*(2.500000 29.000000)*/ -{0x3ff8000000000000ULL, 0x4008000000000000ULL},/*(1.500000 3.000000)*/ -{0x3ff0000000000000ULL, 0x4000000000000000ULL}/*(1.000000, 2.000000)*/ -} -}, -{ -ull:{ -{0x8010000000000002ULL, 0x9000000000000000ULL},/*(-0.000000 -0.000000)*/ -{0x8000000000000000ULL, 0x0000000000000000ULL},/*(-0.000000 0.000000)*/ -{0x0000000000000000ULL, 0x0000000000000000ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0xffefffffffffffffULL, 0x7fefffffffffffffULL},/*(-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0xffefffffffffffffULL, 0x7fefffffffffffffULL},/*(-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000)*/ -{0x8000000000000000ULL, 0x0000000000000000ULL}/*(-0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0xfff0000000000000ULL, 0x7ff0000000000000ULL},/*(-inf inf)*/ -{0xfff0000000000000ULL, 0x7ff0000000000000ULL},/*(-inf inf)*/ -{0x7ff8000000000000ULL, 0x7ff8000000000000ULL}/*(nan, nan)*/ -} -}, -{ -ull:{ -{0x800ffffffffffff3ULL, 0x09d0000000000006ULL},/*(-0.000000 0.000000)*/ -{0x8000000000000005ULL, 0x8010000000000005ULL},/*(-0.000000 -0.000000)*/ -{0x8000000000000003ULL, 0x000fffffffffff88ULL}/*(-0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x1000000000000000ULL, 0x0000000000000001ULL},/*(0.000000 0.000000)*/ -{0x0010000000000005ULL, 0x8000000000000001ULL},/*(0.000000 -0.000000)*/ -{0x00058000000001eaULL, 0x0000000000000000ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0010000000000002ULL, 0x1000000000000000ULL},/*(0.000000 0.000000)*/ -{0x800000000000000bULL, 0x0010000000000007ULL},/*(-0.000000 0.000000)*/ -{0x0000000000000006ULL, 0x000c800000000e62ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0000000000000002ULL, 0x0000000000000003ULL},/*(0.000000 0.000000)*/ -{0x0000000000000003ULL, 0x0000000000000002ULL},/*(0.000000 0.000000)*/ -{0x0000000000000002ULL, 0x0000000000000001ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x806ffffffffffff3ULL, 0x0010000000000000ULL},/*(-0.000000 0.000000)*/ -{0x8000000000000005ULL, 0x0000000000000009ULL},/*(-0.000000 0.000000)*/ -{0x8000000000000003ULL, 0x0000000000000007ULL}/*(-0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0000000000000000ULL, 0x8000000000000000ULL},/*(0.000000 -0.000000)*/ -{0x800ffffffffffff1ULL, 0x0000000000000003ULL},/*(-0.000000 0.000000)*/ -{0x0000000000000000ULL, 0x8000000000000000ULL}/*(0.000000, -0.000000)*/ -} -}, -{ -ull:{ -{0x1000000000000000ULL, 0x8000000000000000ULL},/*(0.000000 -0.000000)*/ -{0x0010000000000005ULL, 0x0000000000000001ULL},/*(0.000000 0.000000)*/ -{0x00058000000001eaULL, 0x8000000000000000ULL}/*(0.000000, -0.000000)*/ -} -}, -{ -ull:{ -{0x0fbfffffffffffffULL, 0x0f30000000000000ULL},/*(0.000000 0.000000)*/ -{0x000ffffffffffff1ULL, 0x0000000000000003ULL},/*(0.000000 0.000000)*/ -{0x000b7400000053f7ULL, 0x0000000000000001ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0000000000000003ULL, 0x0000000000000003ULL},/*(0.000000 0.000000)*/ -{0x0000000000000006ULL, 0x8000000000000006ULL},/*(0.000000 -0.000000)*/ -{0x0000000000000003ULL, 0x0000000000000003ULL}/*(0.000000, 0.000000)*/ -} -}, -{ -ull:{ -{0x0020000000000001ULL, 0x8020000000000001ULL},/*(0.000000 -0.000000)*/ -{0x8010000000000002ULL, 0x0010000000000002ULL},/*(-0.000000 0.000000)*/ -{0x0010000000000000ULL, 0x8010000000000000ULL}/*(0.000000, -0.000000)*/ -} -}, - - - { - ull:{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - //vec_double2 input; - - TEST_SET_START("96743652190000NM","FLR", "floord2"); - - TEST_START("floord2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ull.xxx[0] == 0) - && (test_a[ii].ull.xxx[1] == 0) - && (test_a[ii].ull.xxx[2] == 0) ) break; - - //input = *((vec_double2 *)&test_a[ii].dbl.xxx[0]); - res_v = fmodd2 (*((vec_double2 *)&test_a[ii].dbl.xxx[0]), - *((vec_double2 *)&test_a[ii].dbl.yyy[0]) ); - sprintf(msg,"9674365219%04dFLR", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, (vec_llong2)*((vec_double2 *)&test_a[ii].dbl.rrr[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/fmodf4.c b/Extras/simdmathlibrary/spu/tests/fmodf4.c deleted file mode 100644 index 48766f430..000000000 --- a/Extras/simdmathlibrary/spu/tests/fmodf4.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Test fmodf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040928191240EJL","EJL", "fmodf4"); - - unsigned int i0n = 0x449edbc6; - unsigned int i0d = 0x40cf799d; - unsigned int i0r = 0x3daa7300; - unsigned int i1n = 0x6bca107a; - unsigned int i1d = 0x6c4a107a; - unsigned int i1r = 0x6bca107a; - unsigned int i2n = 0x1c123605; - unsigned int i2d = 0x1c923602; - unsigned int i2r = 0x1c123605; - unsigned int i3n = 0x2b4c50fa; - unsigned int i3d = 0x253a3ae3; - unsigned int i3r = 0x25141df9; - unsigned int i4n = 0x73addffc; - unsigned int i4d = 0x742ddffc; - unsigned int i4r = 0x73addffc; - unsigned int i5n = 0x29d4d97c; - unsigned int i5d = 0x2a546e77; - unsigned int i5r = 0x29d4d97c; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0d_v = spu_splats(x0d); - vec_float4 x0r_v = spu_splats(x0r); - - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1d_v = spu_splats(x1d); - vec_float4 x1r_v = spu_splats(x1r); - - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2d_v = spu_splats(x2d); - vec_float4 x2r_v = spu_splats(x2r); - - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3d_v = spu_splats(x3d); - vec_float4 x3r_v = spu_splats(x3r); - - vec_float4 x4n_v = spu_splats(x4n); - vec_float4 x4d_v = spu_splats(x4d); - vec_float4 x4r_v = spu_splats(x4r); - - vec_float4 x5n_v = spu_splats(x5n); - vec_float4 x5d_v = spu_splats(x5d); - vec_float4 x5r_v = spu_splats(x5r); - - float res; - vec_float4 res_v; - - TEST_START("fmodf4"); - res_v = fmodf4(x0n_v, x0d_v); - TEST_CHECK("20040928191245EJL", allequal_ulps_float4( res_v, x0r_v, 1 ), 0); - res_v = fmodf4(x1n_v, x1d_v); - TEST_CHECK("20040928191247EJL", allequal_ulps_float4( res_v, x1r_v, 1 ), 0); - res_v = fmodf4(x2n_v, x2d_v); - TEST_CHECK("20040928191249EJL", allequal_ulps_float4( res_v, x2r_v, 1 ), 0); - res_v = fmodf4(x3n_v, x3d_v); - TEST_CHECK("20040928191251EJL", allequal_ulps_float4( res_v, x3r_v, 1 ), 0); - res_v = fmodf4(x4n_v, x4d_v); - TEST_CHECK("20040928191253EJL", allequal_ulps_float4( res_v, x4r_v, 1 ), 0); - res_v = fmodf4(x5n_v, x5d_v); - TEST_CHECK("20040928191255EJL", allequal_ulps_float4( res_v, x5r_v, 1 ), 0); - - TEST_START("fmodf"); - res = fmodf(x0n, x0d); - TEST_CHECK("20040928191258EJL", ulpDiff_f( res, x0r ) <= 1, 0); - res = fmodf(x1n, x1d); - TEST_CHECK("20040928191300EJL", ulpDiff_f( res, x1r ) <= 1, 0); - res = fmodf(x2n, x2d); - TEST_CHECK("20040928191302EJL", ulpDiff_f( res, x2r ) <= 1, 0); - res = fmodf(x3n, x3d); - TEST_CHECK("20040928191303EJL", ulpDiff_f( res, x3r ) <= 1, 0); - res = fmodf(x4n, x4d); - TEST_CHECK("20040928191305EJL", ulpDiff_f( res, x4r ) <= 1, 0); - res = fmodf(x5n, x5d); - TEST_CHECK("20040928191307EJL", ulpDiff_f( res, x5r ) <= 1, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fpclassifyd2.c b/Extras/simdmathlibrary/spu/tests/fpclassifyd2.c deleted file mode 100644 index b7206bb07..000000000 --- a/Extras/simdmathlibrary/spu/tests/fpclassifyd2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test fpclassifyd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060828000000AAN","AAN", "fpclassifyd2"); - - // -Nan - double x0 = hide_double(-nan("")); - long long r0 = FP_NAN; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - long long r1 = FP_INFINITE; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - long long r2 = FP_NORMAL; - - // -Norm - double x3 = hide_double(-824842.58421394); - long long r3 = FP_NORMAL; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - long long r4 = FP_NORMAL; - - // -Denorm - double x5 = hide_double(-2.40e-310); - long long r5 = FP_SUBNORMAL; - - // -Unf - double x6 = hide_double(-1.0e-999); - long long r6 = FP_ZERO; - - // -0 - double x7 = hide_double(-0.0); - long long r7 = FP_ZERO; - - // 0 - double x8 = hide_double( 0.0); - long long r8 = FP_ZERO; - - // +Unf - double x9 = hide_double( 1.0e-999); - long long r9 = FP_ZERO; - - // +Denorm - double x10 = hide_double( 2.40e-310); - long long r10 = FP_SUBNORMAL; - - // +Dmin - double x11 = hide_double( DBL_MIN); - long long r11 = FP_NORMAL; - - // +Norm - double x12 = hide_double(3.14152634); - long long r12 = FP_NORMAL; - - // +Dmax - double x13 = hide_double(DBL_MAX); - long long r13 = FP_NORMAL; - - // +Inf - double x14 = hide_double(HUGE_VAL); - long long r14 = FP_INFINITE; - - //+Nan - double x15 = hide_double( nan("")); - long long r15 = FP_NAN; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0x000AAAAAAAAAAAAAull), -1.0e-999 }; - vec_llong2 r16_v = (vec_llong2) {FP_SUBNORMAL, FP_ZERO}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_llong2 r17_v = (vec_llong2) {FP_NORMAL, FP_SUBNORMAL}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_llong2 r18_v = (vec_llong2) {FP_NAN, FP_NORMAL}; - - // Compound - vec_double2 x19_v = (vec_double2) {HUGE_VAL, -nan("") }; - vec_llong2 r19_v = (vec_llong2) {FP_INFINITE, FP_NAN}; - - // Compound - vec_double2 x20_v = (vec_double2) { -1.0e-999, -HUGE_VAL} ; - vec_llong2 r20_v = (vec_llong2) {FP_ZERO, FP_INFINITE}; - - vec_double2 x0_v = spu_splats(x0); - vec_llong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_llong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_llong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_llong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_llong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_llong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_llong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_llong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_llong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_llong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_llong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_llong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_llong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_llong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_llong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_llong2 r15_v = spu_splats(r15); - - vec_llong2 res_v; - - TEST_START("fpclassifyd2"); - - res_v = (vec_llong2)fpclassifyd2(x0_v); - TEST_CHECK("20060828000000AAN", allequal_llong2( res_v, r0_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x1_v); - TEST_CHECK("20060828000001AAN", allequal_llong2( res_v, r1_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x2_v); - TEST_CHECK("20060828000002AAN", allequal_llong2( res_v, r2_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x3_v); - TEST_CHECK("20060828000003AAN", allequal_llong2( res_v, r3_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x4_v); - TEST_CHECK("20060828000004AAN", allequal_llong2( res_v, r4_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x5_v); - TEST_CHECK("20060828000005AAN", allequal_llong2( res_v, r5_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x6_v); - TEST_CHECK("20060828000006AAN", allequal_llong2( res_v, r6_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x7_v); - TEST_CHECK("20060828000007AAN", allequal_llong2( res_v, r7_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x8_v); - TEST_CHECK("20060828000008AAN", allequal_llong2( res_v, r8_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x9_v); - TEST_CHECK("20060828000009AAN", allequal_llong2( res_v, r9_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x10_v); - TEST_CHECK("20060828000010AAN", allequal_llong2( res_v, r10_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x11_v); - TEST_CHECK("20060828000011AAN", allequal_llong2( res_v, r11_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x12_v); - TEST_CHECK("20060828000012AAN", allequal_llong2( res_v, r12_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x13_v); - TEST_CHECK("20060828000013AAN", allequal_llong2( res_v, r13_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x14_v); - TEST_CHECK("20060828000014AAN", allequal_llong2( res_v, r14_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x15_v); - TEST_CHECK("20060828000015AAN", allequal_llong2( res_v, r15_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x16_v); - TEST_CHECK("20060828000016AAN", allequal_llong2( res_v, r16_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x17_v); - TEST_CHECK("20060828000017AAN", allequal_llong2( res_v, r17_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x18_v); - TEST_CHECK("20060828000018AAN", allequal_llong2( res_v, r18_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x19_v); - TEST_CHECK("20060828000019AAN", allequal_llong2( res_v, r19_v ), 0); - res_v = (vec_llong2)fpclassifyd2(x20_v); - TEST_CHECK("20060828000020AAN", allequal_llong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/fpclassifyf4.c b/Extras/simdmathlibrary/spu/tests/fpclassifyf4.c deleted file mode 100644 index e1cdc8d7b..000000000 --- a/Extras/simdmathlibrary/spu/tests/fpclassifyf4.c +++ /dev/null @@ -1,200 +0,0 @@ -/* Test fpclassifyf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060828000000AAN","AAN", "fpclassifyf4"); - - // -Nan - float x0 = hide_float(-NANF); - int r0 = FP_NORMAL; - - // -Inf - float x1 = hide_float(-HUGE_VALF); - int r1 = FP_NORMAL; - - // -Smax - float x2 = hide_float(make_float(0xFFFFFFFF)); - int r2 = FP_NORMAL; - - // -Norm - float x3 = hide_float(-824842.58421394f); - int r3 = FP_NORMAL; - - // -Smin - float x4 = hide_float(make_float(0x80800000)); - int r4 = FP_NORMAL; - - // -Denorm - float x5 = hide_float(make_float(0x803AAAAA)); - int r5 = FP_SUBNORMAL; - - // -Unf - float x6 = hide_float(-1.0e-999); - int r6 = FP_ZERO; - - // -0 - float x7 = hide_float(-0.0f); - int r7 = FP_ZERO; - - // 0 - float x8 = hide_float( 0.0f); - int r8 = FP_ZERO; - - // +Unf - float x9 = hide_float( 1.0e-999); - int r9 = FP_ZERO; - - // +Denorm - float x10 = hide_float(make_float(0x003AAAAA)); - int r10 = FP_SUBNORMAL; - - // +Smin - float x11 = hide_float(make_float(0x00800000)); - int r11 = FP_NORMAL; - - // +Norm - float x12 = hide_float(3.14152634f); - int r12 = FP_NORMAL; - - // +Smax - float x13 = hide_float(make_float(0x7FFFFFFF)); - int r13 = FP_NORMAL; - - // +Inf - float x14 = hide_float(HUGE_VALF); - int r14 = FP_NORMAL; - - //+Nan - float x15 = hide_float(NANF); - int r15 = FP_NORMAL; - - // Compound - vec_float4 x16_v = (vec_float4) {make_float(0x003AAAAA), -1.0e-999, 345.27533, make_float(0x803AAAAA)}; - vec_int4 r16_v = (vec_int4) {FP_SUBNORMAL, FP_ZERO, FP_NORMAL, FP_SUBNORMAL}; - - vec_float4 x0_v = spu_splats(x0); - vec_int4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_int4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_int4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_int4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_int4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_int4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_int4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_int4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_int4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_int4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_int4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_int4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_int4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_int4 r13_v = spu_splats(r13); - - vec_float4 x14_v = spu_splats(x14); - vec_int4 r14_v = spu_splats(r14); - - vec_float4 x15_v = spu_splats(x15); - vec_int4 r15_v = spu_splats(r15); - - vec_int4 res_v; - - TEST_START("fpclassifyf4"); - - res_v = (vec_int4)fpclassifyf4(x0_v); - TEST_CHECK("20060828000000AAN", allequal_int4( res_v, r0_v ), 0); - res_v = (vec_int4)fpclassifyf4(x1_v); - TEST_CHECK("20060828000001AAN", allequal_int4( res_v, r1_v ), 0); - res_v = (vec_int4)fpclassifyf4(x2_v); - TEST_CHECK("20060828000002AAN", allequal_int4( res_v, r2_v ), 0); - res_v = (vec_int4)fpclassifyf4(x3_v); - TEST_CHECK("20060828000003AAN", allequal_int4( res_v, r3_v ), 0); - res_v = (vec_int4)fpclassifyf4(x4_v); - TEST_CHECK("20060828000004AAN", allequal_int4( res_v, r4_v ), 0); - res_v = (vec_int4)fpclassifyf4(x5_v); - TEST_CHECK("20060828000005AAN", allequal_int4( res_v, r5_v ), 0); - res_v = (vec_int4)fpclassifyf4(x6_v); - TEST_CHECK("20060828000006AAN", allequal_int4( res_v, r6_v ), 0); - res_v = (vec_int4)fpclassifyf4(x7_v); - TEST_CHECK("20060828000007AAN", allequal_int4( res_v, r7_v ), 0); - res_v = (vec_int4)fpclassifyf4(x8_v); - TEST_CHECK("20060828000008AAN", allequal_int4( res_v, r8_v ), 0); - res_v = (vec_int4)fpclassifyf4(x9_v); - TEST_CHECK("20060828000009AAN", allequal_int4( res_v, r9_v ), 0); - res_v = (vec_int4)fpclassifyf4(x10_v); - TEST_CHECK("20060828000010AAN", allequal_int4( res_v, r10_v ), 0); - res_v = (vec_int4)fpclassifyf4(x11_v); - TEST_CHECK("20060828000011AAN", allequal_int4( res_v, r11_v ), 0); - res_v = (vec_int4)fpclassifyf4(x12_v); - TEST_CHECK("20060828000012AAN", allequal_int4( res_v, r12_v ), 0); - res_v = (vec_int4)fpclassifyf4(x13_v); - TEST_CHECK("20060828000013AAN", allequal_int4( res_v, r13_v ), 0); - res_v = (vec_int4)fpclassifyf4(x14_v); - TEST_CHECK("20060828000014AAN", allequal_int4( res_v, r14_v ), 0); - res_v = (vec_int4)fpclassifyf4(x15_v); - TEST_CHECK("20060828000015AAN", allequal_int4( res_v, r15_v ), 0); - res_v = (vec_int4)fpclassifyf4(x16_v); - TEST_CHECK("20060828000016AAN", allequal_int4( res_v, r16_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/frexpd2.c b/Extras/simdmathlibrary/spu/tests/frexpd2.c deleted file mode 100644 index e7ddefd45..000000000 --- a/Extras/simdmathlibrary/spu/tests/frexpd2.c +++ /dev/null @@ -1,418 +0,0 @@ -/* Test frexpd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060907000000AAN","AAN", "frexpd2"); - - vec_double2 res_v; - vec_llong2 exp_v; - - // -Nan - double x0 = hide_double(-nan("")); - double r0 = hide_double( nan("")); - //long long e0 = 0; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - double r1 = x1; - //long long e1 = 0; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - double r2 = hide_double(make_double(0xBFEFFFFFFFFFFFFFull)); - long long e2 = 1024; - - // -Norm - double x3 = hide_double(-824842.58421394); - double r3 = hide_double(make_double(0xBFE92C152B1E16ECull)); - long long e3 = 20; - - // -Dmin - double x4 = hide_double(make_double(0x8000000000000001ull)); - double r4 = hide_double(make_double(0xBFE0000000000000ull)); - long long e4 = -1073; - - // -Denorm - double x5 = hide_double(-2.40e-310); - double r5 = hide_double(make_double(0xBFE6170DBAADCD80ull)); - long long e5 = -1028; - - // -Unf - double x6 = hide_double(-1.0e-999); - double r6 = hide_double(make_double(0x0000000000000000ull)); - long long e6 = 0; - - // -0 - double x7 = hide_double(-0.0); - double r7 = hide_double(make_double(0x0000000000000000ull)); - long long e7 = 0; - - // 0 - double x8 = hide_double( 0.0); - double r8 = hide_double(make_double(0x0000000000000000ull)); - long long e8 = 0; - - // +Unf - double x9 = hide_double( 1.0e-999); - double r9 = hide_double(make_double(0x0000000000000000ull)); - long long e9 = 0; - - // +Denorm - double x10 = hide_double( 2.40e-310); - double r10 = hide_double(make_double(0x3FE6170DBAADCD80ull)); - long long e10 = -1028; - - // +Dmin - double x11 = hide_double(make_double(0x0000000000000001ull)); - double r11 = hide_double(make_double(0x3FE0000000000000ull)); - long long e11 = -1073; - - // +Norm - double x12 = hide_double(3.14152634); - double r12 = hide_double(make_double(0x3FE921D88FCE94A3ull)); - long long e12 = 2; - - // +Norm - double x13 = hide_double(7.0673903e149); - double r13 = hide_double(make_double(0x3FEBA2C056BA0DB2ull)); - long long e13 = 498; - - // +Norm - double x14 = hide_double(2.4673e304); - double r14 = hide_double(make_double(0x3FE1FD485BDF688Eull)); - long long e14 = 1012; - - // +Norm - double x15 = hide_double(7.235672e-25); - double r15 = hide_double(make_double(0x3FEBFDDCCA6FF682ull)); - long long e15 = -80; - - // +Denorm - double x16 = hide_double(9.452854e-312); - double r16 = hide_double(make_double(0x3FEBD784FE999000ull)); - long long e16 = -1033; - - // +Demorm - double x17 = hide_double(3.045784e-320); - double r17 = hide_double(make_double(0x3FE8150000000000ull)); - long long e17 = -1061; - - // -Norm - double x18 = hide_double(-6.459273e7); - double r18 = hide_double(make_double(0xBFEECCDAD0000000ull)); - long long e18 = 26; - - // -Norm - double x19 = hide_double(-2.493472e-99); - double r19 = hide_double(make_double(0xBFE5D0BDA52F448Cull)); - long long e19 = -327; - - // -Norm - double x20 = hide_double(-1.4824543e128); - double r20 = hide_double(make_double(0xBFEB5FFBEAE7B3E1ull)); - long long e20 = 426; - - // -Denorm - double x21 = hide_double(-5.53856231e-315); - double r21 = hide_double(make_double(0xBFE0B457A5000000ull)); - long long e21 = -1043; - - // -Demorm - double x22 = hide_double(-2.5684367e-312); - double r22 = hide_double(make_double(0xBFEE427A82514000ull)); - long long e22 = -1035; - - // +Dmax - double x23 = hide_double(DBL_MAX); - double r23 = hide_double(make_double(0x3FEFFFFFFFFFFFFFull)); - long long e23 = 1024; - - // +Inf - double x24 = hide_double(HUGE_VAL); - double r24 = x24; - //long long e24 = 0; - - //+Nan - double x25 = hide_double( nan("")); - double r25 = hide_double( nan("")); - //long long e25 = 0; - - // Compound - vec_double2 x26_v = (vec_double2) { -2.561286432e-317, -1.0e-999 }; - vec_double2 r26_v = (vec_double2) { hide_double(make_double(0xBFE3C69940000000ull)), 0.0 }; - vec_llong2 e26_v = (vec_llong2) { -1051, 0 }; - - // Compound - vec_double2 x27_v = (vec_double2) { 345.27533, -8.673e-310 }; - vec_double2 r27_v = (vec_double2) { hide_double(make_double(0x3FE59467C06E19B9ull)), hide_double(make_double(0xBFE3F4FCCDB156C0ull)) }; - vec_llong2 e27_v = (vec_llong2) { 9, -1026 }; - - // Compound - vec_llong2 keep28_v = exp_v; - vec_double2 x28_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_double2 r28_v = (vec_double2) { nan(""), hide_double(make_double(0xBFEC1043703246A4ull)) }; - vec_llong2 e28_v = (vec_llong2) { spu_extract(exp_v, 0), 22 }; - - // Compound - vec_llong2 keep29_v = exp_v; - vec_double2 x29_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_double2 r29_v = (vec_double2) { HUGE_VAL, nan("") }; - vec_llong2 e29_v = (vec_llong2) { spu_extract(exp_v, 0), spu_extract(exp_v, 1) }; - - // Compound - vec_llong2 keep30_v = exp_v; - vec_double2 x30_v = (vec_double2) { -1.2e-99, -HUGE_VAL } ; - vec_double2 r30_v = (vec_double2) { hide_double(make_double(0xBFE4FF632B6A83E4ull)), -HUGE_VAL }; - vec_llong2 e30_v = (vec_llong2) { -328, spu_extract(exp_v, 1) }; - - vec_llong2 keep0_v = exp_v; - vec_double2 x0_v = spu_splats(x0); - vec_double2 r0_v = spu_splats(r0); - vec_llong2 e0_v = exp_v; - - vec_llong2 keep1_v = exp_v; - vec_double2 x1_v = spu_splats(x1); - vec_double2 r1_v = spu_splats(r1); - vec_llong2 e1_v = exp_v; - - vec_double2 x2_v = spu_splats(x2); - vec_double2 r2_v = spu_splats(r2); - vec_llong2 e2_v = spu_splats(e2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 r3_v = spu_splats(r3); - vec_llong2 e3_v = spu_splats(e3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 r4_v = spu_splats(r4); - vec_llong2 e4_v = spu_splats(e4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 r5_v = spu_splats(r5); - vec_llong2 e5_v = spu_splats(e5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 r6_v = spu_splats(r6); - vec_llong2 e6_v = spu_splats(e6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 r7_v = spu_splats(r7); - vec_llong2 e7_v = spu_splats(e7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 r8_v = spu_splats(r8); - vec_llong2 e8_v = spu_splats(e8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 r9_v = spu_splats(r9); - vec_llong2 e9_v = spu_splats(e9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 r10_v = spu_splats(r10); - vec_llong2 e10_v = spu_splats(e10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 r11_v = spu_splats(r11); - vec_llong2 e11_v = spu_splats(e11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 r12_v = spu_splats(r12); - vec_llong2 e12_v = spu_splats(e12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 r13_v = spu_splats(r13); - vec_llong2 e13_v = spu_splats(e13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 r14_v = spu_splats(r14); - vec_llong2 e14_v = spu_splats(e14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 r15_v = spu_splats(r15); - vec_llong2 e15_v = spu_splats(e15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 r16_v = spu_splats(r16); - vec_llong2 e16_v = spu_splats(e16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 r17_v = spu_splats(r17); - vec_llong2 e17_v = spu_splats(e17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 r18_v = spu_splats(r18); - vec_llong2 e18_v = spu_splats(e18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 r19_v = spu_splats(r19); - vec_llong2 e19_v = spu_splats(e19); - - vec_double2 x20_v = spu_splats(x20); - vec_double2 r20_v = spu_splats(r20); - vec_llong2 e20_v = spu_splats(e20); - - vec_double2 x21_v = spu_splats(x21); - vec_double2 r21_v = spu_splats(r21); - vec_llong2 e21_v = spu_splats(e21); - - vec_double2 x22_v = spu_splats(x22); - vec_double2 r22_v = spu_splats(r22); - vec_llong2 e22_v = spu_splats(e22); - - vec_double2 x23_v = spu_splats(x23); - vec_double2 r23_v = spu_splats(r23); - vec_llong2 e23_v = spu_splats(e23); - - vec_llong2 keep24_v = exp_v; - vec_double2 x24_v = spu_splats(x24); - vec_double2 r24_v = spu_splats(r24); - vec_llong2 e24_v = exp_v; - - vec_llong2 keep25_v = exp_v; - vec_double2 x25_v = spu_splats(x25); - vec_double2 r25_v = spu_splats(r25); - vec_llong2 e25_v = exp_v; - - TEST_START("frexpd2"); - - exp_v = keep0_v; - res_v = (vec_double2)frexpd2(x0_v, &exp_v); - TEST_CHECK("20060907000000AAN", allnan_double2( res_v ), 0); (void)r0_v; - TEST_CHECK("20060907000000AAN", allequal_llong2( exp_v, e0_v ), 0); - exp_v = keep1_v; - res_v = (vec_double2)frexpd2(x1_v, &exp_v); - TEST_CHECK("20060907000001AAN", allequal_double2( res_v, r1_v ), 0); - TEST_CHECK("20060907000001AAN", allequal_llong2( exp_v, e1_v ), 0); - res_v = (vec_double2)frexpd2(x2_v, &exp_v); - TEST_CHECK("20060907000002AAN", allequal_double2( res_v, r2_v ), 0); - TEST_CHECK("20060907000002AAN", allequal_llong2( exp_v, e2_v ), 0); - res_v = (vec_double2)frexpd2(x3_v, &exp_v); - TEST_CHECK("20060907000003AAN", allequal_double2( res_v, r3_v ), 0); - TEST_CHECK("20060907000003AAN", allequal_llong2( exp_v, e3_v ), 0); - res_v = (vec_double2)frexpd2(x4_v, &exp_v); - TEST_CHECK("20060907000004AAN", allequal_double2( res_v, r4_v ), 0); - TEST_CHECK("20060907000004AAN", allequal_llong2( exp_v, e4_v ), 0); - res_v = (vec_double2)frexpd2(x5_v, &exp_v); - TEST_CHECK("20060907000005AAN", allequal_double2( res_v, r5_v ), 0); - TEST_CHECK("20060907000005AAN", allequal_llong2( exp_v, e5_v ), 0); - res_v = (vec_double2)frexpd2(x6_v, &exp_v); - TEST_CHECK("20060907000006AAN", allequal_double2( res_v, r6_v ), 0); - TEST_CHECK("20060907000006AAN", allequal_llong2( exp_v, e6_v ), 0); - res_v = (vec_double2)frexpd2(x7_v, &exp_v); - TEST_CHECK("20060907000007AAN", allequal_double2( res_v, r7_v ), 0); - TEST_CHECK("20060907000007AAN", allequal_llong2( exp_v, e7_v ), 0); - res_v = (vec_double2)frexpd2(x8_v, &exp_v); - TEST_CHECK("20060907000008AAN", allequal_double2( res_v, r8_v ), 0); - TEST_CHECK("20060907000008AAN", allequal_llong2( exp_v, e8_v ), 0); - res_v = (vec_double2)frexpd2(x9_v, &exp_v); - TEST_CHECK("20060907000009AAN", allequal_double2( res_v, r9_v ), 0); - TEST_CHECK("20060907000009AAN", allequal_llong2( exp_v, e9_v ), 0); - res_v = (vec_double2)frexpd2(x10_v, &exp_v); - TEST_CHECK("20060907000010AAN", allequal_double2( res_v, r10_v ), 0); - TEST_CHECK("20060907000010AAN", allequal_llong2( exp_v, e10_v ), 0); - res_v = (vec_double2)frexpd2(x11_v, &exp_v); - TEST_CHECK("20060907000011AAN", allequal_double2( res_v, r11_v ), 0); - TEST_CHECK("20060907000011AAN", allequal_llong2( exp_v, e11_v ), 0); - res_v = (vec_double2)frexpd2(x12_v, &exp_v); - TEST_CHECK("20060907000012AAN", allequal_double2( res_v, r12_v ), 0); - TEST_CHECK("20060907000012AAN", allequal_llong2( exp_v, e12_v ), 0); - res_v = (vec_double2)frexpd2(x13_v, &exp_v); - TEST_CHECK("20060907000013AAN", allequal_double2( res_v, r13_v ), 0); - TEST_CHECK("20060907000013AAN", allequal_llong2( exp_v, e13_v ), 0); - res_v = (vec_double2)frexpd2(x14_v, &exp_v); - TEST_CHECK("20060907000014AAN", allequal_double2( res_v, r14_v ), 0); - TEST_CHECK("20060907000014AAN", allequal_llong2( exp_v, e14_v ), 0); - res_v = (vec_double2)frexpd2(x15_v, &exp_v); - TEST_CHECK("20060907000015AAN", allequal_double2( res_v, r15_v ), 0); - TEST_CHECK("20060907000015AAN", allequal_llong2( exp_v, e15_v ), 0); - res_v = (vec_double2)frexpd2(x16_v, &exp_v); - TEST_CHECK("20060907000016AAN", allequal_double2( res_v, r16_v ), 0); - TEST_CHECK("20060907000016AAN", allequal_llong2( exp_v, e16_v ), 0); - res_v = (vec_double2)frexpd2(x17_v, &exp_v); - TEST_CHECK("20060907000017AAN", allequal_double2( res_v, r17_v ), 0); - TEST_CHECK("20060907000017AAN", allequal_llong2( exp_v, e17_v ), 0); - res_v = (vec_double2)frexpd2(x18_v, &exp_v); - TEST_CHECK("20060907000018AAN", allequal_double2( res_v, r18_v ), 0); - TEST_CHECK("20060907000018AAN", allequal_llong2( exp_v, e18_v ), 0); - res_v = (vec_double2)frexpd2(x19_v, &exp_v); - TEST_CHECK("20060907000019AAN", allequal_double2( res_v, r19_v ), 0); - TEST_CHECK("20060907000019AAN", allequal_llong2( exp_v, e19_v ), 0); - res_v = (vec_double2)frexpd2(x20_v, &exp_v); - TEST_CHECK("20060907000020AAN", allequal_double2( res_v, r20_v ), 0); - TEST_CHECK("20060907000020AAN", allequal_llong2( exp_v, e20_v ), 0); - res_v = (vec_double2)frexpd2(x21_v, &exp_v); - TEST_CHECK("20060907000021AAN", allequal_double2( res_v, r21_v ), 0); - TEST_CHECK("20060907000021AAN", allequal_llong2( exp_v, e21_v ), 0); - res_v = (vec_double2)frexpd2(x22_v, &exp_v); - TEST_CHECK("20060907000022AAN", allequal_double2( res_v, r22_v ), 0); - TEST_CHECK("20060907000022AAN", allequal_llong2( exp_v, e22_v ), 0); - res_v = (vec_double2)frexpd2(x23_v, &exp_v); - TEST_CHECK("20060907000023AAN", allequal_double2( res_v, r23_v ), 0); - TEST_CHECK("20060907000023AAN", allequal_llong2( exp_v, e23_v ), 0); - exp_v = keep24_v; - res_v = (vec_double2)frexpd2(x24_v, &exp_v); - TEST_CHECK("20060907000024AAN", allequal_double2( res_v, r24_v ), 0); - TEST_CHECK("20060907000024AAN", allequal_llong2( exp_v, e24_v ), 0); - exp_v = keep25_v; - res_v = (vec_double2)frexpd2(x25_v, &exp_v); - TEST_CHECK("20060907000025AAN", allnan_double2( res_v ), 0); (void)r25_v; - TEST_CHECK("20060907000025AAN", allequal_llong2( exp_v, e25_v ), 0); - res_v = (vec_double2)frexpd2(x26_v, &exp_v); - TEST_CHECK("20060907000026AAN", allequal_double2( res_v, r26_v ), 0); - TEST_CHECK("20060907000026AAN", allequal_llong2( exp_v, e26_v ), 0); - res_v = (vec_double2)frexpd2(x27_v, &exp_v); - TEST_CHECK("20060907000027AAN", allequal_double2( res_v, r27_v ), 0); - TEST_CHECK("20060907000027AAN", allequal_llong2( exp_v, e27_v ), 0); - exp_v = keep28_v; - res_v = (vec_double2)frexpd2(x28_v, &exp_v); - TEST_CHECK("20060907000028AAN", allequal_ulps_double2( res_v, r28_v, 0 ), 0); - TEST_CHECK("20060907000028AAN", allequal_llong2( exp_v, e28_v ), 0); - exp_v = keep29_v; - res_v = (vec_double2)frexpd2(x29_v, &exp_v); - TEST_CHECK("20060907000029AAN", allequal_ulps_double2( res_v, r29_v, 0 ), 0); - TEST_CHECK("20060907000029AAN", allequal_llong2( exp_v, e29_v ), 0); - exp_v = keep30_v; - res_v = (vec_double2)frexpd2(x30_v, &exp_v); - TEST_CHECK("20060907000030AAN", allequal_ulps_double2( res_v, r30_v, 0 ), 0); - TEST_CHECK("20060907000000AAN", allequal_llong2( exp_v, e30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/frexpf4.c b/Extras/simdmathlibrary/spu/tests/frexpf4.c deleted file mode 100644 index 645b5cec3..000000000 --- a/Extras/simdmathlibrary/spu/tests/frexpf4.c +++ /dev/null @@ -1,405 +0,0 @@ -/* Test frexpf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20060907000000AAN","AAN", "frexpf4"); - - // -Norm (IEEE-754: -Nan) - float x0 = hide_float(make_float(0xFFC00000)); - float r0 = hide_float(make_float(0xBF400000)); - int e0 = 129; - - // -Norm (IEEE-754: -Inf) - float x1 = hide_float(-HUGE_VALF); - float r1 = hide_float(make_float(0xBF7FFFFF)); - int e1 = 129; - - // -Smax - float x2 = hide_float(make_float(0xFFFFFFFF)); - float r2 = hide_float(make_float(0xBF7FFFFF)); - int e2 = 129; - - // -Norm - float x3 = hide_float(-824842.58421394); - float r3 = hide_float(make_float(0xBF4960A9)); - int e3 = 20; - - // -Smin - float x4 = hide_float(make_float(0x80800000)); - float r4 = hide_float(make_float(0xBF000000)); - int e4 = -125; - - // -Denorm - float x5 = hide_float(make_float(0x807AAAAA)); - float r5 = 0.0; - int e5 = 0; - - // -Unf - float x6 = hide_float(-1.0e-999); - float r6 = 0.0; - int e6 = 0; - - // -0 - float x7 = hide_float(-0.0); - float r7 = 0.0; - int e7 = 0; - - // 0 - float x8 = hide_float( 0.0); - float r8 = 0.0; - int e8 = 0; - - // +Unf - float x9 = hide_float( 1.0e-999); - float r9 = 0.0; - int e9 = 0; - - // +Denorm - float x10 = hide_float(make_float(0x007AAAAA)); - float r10 = 0.0; - int e10 = 0; - - // +Smin - float x11 = hide_float(make_float(0x00800000)); - float r11 = hide_float(make_float(0x3F000000)); - int e11 = -125; - - // +Norm - float x12 = hide_float(3.14152634); - float r12 = hide_float(make_float(0x3F490EC4)); - int e12 = 2; - - // +Norm - float x13 = hide_float(7.0673903e37); - float r13 = hide_float(make_float(0x3F54AD32)); - int e13 = 126; - - // +Norm - float x14 = hide_float(2.4673e14); - float r14 = hide_float(make_float(0x3F60664E)); - int e14 = 48; - - // +Norm - float x15 = hide_float(7.235672e-25); - float r15 = hide_float(make_float(0x3F5FEEE6)); - int e15 = -80; - - // +Norm - float x16 = hide_float(9.452854e17); - float r16 = hide_float(make_float(0x3F51E541)); - int e16 = 60; - - // +Norm - float x17 = hide_float(3.045784e-18); - float r17 = hide_float(make_float(0x3F60BD3C)); - int e17 = -58; - - // -Norm - float x18 = hide_float(-6.459273e7); - float r18 = hide_float(make_float(0xBF7666D6)); - int e18 = 26; - - // -Norm - float x19 = hide_float(-2.493472e-9); - float r19 = hide_float(make_float(0xBF2B59A0)); - int e19 = -28; - - // -Norm - float x20 = hide_float(-1.4824543e28); - float r20 = hide_float(make_float(0xBF3F9A4C)); - int e20 = 94; - - // -Norm - float x21 = hide_float(-5.53856231e-27); - float r21 = hide_float(make_float(0xBF5B67B2)); - int e21 = -87; - - // -Norm - float x22 = hide_float(-1.000001); - float r22 = hide_float(make_float(0xBF000008)); - int e22 = 1; - - // +Smax - float x23 = hide_float(make_float(0x7FFFFFFF)); - float r23 = hide_float(make_float(0x3F7FFFFF)); - int e23 = 129; - - //+Norm (IEEE-754: +Inf) - float x24 = hide_float(HUGE_VALF); - float r24 = hide_float(make_float(0x3F7FFFFF)); - int e24 = 129; - - //+Norm (IEEE-754: +Nan) - float x25 = hide_float(make_float(0x7FC00000)); - float r25 = hide_float(make_float(0x3F400000)); - int e25 = 129; - - // Compound - vec_float4 x26_v = (vec_float4) { -2.561286432e10, make_float(0x7FFFFFFF), -1.0e-999, 7.235672e-25 }; - vec_float4 r26_v = (vec_float4) { make_float(0xBF3ED4A9), make_float(0x3F7FFFFF), 0.0, make_float(0x3F5FEEE6) }; - vec_int4 e26_v = (vec_int4) { 35, 129, 0, -80 }; - - // Compound - vec_float4 x27_v = (vec_float4) { 345.27533f, 7.0673903e37, -0.0f, -2.40e-310 }; - vec_float4 r27_v = (vec_float4) { make_float(0x3F2CA33E), make_float(0x3F54AD32), 0.0, 0.0}; - vec_int4 e27_v = (vec_int4) { 9, 126, 0, 0 }; - - // Compound - vec_float4 x28_v = (vec_float4) { make_float(0x7FC00000), -824842.58421394f, -0.0f, -3678342.8765343f }; - vec_float4 r28_v = (vec_float4) { make_float(0x3F400000), make_float(0xBF4960A9), 0.0, make_float(0xBF60821B) }; - vec_int4 e28_v = (vec_int4) { 129, 20, 0, 22 }; - - // Compound - vec_float4 x29_v = (vec_float4) { HUGE_VALF, 1.0e-99, -5.53856231e-27, make_float(0xFFC00000) }; - vec_float4 r29_v = (vec_float4) { make_float(0x3F7FFFFF), 0.0, make_float(0xBF5B67B2), make_float(0xBF400000) }; - vec_int4 e29_v = (vec_int4) { 129, 0, -87, 129 }; - - // Compound - vec_float4 x30_v = (vec_float4) { 1.2e-57, -1.2e-19, 3.045784e-18, -HUGE_VALF } ; - vec_float4 r30_v = (vec_float4) { 0.0, make_float(0xBF0DABC6 ), make_float(0x3F60BD3C), make_float(0xBF7FFFFF) }; - vec_int4 e30_v = (vec_int4) { 0, -62, -58, 129 }; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 r0_v = spu_splats(r0); - vec_int4 e0_v = spu_splats(e0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 r1_v = spu_splats(r1); - vec_int4 e1_v = spu_splats(e1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 r2_v = spu_splats(r2); - vec_int4 e2_v = spu_splats(e2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 r3_v = spu_splats(r3); - vec_int4 e3_v = spu_splats(e3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 r4_v = spu_splats(r4); - vec_int4 e4_v = spu_splats(e4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 r5_v = spu_splats(r5); - vec_int4 e5_v = spu_splats(e5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 r6_v = spu_splats(r6); - vec_int4 e6_v = spu_splats(e6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 r7_v = spu_splats(r7); - vec_int4 e7_v = spu_splats(e7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 r8_v = spu_splats(r8); - vec_int4 e8_v = spu_splats(e8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 r9_v = spu_splats(r9); - vec_int4 e9_v = spu_splats(e9); - - vec_float4 x10_v = spu_splats(x10); - vec_float4 r10_v = spu_splats(r10); - vec_int4 e10_v = spu_splats(e10); - - vec_float4 x11_v = spu_splats(x11); - vec_float4 r11_v = spu_splats(r11); - vec_int4 e11_v = spu_splats(e11); - - vec_float4 x12_v = spu_splats(x12); - vec_float4 r12_v = spu_splats(r12); - vec_int4 e12_v = spu_splats(e12); - - vec_float4 x13_v = spu_splats(x13); - vec_float4 r13_v = spu_splats(r13); - vec_int4 e13_v = spu_splats(e13); - - vec_float4 x14_v = spu_splats(x14); - vec_float4 r14_v = spu_splats(r14); - vec_int4 e14_v = spu_splats(e14); - - vec_float4 x15_v = spu_splats(x15); - vec_float4 r15_v = spu_splats(r15); - vec_int4 e15_v = spu_splats(e15); - - vec_float4 x16_v = spu_splats(x16); - vec_float4 r16_v = spu_splats(r16); - vec_int4 e16_v = spu_splats(e16); - - vec_float4 x17_v = spu_splats(x17); - vec_float4 r17_v = spu_splats(r17); - vec_int4 e17_v = spu_splats(e17); - - vec_float4 x18_v = spu_splats(x18); - vec_float4 r18_v = spu_splats(r18); - vec_int4 e18_v = spu_splats(e18); - - vec_float4 x19_v = spu_splats(x19); - vec_float4 r19_v = spu_splats(r19); - vec_int4 e19_v = spu_splats(e19); - - vec_float4 x20_v = spu_splats(x20); - vec_float4 r20_v = spu_splats(r20); - vec_int4 e20_v = spu_splats(e20); - - vec_float4 x21_v = spu_splats(x21); - vec_float4 r21_v = spu_splats(r21); - vec_int4 e21_v = spu_splats(e21); - - vec_float4 x22_v = spu_splats(x22); - vec_float4 r22_v = spu_splats(r22); - vec_int4 e22_v = spu_splats(e22); - - vec_float4 x23_v = spu_splats(x23); - vec_float4 r23_v = spu_splats(r23); - vec_int4 e23_v = spu_splats(e23); - - vec_float4 x24_v = spu_splats(x24); - vec_float4 r24_v = spu_splats(r24); - vec_int4 e24_v = spu_splats(e24); - - vec_float4 x25_v = spu_splats(x25); - vec_float4 r25_v = spu_splats(r25); - vec_int4 e25_v = spu_splats(e25); - - vec_float4 res_v; - vec_int4 exp_v; - - TEST_START("frexpf4"); - - res_v = (vec_float4)frexpf4(x0_v, &exp_v); - TEST_CHECK("20060907000000AAN", allequal_ulps_float4( res_v, r0_v, 0 ), 0); - TEST_CHECK("20060907000000AAN", allequal_int4( exp_v, e0_v ), 0); - res_v = (vec_float4)frexpf4(x1_v, &exp_v); - TEST_CHECK("20060907000001AAN", allequal_ulps_float4( res_v, r1_v, 0 ), 0); - TEST_CHECK("20060907000001AAN", allequal_int4( exp_v, e1_v ), 0); - res_v = (vec_float4)frexpf4(x2_v, &exp_v); - TEST_CHECK("20060907000002AAN", allequal_ulps_float4( res_v, r2_v, 0 ), 0); - TEST_CHECK("20060907000002AAN", allequal_int4( exp_v, e2_v ), 0); - res_v = (vec_float4)frexpf4(x3_v, &exp_v); - TEST_CHECK("20060907000003AAN", allequal_float4( res_v, r3_v ), 0); - TEST_CHECK("20060907000003AAN", allequal_int4( exp_v, e3_v ), 0); - res_v = (vec_float4)frexpf4(x4_v, &exp_v); - TEST_CHECK("20060907000004AAN", allequal_float4( res_v, r4_v ), 0); - TEST_CHECK("20060907000004AAN", allequal_int4( exp_v, e4_v ), 0); - res_v = (vec_float4)frexpf4(x5_v, &exp_v); - TEST_CHECK("20060907000005AAN", allequal_float4( res_v, r5_v ), 0); - TEST_CHECK("20060907000005AAN", allequal_int4( exp_v, e5_v ), 0); - res_v = (vec_float4)frexpf4(x6_v, &exp_v); - TEST_CHECK("20060907000006AAN", allequal_float4( res_v, r6_v ), 0); - TEST_CHECK("20060907000006AAN", allequal_int4( exp_v, e6_v ), 0); - res_v = (vec_float4)frexpf4(x7_v, &exp_v); - TEST_CHECK("20060907000007AAN", allequal_float4( res_v, r7_v ), 0); - TEST_CHECK("20060907000007AAN", allequal_int4( exp_v, e7_v ), 0); - res_v = (vec_float4)frexpf4(x8_v, &exp_v); - TEST_CHECK("20060907000008AAN", allequal_float4( res_v, r8_v ), 0); - TEST_CHECK("20060907000008AAN", allequal_int4( exp_v, e8_v ), 0); - res_v = (vec_float4)frexpf4(x9_v, &exp_v); - TEST_CHECK("20060907000009AAN", allequal_float4( res_v, r9_v ), 0); - TEST_CHECK("20060907000009AAN", allequal_int4( exp_v, e9_v ), 0); - res_v = (vec_float4)frexpf4(x10_v, &exp_v); - TEST_CHECK("20060907000010AAN", allequal_float4( res_v, r10_v ), 0); - TEST_CHECK("20060907000010AAN", allequal_int4( exp_v, e10_v ), 0); - res_v = (vec_float4)frexpf4(x11_v, &exp_v); - TEST_CHECK("20060907000011AAN", allequal_float4( res_v, r11_v ), 0); - TEST_CHECK("20060907000011AAN", allequal_int4( exp_v, e11_v ), 0); - res_v = (vec_float4)frexpf4(x12_v, &exp_v); - TEST_CHECK("20060907000012AAN", allequal_float4( res_v, r12_v ), 0); - TEST_CHECK("20060907000012AAN", allequal_int4( exp_v, e12_v ), 0); - res_v = (vec_float4)frexpf4(x13_v, &exp_v); - TEST_CHECK("20060907000013AAN", allequal_float4( res_v, r13_v ), 0); - TEST_CHECK("20060907000013AAN", allequal_int4( exp_v, e13_v ), 0); - res_v = (vec_float4)frexpf4(x14_v, &exp_v); - TEST_CHECK("20060907000014AAN", allequal_float4( res_v, r14_v ), 0); - TEST_CHECK("20060907000014AAN", allequal_int4( exp_v, e14_v ), 0); - res_v = (vec_float4)frexpf4(x15_v, &exp_v); - TEST_CHECK("20060907000015AAN", allequal_float4( res_v, r15_v ), 0); - TEST_CHECK("20060907000015AAN", allequal_int4( exp_v, e15_v ), 0); - res_v = (vec_float4)frexpf4(x16_v, &exp_v); - TEST_CHECK("20060907000016AAN", allequal_float4( res_v, r16_v ), 0); - TEST_CHECK("20060907000016AAN", allequal_int4( exp_v, e16_v ), 0); - res_v = (vec_float4)frexpf4(x17_v, &exp_v); - TEST_CHECK("20060907000017AAN", allequal_float4( res_v, r17_v ), 0); - TEST_CHECK("20060907000017AAN", allequal_int4( exp_v, e17_v ), 0); - res_v = (vec_float4)frexpf4(x18_v, &exp_v); - TEST_CHECK("20060907000018AAN", allequal_float4( res_v, r18_v ), 0); - TEST_CHECK("20060907000018AAN", allequal_int4( exp_v, e18_v ), 0); - res_v = (vec_float4)frexpf4(x19_v, &exp_v); - TEST_CHECK("20060907000019AAN", allequal_float4( res_v, r19_v ), 0); - TEST_CHECK("20060907000019AAN", allequal_int4( exp_v, e19_v ), 0); - res_v = (vec_float4)frexpf4(x20_v, &exp_v); - TEST_CHECK("20060907000020AAN", allequal_float4( res_v, r20_v ), 0); - TEST_CHECK("20060907000020AAN", allequal_int4( exp_v, e20_v ), 0); - res_v = (vec_float4)frexpf4(x21_v, &exp_v); - TEST_CHECK("20060907000021AAN", allequal_float4( res_v, r21_v ), 0); - TEST_CHECK("20060907000021AAN", allequal_int4( exp_v, e21_v ), 0); - res_v = (vec_float4)frexpf4(x22_v, &exp_v); - TEST_CHECK("20060907000022AAN", allequal_float4( res_v, r22_v ), 0); - TEST_CHECK("20060907000022AAN", allequal_int4( exp_v, e22_v ), 0); - res_v = (vec_float4)frexpf4(x23_v, &exp_v); - TEST_CHECK("20060907000023AAN", allequal_float4( res_v, r23_v ), 0); - TEST_CHECK("20060907000023AAN", allequal_int4( exp_v, e23_v ), 0); - res_v = (vec_float4)frexpf4(x24_v, &exp_v); - TEST_CHECK("20060907000024AAN", allequal_float4( res_v, r24_v ), 0); - TEST_CHECK("20060907000024AAN", allequal_int4( exp_v, e24_v ), 0); - res_v = (vec_float4)frexpf4(x25_v, &exp_v); - TEST_CHECK("20060907000025AAN", allequal_float4( res_v, r25_v ), 0); - TEST_CHECK("20060907000025AAN", allequal_int4( exp_v, e25_v ), 0); - res_v = (vec_float4)frexpf4(x26_v, &exp_v); - TEST_CHECK("20060907000026AAN", allequal_float4( res_v, r26_v ), 0); - TEST_CHECK("20060907000026AAN", allequal_int4( exp_v, e26_v ), 0); - res_v = (vec_float4)frexpf4(x27_v, &exp_v); - TEST_CHECK("20060907000027AAN", allequal_float4( res_v, r27_v ), 0); - TEST_CHECK("20060907000027AAN", allequal_int4( exp_v, e27_v ), 0); - res_v = (vec_float4)frexpf4(x28_v, &exp_v); - TEST_CHECK("20060907000028AAN", allequal_float4( res_v, r28_v ), 0); - TEST_CHECK("20060907000028AAN", allequal_int4( exp_v, e28_v ), 0); - res_v = (vec_float4)frexpf4(x29_v, &exp_v); - TEST_CHECK("20060907000029AAN", allequal_float4( res_v, r29_v ), 0); - TEST_CHECK("20060907000029AAN", allequal_int4( exp_v, e29_v ), 0); - res_v = (vec_float4)frexpf4(x30_v, &exp_v); - TEST_CHECK("20060907000030AAN", allequal_float4( res_v, r30_v ), 0); - TEST_CHECK("20060907000030AAN", allequal_int4( exp_v, e30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/hypotd2.c b/Extras/simdmathlibrary/spu/tests/hypotd2.c deleted file mode 100644 index d66d1a495..000000000 --- a/Extras/simdmathlibrary/spu/tests/hypotd2.c +++ /dev/null @@ -1,341 +0,0 @@ -/* Test hypotd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060831000000AAN","AAN", "hypotd2"); - - // Does not test precesion, which depends on sqrtd2 implementation - // Uses Pythagorean triplets to test result validity - - //-QNaN, Norm - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - double r0 = hide_double( nan("")); - - //-QNaN, -Norm - double x1 = hide_double(-nan("")); - double y1 = hide_double(-21345853556.492); - double r1 = hide_double( nan("")); - - //-Inf, -QNaN - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(make_double(0xFFFFFFFFFFFFFFFFull)); - double r2 = hide_double( nan("")); - - //-Norm, -SNaN - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(make_double(0xFFF7FFFFFFFFFFFFull)); - double r3 = hide_double( nan("")); - - //-Norm, -Denorm - double x4 = hide_double(-4.0e120); - double y4 = hide_double(-3.0e-320); - double r4 = hide_double( 4.0e120); - - //-Norm, -Inf - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-HUGE_VAL); - double r5 = hide_double(HUGE_VAL); - - //+Inf, -Inf - double x6 = hide_double(HUGE_VAL); - double y6 = hide_double(-HUGE_VAL); - double r6 = hide_double(HUGE_VAL); - - //-Norm, -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - double r7 = hide_double( 168.97345223013); - - //-Unf, -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - double r8 = hide_double( 83532.96153153); - - //-Unf, 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - double r9 = hide_double(0.0); - - //QNaN, 0 - double x10 = hide_double(make_double(0x7FFFFFFFFFFFFFFFull)); - double y10 = hide_double( 0.0); - double r10 = hide_double( nan("")); - - //+Unf, +QNaN - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( nan("")); - double r11 = hide_double( nan("")); - - //+Unf, +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - double r12 = hide_double(0.0031529324); - - //+Norm, +Norm - double x13 = hide_double(55000.0e116); - double y13 = hide_double(480.0e118); - double r13 = hide_double(7.3e120); - - //+Norm, -Denorm - double x14 = hide_double(120.0e120); - double y14 = hide_double(-5.0e-321); - double r14 = hide_double(120.0e120/*1.3e101*/); - - //-Norm, +Demorm - double x15 = hide_double(-0.0000000008); - double y15 = hide_double(1.5e-320); - double r15 = hide_double( 0.8e-9); - - //+Norm, -Norm - double x16 = hide_double( 7.0e-6); - double y16 = hide_double(-24.0e-6); - double r16 = hide_double(25.0e-6); - - //+Norm, +Norm - double x17 = hide_double(0.0055); - double y17 = hide_double(0.0048); - double r17 = hide_double(0.0073); - - //+Denorm, +Norm - double x18 = hide_double(4.5e-320); - double y18 = hide_double(2.8); - double r18 = hide_double(2.8); - - //-Norm, +Norm - double x19 = hide_double(-8000.0); - double y19 = hide_double(39.0e2); - double r19 = hide_double(8900.0); - - //+Norm, +Norm - double x20 = hide_double(6.5e128); - double y20 = hide_double(7.2e128); - double r20 = hide_double(9.7e128); - - //-Norm, -Norm - double x21 = hide_double(-0.0035); - double y21 = hide_double(-1.2e-3); - double r21 = hide_double( 0.0037); - - //+Norm, +Norm - double x22 = hide_double(456548.6027761); - double y22 = hide_double(106165.2293520); - double r22 = hide_double(468729.8610289); - - //+Inf, +Ovf - double x23 = hide_double(HUGE_VAL); - double y23 = hide_double(1.0e999); - double r23 = hide_double(HUGE_VAL); - - //+Norm, +QNaN - double x24 = hide_double(264.345643345); - double y24 = hide_double(make_double(0x7FFAAAAAAAAAAAAAull)); - double r24 = hide_double( nan("")); - - //+Inf, +QNaN - double x25 = hide_double(HUGE_VAL); - double y25 = hide_double(nan("")); - double r25 = hide_double(nan("")); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_double2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_double2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_double2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_double2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_double2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_double2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_double2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_double2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_double2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_double2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_double2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_double2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_double2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_double2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_double2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_double2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_double2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_double2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_double2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_double2 r19_v = spu_splats(r19); - - vec_double2 x20_v = spu_splats(x20); - vec_double2 y20_v = spu_splats(y20); - vec_double2 r20_v = spu_splats(r20); - - vec_double2 x21_v = spu_splats(x21); - vec_double2 y21_v = spu_splats(y21); - vec_double2 r21_v = spu_splats(r21); - - vec_double2 x22_v = spu_splats(x22); - vec_double2 y22_v = spu_splats(y22); - vec_double2 r22_v = spu_splats(r22); - - vec_double2 x23_v = spu_splats(x23); - vec_double2 y23_v = spu_splats(y23); - vec_double2 r23_v = spu_splats(r23); - - vec_double2 x24_v = spu_splats(x24); - vec_double2 y24_v = spu_splats(y24); - vec_double2 r24_v = spu_splats(r24); - - vec_double2 x25_v = spu_splats(x25); - vec_double2 y25_v = spu_splats(y25); - vec_double2 r25_v = spu_splats(r25); - - vec_double2 res_v; - int tolerance = (int)0x0000000000000001ull; - - TEST_START("hypotd2"); - - res_v = (vec_double2)hypotd2(x0_v, y0_v); - TEST_CHECK("20060831000000AAN", allnan_double2( res_v ), 0); (void)r0_v; - res_v = (vec_double2)hypotd2(x1_v, y1_v); - TEST_CHECK("20060831000001AAN", allnan_double2( res_v ), 0); (void)r1_v; - res_v = (vec_double2)hypotd2(x2_v, y2_v); - TEST_CHECK("20060831000002AAN", allnan_double2( res_v ), 0); (void)r2_v; - res_v = (vec_double2)hypotd2(x3_v, y3_v); - TEST_CHECK("20060831000003AAN", allnan_double2( res_v ), 0); (void)r3_v; - res_v = (vec_double2)hypotd2(x4_v, y4_v); - TEST_CHECK("20060831000004AAN", allequal_ulps_double2( res_v, r4_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x5_v, y5_v); - TEST_CHECK("20060831000005AAN", allequal_ulps_double2( res_v, r5_v, 0 ), 0); - res_v = (vec_double2)hypotd2(x6_v, y6_v); - TEST_CHECK("20060831000006AAN", allequal_ulps_double2( res_v, r6_v, 0 ), 0); - res_v = (vec_double2)hypotd2(x7_v, y7_v); - TEST_CHECK("20060831000007AAN", allequal_ulps_double2( res_v, r7_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x8_v, y8_v); - TEST_CHECK("20060831000008AAN", allequal_ulps_double2( res_v, r8_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x9_v, y9_v); - TEST_CHECK("20060831000009AAN", allequal_ulps_double2( res_v, r9_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x10_v, y10_v); - TEST_CHECK("20060831000010AAN", allnan_double2( res_v ), 0); (void)r10_v; - res_v = (vec_double2)hypotd2(x11_v, y11_v); - TEST_CHECK("20060831000011AAN", allnan_double2( res_v ), 0); (void)r11_v; - res_v = (vec_double2)hypotd2(x12_v, y12_v); - TEST_CHECK("20060831000012AAN", allequal_ulps_double2( res_v, r12_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x13_v, y13_v); - TEST_CHECK("20060831000013AAN", allequal_ulps_double2( res_v, r13_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x14_v, y14_v); - TEST_CHECK("20060831000014AAN", allequal_ulps_double2( res_v, r14_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x15_v, y15_v); - TEST_CHECK("20060831000015AAN", allequal_ulps_double2( res_v, r15_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x16_v, y16_v); - TEST_CHECK("20060831000016AAN", allequal_ulps_double2( res_v, r16_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x17_v, y17_v); - TEST_CHECK("20060831000017AAN", allequal_ulps_double2( res_v, r17_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x18_v, y18_v); - TEST_CHECK("20060831000018AAN", allequal_ulps_double2( res_v, r18_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x19_v, y19_v); - TEST_CHECK("20060831000019AAN", allequal_ulps_double2( res_v, r19_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x20_v, y20_v); - TEST_CHECK("20060831000020AAN", allequal_ulps_double2( res_v, r20_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x21_v, y21_v); - TEST_CHECK("20060831000021AAN", allequal_ulps_double2( res_v, r21_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x22_v, y22_v); - TEST_CHECK("20060831000022AAN", allequal_ulps_double2( res_v, r22_v, tolerance ), 0); - res_v = (vec_double2)hypotd2(x23_v, y23_v); - TEST_CHECK("20060831000023AAN", allequal_ulps_double2( res_v, r23_v, 0 ), 0); - res_v = (vec_double2)hypotd2(x24_v, y24_v); - TEST_CHECK("20060831000024AAN", allnan_double2( res_v ), 0); (void)r24_v; - res_v = (vec_double2)hypotd2(x25_v, y25_v); - TEST_CHECK("20060831000025AAN", allnan_double2( res_v ), 0); (void)r25_v; - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/hypotf4.c b/Extras/simdmathlibrary/spu/tests/hypotf4.c deleted file mode 100644 index a71f798b8..000000000 --- a/Extras/simdmathlibrary/spu/tests/hypotf4.c +++ /dev/null @@ -1,208 +0,0 @@ -/* Test hypotf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060831000000AAN","AAN", "hypotf4"); - - // Does not test precesion, which depends on sqrtf4 implementation - // Uses Pythagorean triplets to test result validity - - //-Norm, -0 - float x0 = hide_float(-168.97345223013f); - float y0 = hide_float(-0.0); - float r0 = hide_float( 168.97345223013f); - - //-Unf, -Norm - float x1 = hide_float(-1.0e-999); - float y1 = hide_float(-83532.96153153f); - float r1 = hide_float( 83532.96153153f); - - //-Unf, 0 - float x2 = hide_float(-1.0e-999); - float y2 = hide_float( 0.0); - float r2 = hide_float( 0.0); - - //+Unf, +Norm - float x3 = hide_float(1.0e-999); - float y3 = hide_float(0.0031529324f); - float r3 = hide_float(0.0031529324f); - - //+Norm, +Norm - float x4 = hide_float(5.5e12); - float y4 = hide_float(4.8e12); - float r4 = hide_float(7.3e12); - - //+Norm, -Denorm - float x5 = hide_float(12.0e12); - float y5 = hide_float(make_float(0x803AAAAA)); - float r5 = hide_float(12.0e12); - - //-Norm, +Norm - float x6 = hide_float(-0.0000000008); - float y6 = hide_float( 0.0000000015); - float r6 = hide_float( 0.0000000017); - - //+Norm, -Norm - float x7 = hide_float( 7.0e-6); - float y7 = hide_float(-24.0e-6); - float r7 = hide_float( 25.0e-6); - - //+Norm, +Norm - float x8 = hide_float(0.0055f); - float y8 = hide_float(0.0048f); - float r8 = hide_float(0.0073f); - - //+Denorm, +Norm - float x9 = hide_float(make_float(0x007AAAAA)); - float y9 = hide_float(2.8f); - float r9 = hide_float(2.8f); - - //-Norm, +Norm - float x10 = hide_float(-8000.0); - float y10 = hide_float(39.0e2); - float r10 = hide_float(8900.0); - - //+Norm, +Norm - float x11 = hide_float(6.5e16); - float y11 = hide_float(7.2e16); - float r11 = hide_float(9.7e16); - - //-Norm, -Norm - float x12 = hide_float(-0.0035); - float y12 = hide_float(-12e-4); - float r12 = hide_float(3700e-6); - - //+Norm, +Norm - float x13 = hide_float(456548.6027761f); - float y13 = hide_float(106165.2293520f); - float r13 = hide_float(468729.8610289f); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_float4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_float4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_float4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_float4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_float4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_float4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_float4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_float4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_float4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_float4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_float4 y10_v = spu_splats(y10); - vec_float4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_float4 y11_v = spu_splats(y11); - vec_float4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_float4 y12_v = spu_splats(y12); - vec_float4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_float4 y13_v = spu_splats(y13); - vec_float4 r13_v = spu_splats(r13); - - vec_float4 res_v; - int tolerance = 0x00000001; - - TEST_START("hypotf4"); - - res_v = (vec_float4)hypotf4(x0_v, y0_v); - TEST_CHECK("20060831000000AAN", allequal_ulps_float4( res_v, r0_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x1_v, y1_v); - TEST_CHECK("20060831000001AAN", allequal_ulps_float4( res_v, r1_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x2_v, y2_v); - TEST_CHECK("20060831000002AAN", allequal_ulps_float4( res_v, r2_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x3_v, y3_v); - TEST_CHECK("20060831000003AAN", allequal_ulps_float4( res_v, r3_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x4_v, y4_v); - TEST_CHECK("20060831000004AAN", allequal_ulps_float4( res_v, r4_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x5_v, y5_v); - TEST_CHECK("20060831000005AAN", allequal_ulps_float4( res_v, r5_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x6_v, y6_v); - TEST_CHECK("20060831000006AAN", allequal_ulps_float4( res_v, r6_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x7_v, y7_v); - TEST_CHECK("20060831000007AAN", allequal_ulps_float4( res_v, r7_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x8_v, y8_v); - TEST_CHECK("20060831000008AAN", allequal_ulps_float4( res_v, r8_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x9_v, y9_v); - TEST_CHECK("20060831000009AAN", allequal_ulps_float4( res_v, r9_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x10_v, y10_v); - TEST_CHECK("20060831000010AAN", allequal_ulps_float4( res_v, r10_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x11_v, y11_v); - TEST_CHECK("20060831000011AAN", allequal_ulps_float4( res_v, r11_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x12_v, y12_v); - TEST_CHECK("20060831000012AAN", allequal_ulps_float4( res_v, r12_v, tolerance ), 0); - res_v = (vec_float4)hypotf4(x13_v, y13_v); - TEST_CHECK("20060831000013AAN", allequal_ulps_float4( res_v, r13_v, tolerance ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/ilogbd2.c b/Extras/simdmathlibrary/spu/tests/ilogbd2.c deleted file mode 100644 index 38cd9814b..000000000 --- a/Extras/simdmathlibrary/spu/tests/ilogbd2.c +++ /dev/null @@ -1,316 +0,0 @@ -/* Test ilogbd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060904000000AAN","AAN", "ilogbd2"); - - // -Nan - double x0 = hide_double(-nan("")); - long long r0 = (long long)FP_ILOGBNAN; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - long long r1 = (long long)FP_ILOGB0; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - long long r2 = 1023ll; - - // -Norm - double x3 = hide_double(-824842.58421394); - long long r3 = 19ll; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - long long r4 = -1022ll; - - // -Denorm - double x5 = hide_double(-2.40e-310); - long long r5 = -1029ll; - - // -Unf - double x6 = hide_double(-1.0e-999); - long long r6 = (long long)FP_ILOGB0; - - // -0 - double x7 = hide_double(-0.0); - long long r7 = (long long)FP_ILOGB0; - - // 0 - double x8 = hide_double( 0.0); - long long r8 = (long long)FP_ILOGB0; - - // +Unf - double x9 = hide_double( 1.0e-999); - long long r9 = (long long)FP_ILOGB0; - - // +Denorm - double x10 = hide_double( 2.40e-310); - long long r10 = -1029ll; - - // +Dmin - double x11 = hide_double( DBL_MIN); - long long r11 = -1022ll; - - // +Norm - double x12 = hide_double(3.14152634); - long long r12 = 1ll; - - // +Norm - double x13 = hide_double(7.0673903e149); - long long r13 = 497ll; - - // +Norm - double x14 = hide_double(2.4673e304); - long long r14 = 1011ll; - - // +Norm - double x15 = hide_double(7.235672e-25); - long long r15 = -81ll; - - // +Denorm - double x16 = hide_double(9.452854e-312); - long long r16 = -1034ll; - - // +Demorm - double x17 = hide_double(3.045784e-320); - long long r17 = -1062ll; - - // -Norm - double x18 = hide_double(-6.459273e7); - long long r18 = 25ll; - - // -Norm - double x19 = hide_double(-2.493472e-99); - long long r19 = -328ll; - - // -Norm - double x20 = hide_double(-1.4824543e128); - long long r20 = 425ll; - - // -Denorm - double x21 = hide_double(-5.53856231e-315); - long long r21 = -1044ll; - - // -Demorm - double x22 = hide_double(-2.5684367e-312); - long long r22 = -1036ll; - - // +Dmax - double x23 = hide_double(DBL_MAX); - long long r23 = 1023ll; - - // +Inf - double x24 = hide_double(HUGE_VAL); - long long r24 = (long long)FP_ILOGB0; - - //+Nan - double x25 = hide_double( nan("")); - long long r25 = (long long)FP_ILOGBNAN; - - // Compound - vec_double2 x26_v = (vec_double2) { -2.561286432e-317, -1.0e-999 }; - vec_llong2 r26_v = (vec_llong2) { -1052ll, FP_ILOGB0 }; - - // Compound - vec_double2 x27_v = (vec_double2) { 345.27533, -8.673e-310 }; - vec_llong2 r27_v = (vec_llong2) { 8ll, -1027ll }; - - // Compound - vec_double2 x28_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_llong2 r28_v = (vec_llong2) { FP_ILOGBNAN, 21ll }; - - // Compound - vec_double2 x29_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_llong2 r29_v = (vec_llong2) { FP_ILOGB0, FP_ILOGBNAN }; - - // Compound - vec_double2 x30_v = (vec_double2) { -1.2e-99, -HUGE_VAL } ; - vec_llong2 r30_v = (vec_llong2) { -329ll, FP_ILOGB0 }; - - vec_double2 x0_v = spu_splats(x0); - vec_llong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_llong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_llong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_llong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_llong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_llong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_llong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_llong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_llong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_llong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_llong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_llong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_llong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_llong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_llong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_llong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_llong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_llong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_llong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_llong2 r19_v = spu_splats(r19); - - vec_double2 x20_v = spu_splats(x20); - vec_llong2 r20_v = spu_splats(r20); - - vec_double2 x21_v = spu_splats(x21); - vec_llong2 r21_v = spu_splats(r21); - - vec_double2 x22_v = spu_splats(x22); - vec_llong2 r22_v = spu_splats(r22); - - vec_double2 x23_v = spu_splats(x23); - vec_llong2 r23_v = spu_splats(r23); - - vec_double2 x24_v = spu_splats(x24); - vec_llong2 r24_v = spu_splats(r24); - - vec_double2 x25_v = spu_splats(x25); - vec_llong2 r25_v = spu_splats(r25); - - vec_llong2 res_v; - - TEST_START("ilogbd2"); - - res_v = (vec_llong2)ilogbd2(x0_v); - TEST_CHECK("20060904000000AAN", allequal_llong2( res_v, r0_v ), 0); - res_v = (vec_llong2)ilogbd2(x1_v); - TEST_CHECK("20060904000001AAN", allequal_llong2( res_v, r1_v ), 0); - res_v = (vec_llong2)ilogbd2(x2_v); - TEST_CHECK("20060904000002AAN", allequal_llong2( res_v, r2_v ), 0); - res_v = (vec_llong2)ilogbd2(x3_v); - TEST_CHECK("20060904000003AAN", allequal_llong2( res_v, r3_v ), 0); - res_v = (vec_llong2)ilogbd2(x4_v); - TEST_CHECK("20060904000004AAN", allequal_llong2( res_v, r4_v ), 0); - res_v = (vec_llong2)ilogbd2(x5_v); - TEST_CHECK("20060904000005AAN", allequal_llong2( res_v, r5_v ), 0); - res_v = (vec_llong2)ilogbd2(x6_v); - TEST_CHECK("20060904000006AAN", allequal_llong2( res_v, r6_v ), 0); - res_v = (vec_llong2)ilogbd2(x7_v); - TEST_CHECK("20060904000007AAN", allequal_llong2( res_v, r7_v ), 0); - res_v = (vec_llong2)ilogbd2(x8_v); - TEST_CHECK("20060904000008AAN", allequal_llong2( res_v, r8_v ), 0); - res_v = (vec_llong2)ilogbd2(x9_v); - TEST_CHECK("20060904000009AAN", allequal_llong2( res_v, r9_v ), 0); - res_v = (vec_llong2)ilogbd2(x10_v); - TEST_CHECK("20060904000010AAN", allequal_llong2( res_v, r10_v ), 0); - res_v = (vec_llong2)ilogbd2(x11_v); - TEST_CHECK("20060904000011AAN", allequal_llong2( res_v, r11_v ), 0); - res_v = (vec_llong2)ilogbd2(x12_v); - TEST_CHECK("20060904000012AAN", allequal_llong2( res_v, r12_v ), 0); - res_v = (vec_llong2)ilogbd2(x13_v); - TEST_CHECK("20060904000013AAN", allequal_llong2( res_v, r13_v ), 0); - res_v = (vec_llong2)ilogbd2(x14_v); - TEST_CHECK("20060904000014AAN", allequal_llong2( res_v, r14_v ), 0); - res_v = (vec_llong2)ilogbd2(x15_v); - TEST_CHECK("20060904000015AAN", allequal_llong2( res_v, r15_v ), 0); - res_v = (vec_llong2)ilogbd2(x16_v); - TEST_CHECK("20060904000016AAN", allequal_llong2( res_v, r16_v ), 0); - res_v = (vec_llong2)ilogbd2(x17_v); - TEST_CHECK("20060904000017AAN", allequal_llong2( res_v, r17_v ), 0); - res_v = (vec_llong2)ilogbd2(x18_v); - TEST_CHECK("20060904000018AAN", allequal_llong2( res_v, r18_v ), 0); - res_v = (vec_llong2)ilogbd2(x19_v); - TEST_CHECK("20060904000019AAN", allequal_llong2( res_v, r19_v ), 0); - res_v = (vec_llong2)ilogbd2(x20_v); - TEST_CHECK("20060904000020AAN", allequal_llong2( res_v, r20_v ), 0); - res_v = (vec_llong2)ilogbd2(x21_v); - TEST_CHECK("20060904000021AAN", allequal_llong2( res_v, r21_v ), 0); - res_v = (vec_llong2)ilogbd2(x22_v); - TEST_CHECK("20060904000022AAN", allequal_llong2( res_v, r22_v ), 0); - res_v = (vec_llong2)ilogbd2(x23_v); - TEST_CHECK("20060904000023AAN", allequal_llong2( res_v, r23_v ), 0); - res_v = (vec_llong2)ilogbd2(x24_v); - TEST_CHECK("20060904000024AAN", allequal_llong2( res_v, r24_v ), 0); - res_v = (vec_llong2)ilogbd2(x25_v); - TEST_CHECK("20060904000025AAN", allequal_llong2( res_v, r25_v ), 0); - res_v = (vec_llong2)ilogbd2(x26_v); - TEST_CHECK("20060904000026AAN", allequal_llong2( res_v, r26_v ), 0); - res_v = (vec_llong2)ilogbd2(x27_v); - TEST_CHECK("20060904000027AAN", allequal_llong2( res_v, r27_v ), 0); - res_v = (vec_llong2)ilogbd2(x28_v); - TEST_CHECK("20060904000028AAN", allequal_llong2( res_v, r28_v ), 0); - res_v = (vec_llong2)ilogbd2(x29_v); - TEST_CHECK("20060904000029AAN", allequal_llong2( res_v, r29_v ), 0); - res_v = (vec_llong2)ilogbd2(x30_v); - TEST_CHECK("20060904000030AAN", allequal_llong2( res_v, r30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/ilogbf4.c b/Extras/simdmathlibrary/spu/tests/ilogbf4.c deleted file mode 100644 index cb804aaa3..000000000 --- a/Extras/simdmathlibrary/spu/tests/ilogbf4.c +++ /dev/null @@ -1,317 +0,0 @@ -/* Test ilogbf4 for SPU - 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. - */ - - - -#include -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060904000000AAN","AAN", "ilogbf4"); - - // -Norm (IEEE-754: -Nan) - float x0 = hide_float(make_float(0xFFC00000)); - int r0 = 128; - - // -Norm (IEEE-754: -Inf) - float x1 = hide_float(-HUGE_VALF); - int r1 = 128; - - // -Smax - float x2 = hide_float(-FLT_MAX); - int r2 = 128; - - // -Norm - float x3 = hide_float(-824842.58421394); - int r3 = 19; - - // -Smin - float x4 = hide_float(make_float(0x80800000)); - int r4 = -126; - - // -Denorm - float x5 = hide_float(make_float(0x807AAAAA)); - int r5 = (int)FP_ILOGB0; - - // -Unf - float x6 = hide_float(-1.0e-999); - int r6 = (int)FP_ILOGB0; - - // -0 - float x7 = hide_float(-0.0); - int r7 = (int)FP_ILOGB0; - - // 0 - float x8 = hide_float( 0.0); - int r8 = (int)FP_ILOGB0; - - // +Unf - float x9 = hide_float( 1.0e-999); - int r9 = (int)FP_ILOGB0; - - // +Denorm - float x10 = hide_float(make_float(0x007AAAAA)); - int r10 = (int)FP_ILOGB0; - - // +Smin - float x11 = hide_float(make_float(0x00800000)); - int r11 = -126; - - // +Norm - float x12 = hide_float(3.14152634); - int r12 = 1; - - // +Norm - float x13 = hide_float(7.0673903e37); - int r13 = 125; - - // +Norm - float x14 = hide_float(2.4673e14); - int r14 = 47; - - // +Norm - float x15 = hide_float(7.235672e-25); - int r15 = -81; - - // +Norm - float x16 = hide_float(9.452854e17); - int r16 = 59; - - // +Norm - float x17 = hide_float(3.045784e-18); - int r17 = -59; - - // -Norm - float x18 = hide_float(-6.459273e7); - int r18 = 25; - - // -Norm - float x19 = hide_float(-2.493472e-9); - int r19 = -29; - - // -Norm - float x20 = hide_float(-1.4824543e28); - int r20 = 93; - - // -Norm - float x21 = hide_float(-5.53856231e-27); - int r21 = -88; - - // -Norm - float x22 = hide_float(-1.000001); - int r22 = 0; - - // +Smax - float x23 = hide_float(FLT_MAX); - int r23 = 128; - - //+Norm (IEEE-754: +Inf) - float x24 = hide_float( HUGE_VALF); - int r24 = 128; - - //+Norm (IEEE-754: +Nan) - float x25 = hide_float(make_float(0x7FC00000)); - int r25 = 128; - - // Compound - vec_float4 x26_v = (vec_float4) { -2.561286432e10, FLT_MAX, -1.0e-999, 7.235672e-25 }; - vec_int4 r26_v = (vec_int4) { 34, 128, FP_ILOGB0, -81 }; - - // Compound - vec_float4 x27_v = (vec_float4) { 345.27533, 7.0673903e37, -0.0, -2.40e-310 }; - vec_int4 r27_v = (vec_int4) { 8, 125, FP_ILOGB0, FP_ILOGB0 }; - - // Compound - vec_float4 x28_v = (vec_float4) { make_float(0x7FC00000), -824842.58421394, -0.0, -3678342.8765343 }; - vec_int4 r28_v = (vec_int4) { 128, 19, FP_ILOGB0, 21 }; - - // Compound - vec_float4 x29_v = (vec_float4) { HUGE_VALF, 1.0e-99, -5.53856231e-27, make_float(0xFFC00000) }; - vec_int4 r29_v = (vec_int4) { 128, FP_ILOGB0, -88, 128 }; - - // Compound - vec_float4 x30_v = (vec_float4) { 1.2e-57, -1.2e-19, 3.045784e-18, -HUGE_VALF } ; - vec_int4 r30_v = (vec_int4) { FP_ILOGB0, -63, -59, 128 }; - - vec_float4 x0_v = spu_splats(x0); - vec_int4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_int4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_int4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_int4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_int4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_int4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_int4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_int4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_int4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_int4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_int4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_int4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_int4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_int4 r13_v = spu_splats(r13); - - vec_float4 x14_v = spu_splats(x14); - vec_int4 r14_v = spu_splats(r14); - - vec_float4 x15_v = spu_splats(x15); - vec_int4 r15_v = spu_splats(r15); - - vec_float4 x16_v = spu_splats(x16); - vec_int4 r16_v = spu_splats(r16); - - vec_float4 x17_v = spu_splats(x17); - vec_int4 r17_v = spu_splats(r17); - - vec_float4 x18_v = spu_splats(x18); - vec_int4 r18_v = spu_splats(r18); - - vec_float4 x19_v = spu_splats(x19); - vec_int4 r19_v = spu_splats(r19); - - vec_float4 x20_v = spu_splats(x20); - vec_int4 r20_v = spu_splats(r20); - - vec_float4 x21_v = spu_splats(x21); - vec_int4 r21_v = spu_splats(r21); - - vec_float4 x22_v = spu_splats(x22); - vec_int4 r22_v = spu_splats(r22); - - vec_float4 x23_v = spu_splats(x23); - vec_int4 r23_v = spu_splats(r23); - - vec_float4 x24_v = spu_splats(x24); - vec_int4 r24_v = spu_splats(r24); - - vec_float4 x25_v = spu_splats(x25); - vec_int4 r25_v = spu_splats(r25); - - vec_int4 res_v; - - TEST_START("ilogbf4"); - - res_v = (vec_int4)ilogbf4(x0_v); - TEST_CHECK("20060904000000AAN", allequal_int4( res_v, r0_v ), 0); - res_v = (vec_int4)ilogbf4(x1_v); - TEST_CHECK("20060904000001AAN", allequal_int4( res_v, r1_v ), 0); - res_v = (vec_int4)ilogbf4(x2_v); - TEST_CHECK("20060904000002AAN", allequal_int4( res_v, r2_v ), 0); - res_v = (vec_int4)ilogbf4(x3_v); - TEST_CHECK("20060904000003AAN", allequal_int4( res_v, r3_v ), 0); - res_v = (vec_int4)ilogbf4(x4_v); - TEST_CHECK("20060904000004AAN", allequal_int4( res_v, r4_v ), 0); - res_v = (vec_int4)ilogbf4(x5_v); - TEST_CHECK("20060904000005AAN", allequal_int4( res_v, r5_v ), 0); - res_v = (vec_int4)ilogbf4(x6_v); - TEST_CHECK("20060904000006AAN", allequal_int4( res_v, r6_v ), 0); - res_v = (vec_int4)ilogbf4(x7_v); - TEST_CHECK("20060904000007AAN", allequal_int4( res_v, r7_v ), 0); - res_v = (vec_int4)ilogbf4(x8_v); - TEST_CHECK("20060904000008AAN", allequal_int4( res_v, r8_v ), 0); - res_v = (vec_int4)ilogbf4(x9_v); - TEST_CHECK("20060904000009AAN", allequal_int4( res_v, r9_v ), 0); - res_v = (vec_int4)ilogbf4(x10_v); - TEST_CHECK("20060904000010AAN", allequal_int4( res_v, r10_v ), 0); - res_v = (vec_int4)ilogbf4(x11_v); - TEST_CHECK("20060904000011AAN", allequal_int4( res_v, r11_v ), 0); - res_v = (vec_int4)ilogbf4(x12_v); - TEST_CHECK("20060904000012AAN", allequal_int4( res_v, r12_v ), 0); - res_v = (vec_int4)ilogbf4(x13_v); - TEST_CHECK("20060904000013AAN", allequal_int4( res_v, r13_v ), 0); - res_v = (vec_int4)ilogbf4(x14_v); - TEST_CHECK("20060904000014AAN", allequal_int4( res_v, r14_v ), 0); - res_v = (vec_int4)ilogbf4(x15_v); - TEST_CHECK("20060904000015AAN", allequal_int4( res_v, r15_v ), 0); - res_v = (vec_int4)ilogbf4(x16_v); - TEST_CHECK("20060904000016AAN", allequal_int4( res_v, r16_v ), 0); - res_v = (vec_int4)ilogbf4(x17_v); - TEST_CHECK("20060904000017AAN", allequal_int4( res_v, r17_v ), 0); - res_v = (vec_int4)ilogbf4(x18_v); - TEST_CHECK("20060904000018AAN", allequal_int4( res_v, r18_v ), 0); - res_v = (vec_int4)ilogbf4(x19_v); - TEST_CHECK("20060904000019AAN", allequal_int4( res_v, r19_v ), 0); - res_v = (vec_int4)ilogbf4(x20_v); - TEST_CHECK("20060904000020AAN", allequal_int4( res_v, r20_v ), 0); - res_v = (vec_int4)ilogbf4(x21_v); - TEST_CHECK("20060904000021AAN", allequal_int4( res_v, r21_v ), 0); - res_v = (vec_int4)ilogbf4(x22_v); - TEST_CHECK("20060904000022AAN", allequal_int4( res_v, r22_v ), 0); - res_v = (vec_int4)ilogbf4(x23_v); - TEST_CHECK("20060904000023AAN", allequal_int4( res_v, r23_v ), 0); - res_v = (vec_int4)ilogbf4(x24_v); - TEST_CHECK("20060904000024AAN", allequal_int4( res_v, r24_v ), 0); - res_v = (vec_int4)ilogbf4(x25_v); - TEST_CHECK("20060904000025AAN", allequal_int4( res_v, r25_v ), 0); - res_v = (vec_int4)ilogbf4(x26_v); - TEST_CHECK("20060904000026AAN", allequal_int4( res_v, r26_v ), 0); - res_v = (vec_int4)ilogbf4(x27_v); - TEST_CHECK("20060904000027AAN", allequal_int4( res_v, r27_v ), 0); - res_v = (vec_int4)ilogbf4(x28_v); - TEST_CHECK("20060904000028AAN", allequal_int4( res_v, r28_v ), 0); - res_v = (vec_int4)ilogbf4(x29_v); - TEST_CHECK("20060904000029AAN", allequal_int4( res_v, r29_v ), 0); - res_v = (vec_int4)ilogbf4(x30_v); - TEST_CHECK("20060904000030AAN", allequal_int4( res_v, r30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/irintf4.c b/Extras/simdmathlibrary/spu/tests/irintf4.c deleted file mode 100644 index afd1cbcc6..000000000 --- a/Extras/simdmathlibrary/spu/tests/irintf4.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Test irintf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#define DEFINE_DATA(val,a,b)\ - float val = hide_float(a); \ - signed int val ## _out =b;\ - vec_float4 val ## _v = spu_splats(val);\ - vec_int4 val ## _out_v = spu_splats(val ## _out); - -#define DEFINE_DATA_UNSIGNED(val,a,b)\ - unsigned int val ## _in = a;\ - float val = make_float(val ## _in);\ - signed int val ## _out = b;\ - vec_float4 val ## _v = spu_splats(val);\ - vec_int4 val ## _out_v = spu_splats(val ## _out); - -#define DO_TEST(var,id) \ - res_v = irintf4(var ## _v); \ - TEST_CHECK(" #id ", allequal_int4( res_v, var ## _out_v ), 0); - -int main() -{ - vec_int4 res_v; - - TEST_SET_START("921537538600","RNT", "irintf4"); - - /* - Define original values and the results - */ - //s=0 - DEFINE_DATA(x1, 1.0, 1) - DEFINE_DATA(x2, -1.0,-1) - - //s=-1 - DEFINE_DATA(x3, 0.5, 0) - DEFINE_DATA(x4, -0.5, 0) - //s=-2 - DEFINE_DATA(x5, 0.25, 0) - //s=-3 - DEFINE_DATA(x6, 0.125, 0) - - //s=0, e=27, f=0 -> 134217728 - DEFINE_DATA_UNSIGNED(x7, 0x4d000000,134217728) - //s=0, e=-126, f=0 --> 0 - DEFINE_DATA_UNSIGNED(x8, 0x800000,0) - - /* TEST */ - TEST_START("irintf4"); - - DO_TEST(x1,921537538601RNT) - DO_TEST(x2,921537538602RNT) - DO_TEST(x3,921537538603RNT) - DO_TEST(x4,921537538604RNT) - DO_TEST(x5,921537538605RNT) - DO_TEST(x6,921537538606RNT) - DO_TEST(x7,921537538607RNT) - DO_TEST(x8,921537538608RNT) - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/iroundf4.c b/Extras/simdmathlibrary/spu/tests/iroundf4.c deleted file mode 100644 index a6d3fe199..000000000 --- a/Extras/simdmathlibrary/spu/tests/iroundf4.c +++ /dev/null @@ -1,96 +0,0 @@ -/* Test iroundf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#define DEFINE_DATA(val,a,b)\ - float val = hide_float(a); \ - signed int val ## _out =b;\ - vec_float4 val ## _v = spu_splats(val);\ - vec_int4 val ## _out_v = spu_splats(val ## _out); - -#define DEFINE_DATA_UNSIGNED(val,a,b)\ - unsigned int val ## _in = a;\ - float val = make_float(val ## _in);\ - signed int val ## _out = b;\ - vec_float4 val ## _v = spu_splats(val);\ - vec_int4 val ## _out_v = spu_splats(val ## _out); - -#define DO_TEST(var,id) \ - res_v = iroundf4(var ## _v); \ - TEST_CHECK(" #id ", allequal_int4( res_v, var ## _out_v ), 0); - - -int main() -{ - vec_int4 res_v; - - TEST_SET_START("592642590100","RUD", "iroundf4"); - - /* - Define original values and the results - */ - //s=0 - DEFINE_DATA(x1, 1.0, 1.0f) - DEFINE_DATA(x2, -1.0,-1.0f) - //s=-1 - DEFINE_DATA(x3, 0.5, 1.0f) - DEFINE_DATA(x4, -0.5, -1.0f) - //s=-2 - DEFINE_DATA(x5, 0.25, 0.0f) - //s=-3 - DEFINE_DATA(x6, 0.125, 0.0f) - //s=0, e=27, f=0 -> 134217728 - DEFINE_DATA_UNSIGNED(x7, 0x4d000000,134217728) - //s=0, e=-126, f=0 --> 0 - DEFINE_DATA_UNSIGNED(x8, 0x800000,0) - - /* TEST */ - TEST_START("iroundf4"); - - DO_TEST(x1,592642590101RUD) - DO_TEST(x2,592642590102RUD) - DO_TEST(x3,592642590103RUD) - DO_TEST(x4,592642590104RUD) - DO_TEST(x5,592642590105RUD) - DO_TEST(x6,592642590106RUD) - DO_TEST(x7,592642590107RUD) - DO_TEST(x8,592642590108RUD) - - TEST_SET_DONE(); - - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/is0denormd2.c b/Extras/simdmathlibrary/spu/tests/is0denormd2.c deleted file mode 100644 index 9433749b8..000000000 --- a/Extras/simdmathlibrary/spu/tests/is0denormd2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test is0denormd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "is0denormd2"); - - // -Nan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0x0000000000000000ull; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - // -Norm - double x3 = hide_double(-824842.58421394); - unsigned long long r3 = 0x0000000000000000ull; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - unsigned long long r4 = 0x0000000000000000ull; - - // -Denorm - double x5 = hide_double(-2.40e-310); - unsigned long long r5 = 0xffffffffffffffffull; - - // -Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0xffffffffffffffffull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0xffffffffffffffffull; - - // +Unf - double x9 = hide_double( 1.0e-999); - unsigned long long r9 = 0xffffffffffffffffull; - - // +Denorm - double x10 = hide_double( 2.40e-310); - unsigned long long r10 = 0xffffffffffffffffull; - - // +Dmin - double x11 = hide_double( DBL_MIN); - unsigned long long r11 = 0x0000000000000000ull; - - // +Norm - double x12 = hide_double(3.14152634); - unsigned long long r12 = 0x0000000000000000ull; - - // +Dmax - double x13 = hide_double(DBL_MAX); - unsigned long long r13 = 0x0000000000000000ull; - - // +Inf - double x14 = hide_double( HUGE_VAL); - unsigned long long r14 = 0x0000000000000000ull; - - //+Nan - double x15 = hide_double( nan("")); - unsigned long long r15 = 0x0000000000000000ull; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0x000AAAAAAAAAAAAAull), -1.0e-999 }; - vec_ullong2 r16_v = (vec_ullong2) {0xffffffffffffffffull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_ullong2 r17_v = (vec_ullong2) {0x0000000000000000ull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_ullong2 r18_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x19_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_ullong2 r19_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x20_v = (vec_double2) { -1.0e-999, -HUGE_VAL} ; - vec_ullong2 r20_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("is0denormd2"); - - res_v = (vec_ullong2)is0denormd2(x0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)is0denormd2(x1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)is0denormd2(x2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)is0denormd2(x3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)is0denormd2(x4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)is0denormd2(x5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)is0denormd2(x6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)is0denormd2(x7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)is0denormd2(x8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)is0denormd2(x9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)is0denormd2(x10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)is0denormd2(x11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)is0denormd2(x12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)is0denormd2(x13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)is0denormd2(x14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)is0denormd2(x15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)is0denormd2(x16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)is0denormd2(x17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)is0denormd2(x18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)is0denormd2(x19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - res_v = (vec_ullong2)is0denormd2(x20_v); - TEST_CHECK("20060830000020AAN", allequal_ullong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/is0denormf4.c b/Extras/simdmathlibrary/spu/tests/is0denormf4.c deleted file mode 100644 index dcb91d608..000000000 --- a/Extras/simdmathlibrary/spu/tests/is0denormf4.c +++ /dev/null @@ -1,200 +0,0 @@ -/* Test is0denormf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "is0denormf4"); - - // -Nan - float x0 = hide_float(-NANF); - unsigned int r0 = 0x00000000; - - // -Inf - float x1 = hide_float(-HUGE_VALF); - unsigned int r1 = 0x00000000; - - // -Smax - float x2 = hide_float(make_float(0xffffffff)); - unsigned int r2 = 0x00000000; - - // -Norm - float x3 = hide_float(-824842.58421394f); - unsigned int r3 = 0x00000000; - - // -Smin - float x4 = hide_float(make_float(0x80800000)); - unsigned int r4 = 0x00000000; - - // -Denorm - float x5 = hide_float(make_float(0x803aaaaa)); - unsigned int r5 = 0xffffffff; - - // -Unf - float x6 = hide_float(-1.0e-999); - unsigned int r6 = 0xffffffff; - - // -0 - float x7 = hide_float(-0.0f); - unsigned int r7 = 0xffffffff; - - // 0 - float x8 = hide_float( 0.0f); - unsigned int r8 = 0xffffffff; - - // +Unf - float x9 = hide_float( 1.0e-999); - unsigned int r9 = 0xffffffff; - - // +Denorm - float x10 = hide_float(make_float(0x003aaaaa)); - unsigned int r10 = 0xffffffff; - - // +Smin - float x11 = hide_float(make_float(0x00800000)); - unsigned int r11 = 0x00000000; - - // +Norm - float x12 = hide_float(3.14152634f); - unsigned int r12 = 0x00000000; - - // +Smax - float x13 = hide_float(make_float(0x7fffffff)); - unsigned int r13 = 0x00000000; - - // +Inf - float x14 = hide_float( HUGE_VALF); - unsigned int r14 = 0x00000000; - - //+Nan - float x15 = hide_float(NANF); - unsigned int r15 = 0x00000000; - - // Compound - vec_float4 x16_v = (vec_float4) {make_float(0x003AAAAA), -1.0e-999, 345.27533, make_float(0x803AAAAA)}; - vec_uint4 r16_v = (vec_uint4) {0xffffffff, 0xffffffff, 0x00000000, 0xffffffff}; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_uint4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_uint4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_uint4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_uint4 r13_v = spu_splats(r13); - - vec_float4 x14_v = spu_splats(x14); - vec_uint4 r14_v = spu_splats(r14); - - vec_float4 x15_v = spu_splats(x15); - vec_uint4 r15_v = spu_splats(r15); - - vec_uint4 res_v; - - TEST_START("is0denormf4"); - - res_v = (vec_uint4)is0denormf4(x0_v); - TEST_CHECK("20060830000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)is0denormf4(x1_v); - TEST_CHECK("20060830000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)is0denormf4(x2_v); - TEST_CHECK("20060830000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)is0denormf4(x3_v); - TEST_CHECK("20060830000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)is0denormf4(x4_v); - TEST_CHECK("20060830000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)is0denormf4(x5_v); - TEST_CHECK("20060830000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)is0denormf4(x6_v); - TEST_CHECK("20060830000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)is0denormf4(x7_v); - TEST_CHECK("20060830000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)is0denormf4(x8_v); - TEST_CHECK("20060830000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)is0denormf4(x9_v); - TEST_CHECK("20060830000009AAN", allequal_uint4( res_v, r9_v ), 0); - res_v = (vec_uint4)is0denormf4(x10_v); - TEST_CHECK("20060830000010AAN", allequal_uint4( res_v, r10_v ), 0); - res_v = (vec_uint4)is0denormf4(x11_v); - TEST_CHECK("20060830000011AAN", allequal_uint4( res_v, r11_v ), 0); - res_v = (vec_uint4)is0denormf4(x12_v); - TEST_CHECK("20060830000012AAN", allequal_uint4( res_v, r12_v ), 0); - res_v = (vec_uint4)is0denormf4(x13_v); - TEST_CHECK("20060830000013AAN", allequal_uint4( res_v, r13_v ), 0); - res_v = (vec_uint4)is0denormf4(x14_v); - TEST_CHECK("20060830000014AAN", allequal_uint4( res_v, r14_v ), 0); - res_v = (vec_uint4)is0denormf4(x15_v); - TEST_CHECK("20060830000015AAN", allequal_uint4( res_v, r15_v ), 0); - res_v = (vec_uint4)is0denormf4(x16_v); - TEST_CHECK("20060830000016AAN", allequal_uint4( res_v, r16_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isequald2.c b/Extras/simdmathlibrary/spu/tests/isequald2.c deleted file mode 100644 index 5e80be8c2..000000000 --- a/Extras/simdmathlibrary/spu/tests/isequald2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test isequald2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "isequald2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0x0000000000000000ull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0x0000000000000000ull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0xffffffffffffffffull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0x0000000000000000ull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0x0000000000000000ull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0xffffffffffffffffull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0xffffffffffffffffull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0xffffffffffffffffull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0x0000000000000000ull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0x0000000000000000ull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0xffffffffffffffffull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0x0000000000000000ull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0x0000000000000000ull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0x0000000000000000ull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0x0000000000000000ull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("isequald2"); - - res_v = (vec_ullong2)isequald2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isequald2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isequald2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isequald2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isequald2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isequald2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isequald2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isequald2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isequald2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isequald2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isequald2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isequald2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isequald2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isequald2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isequald2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isequald2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isequald2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isequald2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isequald2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isequald2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isequalf4.c b/Extras/simdmathlibrary/spu/tests/isequalf4.c deleted file mode 100644 index 52c5ad508..000000000 --- a/Extras/simdmathlibrary/spu/tests/isequalf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test isequalf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060817000000AAN","AAN", "isequalf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0xffffffff; - - float x1 = hide_float(FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float( 1e-999); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0xffffffff; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isequalf4"); - - res_v = (vec_uint4)isequalf4(x0_v, y0_v); - TEST_CHECK("20060817000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isequalf4(x1_v, y1_v); - TEST_CHECK("20060817000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isequalf4(x2_v, y2_v); - TEST_CHECK("20060817000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isequalf4(x3_v, y3_v); - TEST_CHECK("20060817000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isequalf4(x4_v, y4_v); - TEST_CHECK("20060817000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isequalf4(x5_v, y5_v); - TEST_CHECK("20060817000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isequalf4(x6_v, y6_v); - TEST_CHECK("20060817000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isequalf4(x7_v, y7_v); - TEST_CHECK("20060817000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isequalf4(x8_v, y8_v); - TEST_CHECK("20060817000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isequalf4(x9_v, y9_v); - TEST_CHECK("20060817000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isfinited2.c b/Extras/simdmathlibrary/spu/tests/isfinited2.c deleted file mode 100644 index 798195505..000000000 --- a/Extras/simdmathlibrary/spu/tests/isfinited2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test isfinited2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "isfinited2"); - - // -Nan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0x0000000000000000ull; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - // -Norm - double x3 = hide_double(-824842.58421394); - unsigned long long r3 = 0xffffffffffffffffull; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - unsigned long long r4 = 0xffffffffffffffffull; - - // -Denorm - double x5 = hide_double(-2.40e-310); - unsigned long long r5 = 0xffffffffffffffffull; - - // -Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0xffffffffffffffffull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0xffffffffffffffffull; - - // +Unf - double x9 = hide_double( 1.0e-999); - unsigned long long r9 = 0xffffffffffffffffull; - - // +Denorm - double x10 = hide_double( 2.40e-310); - unsigned long long r10 = 0xffffffffffffffffull; - - // +Dmin - double x11 = hide_double( DBL_MIN); - unsigned long long r11 = 0xffffffffffffffffull; - - // +Norm - double x12 = hide_double(3.14152634); - unsigned long long r12 = 0xffffffffffffffffull; - - // +Dmax - double x13 = hide_double(DBL_MAX); - unsigned long long r13 = 0xffffffffffffffffull; - - // +Inf - double x14 = hide_double(HUGE_VAL); - unsigned long long r14 = 0x0000000000000000ull; - - //+Nan - double x15 = hide_double( nan("")); - unsigned long long r15 = 0x0000000000000000ull; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0x000AAAAAAAAAAAAAull), -1.0e-999 }; - vec_ullong2 r16_v = (vec_ullong2) {0xffffffffffffffffull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_ullong2 r17_v = (vec_ullong2) {0xffffffffffffffffull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_ullong2 r18_v = (vec_ullong2) {0x0000000000000000ull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x19_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_ullong2 r19_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x20_v = (vec_double2) { -1.0e-999, -HUGE_VAL} ; - vec_ullong2 r20_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("isfinited2"); - - res_v = (vec_ullong2)isfinited2(x0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isfinited2(x1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isfinited2(x2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isfinited2(x3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isfinited2(x4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isfinited2(x5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isfinited2(x6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isfinited2(x7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isfinited2(x8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isfinited2(x9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isfinited2(x10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isfinited2(x11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isfinited2(x12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isfinited2(x13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isfinited2(x14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isfinited2(x15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isfinited2(x16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isfinited2(x17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isfinited2(x18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isfinited2(x19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - res_v = (vec_ullong2)isfinited2(x20_v); - TEST_CHECK("20060830000020AAN", allequal_ullong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isfinitef4.c b/Extras/simdmathlibrary/spu/tests/isfinitef4.c deleted file mode 100644 index aff25a2f0..000000000 --- a/Extras/simdmathlibrary/spu/tests/isfinitef4.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Test isfinitef4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060822000000AAN","AAN", "isfinitef4"); - - float x0 = hide_float(-0.0f); - unsigned int r0 = 0xffffffff; - - float x1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0xffffffff; - - float x2 = hide_float(-0.0000000013152f); - unsigned int r2 = 0xffffffff; - - float x3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - float x4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0xffffffff; - - float x5 = hide_float(876543.12345f); - unsigned int r5 = 0xffffffff; - - float x6 = hide_float( 1e-999); // Smin - unsigned int r6 = 0xffffffff; - - float x7 = hide_float(5172.2845321f); - unsigned int r7 = 0xffffffff; - - float x8 = hide_float(2353705.31415f); - unsigned int r8 = 0xffffffff; - - float x9 = hide_float(FLT_MAX); // Smax - unsigned int r9 = 0xffffffff; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isfinitef4"); - - res_v = (vec_uint4)isfinitef4(x0_v); - TEST_CHECK("20060822000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isfinitef4(x1_v); - TEST_CHECK("20060822000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isfinitef4(x2_v); - TEST_CHECK("20060822000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isfinitef4(x3_v); - TEST_CHECK("20060822000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isfinitef4(x4_v); - TEST_CHECK("20060822000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isfinitef4(x5_v); - TEST_CHECK("20060822000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isfinitef4(x6_v); - TEST_CHECK("20060822000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isfinitef4(x7_v); - TEST_CHECK("20060822000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isfinitef4(x8_v); - TEST_CHECK("20060822000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isfinitef4(x9_v); - TEST_CHECK("20060822000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isgreaterd2.c b/Extras/simdmathlibrary/spu/tests/isgreaterd2.c deleted file mode 100644 index 5c4ff593e..000000000 --- a/Extras/simdmathlibrary/spu/tests/isgreaterd2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test isgreaterd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "isgreaterd2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0xffffffffffffffffull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0xffffffffffffffffull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0x0000000000000000ull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0x0000000000000000ull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0xffffffffffffffffull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0xffffffffffffffffull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0x0000000000000000ull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0x0000000000000000ull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0x0000000000000000ull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0x0000000000000000ull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0xffffffffffffffffull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0x0000000000000000ull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0x0000000000000000ull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0xffffffffffffffffull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0x0000000000000000ull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0xffffffffffffffffull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("isgreaterd2"); - - res_v = (vec_ullong2)isgreaterd2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isgreaterd2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isgreaterequald2.c b/Extras/simdmathlibrary/spu/tests/isgreaterequald2.c deleted file mode 100644 index 00bf97ae0..000000000 --- a/Extras/simdmathlibrary/spu/tests/isgreaterequald2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test isgreaterequald2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "isgreaterequald2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0xffffffffffffffffull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0xffffffffffffffffull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0x0000000000000000ull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0xffffffffffffffffull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0xffffffffffffffffull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0xffffffffffffffffull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0xffffffffffffffffull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0xffffffffffffffffull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0xffffffffffffffffull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0x0000000000000000ull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0xffffffffffffffffull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0xffffffffffffffffull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0x0000000000000000ull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0xffffffffffffffffull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0x0000000000000000ull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0xffffffffffffffffull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("isgreaterequald2"); - - res_v = (vec_ullong2)isgreaterequald2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isgreaterequald2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isgreaterequalf4.c b/Extras/simdmathlibrary/spu/tests/isgreaterequalf4.c deleted file mode 100644 index ac13a26e1..000000000 --- a/Extras/simdmathlibrary/spu/tests/isgreaterequalf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test isgreaterequalf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060817000000AAN","AAN", "isgreaterequalf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0xffffffff; - - float x1 = hide_float(FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0xffffffff; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0xffffffff; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-FLT_MIN); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float(FLT_MIN); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0xffffffff; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0xffffffff; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isgreaterequalf4"); - - res_v = (vec_uint4)isgreaterequalf4(x0_v, y0_v); - TEST_CHECK("20060817000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x1_v, y1_v); - TEST_CHECK("20060817000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x2_v, y2_v); - TEST_CHECK("20060817000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x3_v, y3_v); - TEST_CHECK("20060817000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x4_v, y4_v); - TEST_CHECK("20060817000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x5_v, y5_v); - TEST_CHECK("20060817000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x6_v, y6_v); - TEST_CHECK("20060817000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x7_v, y7_v); - TEST_CHECK("20060817000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x8_v, y8_v); - TEST_CHECK("20060817000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isgreaterequalf4(x9_v, y9_v); - TEST_CHECK("20060817000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isgreaterf4.c b/Extras/simdmathlibrary/spu/tests/isgreaterf4.c deleted file mode 100644 index 8390f8ce6..000000000 --- a/Extras/simdmathlibrary/spu/tests/isgreaterf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test isgreaterf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060817000000AAN","AAN", "isgreaterf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float(FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0xffffffff; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0xffffffff; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-FLT_MIN); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float(FLT_MIN); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0xffffffff; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isgreaterf4"); - - res_v = (vec_uint4)isgreaterf4(x0_v, y0_v); - TEST_CHECK("20060817000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isgreaterf4(x1_v, y1_v); - TEST_CHECK("20060817000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isgreaterf4(x2_v, y2_v); - TEST_CHECK("20060817000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isgreaterf4(x3_v, y3_v); - TEST_CHECK("20060817000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isgreaterf4(x4_v, y4_v); - TEST_CHECK("20060817000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isgreaterf4(x5_v, y5_v); - TEST_CHECK("20060817000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isgreaterf4(x6_v, y6_v); - TEST_CHECK("20060817000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isgreaterf4(x7_v, y7_v); - TEST_CHECK("20060817000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isgreaterf4(x8_v, y8_v); - TEST_CHECK("20060817000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isgreaterf4(x9_v, y9_v); - TEST_CHECK("20060817000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isinfd2.c b/Extras/simdmathlibrary/spu/tests/isinfd2.c deleted file mode 100644 index 94b49a3b6..000000000 --- a/Extras/simdmathlibrary/spu/tests/isinfd2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test isinfd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "isinfd2"); - - // -Nan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0x0000000000000000ull; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0xffffffffffffffffull; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - // -Norm - double x3 = hide_double(-824842.58421394); - unsigned long long r3 = 0x0000000000000000ull; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - unsigned long long r4 = 0x0000000000000000ull; - - // -Denorm - double x5 = hide_double(-2.40e-310); - unsigned long long r5 = 0x0000000000000000ull; - - // -Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0x0000000000000000ull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0x0000000000000000ull; - - // +Inf - double x9 = hide_double( 1.0e999); - unsigned long long r9 = 0xffffffffffffffffull; - - // +Denorm - double x10 = hide_double( 2.40e-310); - unsigned long long r10 = 0x0000000000000000ull; - - // +Dmin - double x11 = hide_double( DBL_MIN); - unsigned long long r11 = 0x0000000000000000ull; - - // +Norm - double x12 = hide_double(3.14152634); - unsigned long long r12 = 0x0000000000000000ull; - - // +Dmax - double x13 = hide_double(DBL_MAX); - unsigned long long r13 = 0x0000000000000000ull; - - // +Inf - double x14 = hide_double(HUGE_VAL); - unsigned long long r14 = 0xffffffffffffffffull; - - //+Nan - double x15 = hide_double( nan("")); - unsigned long long r15 = 0x0000000000000000ull; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0x000AAAAAAAAAAAAAull), -1.0e-999 }; - vec_ullong2 r16_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_ullong2 r17_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), 1.0e999 }; - vec_ullong2 r18_v = (vec_ullong2) {0x0000000000000000ull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x19_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_ullong2 r19_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - // Compound - vec_double2 x20_v = (vec_double2) { -1.0e999, -HUGE_VAL} ; - vec_ullong2 r20_v = (vec_ullong2) {0xffffffffffffffffull, 0xffffffffffffffffull}; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("isinfd2"); - - res_v = (vec_ullong2)isinfd2(x0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isinfd2(x1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isinfd2(x2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isinfd2(x3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isinfd2(x4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isinfd2(x5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isinfd2(x6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isinfd2(x7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isinfd2(x8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isinfd2(x9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isinfd2(x10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isinfd2(x11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isinfd2(x12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isinfd2(x13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isinfd2(x14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isinfd2(x15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isinfd2(x16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isinfd2(x17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isinfd2(x18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isinfd2(x19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - res_v = (vec_ullong2)isinfd2(x20_v); - TEST_CHECK("20060830000020AAN", allequal_ullong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isinff4.c b/Extras/simdmathlibrary/spu/tests/isinff4.c deleted file mode 100644 index f2bf174c2..000000000 --- a/Extras/simdmathlibrary/spu/tests/isinff4.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Test isinff4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060822000000AAN","AAN", "isinff4"); - - float x0 = hide_float(-0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float( 1e-999); // Smin - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isinff4"); - - res_v = (vec_uint4)isinff4(x0_v); - TEST_CHECK("20060822000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isinff4(x1_v); - TEST_CHECK("20060822000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isinff4(x2_v); - TEST_CHECK("20060822000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isinff4(x3_v); - TEST_CHECK("20060822000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isinff4(x4_v); - TEST_CHECK("20060822000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isinff4(x5_v); - TEST_CHECK("20060822000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isinff4(x6_v); - TEST_CHECK("20060822000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isinff4(x7_v); - TEST_CHECK("20060822000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isinff4(x8_v); - TEST_CHECK("20060822000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isinff4(x9_v); - TEST_CHECK("20060822000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessd2.c b/Extras/simdmathlibrary/spu/tests/islessd2.c deleted file mode 100644 index 087df293a..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessd2.c +++ /dev/null @@ -1,272 +0,0 @@ -/* Test islessd2 for SPU - 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. - */ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "islessd2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0x0000000000000000ull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0xffffffffffffffffull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0x0000000000000000ull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0x0000000000000000ull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0x0000000000000000ull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0x0000000000000000ull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0x0000000000000000ull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0x0000000000000000ull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0xffffffffffffffffull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0x0000000000000000ull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0x0000000000000000ull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0xffffffffffffffffull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0x0000000000000000ull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0xffffffffffffffffull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0x0000000000000000ull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("islessd2"); - - res_v = (vec_ullong2)islessd2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)islessd2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)islessd2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)islessd2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)islessd2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)islessd2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)islessd2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)islessd2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)islessd2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)islessd2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)islessd2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)islessd2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)islessd2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)islessd2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)islessd2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)islessd2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)islessd2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)islessd2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)islessd2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)islessd2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessequald2.c b/Extras/simdmathlibrary/spu/tests/islessequald2.c deleted file mode 100644 index 52c9ea4cb..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessequald2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test islessequald2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "islessequald2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0x0000000000000000ull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0xffffffffffffffffull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0xffffffffffffffffull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0x0000000000000000ull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0x0000000000000000ull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0xffffffffffffffffull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0xffffffffffffffffull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0xffffffffffffffffull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0xffffffffffffffffull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0x0000000000000000ull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0xffffffffffffffffull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0xffffffffffffffffull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0x0000000000000000ull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0xffffffffffffffffull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0x0000000000000000ull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("islessequald2"); - - res_v = (vec_ullong2)islessequald2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)islessequald2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)islessequald2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)islessequald2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)islessequald2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)islessequald2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)islessequald2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)islessequald2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)islessequald2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)islessequald2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)islessequald2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)islessequald2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)islessequald2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)islessequald2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)islessequald2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)islessequald2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)islessequald2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)islessequald2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)islessequald2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)islessequald2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessequalf4.c b/Extras/simdmathlibrary/spu/tests/islessequalf4.c deleted file mode 100644 index 0960e1c15..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessequalf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test islessequalf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060816000000AAN","AAN", "islessequalf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0xffffffff; - - float x1 = hide_float(FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-FLT_MIN); //-Smin - unsigned int r4 = 0xffffffff; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0xffffffff; - - float x6 = hide_float(FLT_MIN); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0xffffffff; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0xffffffff; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0xffffffff; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("islessequalf4"); - - res_v = (vec_uint4)islessequalf4(x0_v, y0_v); - TEST_CHECK("20060816000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)islessequalf4(x1_v, y1_v); - TEST_CHECK("20060816000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)islessequalf4(x2_v, y2_v); - TEST_CHECK("20060816000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)islessequalf4(x3_v, y3_v); - TEST_CHECK("20060816000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)islessequalf4(x4_v, y4_v); - TEST_CHECK("20060816000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)islessequalf4(x5_v, y5_v); - TEST_CHECK("20060816000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)islessequalf4(x6_v, y6_v); - TEST_CHECK("20060816000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)islessequalf4(x7_v, y7_v); - TEST_CHECK("20060816000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)islessequalf4(x8_v, y8_v); - TEST_CHECK("20060816000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)islessequalf4(x9_v, y9_v); - TEST_CHECK("20060816000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessf4.c b/Extras/simdmathlibrary/spu/tests/islessf4.c deleted file mode 100644 index 593cea616..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test islessf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060815000000AAN","AAN", "islessf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float(FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-FLT_MIN); //-Smin - unsigned int r4 = 0xffffffff; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0xffffffff; - - float x6 = hide_float(FLT_MIN); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0xffffffff; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0xffffffff; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("islessf4"); - - res_v = (vec_uint4)islessf4(x0_v, y0_v); - TEST_CHECK("20060815000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)islessf4(x1_v, y1_v); - TEST_CHECK("20060815000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)islessf4(x2_v, y2_v); - TEST_CHECK("20060815000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)islessf4(x3_v, y3_v); - TEST_CHECK("20060815000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)islessf4(x4_v, y4_v); - TEST_CHECK("20060815000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)islessf4(x5_v, y5_v); - TEST_CHECK("20060815000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)islessf4(x6_v, y6_v); - TEST_CHECK("20060815000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)islessf4(x7_v, y7_v); - TEST_CHECK("20060815000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)islessf4(x8_v, y8_v); - TEST_CHECK("20060815000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)islessf4(x9_v, y9_v); - TEST_CHECK("20060815000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessgreaterd2.c b/Extras/simdmathlibrary/spu/tests/islessgreaterd2.c deleted file mode 100644 index e16ec86b0..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessgreaterd2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test islessgreaterd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060825000000AAN","AAN", "islessgreaterd2"); - - //-QNaN: NG - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0x0000000000000000ull; - - //+Inf > -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0xffffffffffffffffull; - - //-Inf < -Dmax - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - //-Norm > -Inf - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(-HUGE_VAL); - unsigned long long r3 = 0xffffffffffffffffull; - - //-Norm < -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0xffffffffffffffffull; - - //-Norm = -Norm - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-168.97345223013); - unsigned long long r5 = 0x0000000000000000ull; - - //-Norm > -Norm - double x6 = hide_double(-168.97345223013); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0xffffffffffffffffull; - - //-Norm < -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - //-Unf > -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0xffffffffffffffffull; - - //-Unf = 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0x0000000000000000ull; - - //-0 = 0 - double x10 = hide_double(-0.0); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0x0000000000000000ull; - - //+Unf = 0 - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( 0.0); - unsigned long long r11 = 0x0000000000000000ull; - - //+Unf < +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0xffffffffffffffffull; - - //+Norm > +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0xffffffffffffffffull; - - //+Norm = +Norm - double x14 = hide_double(5172.2845321); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0x0000000000000000ull; - - //+Norm < +Norm - double x15 = hide_double(264.345643345); - double y15 = hide_double(2353705.31415); - unsigned long long r15 = 0xffffffffffffffffull; - - //+Norm > -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0xffffffffffffffffull; - - //+Norm < +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0xffffffffffffffffull; - - //+Inf > +Dmax - double x18 = hide_double(HUGE_VAL); - double y18 = hide_double(DBL_MAX); - unsigned long long r18 = 0xffffffffffffffffull; - - //+QNaN: NG - double x19 = hide_double(nan("")); - double y19 = hide_double(3.14); - unsigned long long r19 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("islessgreaterd2"); - - res_v = (vec_ullong2)islessgreaterd2(x0_v, y0_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x1_v, y1_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x2_v, y2_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x3_v, y3_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x4_v, y4_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x5_v, y5_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x6_v, y6_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x7_v, y7_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x8_v, y8_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x9_v, y9_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x10_v, y10_v); - TEST_CHECK("20060825000000AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x11_v, y11_v); - TEST_CHECK("20060825000001AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x12_v, y12_v); - TEST_CHECK("20060825000002AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x13_v, y13_v); - TEST_CHECK("20060825000003AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x14_v, y14_v); - TEST_CHECK("20060825000004AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x15_v, y15_v); - TEST_CHECK("20060825000005AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x16_v, y16_v); - TEST_CHECK("20060825000006AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x17_v, y17_v); - TEST_CHECK("20060825000007AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x18_v, y18_v); - TEST_CHECK("20060825000008AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)islessgreaterd2(x19_v, y19_v); - TEST_CHECK("20060825000009AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/islessgreaterf4.c b/Extras/simdmathlibrary/spu/tests/islessgreaterf4.c deleted file mode 100644 index ae8e1231e..000000000 --- a/Extras/simdmathlibrary/spu/tests/islessgreaterf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test islessgreaterf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060816000000AAN","AAN", "islessgreaterf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float( FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0xffffffff; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0xffffffff; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0xffffffff; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0xffffffff; - - float x6 = hide_float( 1e-999); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0xffffffff; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0xffffffff; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0xffffffff; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("islessgreaterf4"); - - res_v = (vec_uint4)islessgreaterf4(x0_v, y0_v); - TEST_CHECK("20060816000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x1_v, y1_v); - TEST_CHECK("20060816000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x2_v, y2_v); - TEST_CHECK("20060816000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x3_v, y3_v); - TEST_CHECK("20060816000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x4_v, y4_v); - TEST_CHECK("20060816000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x5_v, y5_v); - TEST_CHECK("20060816000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x6_v, y6_v); - TEST_CHECK("20060816000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x7_v, y7_v); - TEST_CHECK("20060816000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x8_v, y8_v); - TEST_CHECK("20060816000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)islessgreaterf4(x9_v, y9_v); - TEST_CHECK("20060816000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isnand2.c b/Extras/simdmathlibrary/spu/tests/isnand2.c deleted file mode 100644 index 9d42a7da7..000000000 --- a/Extras/simdmathlibrary/spu/tests/isnand2.c +++ /dev/null @@ -1,226 +0,0 @@ -/* Test isnand2 for SPU - 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. - */ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "isnand2"); - - // -QNan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0xffffffffffffffffull; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0x0000000000000000ull; - - // -QNaN - double x3 = hide_double(make_double(0xFFFFFFFFFFFFFFFFull)); - unsigned long long r3 = 0xffffffffffffffffull; - - // -SNaN - double x4 = hide_double(make_double(0xFFF7FFFFFFFFFFFFull)); - unsigned long long r4 = 0xffffffffffffffffull; - - // -Denorm - double x5 = hide_double(-2.40e-310); - unsigned long long r5 = 0x0000000000000000ull; - - // -Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0x0000000000000000ull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0x0000000000000000ull; - - // +Inf - double x9 = hide_double( 1.0e999); - unsigned long long r9 = 0x0000000000000000ull; - - // +QNaN - double x10 = hide_double(make_double(0x7FFFFFFFFFFFFFFFull)); - unsigned long long r10 = 0xffffffffffffffffull; - - // +Dmin - double x11 = hide_double( DBL_MIN); - unsigned long long r11 = 0x0000000000000000ull; - - // +Norm - double x12 = hide_double(3.14152634); - unsigned long long r12 = 0x0000000000000000ull; - - // +SNaN - double x13 = hide_double(make_double(0x7FF3333333333333ull)); - unsigned long long r13 = 0xffffffffffffffffull; - - // +Inf - double x14 = hide_double(HUGE_VAL); - unsigned long long r14 = 0x0000000000000000ull; - - //+Nan - double x15 = hide_double( nan("")); - unsigned long long r15 = 0xffffffffffffffffull; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0xFFF7000000000000ull), -1.0e-999 }; - vec_ullong2 r16_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_ullong2 r17_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_ullong2 r18_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - // Compound - vec_double2 x19_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_ullong2 r19_v = (vec_ullong2) {0x0000000000000000ull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x20_v = (vec_double2) { make_double(0x7FF8000000000000ull), -HUGE_VAL} ; - vec_ullong2 r20_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("isnand2"); - - res_v = (vec_ullong2)isnand2(x0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isnand2(x1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isnand2(x2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isnand2(x3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isnand2(x4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isnand2(x5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isnand2(x6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isnand2(x7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isnand2(x8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isnand2(x9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isnand2(x10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isnand2(x11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isnand2(x12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isnand2(x13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isnand2(x14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isnand2(x15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isnand2(x16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isnand2(x17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isnand2(x18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isnand2(x19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - res_v = (vec_ullong2)isnand2(x20_v); - TEST_CHECK("20060830000020AAN", allequal_ullong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isnanf4.c b/Extras/simdmathlibrary/spu/tests/isnanf4.c deleted file mode 100644 index c0c5572a5..000000000 --- a/Extras/simdmathlibrary/spu/tests/isnanf4.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Test isnanf4 for SPU - 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. - */ - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060822000000AAN","AAN", "isnanf4"); - - float x0 = hide_float(-0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float( 1e-999); // Smin - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isnanf4"); - - res_v = (vec_uint4)isnanf4(x0_v); - TEST_CHECK("20060822000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isnanf4(x1_v); - TEST_CHECK("20060822000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isnanf4(x2_v); - TEST_CHECK("20060822000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isnanf4(x3_v); - TEST_CHECK("20060822000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isnanf4(x4_v); - TEST_CHECK("20060822000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isnanf4(x5_v); - TEST_CHECK("20060822000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isnanf4(x6_v); - TEST_CHECK("20060822000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isnanf4(x7_v); - TEST_CHECK("20060822000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isnanf4(x8_v); - TEST_CHECK("20060822000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isnanf4(x9_v); - TEST_CHECK("20060822000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isnormald2.c b/Extras/simdmathlibrary/spu/tests/isnormald2.c deleted file mode 100644 index 7200dd5c9..000000000 --- a/Extras/simdmathlibrary/spu/tests/isnormald2.c +++ /dev/null @@ -1,225 +0,0 @@ -/* Test isnormald2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "isnormald2"); - - // -Nan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0x0000000000000000ull; - - // -Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - // -Dmax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - // -Norm - double x3 = hide_double(-824842.58421394); - unsigned long long r3 = 0xffffffffffffffffull; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - unsigned long long r4 = 0xffffffffffffffffull; - - // -Denorm - double x5 = hide_double(-2.40e-310); - unsigned long long r5 = 0x0000000000000000ull; - - // -Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0x0000000000000000ull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0x0000000000000000ull; - - // +Unf - double x9 = hide_double( 1.0e-999); - unsigned long long r9 = 0x0000000000000000ull; - - // +Denorm - double x10 = hide_double( 2.40e-310); - unsigned long long r10 = 0x0000000000000000ull; - - // +Dmin - double x11 = hide_double( DBL_MIN); - unsigned long long r11 = 0xffffffffffffffffull; - - // +Norm - double x12 = hide_double(3.14152634); - unsigned long long r12 = 0xffffffffffffffffull; - - // +Dmax - double x13 = hide_double(DBL_MAX); - unsigned long long r13 = 0xffffffffffffffffull; - - // +Inf - double x14 = hide_double(HUGE_VAL); - unsigned long long r14 = 0x0000000000000000ull; - - //+Nan - double x15 = hide_double( nan("")); - unsigned long long r15 = 0x0000000000000000ull; - - // Compound - vec_double2 x16_v = (vec_double2) {make_double(0x000AAAAAAAAAAAAAull), -1.0e-999 }; - vec_ullong2 r16_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x17_v = (vec_double2) { 345.27533, -2.40e-310 }; - vec_ullong2 r17_v = (vec_ullong2) {0xffffffffffffffffull, 0x0000000000000000ull}; - - // Compound - vec_double2 x18_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_ullong2 r18_v = (vec_ullong2) {0x0000000000000000ull, 0xffffffffffffffffull}; - - // Compound - vec_double2 x19_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_ullong2 r19_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - // Compound - vec_double2 x20_v = (vec_double2) { -1.0e-999, -HUGE_VAL}; - vec_ullong2 r20_v = (vec_ullong2) {0x0000000000000000ull, 0x0000000000000000ull}; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("isnormald2"); - - res_v = (vec_ullong2)isnormald2(x0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isnormald2(x1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isnormald2(x2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isnormald2(x3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isnormald2(x4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isnormald2(x5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isnormald2(x6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isnormald2(x7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isnormald2(x8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isnormald2(x9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isnormald2(x10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isnormald2(x11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isnormald2(x12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isnormald2(x13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isnormald2(x14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isnormald2(x15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isnormald2(x16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isnormald2(x17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isnormald2(x18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isnormald2(x19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - res_v = (vec_ullong2)isnormald2(x20_v); - TEST_CHECK("20060830000020AAN", allequal_ullong2( res_v, r20_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isnormalf4.c b/Extras/simdmathlibrary/spu/tests/isnormalf4.c deleted file mode 100644 index 30cde0933..000000000 --- a/Extras/simdmathlibrary/spu/tests/isnormalf4.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Test isnormalf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060822000000AAN","AAN", "isnormalf4"); - - float x0 = hide_float(-0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0xffffffff; - - float x2 = hide_float( 0.0f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - float x4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(876543.12345f); - unsigned int r5 = 0xffffffff; - - float x6 = hide_float(1e-999); // Smin - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - unsigned int r7 = 0xffffffff; - - float x8 = hide_float(2353705.31415f); - unsigned int r8 = 0xffffffff; - - float x9 = hide_float(FLT_MAX); // Smax - unsigned int r9 = 0xffffffff; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isnormalf4"); - - res_v = (vec_uint4)isnormalf4(x0_v); - TEST_CHECK("20060822000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isnormalf4(x1_v); - TEST_CHECK("20060822000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isnormalf4(x2_v); - TEST_CHECK("20060822000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isnormalf4(x3_v); - TEST_CHECK("20060822000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isnormalf4(x4_v); - TEST_CHECK("20060822000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isnormalf4(x5_v); - TEST_CHECK("20060822000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isnormalf4(x6_v); - TEST_CHECK("20060822000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isnormalf4(x7_v); - TEST_CHECK("20060822000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isnormalf4(x8_v); - TEST_CHECK("20060822000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isnormalf4(x9_v); - TEST_CHECK("20060822000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isunorderedd2.c b/Extras/simdmathlibrary/spu/tests/isunorderedd2.c deleted file mode 100644 index 4f562b35c..000000000 --- a/Extras/simdmathlibrary/spu/tests/isunorderedd2.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Test isunorderedd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060830000000AAN","AAN", "isunorderedd2"); - - //-QNaN, Norm - double x0 = hide_double(-nan("")); - double y0 = hide_double(1.0); - unsigned long long r0 = 0xffffffffffffffffull; - - //+Inf, -Inf - double x1 = hide_double( HUGE_VAL); - double y1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0x0000000000000000ull; - - //-Inf, -QNaN - double x2 = hide_double(-HUGE_VAL); - double y2 = hide_double(make_double(0xFFFFFFFFFFFFFFFFull)); - unsigned long long r2 = 0xffffffffffffffffull; - - //-Norm, -SNaN - double x3 = hide_double(-67418234.34256245); - double y3 = hide_double(make_double(0xFFF7FFFFFFFFFFFFull)); - unsigned long long r3 = 0xffffffffffffffffull; - - //-Norm, -Denorm - double x4 = hide_double(-273453.3234458053); - double y4 = hide_double(-3.0e-321); - unsigned long long r4 = 0x0000000000000000ull; - - //-Norm, -Inf - double x5 = hide_double(-168.97345223013); - double y5 = hide_double(-HUGE_VAL); - unsigned long long r5 = 0x0000000000000000ull; - - //-QNaN, -Norm - double x6 = hide_double(-nan("")); - double y6 = hide_double(-21345853556.492); - unsigned long long r6 = 0xffffffffffffffffull; - - //-Norm, -0 - double x7 = hide_double(-168.97345223013); - double y7 = hide_double(-0.0); - unsigned long long r7 = 0x0000000000000000ull; - - //-Unf, -Norm - double x8 = hide_double(-1.0e-999); - double y8 = hide_double(-83532.96153153); - unsigned long long r8 = 0x0000000000000000ull; - - //-Unf, 0 - double x9 = hide_double(-1.0e-999); - double y9 = hide_double(0.0); - unsigned long long r9 = 0x0000000000000000ull; - - //QNaN, 0 - double x10 = hide_double(make_double(0x7FFFFFFFFFFFFFFFull)); - double y10 = hide_double( 0.0); - unsigned long long r10 = 0xffffffffffffffffull; - - //+Unf, +QNaN - double x11 = hide_double( 1.0e-999); - double y11 = hide_double( nan("")); - unsigned long long r11 = 0xffffffffffffffffull; - - //+Unf, +Norm - double x12 = hide_double( 1e-999); - double y12 = hide_double(0.0031529324); - unsigned long long r12 = 0x0000000000000000ull; - - //+Norm, +Denorm - double x13 = hide_double(5172.2845321); - double y13 = hide_double(3.0e-321); - unsigned long long r13 = 0x0000000000000000ull; - - //+SNaN, +Norm - double x14 = hide_double(make_double(0x7FF3333333333333ull)); - double y14 = hide_double(5172.2845321); - unsigned long long r14 = 0xffffffffffffffffull; - - //+Norm, +QNaN - double x15 = hide_double(264.345643345); - double y15 = hide_double(make_double(0x7FFAAAAAAAAAAAAAull)); - unsigned long long r15 = 0xffffffffffffffffull; - - //+Norm, -Norm - double x16 = hide_double( 926.605118542); - double y16 = hide_double(-9.43574552184); - unsigned long long r16 = 0x0000000000000000ull; - - //+Norm, +Dmax - double x17 = hide_double( 926.605118542); - double y17 = hide_double(DBL_MAX); - unsigned long long r17 = 0x0000000000000000ull; - - //+Inf, +Ovf - double x18 = hide_double( HUGE_VAL); - double y18 = hide_double( 1.0e999); - unsigned long long r18 = 0x0000000000000000ull; - - //+Inf, +QNaN - double x19 = hide_double( HUGE_VAL); - double y19 = hide_double(nan("")); - unsigned long long r19 = 0xffffffffffffffffull; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 y0_v = spu_splats(y0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 y1_v = spu_splats(y1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 y2_v = spu_splats(y2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 y3_v = spu_splats(y3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 y4_v = spu_splats(y4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 y5_v = spu_splats(y5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 y6_v = spu_splats(y6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 y7_v = spu_splats(y7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 y8_v = spu_splats(y8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 y9_v = spu_splats(y9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 y10_v = spu_splats(y10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 y11_v = spu_splats(y11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 y12_v = spu_splats(y12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 y13_v = spu_splats(y13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 y14_v = spu_splats(y14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 y15_v = spu_splats(y15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 y16_v = spu_splats(y16); - vec_ullong2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 y17_v = spu_splats(y17); - vec_ullong2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 y18_v = spu_splats(y18); - vec_ullong2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 y19_v = spu_splats(y19); - vec_ullong2 r19_v = spu_splats(r19); - - vec_ullong2 res_v; - - TEST_START("isunorderedd2"); - - res_v = (vec_ullong2)isunorderedd2(x0_v, y0_v); - TEST_CHECK("20060830000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x1_v, y1_v); - TEST_CHECK("20060830000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x2_v, y2_v); - TEST_CHECK("20060830000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x3_v, y3_v); - TEST_CHECK("20060830000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x4_v, y4_v); - TEST_CHECK("20060830000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x5_v, y5_v); - TEST_CHECK("20060830000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x6_v, y6_v); - TEST_CHECK("20060830000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x7_v, y7_v); - TEST_CHECK("20060830000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x8_v, y8_v); - TEST_CHECK("20060830000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x9_v, y9_v); - TEST_CHECK("20060830000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x10_v, y10_v); - TEST_CHECK("20060830000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x11_v, y11_v); - TEST_CHECK("20060830000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x12_v, y12_v); - TEST_CHECK("20060830000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x13_v, y13_v); - TEST_CHECK("20060830000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x14_v, y14_v); - TEST_CHECK("20060830000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x15_v, y15_v); - TEST_CHECK("20060830000015AAN", allequal_ullong2( res_v, r15_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x16_v, y16_v); - TEST_CHECK("20060830000016AAN", allequal_ullong2( res_v, r16_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x17_v, y17_v); - TEST_CHECK("20060830000017AAN", allequal_ullong2( res_v, r17_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x18_v, y18_v); - TEST_CHECK("20060830000018AAN", allequal_ullong2( res_v, r18_v ), 0); - res_v = (vec_ullong2)isunorderedd2(x19_v, y19_v); - TEST_CHECK("20060830000019AAN", allequal_ullong2( res_v, r19_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/isunorderedf4.c b/Extras/simdmathlibrary/spu/tests/isunorderedf4.c deleted file mode 100644 index d26a6c8d9..000000000 --- a/Extras/simdmathlibrary/spu/tests/isunorderedf4.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test isunorderedf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060822000000AAN","AAN", "isunorderedf4"); - - float x0 = hide_float(-0.0f); - float y0 = hide_float( 0.0f); - unsigned int r0 = 0x00000000; - - float x1 = hide_float( FLT_MAX); //+Smax - float y1 = hide_float(-FLT_MAX); //-Smax - unsigned int r1 = 0x00000000; - - float x2 = hide_float(-0.0000000013152f); - float y2 = hide_float(-234245.85323441f); - unsigned int r2 = 0x00000000; - - float x3 = hide_float(-168.97345223013f); - float y3 = hide_float(-168.97345223013f); - unsigned int r3 = 0x00000000; - - float x4 = hide_float(-83532.96153153f); - float y4 = hide_float(-1e-999); //-Smin - unsigned int r4 = 0x00000000; - - float x5 = hide_float(-321.01234567f); - float y5 = hide_float(876543.12345f); - unsigned int r5 = 0x00000000; - - float x6 = hide_float( 1e-999); // Smin - float y6 = hide_float(0.0031529324f); - unsigned int r6 = 0x00000000; - - float x7 = hide_float(5172.2845321f); - float y7 = hide_float(5172.2845321f); - unsigned int r7 = 0x00000000; - - float x8 = hide_float(264.345643345f); - float y8 = hide_float(2353705.31415f); - unsigned int r8 = 0x00000000; - - float x9 = hide_float(FLT_MAX); // Smax - float y9 = hide_float(9.43574552184f); - unsigned int r9 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 y0_v = spu_splats(y0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 y1_v = spu_splats(y1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 y2_v = spu_splats(y2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 y3_v = spu_splats(y3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 y4_v = spu_splats(y4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 y5_v = spu_splats(y5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 y6_v = spu_splats(y6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 y7_v = spu_splats(y7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 y8_v = spu_splats(y8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 y9_v = spu_splats(y9); - vec_uint4 r9_v = spu_splats(r9); - - vec_uint4 res_v; - - TEST_START("isunorderedf4"); - - res_v = (vec_uint4)isunorderedf4(x0_v, y0_v); - TEST_CHECK("20060822000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)isunorderedf4(x1_v, y1_v); - TEST_CHECK("20060822000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)isunorderedf4(x2_v, y2_v); - TEST_CHECK("20060822000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)isunorderedf4(x3_v, y3_v); - TEST_CHECK("20060822000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)isunorderedf4(x4_v, y4_v); - TEST_CHECK("20060822000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)isunorderedf4(x5_v, y5_v); - TEST_CHECK("20060822000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)isunorderedf4(x6_v, y6_v); - TEST_CHECK("20060822000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)isunorderedf4(x7_v, y7_v); - TEST_CHECK("20060822000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)isunorderedf4(x8_v, y8_v); - TEST_CHECK("20060822000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)isunorderedf4(x9_v, y9_v); - TEST_CHECK("20060822000009AAN", allequal_uint4( res_v, r9_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/ldexpd2.c b/Extras/simdmathlibrary/spu/tests/ldexpd2.c deleted file mode 100644 index bb959829d..000000000 --- a/Extras/simdmathlibrary/spu/tests/ldexpd2.c +++ /dev/null @@ -1,250 +0,0 @@ -/* Test ldexpd2 for SPU - 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. - */ -/** - * - *@@ ldexpd2 - Multiply Double by 2 Raised to its Power - * For large elements of ex (overflow), returns HUGE_VALF - * For small elements of ex (underflow), returns 0. - * - *@brief - * boundary test for ldexpd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#undef LDEXPD2_ROUND - - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int exp[2]; - unsigned long long int ans0[2]; - unsigned long long int ans1[2]; - unsigned long long int ans2[2]; - unsigned long long int ans3[2]; -} TestVec64_Ldexp; - -int main() -{ - TestVec64_Ldexp test_a[] = { - { - // zero - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000400ULL,0xFFFFFFFFFFFFFC00ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // MIN , MAX - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL} - },{ -#ifdef LDEXPD2_ROUND - // denotmalized - {0x8000000000000003ULL,0x0000000000000003ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x8000000000000002ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000002ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000002ULL,0x0000000000000002ULL} - },{ - // denotmalized -54 - {0x0010000000000001ULL,0x8010000000000001ULL}, - {0xFFFFFFFFFFFFFFCAULL,0xFFFFFFFFFFFFFFCAULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFFFFFFF7CEULL,0xFFFFFFFFFFFFF7CEULL}, - {0x0000000000000001ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000001ULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFFFFFFF7CDULL,0xFFFFFFFFFFFFF7CDULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ -#else // LDEXPD2_ROUND - // denotmalized - {0x8000000000000003ULL,0x0000000000000003ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL} - },{ - -#endif // LDEXPD2_ROUND - // denotmalized - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL} - },{ - // denotmalized - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL} - },{ - // 1.0 - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x00000000000003ffULL,0x00000000000003ffULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL} - },{ - // 1.0 -> max - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x0000000000000400ULL,0x0000000000000400ULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFF00000000ULL,0xFFFFFFFF00000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // min-> - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - },{ - // NaN , -NaN - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060905160000NM","NM", "ldexpd2"); - - TEST_START("ldexpd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - spu_mtfpscr(((vec_uint4){0x0100,0,0,0})); - res_v = ldexpd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090516%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans0[0])), 0); - -#ifdef LDEXPD2_ROUND - - spu_mtfpscr(((vec_uint4){0x0600,0,0,0})); - res_v = ldexpd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090516%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans1[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0b00,0,0,0})); - res_v = ldexpd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090516%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans2[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0c00,0,0,0})); - res_v = ldexpd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090516%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans3[0])), 0); -#endif // LDEXPD2_ROUND - - } - - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/llabsi2.c b/Extras/simdmathlibrary/spu/tests/llabsi2.c deleted file mode 100644 index 3b08ab15f..000000000 --- a/Extras/simdmathlibrary/spu/tests/llabsi2.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Test llabsi2 for SPU - 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. - */ -/** - * - *@@ llabsi2 - returns absolute value of input. - * - *@brief - * boundary test for llabsi2. - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - - -#include -#include -#include -//#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20060831134500NM","NM", "llabsi2"); - - vec_llong2 x0_v = ((vec_llong2){ 0, 0}); - vec_llong2 r0_v = ((vec_llong2){ 0, 0}); - - vec_llong2 x1_v = ((vec_llong2){-1, 1}); - vec_llong2 r1_v = ((vec_llong2){ 1, 1}); - - vec_llong2 x2_v = ((vec_llong2){ 1,-1}); - vec_llong2 r2_v = ((vec_llong2){ 1, 1}); - // 0x7FFFFFFFFFFFFFFF - vec_llong2 x3_v = ((vec_llong2){ 9223372036854775807LL,-9223372036854775807LL}); - vec_llong2 r3_v = ((vec_llong2){ 9223372036854775807LL, 9223372036854775807LL}); - // 0x8000000000000000 - vec_llong2 x4_v = ((vec_llong2){0x8000000000000000LL,0x8000000000000000LL}); - vec_llong2 r4_v = ((vec_llong2){0x8000000000000000LL,0x8000000000000000LL}); - - vec_llong2 res_v; - - TEST_START("llabsi2"); - res_v = llabsi2 (x0_v); - TEST_CHECK("20060831134501NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llabsi2 (x1_v); - TEST_CHECK("20060831134502NM", allequal_llong2( res_v, r1_v ), 0); - res_v = llabsi2 (x2_v); - TEST_CHECK("20060831134503NM", allequal_llong2( res_v, r2_v ), 0); - res_v = llabsi2 (x3_v); - TEST_CHECK("20060831134504NM", allequal_llong2( res_v, r3_v ), 0); - res_v = llabsi2 (x4_v); - TEST_CHECK("20060831134505NM", allequal_llong2( res_v, r4_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/lldivi2.c b/Extras/simdmathlibrary/spu/tests/lldivi2.c deleted file mode 100644 index 2c0b9e32b..000000000 --- a/Extras/simdmathlibrary/spu/tests/lldivi2.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Test lldivi2 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060908152000MH","MH", "lldivi2"); - - signed long long x0n = 0x0c0e84c75f216c43ll; - signed long long x0d = 0x00000000000abcdell; - signed long long x0q = 0x0000011f71fb04cbll; - signed long long x0r = 0x0000000000003039ll; - signed long long x1n = 0x0c0e84c75f216c43ll; - signed long long x1d = 0x0000011f71fb04cbll; - signed long long x1q = 0x00000000000abcdell; - signed long long x1r = 0x0000000000003039ll; - - signed long long x2n = 0x08e732f9d4baf903ll; - signed long long x2d = 0x0000000000976bb6ll; - signed long long x2q = 0x0000000f0d55f4d9ll; - signed long long x2r = 0x00000000004933bdll; - signed long long x3n = 0x08e732f9d4baf903ll; - signed long long x3d = 0x0000000f0d55f4d9ll; - signed long long x3q = 0x0000000000976bb6ll; - signed long long x3r = 0x00000000004933bdll; - - signed long long x4n = 0xffffffffffffffffll; - signed long long x4d = 0xfffffffffffffffell; - signed long long x4q = 0x0000000000000000ll; - signed long long x4r = 0xffffffffffffffffll; - signed long long x5n = 0xffffffffffffffffll; - signed long long x5d = 0x0000000000000001ll; - signed long long x5q = 0xffffffffffffffffll; - signed long long x5r = 0x0000000000000000ll; - - signed long long x6n = 0xffffffffffffffffll; - signed long long x6d = 0x0000000000000002ll; - signed long long x6q = 0x0000000000000000ll; - signed long long x6r = 0xffffffffffffffffll; - signed long long x7n = 0xffffffffffffffffll; - signed long long x7d = 0x7fffffffffffffffll; - signed long long x7q = 0x0000000000000000ll; - signed long long x7r = 0xffffffffffffffffll; - - signed long long x8n = 0xf8c0d45d0ff344f0ll; - signed long long x8d = 0x000019aa3e41e0bdll; - signed long long x8q = 0xffffffffffffb7b8ll; - signed long long x8r = 0xffffedc119afa218ll; - signed long long x9n = 0xf8c0d45d0ff344f0ll; - signed long long x9d = 0x000000000009b13bll; - signed long long x9q = 0xffffff4097efb39ell; - signed long long x9r = 0xfffffffffff6a186ll; - - vec_llong2 x0n_v = (vec_llong2){ x0n, x1n }; - vec_llong2 x0d_v = (vec_llong2){ x0d, x1d }; - vec_llong2 x0q_v = (vec_llong2){ x0q, x1q }; - vec_llong2 x0r_v = (vec_llong2){ x0r, x1r }; - vec_llong2 x1n_v = (vec_llong2){ x2n, x3n }; - vec_llong2 x1d_v = (vec_llong2){ x2d, x3d }; - vec_llong2 x1q_v = (vec_llong2){ x2q, x3q }; - vec_llong2 x1r_v = (vec_llong2){ x2r, x3r }; - vec_llong2 x2n_v = (vec_llong2){ x4n, x5n }; - vec_llong2 x2d_v = (vec_llong2){ x4d, x5d }; - vec_llong2 x2q_v = (vec_llong2){ x4q, x5q }; - vec_llong2 x2r_v = (vec_llong2){ x4r, x5r }; - vec_llong2 x3n_v = (vec_llong2){ x6n, x7n }; - vec_llong2 x3d_v = (vec_llong2){ x6d, x7d }; - vec_llong2 x3q_v = (vec_llong2){ x6q, x7q }; - vec_llong2 x3r_v = (vec_llong2){ x6r, x7r }; - vec_llong2 x4n_v = (vec_llong2){ x8n, x9n }; - vec_llong2 x4d_v = (vec_llong2){ x8d, x9d }; - vec_llong2 x4q_v = (vec_llong2){ x8q, x9q }; - vec_llong2 x4r_v = (vec_llong2){ x8r, x9r }; - - lldivi2_t res; - - TEST_START("lldivi2"); - res = lldivi2(x0n_v, x0d_v); - TEST_CHECK("20060908152001MH", allequal_llong2( res.quot, x0q_v ) && allequal_llong2( res.rem, x0r_v ), 0); - res = lldivi2(x1n_v, x1d_v); - TEST_CHECK("20060908152002MH", allequal_llong2( res.quot, x1q_v ) && allequal_llong2( res.rem, x1r_v ), 0); - res = lldivi2(x2n_v, x2d_v); - TEST_CHECK("20060908152003MH", allequal_llong2( res.quot, x2q_v ) && allequal_llong2( res.rem, x2r_v ), 0); - res = lldivi2(x3n_v, x3d_v); - TEST_CHECK("20060908152004MH", allequal_llong2( res.quot, x3q_v ) && allequal_llong2( res.rem, x3r_v ), 0); - res = lldivi2(x4n_v, x4d_v); - TEST_CHECK("20060908152005MH", allequal_llong2( res.quot, x4q_v ) && allequal_llong2( res.rem, x4r_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/lldivu2.c b/Extras/simdmathlibrary/spu/tests/lldivu2.c deleted file mode 100644 index 813b2d260..000000000 --- a/Extras/simdmathlibrary/spu/tests/lldivu2.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Test lldivu2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060904200000MH","MH", "lldivu2"); - - unsigned long long x0n = 0x0c0e84c75f216c43ull; - unsigned long long x0d = 0x00000000000abcdeull; - unsigned long long x0q = 0x0000011f71fb04cbull; - unsigned long long x0r = 0x0000000000003039ull; - unsigned long long x1n = 0x0c0e84c75f216c43ull; - unsigned long long x1d = 0x0000011f71fb04cbull; - unsigned long long x1q = 0x00000000000abcdeull; - unsigned long long x1r = 0x0000000000003039ull; - - unsigned long long x2n = 0x08e732f9d4baf903ull; - unsigned long long x2d = 0x0000000000976bb6ull; - unsigned long long x2q = 0x0000000f0d55f4d9ull; - unsigned long long x2r = 0x00000000004933bdull; - unsigned long long x3n = 0x08e732f9d4baf903ull; - unsigned long long x3d = 0x0000000f0d55f4d9ull; - unsigned long long x3q = 0x0000000000976bb6ull; - unsigned long long x3r = 0x00000000004933bdull; - - unsigned long long x4n = 0xffffffffffffffffull; - unsigned long long x4d = 0xfffffffffffffffeull; - unsigned long long x4q = 0x0000000000000001ull; - unsigned long long x4r = 0x0000000000000001ull; - unsigned long long x5n = 0xffffffffffffffffull; - unsigned long long x5d = 0x0000000000000001ull; - unsigned long long x5q = 0xffffffffffffffffull; - unsigned long long x5r = 0x0000000000000000ull; - - unsigned long long x6n = 0xffffffffffffffffull; - unsigned long long x6d = 0x0000000000000002ull; - unsigned long long x6q = 0x7fffffffffffffffull; - unsigned long long x6r = 0x0000000000000001ull; - unsigned long long x7n = 0xffffffffffffffffull; - unsigned long long x7d = 0x7fffffffffffffffull; - unsigned long long x7q = 0x0000000000000002ull; - unsigned long long x7r = 0x0000000000000001ull; - - unsigned long long x8n = 0xf8c0d45d0ff344f0ull; - unsigned long long x8d = 0x000019aa3e41e0bdull; - unsigned long long x8q = 0x000000000009b13bull; - unsigned long long x8r = 0x000004c443bccc61ull; - unsigned long long x9n = 0xf8c0d45d0ff344f0ull; - unsigned long long x9d = 0x000000000009b13bull; - unsigned long long x9q = 0x000019aa3ebfc739ull; - unsigned long long x9r = 0x000000000000f1cdull; - - vec_ullong2 x0n_v = (vec_ullong2){ x0n, x1n }; - vec_ullong2 x0d_v = (vec_ullong2){ x0d, x1d }; - vec_ullong2 x0q_v = (vec_ullong2){ x0q, x1q }; - vec_ullong2 x0r_v = (vec_ullong2){ x0r, x1r }; - vec_ullong2 x1n_v = (vec_ullong2){ x2n, x3n }; - vec_ullong2 x1d_v = (vec_ullong2){ x2d, x3d }; - vec_ullong2 x1q_v = (vec_ullong2){ x2q, x3q }; - vec_ullong2 x1r_v = (vec_ullong2){ x2r, x3r }; - vec_ullong2 x2n_v = (vec_ullong2){ x4n, x5n }; - vec_ullong2 x2d_v = (vec_ullong2){ x4d, x5d }; - vec_ullong2 x2q_v = (vec_ullong2){ x4q, x5q }; - vec_ullong2 x2r_v = (vec_ullong2){ x4r, x5r }; - vec_ullong2 x3n_v = (vec_ullong2){ x6n, x7n }; - vec_ullong2 x3d_v = (vec_ullong2){ x6d, x7d }; - vec_ullong2 x3q_v = (vec_ullong2){ x6q, x7q }; - vec_ullong2 x3r_v = (vec_ullong2){ x6r, x7r }; - vec_ullong2 x4n_v = (vec_ullong2){ x8n, x9n }; - vec_ullong2 x4d_v = (vec_ullong2){ x8d, x9d }; - vec_ullong2 x4q_v = (vec_ullong2){ x8q, x9q }; - vec_ullong2 x4r_v = (vec_ullong2){ x8r, x9r }; - - lldivu2_t res; - - TEST_START("lldivu2"); - res = lldivu2(x0n_v, x0d_v); - TEST_CHECK("20060904200001MH", allequal_ullong2( res.quot, x0q_v ) && allequal_ullong2( res.rem, x0r_v ), 0); - res = lldivu2(x1n_v, x1d_v); - TEST_CHECK("20060904200002MH", allequal_ullong2( res.quot, x1q_v ) && allequal_ullong2( res.rem, x1r_v ), 0); - res = lldivu2(x2n_v, x2d_v); - TEST_CHECK("20060904200003MH", allequal_ullong2( res.quot, x2q_v ) && allequal_ullong2( res.rem, x2r_v ), 0); - res = lldivu2(x3n_v, x3d_v); - TEST_CHECK("20060904200004MH", allequal_ullong2( res.quot, x3q_v ) && allequal_ullong2( res.rem, x3r_v ), 0); - res = lldivu2(x4n_v, x4d_v); - TEST_CHECK("20060904200005MH", allequal_ullong2( res.quot, x4q_v ) && allequal_ullong2( res.rem, x4r_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/llrintd2.c b/Extras/simdmathlibrary/spu/tests/llrintd2.c deleted file mode 100644 index 449bb4cb3..000000000 --- a/Extras/simdmathlibrary/spu/tests/llrintd2.c +++ /dev/null @@ -1,215 +0,0 @@ -/* Test llrintd2 for SPU - 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. - */ -/** - * - *@@ llrintd2 - rounds two doubles in to two nearest 64bit integer. - * - *@brief - * boundary test for llrintd2. - * consistent with the current rounding mode. - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - **/ - - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - typedef union { - unsigned long long int ll; - double x; - } SrcType64; - SrcType64 tmp64; - TEST_SET_START("20060921101000NM","NM", "llrintd2"); - -// unsigned long long i11 = 0x7FFFFFFFFFFFFDFFull; //limit -// unsigned long long i12 = 0xFFFFFFFFFFFFFDFFull; //limit - -// double x0 = hide_double(-HUGE_VAL); // -Inf -// double x1 = hide_double(HUGE_VAL); // Inf - double x2 = hide_double(0.0); // +0 - double x3 = hide_double(-0.0); // -0 -// double x4 = hide_double(nan("")); // NaN -> NaN - double x5 = hide_double( 0.5); - double x6 = hide_double(-0.5); - double x7 = hide_double( 0.4999999999999999); // 0 - double x8 = hide_double(-0.4999999999999999); // 0 - double x9 = hide_double( 999999999999999.5); // 1000000000000000 - double x10 = hide_double(-999999999999999.5); //-1000000000000000 -// double x11 = hide_double(make_double(i11)); // 9223372036854774784 -// double x12 = hide_double(make_double(i12)); //-9223372036854774784 - double x11 = hide_double(9223372036854774784ll); // 9223372036854774784 - double x12 = hide_double(-9223372036854774784ll); //-9223372036854774784 - double x13 = DBL_MIN; - double x14 = (0.0 - DBL_MIN); - - double x15 = hide_double( 0.5000000000000001); - double x16 = hide_double(-0.000001); - - tmp64.ll = 0x3FEFFFFFFFFFFFFFULL; - double x17 = tmp64.x; - tmp64.ll = 0xC32FFFFFFFFFFFFFULL; - double x18 = tmp64.x; - - vec_double2 x0_v = ((vec_double2){x2, x3}); //+0,-0 - vec_llong2 r0_v = ((vec_llong2){0,0}); // 0, 0 - vec_double2 x1_v = ((vec_double2){x5, x8}); //+0.5,-0.4999999999999999 - vec_llong2 r10_v = ((vec_llong2){0,0}); - vec_llong2 r11_v = ((vec_llong2){0,0}); - vec_llong2 r12_v = ((vec_llong2){1,0}); - vec_llong2 r13_v = ((vec_llong2){0,-1}); - vec_double2 x2_v = ((vec_double2){x7, x6}); //+0.4999999999999999, -0.5 - vec_llong2 r20_v = ((vec_llong2){0,0}); - vec_llong2 r21_v = ((vec_llong2){0,0}); - vec_llong2 r22_v = ((vec_llong2){1,0}); - vec_llong2 r23_v = ((vec_llong2){0,-1}); - vec_double2 x3_v = ((vec_double2){x10, x11}); //-999999999999999.5, 9223372036854774784 - vec_llong2 r30_v = ((vec_llong2){-1000000000000000ll,9223372036854774784ll}); - vec_llong2 r31_v = ((vec_llong2){-999999999999999ll, 9223372036854774784ll}); - vec_llong2 r32_v = ((vec_llong2){-999999999999999ll, 9223372036854774784ll}); - vec_llong2 r33_v = ((vec_llong2){-1000000000000000ll,9223372036854774784ll}); - vec_double2 x4_v = ((vec_double2){x12, x9}); //-9223372036854774784, 999999999999999.5 - vec_llong2 r40_v = ((vec_llong2){-9223372036854774784ll,1000000000000000ll}); - vec_llong2 r41_v = ((vec_llong2){-9223372036854774784ll,999999999999999ll}); - vec_llong2 r42_v = ((vec_llong2){-9223372036854774784ll,1000000000000000ll}); - vec_llong2 r43_v = ((vec_llong2){-9223372036854774784ll,999999999999999ll}); - vec_double2 x5_v = ((vec_double2){x13, x14}); - vec_llong2 r50_v = ((vec_llong2){0,0}); - vec_llong2 r51_v = ((vec_llong2){0,0}); - vec_llong2 r52_v = ((vec_llong2){1,0}); - vec_llong2 r53_v = ((vec_llong2){0,-1}); - vec_double2 x6_v = ((vec_double2){x15, x16}); - vec_llong2 r60_v = ((vec_llong2){1,0}); - vec_llong2 r61_v = ((vec_llong2){0,0}); - vec_llong2 r62_v = ((vec_llong2){1,0}); - vec_llong2 r63_v = ((vec_llong2){0,-1}); - - vec_double2 x7_v = ((vec_double2){x17, x18}); - vec_llong2 r70_v = ((vec_llong2){1,-4503599627370496LL}); - vec_llong2 r71_v = ((vec_llong2){0,-4503599627370495LL}); - vec_llong2 r72_v = ((vec_llong2){1,-4503599627370495LL}); - vec_llong2 r73_v = ((vec_llong2){0,-4503599627370496LL}); - - vec_llong2 res_v; - - TEST_START("llrintd2"); - - spu_mtfpscr(((vec_uint4){0x0000,0,0,0})); //change FP mode - res_v = llrintd2 (x0_v); - TEST_CHECK("20060921101001NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llrintd2 (x1_v); - TEST_CHECK("20060921101002NM", allequal_llong2( res_v, r10_v ), 0); - res_v = llrintd2 (x2_v); - TEST_CHECK("20060921101003NM", allequal_llong2( res_v, r20_v ), 0); - res_v = llrintd2 (x3_v); - TEST_CHECK("20060921101004NM", allequal_llong2( res_v, r30_v ), 0); - res_v = llrintd2 (x4_v); - TEST_CHECK("20060921101005NM", allequal_llong2( res_v, r40_v ), 0); - res_v = llrintd2 (x5_v); - TEST_CHECK("20060921101006NM", allequal_llong2( res_v, r50_v ), 0); - res_v = llrintd2 (x6_v); - TEST_CHECK("20060921101007NM", allequal_llong2( res_v, r60_v ), 0); - res_v = llrintd2 (x7_v); - TEST_CHECK("20060921101017NM", allequal_llong2( res_v, r70_v ), 0); - - spu_mtfpscr(((vec_uint4){0x0500,0,0,0})); //change FP mode - res_v = llrintd2 (x0_v); - TEST_CHECK("20060921101008NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llrintd2 (x1_v); - TEST_CHECK("20060921101009NM", allequal_llong2( res_v, r11_v ), 0); - res_v = llrintd2 (x2_v); - TEST_CHECK("20060921101010NM", allequal_llong2( res_v, r21_v ), 0); - res_v = llrintd2 (x3_v); - TEST_CHECK("20060921101011NM", allequal_llong2( res_v, r31_v ), 0); - res_v = llrintd2 (x4_v); - TEST_CHECK("20060921101012NM", allequal_llong2( res_v, r41_v ), 0); - res_v = llrintd2 (x5_v); - TEST_CHECK("20060921101013NM", allequal_llong2( res_v, r51_v ), 0); - res_v = llrintd2 (x6_v); - TEST_CHECK("20060921101014NM", allequal_llong2( res_v, r61_v ), 0); - res_v = llrintd2 (x7_v); - TEST_CHECK("20060921101027NM", allequal_llong2( res_v, r71_v ), 0); - - spu_mtfpscr(((vec_uint4){0x0a00,0,0,0})); //change FP mode - res_v = llrintd2 (x0_v); - TEST_CHECK("20060921101015NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llrintd2 (x1_v); - TEST_CHECK("20060921101016NM", allequal_llong2( res_v, r12_v ), 0); - res_v = llrintd2 (x2_v); - TEST_CHECK("20060921101017NM", allequal_llong2( res_v, r22_v ), 0); - res_v = llrintd2 (x3_v); - TEST_CHECK("20060921101018NM", allequal_llong2( res_v, r32_v ), 0); - res_v = llrintd2 (x4_v); - TEST_CHECK("20060921101019NM", allequal_llong2( res_v, r42_v ), 0); - res_v = llrintd2 (x5_v); - TEST_CHECK("20060921101020NM", allequal_llong2( res_v, r52_v ), 0); - res_v = llrintd2 (x6_v); - TEST_CHECK("20060921101021NM", allequal_llong2( res_v, r62_v ), 0); - res_v = llrintd2 (x7_v); - TEST_CHECK("20060921101037NM", allequal_llong2( res_v, r72_v ), 0); - - spu_mtfpscr(((vec_uint4){0x0f00,0,0,0})); //change FP mode - res_v = llrintd2 (x0_v); - TEST_CHECK("20060921101022NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llrintd2 (x1_v); - TEST_CHECK("20060921101023NM", allequal_llong2( res_v, r13_v ), 0); - res_v = llrintd2 (x2_v); - TEST_CHECK("20060921101024NM", allequal_llong2( res_v, r23_v ), 0); - res_v = llrintd2 (x3_v); - TEST_CHECK("20060921101025NM", allequal_llong2( res_v, r33_v ), 0); - res_v = llrintd2 (x4_v); - TEST_CHECK("20060921101026NM", allequal_llong2( res_v, r43_v ), 0); - res_v = llrintd2 (x5_v); - TEST_CHECK("20060921101027NM", allequal_llong2( res_v, r53_v ), 0); - res_v = llrintd2 (x6_v); - TEST_CHECK("20060921101028NM", allequal_llong2( res_v, r63_v ), 0); - res_v = llrintd2 (x7_v); - TEST_CHECK("20060921101047NM", allequal_llong2( res_v, r73_v ), 0); - - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/llrintf4.c b/Extras/simdmathlibrary/spu/tests/llrintf4.c deleted file mode 100644 index 75b6777b6..000000000 --- a/Extras/simdmathlibrary/spu/tests/llrintf4.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Test llrintf4 for SPU - 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. - */ -/** - * - *@@ llrintf4 - rounds four floats in to four nearest 64bit integer. - * - *@brief - * boundary test for llrintf4. On SPU the rounding mode for floats is always towards 0. - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - **/ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -static inline llroundf4_t set_llrintf4_t(long long int in0, long long int in1, long long int in2, long long int in3) -{ - llroundf4_t res; - - res.vll[0] = ((vec_llong2){in0,in1}); - res.vll[1] = ((vec_llong2){in2,in3}); - - return res; -} -int main() -{ - TEST_SET_START("20060918101000NM","NM", "llrintf4"); - -// unsigned long i11 = 0x5efffffful; // 9223371487098961920 -// unsigned long i12 = 0xdefffffful; //-9223371487098961920 -// unsigned long i11 = 0x49fffffful; //2097151.875000 -// unsigned long i12 = 0x4a7ffffful; //4194303.750000 - -// float x0 = hide_float(-FLT_MAX); // -Inf -// float x1 = hide_float(FLT_MAX); // Inf - float x2 = hide_float(0.0); // +0 - float x3 = hide_float(-0.0); // -0 -// float x4 = hide_float(NANF); // NaN -> NaN - float x5 = hide_float( 0.5); - float x6 = hide_float(-0.5); - float x7 = hide_float(-0.499999); - float x8 = hide_float( 0.499999); - float x9 = hide_float(-999999.5); - float x10 = hide_float( 999999.5); -// float x11 = hide_float(make_float(i11)); -// float x12 = hide_float(make_float(i12)); - float x11 = hide_float( 9223371487098961920.); - float x12 = hide_float(-9223371487098961920.); - float x13 = (0.0 - FLT_MIN); - float x14 = FLT_MIN; - float x15 = hide_float(-2097151.875000); - float x16 = hide_float(-4194303.750000); - float x17 = hide_float( 4194303.750000); - float x18 = hide_float( 2097151.875000); - - vec_float4 x0_v = ((vec_float4){ x2, x3, x5, x6}); - llroundf4_t r0_v = set_llrintf4_t(0, 0, 0, 0); - - vec_float4 x1_v = ((vec_float4){ x7, x8, x9, x10}); - llroundf4_t r1_v = set_llrintf4_t(0, 0, -999999, 999999); - - vec_float4 x2_v = ((vec_float4){ x11, x12, x13, x14}); - llroundf4_t r2_v = set_llrintf4_t(9223371487098961920ll, -9223371487098961920ll, 0, 0); - - vec_float4 x3_v = ((vec_float4){ x15, x16, x17, x18}); - llroundf4_t r3_v = set_llrintf4_t(-2097151, -4194303, 4194303, 2097151); - - llroundf4_t res_v; - - TEST_START("llrintf4"); - res_v = llrintf4 (x0_v); - TEST_CHECK("20060918101001NM", allequal_llroundf4( res_v, r0_v ), 0); - res_v = llrintf4 (x1_v); - TEST_CHECK("20060918101002NM", allequal_llroundf4( res_v, r1_v ), 0); - res_v = llrintf4 (x2_v); - TEST_CHECK("20060918101003NM", allequal_llroundf4( res_v, r2_v ), 0); - res_v = llrintf4 (x3_v); - TEST_CHECK("20060918101004NM", allequal_llroundf4( res_v, r3_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/llroundd2.c b/Extras/simdmathlibrary/spu/tests/llroundd2.c deleted file mode 100644 index 6111180bd..000000000 --- a/Extras/simdmathlibrary/spu/tests/llroundd2.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Test llroundd2 for SPU - 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. - */ -/** - * - *@@ llroundd2 - rounds two doubles in to two nearest 64bit integer. - * - *@brief - * boundary test for llroundd2. 0.5 will be rounded to far from 0. - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - **/ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20060916101000NM","NM", "llroundd2"); - -// unsigned long long i11 = 0x7FFFFFFFFFFFFDFFull; //limit -// unsigned long long i12 = 0xFFFFFFFFFFFFFDFFull; //limit - -// double x0 = hide_double(-HUGE_VAL); // -Inf -// double x1 = hide_double(HUGE_VAL); // Inf - double x2 = hide_double(0.0); // +0 - double x3 = hide_double(-0.0); // -0 -// double x4 = hide_double(nan("")); // NaN -> NaN - double x5 = hide_double( 0.5); - double x6 = hide_double(-0.5); - double x7 = hide_double( 0.4999999999999999); // 0 - double x8 = hide_double(-0.4999999999999999); // 0 - double x9 = hide_double( 999999999999999.5); // 1000000000000000 - double x10 = hide_double(-999999999999999.5); //-1000000000000000 -// double x11 = hide_double(make_double(i11)); // 9223372036854774784 -// double x12 = hide_double(make_double(i12)); //-9223372036854774784 - double x11 = hide_double(9223372036854774784ll); // 9223372036854774784 - double x12 = hide_double(-9223372036854774784ll); //-9223372036854774784 - double x13 = DBL_MIN; - double x14 = (0.0 - DBL_MIN); - - vec_double2 x0_v = ((vec_double2){x2, x3}); //+0,-0 - vec_llong2 r0_v = ((vec_llong2){0,0}); // 0, 0 - vec_double2 x1_v = ((vec_double2){x5, x8}); //+0.5,-0.4999999999999999 - vec_llong2 r1_v = ((vec_llong2){1,0}); // 1, 0 - vec_double2 x2_v = ((vec_double2){x7, x6}); //+0.4999999999999999, -0.5 - vec_llong2 r2_v = ((vec_llong2){0,-1}); // 0, -1 - vec_double2 x3_v = ((vec_double2){x10, x11}); //-999999999999999.5, 9223372036854774784 - vec_llong2 r3_v = ((vec_llong2){-1000000000000000ll,9223372036854774784ll}); - vec_double2 x4_v = ((vec_double2){x12, x9}); //-9223372036854774784, 999999999999999.5 - vec_llong2 r4_v = ((vec_llong2){-9223372036854774784ll,1000000000000000ll}); - vec_double2 x5_v = ((vec_double2){x13, x14}); - vec_llong2 r5_v = ((vec_llong2){0,0}); - - vec_llong2 res_v; - - TEST_START("llroundd2"); - res_v = llroundd2 (x0_v); - TEST_CHECK("20060916101001NM", allequal_llong2( res_v, r0_v ), 0); - res_v = llroundd2 (x1_v); - TEST_CHECK("20060916101002NM", allequal_llong2( res_v, r1_v ), 0); - res_v = llroundd2 (x2_v); - TEST_CHECK("20060916101003NM", allequal_llong2( res_v, r2_v ), 0); - res_v = llroundd2 (x3_v); - TEST_CHECK("20060916101004NM", allequal_llong2( res_v, r3_v ), 0); - res_v = llroundd2 (x4_v); - TEST_CHECK("20060916101005NM", allequal_llong2( res_v, r4_v ), 0); - res_v = llroundd2 (x5_v); - TEST_CHECK("20060916101006NM", allequal_llong2( res_v, r5_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/llroundf4.c b/Extras/simdmathlibrary/spu/tests/llroundf4.c deleted file mode 100644 index 8025a2cc4..000000000 --- a/Extras/simdmathlibrary/spu/tests/llroundf4.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Test llroundf4 for SPU - 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. - */ -/** - * - *@@ llroundf4 - rounds four floats in to four nearest 64bit integer. - * - *@brief - * boundary test for llroundf4. 0.5 will be rounded to far from 0. - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * when comparing with return of ppu scalar math library - * answer of 0x??7fffff and 0x??ffffff was something strange - * - **/ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -static inline llroundf4_t set_llroundf4_t(long long int in0, long long int in1, long long int in2, long long int in3) -{ - llroundf4_t res; - - res.vll[0] = ((vec_llong2){in0,in1}); - res.vll[1] = ((vec_llong2){in2,in3}); - - return res; -} -int main() -{ - TEST_SET_START("20060917101000NM","NM", "llroundf4"); - -// unsigned long i11 = 0x5efffffful; // 9223371487098961920 -// unsigned long i12 = 0xdefffffful; //-9223371487098961920 -// unsigned long i11 = 0x49fffffful; //2097151.875000 -// unsigned long i12 = 0x4a7ffffful; //4194303.750000 - -// float x0 = hide_float(-FLT_MAX); // -Inf -// float x1 = hide_float(FLT_MAX); // Inf - float x2 = hide_float(0.0); // +0 - float x3 = hide_float(-0.0); // -0 -// float x4 = hide_float(NANF); // NaN -> NaN - float x5 = hide_float( 0.5); - float x6 = hide_float(-0.5); - float x7 = hide_float(-0.499999); - float x8 = hide_float( 0.499999); - float x9 = hide_float(-999999.5); - float x10 = hide_float( 999999.5); -// float x11 = hide_float(make_float(i11)); -// float x12 = hide_float(make_float(i12)); - float x11 = hide_float( 9223371487098961920.); - float x12 = hide_float(-9223371487098961920.); - float x13 = (0.0 - FLT_MIN); - float x14 = FLT_MIN; - float x15 = hide_float(-2097151.875000); - float x16 = hide_float(-4194303.750000); - float x17 = hide_float( 4194303.750000); - float x18 = hide_float( 2097151.875000); - - vec_float4 x0_v = ((vec_float4){ x2, x3, x5, x6}); - llroundf4_t r0_v = set_llroundf4_t(0, 0, 1, -1); - - vec_float4 x1_v = ((vec_float4){ x7, x8, x9, x10}); - llroundf4_t r1_v = set_llroundf4_t(0, 0, -1000000, 1000000); - - vec_float4 x2_v = ((vec_float4){ x11, x12, x13, x14}); - llroundf4_t r2_v = set_llroundf4_t(9223371487098961920ll, -9223371487098961920ll, 0, 0); - - vec_float4 x3_v = ((vec_float4){ x15, x16, x17, x18}); - llroundf4_t r3_v = set_llroundf4_t(-2097152, -4194304, 4194304, 2097152); - - llroundf4_t res_v; - - TEST_START("llroundf4"); - res_v = llroundf4 (x0_v); - TEST_CHECK("20060916101001NM", allequal_llroundf4( res_v, r0_v ), 0); - res_v = llroundf4 (x1_v); - TEST_CHECK("20060916101002NM", allequal_llroundf4( res_v, r1_v ), 0); - res_v = llroundf4 (x2_v); - TEST_CHECK("20060916101003NM", allequal_llroundf4( res_v, r2_v ), 0); - res_v = llroundf4 (x3_v); - TEST_CHECK("20060916101004NM", allequal_llroundf4( res_v, r3_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/logbd2.c b/Extras/simdmathlibrary/spu/tests/logbd2.c deleted file mode 100644 index 60dbd1cf7..000000000 --- a/Extras/simdmathlibrary/spu/tests/logbd2.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Test logbd2 for SPU - 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. - */ - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060905000000AAN","AAN", "logbd2"); - - // -Nan - double x0 = hide_double(-nan("")); - double r0 = hide_double( nan("")); - - // -Inf - double x1 = hide_double(-HUGE_VAL); - double r1 = hide_double(HUGE_VAL); - - // -Dmax - double x2 = hide_double(-DBL_MAX); - double r2 = 1023.0; - - // -Norm - double x3 = hide_double(-824842.58421394); - double r3 = 19.0; - - // -Dmin - double x4 = hide_double(-DBL_MIN); - double r4 = -1022.0; - - // -Denorm - double x5 = hide_double(-2.40e-310); - double r5 = -1029.0; - - // -Unf - double x6 = hide_double(-1.0e-999); - double r6 = hide_double(-HUGE_VAL); - - // -0 - double x7 = hide_double(-0.0); - double r7 = hide_double(-HUGE_VAL); - - // 0 - double x8 = hide_double( 0.0); - double r8 = hide_double(-HUGE_VAL); - - // +Unf - double x9 = hide_double( 1.0e-999); - double r9 = hide_double(-HUGE_VAL); - - // +Denorm - double x10 = hide_double( 2.40e-310); - double r10 = -1029.0; - - // +Dmin - double x11 = hide_double( DBL_MIN); - double r11 = -1022.0; - - // +Norm - double x12 = hide_double(3.14152634); - double r12 = 1.0; - - // +Norm - double x13 = hide_double(7.0673903e149); - double r13 = 497.0; - - // +Norm - double x14 = hide_double(2.4673e304); - double r14 = 1011.0; - - // +Norm - double x15 = hide_double(7.235672e-25); - double r15 = -81.0; - - // +Denorm - double x16 = hide_double(9.452854e-312); - double r16 = -1034.0; - - // +Demorm - double x17 = hide_double(3.045784e-320); - double r17 = -1062.0; - - // -Norm - double x18 = hide_double(-6.459273e7); - double r18 = 25.0; - - // -Norm - double x19 = hide_double(-2.493472e-99); - double r19 = -328.0; - - // -Norm - double x20 = hide_double(-1.4824543e128); - double r20 = 425.0; - - // -Denorm - double x21 = hide_double(-5.53856231e-315); - double r21 = -1044.0; - - // -Demorm - double x22 = hide_double(-2.5684367e-312); - double r22 = -1036.0; - - // +Dmax - double x23 = hide_double(DBL_MAX); - double r23 = 1023.0; - - // +Inf - double x24 = hide_double(HUGE_VAL); - double r24 = hide_double(HUGE_VAL); - - //+Nan - double x25 = hide_double( nan("")); - double r25 = hide_double( nan("")); - - // Compound - vec_double2 x26_v = (vec_double2) { -2.561286432e-317, -1.0e-999 }; - vec_double2 r26_v = (vec_double2) { -1052.0, hide_double(-HUGE_VAL) }; - - // Compound - vec_double2 x27_v = (vec_double2) { 345.27533, -8.673e-310 }; - vec_double2 r27_v = (vec_double2) { 8.0, -1027.0 }; - - // Compound - vec_double2 x28_v = (vec_double2) { nan(""), -3678342.8765343 }; - vec_double2 r28_v = (vec_double2) { nan(""), 21.0 }; - - // Compound - vec_double2 x29_v = (vec_double2) { HUGE_VAL, -nan("") }; - vec_double2 r29_v = (vec_double2) { HUGE_VAL, nan("") }; - - // Compound - vec_double2 x30_v = (vec_double2) { -1.2e-99, -HUGE_VAL } ; - vec_double2 r30_v = (vec_double2) { -329.0, HUGE_VAL }; - - vec_double2 x0_v = spu_splats(x0); - vec_double2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_double2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_double2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_double2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_double2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_double2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_double2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_double2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_double2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_double2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_double2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_double2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_double2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_double2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_double2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_double2 r15_v = spu_splats(r15); - - vec_double2 x16_v = spu_splats(x16); - vec_double2 r16_v = spu_splats(r16); - - vec_double2 x17_v = spu_splats(x17); - vec_double2 r17_v = spu_splats(r17); - - vec_double2 x18_v = spu_splats(x18); - vec_double2 r18_v = spu_splats(r18); - - vec_double2 x19_v = spu_splats(x19); - vec_double2 r19_v = spu_splats(r19); - - vec_double2 x20_v = spu_splats(x20); - vec_double2 r20_v = spu_splats(r20); - - vec_double2 x21_v = spu_splats(x21); - vec_double2 r21_v = spu_splats(r21); - - vec_double2 x22_v = spu_splats(x22); - vec_double2 r22_v = spu_splats(r22); - - vec_double2 x23_v = spu_splats(x23); - vec_double2 r23_v = spu_splats(r23); - - vec_double2 x24_v = spu_splats(x24); - vec_double2 r24_v = spu_splats(r24); - - vec_double2 x25_v = spu_splats(x25); - vec_double2 r25_v = spu_splats(r25); - - vec_double2 res_v; - - TEST_START("logbd2"); - - res_v = (vec_double2)logbd2(x0_v); - TEST_CHECK("20060905000000AAN", allnan_double2( res_v ), 0); (void)r0_v; - res_v = (vec_double2)logbd2(x1_v); - TEST_CHECK("20060905000001AAN", allequal_double2( res_v, r1_v ), 0); - res_v = (vec_double2)logbd2(x2_v); - TEST_CHECK("20060905000002AAN", allequal_double2( res_v, r2_v ), 0); - res_v = (vec_double2)logbd2(x3_v); - TEST_CHECK("20060905000003AAN", allequal_double2( res_v, r3_v ), 0); - res_v = (vec_double2)logbd2(x4_v); - TEST_CHECK("20060905000004AAN", allequal_double2( res_v, r4_v ), 0); - res_v = (vec_double2)logbd2(x5_v); - TEST_CHECK("20060905000005AAN", allequal_double2( res_v, r5_v ), 0); - res_v = (vec_double2)logbd2(x6_v); - TEST_CHECK("20060905000006AAN", allequal_double2( res_v, r6_v ), 0); - res_v = (vec_double2)logbd2(x7_v); - TEST_CHECK("20060905000007AAN", allequal_double2( res_v, r7_v ), 0); - res_v = (vec_double2)logbd2(x8_v); - TEST_CHECK("20060905000008AAN", allequal_double2( res_v, r8_v ), 0); - res_v = (vec_double2)logbd2(x9_v); - TEST_CHECK("20060905000009AAN", allequal_double2( res_v, r9_v ), 0); - res_v = (vec_double2)logbd2(x10_v); - TEST_CHECK("20060905000010AAN", allequal_double2( res_v, r10_v ), 0); - res_v = (vec_double2)logbd2(x11_v); - TEST_CHECK("20060905000011AAN", allequal_double2( res_v, r11_v ), 0); - res_v = (vec_double2)logbd2(x12_v); - TEST_CHECK("20060905000012AAN", allequal_double2( res_v, r12_v ), 0); - res_v = (vec_double2)logbd2(x13_v); - TEST_CHECK("20060905000013AAN", allequal_double2( res_v, r13_v ), 0); - res_v = (vec_double2)logbd2(x14_v); - TEST_CHECK("20060905000014AAN", allequal_double2( res_v, r14_v ), 0); - res_v = (vec_double2)logbd2(x15_v); - TEST_CHECK("20060905000015AAN", allequal_double2( res_v, r15_v ), 0); - res_v = (vec_double2)logbd2(x16_v); - TEST_CHECK("20060905000016AAN", allequal_double2( res_v, r16_v ), 0); - res_v = (vec_double2)logbd2(x17_v); - TEST_CHECK("20060905000017AAN", allequal_double2( res_v, r17_v ), 0); - res_v = (vec_double2)logbd2(x18_v); - TEST_CHECK("20060905000018AAN", allequal_double2( res_v, r18_v ), 0); - res_v = (vec_double2)logbd2(x19_v); - TEST_CHECK("20060905000019AAN", allequal_double2( res_v, r19_v ), 0); - res_v = (vec_double2)logbd2(x20_v); - TEST_CHECK("20060905000020AAN", allequal_double2( res_v, r20_v ), 0); - res_v = (vec_double2)logbd2(x21_v); - TEST_CHECK("20060905000021AAN", allequal_double2( res_v, r21_v ), 0); - res_v = (vec_double2)logbd2(x22_v); - TEST_CHECK("20060905000022AAN", allequal_double2( res_v, r22_v ), 0); - res_v = (vec_double2)logbd2(x23_v); - TEST_CHECK("20060905000023AAN", allequal_double2( res_v, r23_v ), 0); - res_v = (vec_double2)logbd2(x24_v); - TEST_CHECK("20060905000024AAN", allequal_double2( res_v, r24_v ), 0); - res_v = (vec_double2)logbd2(x25_v); - TEST_CHECK("20060905000025AAN", allnan_double2( res_v ), 0); (void)r25_v; - res_v = (vec_double2)logbd2(x26_v); - TEST_CHECK("20060905000026AAN", allequal_double2( res_v, r26_v ), 0); - res_v = (vec_double2)logbd2(x27_v); - TEST_CHECK("20060905000027AAN", allequal_double2( res_v, r27_v ), 0); - res_v = (vec_double2)logbd2(x28_v); - TEST_CHECK("20060905000028AAN", allequal_ulps_double2( res_v, r28_v, 0 ), 0); - res_v = (vec_double2)logbd2(x29_v); - TEST_CHECK("20060905000029AAN", allequal_ulps_double2( res_v, r29_v, 0 ), 0); - res_v = (vec_double2)logbd2(x30_v); - TEST_CHECK("20060905000030AAN", allequal_double2( res_v, r30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/logbf4.c b/Extras/simdmathlibrary/spu/tests/logbf4.c deleted file mode 100644 index 476a940a5..000000000 --- a/Extras/simdmathlibrary/spu/tests/logbf4.c +++ /dev/null @@ -1,316 +0,0 @@ -/* Test logbf4 for SPU - 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. - */ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060905000000AAN","AAN", "logbf4"); - - // -Norm (IEEE-754: -Nan) - float x0 = hide_float(make_float(0xFFC00000)); - float r0 = 128.0f; - - // -Norm (IEEE-754: -Inf) - float x1 = hide_float(-HUGE_VALF); - float r1 = 128.0f; - - // -Smax - float x2 = hide_float(-FLT_MAX); - float r2 = 128.0f; - - // -Norm - float x3 = hide_float(-824842.58421394); - float r3 = 19.0f; - - // -Smin - float x4 = hide_float(make_float(0x80800000)); - float r4 = -126.0f; - - // -Denorm - float x5 = hide_float(make_float(0x807AAAAA)); - float r5 = -HUGE_VALF; - - // -Unf - float x6 = hide_float(-1.0e-999); - float r6 = -HUGE_VALF; - - // -0 - float x7 = hide_float(-0.0); - float r7 = -HUGE_VALF; - - // 0 - float x8 = hide_float( 0.0); - float r8 = -HUGE_VALF; - - // +Unf - float x9 = hide_float( 1.0e-999); - float r9 = -HUGE_VALF; - - // +Denorm - float x10 = hide_float(make_float(0x007AAAAA)); - float r10 = -HUGE_VALF; - - // +Smin - float x11 = hide_float(make_float(0x00800000)); - float r11 = -126.0f; - - // +Norm - float x12 = hide_float(3.14152634); - float r12 = 1.0f; - - // +Norm - float x13 = hide_float(7.0673903e37); - float r13 = 125.0f; - - // +Norm - float x14 = hide_float(2.4673e14); - float r14 = 47.0f; - - // +Norm - float x15 = hide_float(7.235672e-25); - float r15 = -81.0f; - - // +Norm - float x16 = hide_float(9.452854e17); - float r16 = 59.0f; - - // +Norm - float x17 = hide_float(3.045784e-18); - float r17 = -59.0f; - - // -Norm - float x18 = hide_float(-6.459273e7); - float r18 = 25.0f; - - // -Norm - float x19 = hide_float(-2.493472e-9); - float r19 = -29.0f; - - // -Norm - float x20 = hide_float(-1.4824543e28); - float r20 = 93.0f; - - // -Norm - float x21 = hide_float(-5.53856231e-27); - float r21 = -88.0f; - - // -Norm - float x22 = hide_float(-1.000001); - float r22 = 0.0f; - - // +Smax - float x23 = hide_float(FLT_MAX); - float r23 = 128.0f; - - //+Norm (IEEE-754: +Inf) - float x24 = hide_float(HUGE_VALF); - float r24 = 128.0f; - - //+Norm (IEEE-754: +Nan) - float x25 = hide_float(make_float(0x7FC00000)); - float r25 = 128.0f; - - // Compound - vec_float4 x26_v = (vec_float4) { -2.561286432e10, FLT_MAX, -1.0e-999, 7.235672e-25 }; - vec_float4 r26_v = (vec_float4) { 34.0f, 128.0f, -HUGE_VALF, -81.0f }; - - // Compound - vec_float4 x27_v = (vec_float4) { 345.27533f, 7.0673903e37, -0.0f, -2.40e-310 }; - vec_float4 r27_v = (vec_float4) { 8.0f, 125.0f, -HUGE_VALF, -HUGE_VALF }; - - // Compound - vec_float4 x28_v = (vec_float4) { make_float(0x7FC00000), -824842.58421394f, -0.0f, -3678342.8765343f }; - vec_float4 r28_v = (vec_float4) { 128.0f, 19.0f, -HUGE_VALF, 21.0f }; - - // Compound - vec_float4 x29_v = (vec_float4) { HUGE_VALF, 1.0e-99, -5.53856231e-27, make_float(0xFFC00000) }; - vec_float4 r29_v = (vec_float4) { 128.0f, -HUGE_VALF, -88.0f, 128.0f }; - - // Compound - vec_float4 x30_v = (vec_float4) { 1.2e-57, -1.2e-19, 3.045784e-18, -HUGE_VALF } ; - vec_float4 r30_v = (vec_float4) { -HUGE_VALF, -63.0f, -59.0f, 128.0f }; - - vec_float4 x0_v = spu_splats(x0); - vec_float4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_float4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_float4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_float4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_float4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_float4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_float4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_float4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_float4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_float4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_float4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_float4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_float4 r13_v = spu_splats(r13); - - vec_float4 x14_v = spu_splats(x14); - vec_float4 r14_v = spu_splats(r14); - - vec_float4 x15_v = spu_splats(x15); - vec_float4 r15_v = spu_splats(r15); - - vec_float4 x16_v = spu_splats(x16); - vec_float4 r16_v = spu_splats(r16); - - vec_float4 x17_v = spu_splats(x17); - vec_float4 r17_v = spu_splats(r17); - - vec_float4 x18_v = spu_splats(x18); - vec_float4 r18_v = spu_splats(r18); - - vec_float4 x19_v = spu_splats(x19); - vec_float4 r19_v = spu_splats(r19); - - vec_float4 x20_v = spu_splats(x20); - vec_float4 r20_v = spu_splats(r20); - - vec_float4 x21_v = spu_splats(x21); - vec_float4 r21_v = spu_splats(r21); - - vec_float4 x22_v = spu_splats(x22); - vec_float4 r22_v = spu_splats(r22); - - vec_float4 x23_v = spu_splats(x23); - vec_float4 r23_v = spu_splats(r23); - - vec_float4 x24_v = spu_splats(x24); - vec_float4 r24_v = spu_splats(r24); - - vec_float4 x25_v = spu_splats(x25); - vec_float4 r25_v = spu_splats(r25); - - vec_float4 res_v; - - TEST_START("logbf4"); - - res_v = (vec_float4)logbf4(x0_v); - TEST_CHECK("20060905000000AAN", allequal_float4( res_v, r0_v ), 0); - res_v = (vec_float4)logbf4(x1_v); - TEST_CHECK("20060905000001AAN", allequal_float4( res_v, r1_v ), 0); - res_v = (vec_float4)logbf4(x2_v); - TEST_CHECK("20060905000002AAN", allequal_float4( res_v, r2_v ), 0); - res_v = (vec_float4)logbf4(x3_v); - TEST_CHECK("20060905000003AAN", allequal_float4( res_v, r3_v ), 0); - res_v = (vec_float4)logbf4(x4_v); - TEST_CHECK("20060905000004AAN", allequal_float4( res_v, r4_v ), 0); - res_v = (vec_float4)logbf4(x5_v); - TEST_CHECK("20060905000005AAN", allequal_float4( res_v, r5_v ), 0); - res_v = (vec_float4)logbf4(x6_v); - TEST_CHECK("20060905000006AAN", allequal_float4( res_v, r6_v ), 0); - res_v = (vec_float4)logbf4(x7_v); - TEST_CHECK("20060905000007AAN", allequal_float4( res_v, r7_v ), 0); - res_v = (vec_float4)logbf4(x8_v); - TEST_CHECK("20060905000008AAN", allequal_float4( res_v, r8_v ), 0); - res_v = (vec_float4)logbf4(x9_v); - TEST_CHECK("20060905000009AAN", allequal_float4( res_v, r9_v ), 0); - res_v = (vec_float4)logbf4(x10_v); - TEST_CHECK("20060905000010AAN", allequal_float4( res_v, r10_v ), 0); - res_v = (vec_float4)logbf4(x11_v); - TEST_CHECK("20060905000011AAN", allequal_float4( res_v, r11_v ), 0); - res_v = (vec_float4)logbf4(x12_v); - TEST_CHECK("20060905000012AAN", allequal_float4( res_v, r12_v ), 0); - res_v = (vec_float4)logbf4(x13_v); - TEST_CHECK("20060905000013AAN", allequal_float4( res_v, r13_v ), 0); - res_v = (vec_float4)logbf4(x14_v); - TEST_CHECK("20060905000014AAN", allequal_float4( res_v, r14_v ), 0); - res_v = (vec_float4)logbf4(x15_v); - TEST_CHECK("20060905000015AAN", allequal_float4( res_v, r15_v ), 0); - res_v = (vec_float4)logbf4(x16_v); - TEST_CHECK("20060905000016AAN", allequal_float4( res_v, r16_v ), 0); - res_v = (vec_float4)logbf4(x17_v); - TEST_CHECK("20060905000017AAN", allequal_float4( res_v, r17_v ), 0); - res_v = (vec_float4)logbf4(x18_v); - TEST_CHECK("20060905000018AAN", allequal_float4( res_v, r18_v ), 0); - res_v = (vec_float4)logbf4(x19_v); - TEST_CHECK("20060905000019AAN", allequal_float4( res_v, r19_v ), 0); - res_v = (vec_float4)logbf4(x20_v); - TEST_CHECK("20060905000020AAN", allequal_float4( res_v, r20_v ), 0); - res_v = (vec_float4)logbf4(x21_v); - TEST_CHECK("20060905000021AAN", allequal_float4( res_v, r21_v ), 0); - res_v = (vec_float4)logbf4(x22_v); - TEST_CHECK("20060905000022AAN", allequal_float4( res_v, r22_v ), 0); - res_v = (vec_float4)logbf4(x23_v); - TEST_CHECK("20060905000023AAN", allequal_float4( res_v, r23_v ), 0); - res_v = (vec_float4)logbf4(x24_v); - TEST_CHECK("20060905000024AAN", allequal_float4( res_v, r24_v ), 0); - res_v = (vec_float4)logbf4(x25_v); - TEST_CHECK("20060905000025AAN", allequal_float4( res_v, r25_v ), 0); - res_v = (vec_float4)logbf4(x26_v); - TEST_CHECK("20060905000026AAN", allequal_float4( res_v, r26_v ), 0); - res_v = (vec_float4)logbf4(x27_v); - TEST_CHECK("20060905000027AAN", allequal_float4( res_v, r27_v ), 0); - res_v = (vec_float4)logbf4(x28_v); - TEST_CHECK("20060905000028AAN", allequal_float4( res_v, r28_v ), 0); - res_v = (vec_float4)logbf4(x29_v); - TEST_CHECK("20060905000029AAN", allequal_float4( res_v, r29_v ), 0); - res_v = (vec_float4)logbf4(x30_v); - TEST_CHECK("20060905000030AAN", allequal_float4( res_v, r30_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/modfd2.c b/Extras/simdmathlibrary/spu/tests/modfd2.c deleted file mode 100644 index 88ee903fe..000000000 --- a/Extras/simdmathlibrary/spu/tests/modfd2.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Test modfd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060901173000MH", "MH", "modfd2"); - - unsigned long long i3 = 0x432fffffffffffffull; // 2^52 - 0.5, largest truncatable value. - unsigned long long i3i = 0x432ffffffffffffeull; - unsigned long long i4 = 0x4330000000000000ull; // 2^53, no fractional part. - unsigned long long i5 = 0xcff0000000000001ull; // one more large, and negative, value. - - double x0 = hide_double(0.91825); - double x0i = hide_double(0.0); - double x0f = hide_double(0.91825); - - double x1 = hide_double(-0.12958); - double x1i = hide_double(0.0); - double x1f = hide_double(-0.12958); - - double x2 = hide_double(-79615.1875); - double x2i = hide_double(-79615.0); - double x2f = hide_double(-0.1875); - - double x3 = hide_double(make_double(i3)); - double x3i = hide_double(make_double(i3i)); - double x3f = hide_double(0.5); - - double x4 = hide_double(make_double(i4)); - double x4i = hide_double(make_double(i4)); - double x4f = hide_double(0.0); - - double x5 = hide_double(make_double(i5)); - double x5i = hide_double(make_double(i5)); - double x5f = hide_double(0.0); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 x0i_v = spu_splats(x0i); - vec_double2 x0f_v = spu_splats(x0f); - vec_double2 x1_v = spu_splats(x1); - vec_double2 x1i_v = spu_splats(x1i); - vec_double2 x1f_v = spu_splats(x1f); - vec_double2 x2_v = spu_splats(x2); - vec_double2 x2i_v = spu_splats(x2i); - vec_double2 x2f_v = spu_splats(x2f); - vec_double2 x3_v = spu_splats(x3); - vec_double2 x3i_v = spu_splats(x3i); - vec_double2 x3f_v = spu_splats(x3f); - vec_double2 x4_v = spu_splats(x4); - vec_double2 x4i_v = spu_splats(x4i); - vec_double2 x4f_v = spu_splats(x4f); - vec_double2 x5_v = spu_splats(x5); - vec_double2 x5i_v = spu_splats(x5i); - vec_double2 x5f_v = spu_splats(x5f); - - vec_double2 integer_v, fraction_v; - - TEST_START("modff4"); - fraction_v = modfd2(x0_v, &integer_v); - TEST_CHECK("20040916170647EJL", allequal_double2( integer_v, x0i_v ) && allequal_double2( fraction_v, x0f_v ), 0); - fraction_v = modfd2(x1_v, &integer_v); - TEST_CHECK("20040916170650EJL", allequal_double2( integer_v, x1i_v ) && allequal_double2( fraction_v, x1f_v ), 0); - fraction_v = modfd2(x2_v, &integer_v); - TEST_CHECK("20040916170653EJL", allequal_double2( integer_v, x2i_v ) && allequal_double2( fraction_v, x2f_v ), 0); - fraction_v = modfd2(x3_v, &integer_v); - TEST_CHECK("20040916170656EJL", allequal_double2( integer_v, x3i_v ) && allequal_double2( fraction_v, x3f_v ), 0); - fraction_v = modfd2(x4_v, &integer_v); - TEST_CHECK("20040916170658EJL", allequal_double2( integer_v, x4i_v ) && allequal_double2( fraction_v, x4f_v ), 0); - fraction_v = modfd2(x5_v, &integer_v); - TEST_CHECK("20040916170701EJL", allequal_double2( integer_v, x5i_v ) && allequal_double2( fraction_v, x5f_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/modff4.c b/Extras/simdmathlibrary/spu/tests/modff4.c deleted file mode 100644 index df547a906..000000000 --- a/Extras/simdmathlibrary/spu/tests/modff4.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Test modff4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040916170642EJL", "EJL", "modff"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x0f = hide_float(0.91825f); - - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x1f = hide_float(-0.12958f); - - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x2f = hide_float(-0.1875f); - - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x3f = hide_float(0.5f); - - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x4f = hide_float(0.0f); - - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - float x5f = hide_float(0.0f); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 x0i_v = spu_splats(x0i); - vec_float4 x0f_v = spu_splats(x0f); - vec_float4 x1_v = spu_splats(x1); - vec_float4 x1i_v = spu_splats(x1i); - vec_float4 x1f_v = spu_splats(x1f); - vec_float4 x2_v = spu_splats(x2); - vec_float4 x2i_v = spu_splats(x2i); - vec_float4 x2f_v = spu_splats(x2f); - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3i_v = spu_splats(x3i); - vec_float4 x3f_v = spu_splats(x3f); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4i_v = spu_splats(x4i); - vec_float4 x4f_v = spu_splats(x4f); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5i_v = spu_splats(x5i); - vec_float4 x5f_v = spu_splats(x5f); - - float integer, fraction; - vec_float4 integer_v, fraction_v; - - TEST_START("modff4"); - fraction_v = modff4(x0_v, &integer_v); - TEST_CHECK("20040916170647EJL", allequal_float4( integer_v, x0i_v ) && allequal_float4( fraction_v, x0f_v ), 0); - fraction_v = modff4(x1_v, &integer_v); - TEST_CHECK("20040916170650EJL", allequal_float4( integer_v, x1i_v ) && allequal_float4( fraction_v, x1f_v ), 0); - fraction_v = modff4(x2_v, &integer_v); - TEST_CHECK("20040916170653EJL", allequal_float4( integer_v, x2i_v ) && allequal_float4( fraction_v, x2f_v ), 0); - fraction_v = modff4(x3_v, &integer_v); - TEST_CHECK("20040916170656EJL", allequal_float4( integer_v, x3i_v ) && allequal_float4( fraction_v, x3f_v ), 0); - fraction_v = modff4(x4_v, &integer_v); - TEST_CHECK("20040916170658EJL", allequal_float4( integer_v, x4i_v ) && allequal_float4( fraction_v, x4f_v ), 0); - fraction_v = modff4(x5_v, &integer_v); - TEST_CHECK("20040916170701EJL", allequal_float4( integer_v, x5i_v ) && allequal_float4( fraction_v, x5f_v ), 0); - - TEST_START("modff"); - fraction = modff(x0, &integer); - TEST_CHECK("20040916170704EJL", integer == x0i && fraction == x0f, 0); - fraction = modff(x1, &integer); - TEST_CHECK("20040916170706EJL", integer == x1i && fraction == x1f, 0); - fraction = modff(x2, &integer); - TEST_CHECK("20040916170709EJL", integer == x2i && fraction == x2f, 0); - fraction = modff(x3, &integer); - TEST_CHECK("20040916170711EJL", integer == x3i && fraction == x3f, 0); - fraction = modff(x4, &integer); - TEST_CHECK("20040916170714EJL", integer == x4i && fraction == x4f, 0); - fraction = modff(x5, &integer); - TEST_CHECK("20040916170716EJL", integer == x5i && fraction == x5f, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/nearbyintd2.c b/Extras/simdmathlibrary/spu/tests/nearbyintd2.c deleted file mode 100644 index e15a1f6a0..000000000 --- a/Extras/simdmathlibrary/spu/tests/nearbyintd2.c +++ /dev/null @@ -1,178 +0,0 @@ -/* Test nearbyintd2 for SPU - 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. - */ -/** - * - *@@ nearbyintd2 - Round the input to the nearest integer according to - * the current rounding mode without raising an inexact exception. - * - *@brief - * boundary test for nearbyintd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - **/ - - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int ans0[2]; - unsigned long long int ans1[2]; - unsigned long long int ans2[2]; - unsigned long long int ans3[2]; -} TestVec64_NerI; - -int main() -{ - TestVec64_NerI test_a[] = { - { - // zero - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // border - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL} - },{ - // MIN , MAX - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL} - },{ - // denotmalized - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x3ff0000000000000ULL}, - {0xbff0000000000000ULL,0x0000000000000000ULL} - },{ - // denotmalized - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x3ff0000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0xbff0000000000000ULL} - },{ - // 1.0 - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL} - },{ - // 1.5 - {0x3ff8000000000000ULL,0xbff8000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x4000000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xc000000000000000ULL} - },{ - // 2.5 - {0x4004000000000000ULL,0xc004000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x4008000000000000ULL,0xc000000000000000ULL}, - {0x4000000000000000ULL,0xc008000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060829200000NM","NM", "nearbyintd2"); - - TEST_START("nearbyintd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - spu_mtfpscr(((vec_uint4){0x0000,0,0,0})); - res_v = nearbyintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006082920%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans0[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0500,0,0,0})); - res_v = nearbyintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006082920%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans1[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0a00,0,0,0})); - res_v = nearbyintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006082920%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans2[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0f00,0,0,0})); - res_v = nearbyintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006082920%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans3[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/nearbyintf4.c b/Extras/simdmathlibrary/spu/tests/nearbyintf4.c deleted file mode 100644 index ca6a72bf0..000000000 --- a/Extras/simdmathlibrary/spu/tests/nearbyintf4.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Test nearbyintf4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#define DEFINE_DATA(var,a,b) \ - float var = hide_float(a); \ - float var ## _out = hide_float(b); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -/* - */ -#define DEFINE_DATA_UNSIGNED(var,a,b)\ - unsigned int var ## _ina = a ; \ - unsigned int var ## _inb = b ; \ - float var = make_float(var ## _ina); \ - float var ## _out = make_float(var ## _inb); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -#define DO_TEST(var,id) \ - res_v = nearbyintf4(var ## _v); \ - TEST_CHECK(" #id ", allequal_float4( res_v, var ## _out_v ), 0); - - -int main() -{ - vec_float4 res_v; - - TEST_SET_START("625018616200","NBI", "nearbyintf4"); - - - - - //s=0, e=100, f=7fffff --> s=0, e=100, f=7fffff - DEFINE_DATA_UNSIGNED(x1,0x71ffffff,0x71ffffff) - //s=0, e=22, f=0x7fffff --> s=0,e=22,f=0x7ffffe - DEFINE_DATA_UNSIGNED(x2, 0x4affffff,0x4afffffe) - //s=0, e=23, f=0 --> s=0,e=23,f=0 - DEFINE_DATA_UNSIGNED(x3, 0x4b000000,0x4b000000) - //s=0, e=-126, f=0 --> 0 - DEFINE_DATA_UNSIGNED(x4, 0x800000,0x0) - DEFINE_DATA(x5, 1.001f, 1.f) - DEFINE_DATA(x6, -.05f, 0.f) - DEFINE_DATA(x7, 0.9999f, 0.f) - DEFINE_DATA(x8, 0.4999f, 0.f) - - TEST_START("nearbyintf4"); - DO_TEST(x1,625018616201NBI) - DO_TEST(x2,625018616202NBI) - DO_TEST(x3,625018616203NBI) - DO_TEST(x4,625018616204NBI) - DO_TEST(x5,625018616205NBI) - DO_TEST(x6,625018616206NBI) - DO_TEST(x7,625018616207NBI) - DO_TEST(x8,625018616208NBI) - TEST_SET_DONE(); - - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/negated2.c b/Extras/simdmathlibrary/spu/tests/negated2.c deleted file mode 100644 index 071a90b02..000000000 --- a/Extras/simdmathlibrary/spu/tests/negated2.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Test negated2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040930102626EJL","EJL", "negated2"); - - double x0n = hide_double(-0.0); - double x0p = hide_double(0.0); - double x1n = hide_double(-83532.96153153); - double x1p = hide_double(83532.96153153); - double x2n = hide_double(-0.0000000013152); - double x2p = hide_double(0.0000000013152); - double x3n = hide_double(-HUGE_VAL); - double x3p = hide_double(HUGE_VAL); - - vec_double2 x0n_v = spu_splats(x0n); - vec_double2 x0p_v = spu_splats(x0p); - vec_double2 x1n_v = spu_splats(x1n); - vec_double2 x1p_v = spu_splats(x1p); - vec_double2 x2n_v = spu_splats(x2n); - vec_double2 x2p_v = spu_splats(x2p); - vec_double2 x3n_v = spu_splats(x3n); - vec_double2 x3p_v = spu_splats(x3p); - - vec_double2 res_v; - - TEST_START("negated2"); - res_v = negated2(x0n_v); - TEST_CHECK("20040930102629EJL", allequal_double2( res_v, x0p_v ), 0); - res_v = negated2(x0p_v); - TEST_CHECK("20040930102631EJL", allequal_double2( res_v, x0n_v ), 0); - res_v = negated2(x1n_v); - TEST_CHECK("20040930102632EJL", allequal_double2( res_v, x1p_v ), 0); - res_v = negated2(x1p_v); - TEST_CHECK("20040930102635EJL", allequal_double2( res_v, x1n_v ), 0); - res_v = negated2(x2n_v); - TEST_CHECK("20040930102637EJL", allequal_double2( res_v, x2p_v ), 0); - res_v = negated2(x2p_v); - TEST_CHECK("20040930102639EJL", allequal_double2( res_v, x2n_v ), 0); - res_v = negated2(x3n_v); - TEST_CHECK("20040930102641EJL", allposinf_double2( res_v ), 0); - res_v = negated2(x3p_v); - TEST_CHECK("20040930102643EJL", allneginf_double2( res_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/negatef4.c b/Extras/simdmathlibrary/spu/tests/negatef4.c deleted file mode 100644 index cb9310e43..000000000 --- a/Extras/simdmathlibrary/spu/tests/negatef4.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Test negatef4 for SPU - 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. - */ - - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040930102649EJL","EJL", "negatef4"); - - unsigned int i3n = 0xffffffff; - unsigned int i3p = 0x7fffffff; - - float x0n = hide_float(-0.0f); - float x0p = hide_float(0.0f); - float x1n = hide_float(-83532.96153153f); - float x1p = hide_float(83532.96153153f); - float x2n = hide_float(-0.0000000013152f); - float x2p = hide_float(0.0000000013152f); - float x3n = hide_float(make_float(i3n)); - float x3p = hide_float(make_float(i3p)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0p_v = spu_splats(x0p); - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1p_v = spu_splats(x1p); - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2p_v = spu_splats(x2p); - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3p_v = spu_splats(x3p); - - vec_float4 res_v; - - TEST_START("negatef4"); - res_v = negatef4(x0n_v); - TEST_CHECK("20040930102652EJL", allequal_float4( res_v, x0p_v ), 0); - res_v = negatef4(x0p_v); - TEST_CHECK("20040930102653EJL", allequal_float4( res_v, x0n_v ), 0); - res_v = negatef4(x1n_v); - TEST_CHECK("20040930102655EJL", allequal_float4( res_v, x1p_v ), 0); - res_v = negatef4(x1p_v); - TEST_CHECK("20040930102657EJL", allequal_float4( res_v, x1n_v ), 0); - res_v = negatef4(x2n_v); - TEST_CHECK("20040930102659EJL", allequal_float4( res_v, x2p_v ), 0); - res_v = negatef4(x2p_v); - TEST_CHECK("20040930102701EJL", allequal_float4( res_v, x2n_v ), 0); - res_v = negatef4(x3n_v); - TEST_CHECK("20040930102703EJL", allequal_float4( res_v, x3p_v ), 0); - res_v = negatef4(x3p_v); - TEST_CHECK("20040930102705EJL", allequal_float4( res_v, x3n_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/negatei4.c b/Extras/simdmathlibrary/spu/tests/negatei4.c deleted file mode 100644 index 5ef6df510..000000000 --- a/Extras/simdmathlibrary/spu/tests/negatei4.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Test negatei4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040930102649EJL","EJL", "negatei4"); - - int x0n = hide_int(0); - int x0p = hide_int(0); - int x1n = hide_int(-83532); - int x1p = hide_int(83532); - int x2n = hide_int(-13152); - int x2p = hide_int(13152); - int x3n = hide_int(-1); - int x3p = hide_int(1); - - vec_int4 x0n_v = spu_splats(x0n); - vec_int4 x0p_v = spu_splats(x0p); - vec_int4 x1n_v = spu_splats(x1n); - vec_int4 x1p_v = spu_splats(x1p); - vec_int4 x2n_v = spu_splats(x2n); - vec_int4 x2p_v = spu_splats(x2p); - vec_int4 x3n_v = spu_splats(x3n); - vec_int4 x3p_v = spu_splats(x3p); - - vec_int4 res_v; - - TEST_START("negatei4"); - res_v = negatei4(x0n_v); - TEST_CHECK("20040930102652EJL", allequal_int4( res_v, x0p_v ), 0); - res_v = negatei4(x0p_v); - TEST_CHECK("20040930102653EJL", allequal_int4( res_v, x0n_v ), 0); - res_v = negatei4(x1n_v); - TEST_CHECK("20040930102655EJL", allequal_int4( res_v, x1p_v ), 0); - res_v = negatei4(x1p_v); - TEST_CHECK("20040930102657EJL", allequal_int4( res_v, x1n_v ), 0); - res_v = negatei4(x2n_v); - TEST_CHECK("20040930102659EJL", allequal_int4( res_v, x2p_v ), 0); - res_v = negatei4(x2p_v); - TEST_CHECK("20040930102701EJL", allequal_int4( res_v, x2n_v ), 0); - res_v = negatei4(x3n_v); - TEST_CHECK("20040930102703EJL", allequal_int4( res_v, x3p_v ), 0); - res_v = negatei4(x3p_v); - TEST_CHECK("20040930102705EJL", allequal_int4( res_v, x3n_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/negatell2.c b/Extras/simdmathlibrary/spu/tests/negatell2.c deleted file mode 100644 index 76d346f20..000000000 --- a/Extras/simdmathlibrary/spu/tests/negatell2.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Test negatell2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060731203500MH","MH", "negatell2"); - - vec_llong2 x0n_v = spu_splats(0LL); - vec_llong2 x0p_v = spu_splats(0LL); - vec_llong2 x1n_v = spu_splats(-83582LL); - vec_llong2 x1p_v = spu_splats(83582LL); - vec_llong2 x2n_v = spu_splats(-13152LL); - vec_llong2 x2p_v = spu_splats(13152LL); - vec_llong2 x3n_v = spu_splats(-1LL); - vec_llong2 x3p_v = spu_splats(1LL); - vec_llong2 x4n_v = spu_splats((long long)0x8000000000000001ULL); - vec_llong2 x4p_v = spu_splats(0x7fffffffffffffffLL); - vec_llong2 x5n_v = spu_splats((long long)0x8000000100000000ULL); - vec_llong2 x5p_v = spu_splats(0x7fffffff00000000LL); - - vec_llong2 res_v; - - TEST_START("negatell2"); - res_v = negatell2(x0n_v); - TEST_CHECK("20060731203501MH", allequal_llong2( res_v, x0p_v ), 0); - res_v = negatell2(x0p_v); - TEST_CHECK("20060731203502MH", allequal_llong2( res_v, x0n_v ), 0); - res_v = negatell2(x1n_v); - TEST_CHECK("20060731203503MH", allequal_llong2( res_v, x1p_v ), 0); - res_v = negatell2(x1p_v); - TEST_CHECK("20060731203504MH", allequal_llong2( res_v, x1n_v ), 0); - res_v = negatell2(x2n_v); - TEST_CHECK("20060731203505MH", allequal_llong2( res_v, x2p_v ), 0); - res_v = negatell2(x2p_v); - TEST_CHECK("20060731203506MH", allequal_llong2( res_v, x2n_v ), 0); - res_v = negatell2(x3n_v); - TEST_CHECK("20060731203507MH", allequal_llong2( res_v, x3p_v ), 0); - res_v = negatell2(x3p_v); - TEST_CHECK("20060731203508MH", allequal_llong2( res_v, x3n_v ), 0); - res_v = negatell2(x4n_v); - TEST_CHECK("20060731203509MH", allequal_llong2( res_v, x4p_v ), 0); - res_v = negatell2(x4p_v); - TEST_CHECK("20060731203510MH", allequal_llong2( res_v, x4n_v ), 0); - res_v = negatell2(x5n_v); - TEST_CHECK("20060731203511MH", allequal_llong2( res_v, x5p_v ), 0); - res_v = negatell2(x5p_v); - TEST_CHECK("20060731203512MH", allequal_llong2( res_v, x5n_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/nextafterd2.c b/Extras/simdmathlibrary/spu/tests/nextafterd2.c deleted file mode 100644 index cb409783c..000000000 --- a/Extras/simdmathlibrary/spu/tests/nextafterd2.c +++ /dev/null @@ -1,153 +0,0 @@ -/* Test nextafterd2 for SPU - 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. - */ -/** - * - *@@ nextafterd2 - find next representable floating-point value towards 2nd param. - * - *@brief - * boundary test for nextafterd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int yyy[2]; - unsigned long long int ans[2]; -} TestVec64_NexA; - -int main() -{ - TestVec64_NexA test_a[] = { - { - // -1 -> -0 , 0 -> -1 - {0x8000000000000001ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x8000000000000001ULL}, - {0x8000000000000000ULL,0x8000000000000001ULL} - },{ - // -1 -> -0 , 0 -> -1 - {0x8000000000000001ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000001ULL}, - {0x8000000000000000ULL,0x8000000000000001ULL} - },{ - // 0 -> -0 , -0 -> 0 - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL} - },{ - // -Inf -> MIN , Inf -> MAX - {0xFFF0000000000000ULL,0x7FF0000000000000ULL}, - {0x0010000000000000ULL,0x0000000000000000ULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL} - },{ - // MAX -> Inf , MIN -> -Inf - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL} - },{ - // Denormalize -> Denormalize - {0x0000000000000001ULL,0x8000000000000010ULL}, - {0x0000000000000003ULL,0x8000000000000020ULL}, - {0x0000000000000002ULL,0x8000000000000011ULL} - },{ - // Denormalize -> Normalize - {0x000FFFFFFFFFFFFFULL,0x800FFFFFFFFFFFFFULL}, - {0x0020000000000000ULL,0x8020000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL} - },{ - // Normalize -> Denormalize - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x8010000000000000ULL,0x0020000000000000ULL}, - {0x000FFFFFFFFFFFFFULL,0x800FFFFFFFFFFFFFULL} - },{ - // equal - {0x8FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL}, - {0x8FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL}, - {0x8FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL} - },{ - // - {0x8FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL}, - {0x9FFFFFFFFFFFFFFFULL,0x1FFFFFFFFFFFFFFFULL}, - {0x9000000000000000ULL,0x1000000000000000ULL} - },{ - // - {0x7000000000000000ULL,0xF000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x6FFFFFFFFFFFFFFFULL,0xEFFFFFFFFFFFFFFFULL} - },{ - // Nan - {0x7000000000000000ULL,0xF000000000000000ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060828130000NM","NM", "nextafterd2"); - - TEST_START("nextafterd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - res_v = nextafterd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_double2 *)&test_a[ii].yyy[0])); - sprintf(msg,"2006082813%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/nextafterf4.c b/Extras/simdmathlibrary/spu/tests/nextafterf4.c deleted file mode 100644 index c6cea845f..000000000 --- a/Extras/simdmathlibrary/spu/tests/nextafterf4.c +++ /dev/null @@ -1,162 +0,0 @@ -/* Test nextafterf4 for SPU - 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. - */ - - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -//a :float, b: float: c:bit pattern -#define DEFINE_DATA(var,a,b,c) \ - float var ## _a = a;\ -vec_float4 var ## _a_v = spu_splats(var ## _a); \ - float var ## _b = b;\ -vec_float4 var ## _b_v = spu_splats(var ## _b); \ - unsigned int var ## _inc = c ; \ - float var ## _out = make_float(var ## _inc);\ - vec_float4 var ## _out_v = spu_splats(var ## _out);\ - -//a :bit pattern, b: bit pattern: c:bit pattern -#define DEFINE_DATA_UNSIGNED(var,a,b,c) \ - unsigned int var ## _ina = a ; \ - float var ## _a = make_float(var ## _ina); \ - vec_float4 var ## _a_v = spu_splats(var ## _a); \ - unsigned int var ## _inb = b ; \ - float var ## _b = make_float(var ## _inb); \ - vec_float4 var ## _b_v = spu_splats(var ## _b); \ - unsigned int var ## _inc = c ; \ - float var ## _out = make_float(var ## _inc); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -#define DO_TEST(var,id) \ - res_v = nextafterf4(var ## _a_v, var ## _b_v);\ - TEST_CHECK(" #id ", allequal_float4( res_v, var ## _out_v ), 0); - - -int main() -{ - vec_float4 res_v; - - TEST_SET_START("958726589700","NAR", "nextafterf4"); - - - - // == - // 1.0f --> 1.0f - DEFINE_DATA(x1, 1.0f, 1.0f, 0x3f800000) - DEFINE_DATA(x2, 0.0f, 0.0f, 0x0) - - // * Icrement * - - // -FLT_MAX -> - DEFINE_DATA_UNSIGNED(x3,0xffffffff, 0x0, 0xfffffffe) - //(1, 40, 0) --> (1, 39, 7fffff) - DEFINE_DATA_UNSIGNED(x4,0xd3800000, 0x0, 0xd37fffff) - // (1,-40,0 ) --> (1,-41,0x7fffff) - DEFINE_DATA_UNSIGNED(x5,0xab800000, 0x0, 0xab7fffff) - //-FLT_MIN --> 0 - DEFINE_DATA_UNSIGNED(x6,0x80800000, 0x0, 0x0) - //0.0f --> FLT_MIN - DEFINE_DATA(x7, 0.0f, 1.0f, 0x800000) - //-0.0f --> FLT_MIN - DEFINE_DATA_UNSIGNED(x8, 0x80000000, 0x7fffffff, 0x800000) - //FLT_MIN --> - DEFINE_DATA_UNSIGNED(x9, 0x800000, 0x7fffffff, 0x800001) - // (0, -41, 7fffff) --> (0, -40, 0) - DEFINE_DATA_UNSIGNED(x10, 0x2b7fffff, 0x7fffffff, 0x2b800000) - // (0, 40, 7fffff) --> (0, 41, 0) - DEFINE_DATA_UNSIGNED(x11, 0x53ffffff, 0x7fffffff, 0x54000000) - // FLT_MAX --> - DEFINE_DATA_UNSIGNED(x12,0x7fffffff,0x7fffffff,0x7fffffff) - - // * Decrement * - - // FLT_MAX --> FLT_MAX - DEFINE_DATA_UNSIGNED(x13,0x7fffffff,0x7fffffff,0x7fffffff) - // FLT_MAX --> - DEFINE_DATA_UNSIGNED(x14,0x7fffffff,0x0,0x7ffffffe) - // (0, 41, 0) --> (0, 40, 7fffff) - DEFINE_DATA_UNSIGNED(x15, 0x54000000, 0x0, 0x53ffffff) - // (0, -40, 0) --> (0, -41, 7fffff) - DEFINE_DATA_UNSIGNED(x16, 0x2b800000,0x0, 0x2b7fffff) - // -> FLT_MIN - DEFINE_DATA_UNSIGNED(x17, 0x800001, 0x800000, 0x800000) - // FLT_MIN --> 0 - DEFINE_DATA_UNSIGNED(x18, 0x800000, 0x0, 0x0) - // 0.0 -> -FLT_MIN - DEFINE_DATA_UNSIGNED(x19, 0x0, 0xffffffff, 0x80800000) - // -0.0 -> FLT_MIN - DEFINE_DATA_UNSIGNED(x20, 0x80000000, 0xffffffff, 0x80800000) - //-FLT_MIN --> - DEFINE_DATA_UNSIGNED(x21, 0x80800000, 0xffffffff, 0x80800001) - // (1,-41,0x7fffff) --> (1,-40,0 ) - DEFINE_DATA_UNSIGNED(x22, 0xab7fffff, 0xffffffff, 0xab800000) - //(1, 40, 0) --> (1, 39, 7fffff) - DEFINE_DATA_UNSIGNED(x23, 0xd37fffff, 0xffffffff, 0xd3800000) - // --> -FLT_MAX - DEFINE_DATA_UNSIGNED(x24,0xfffffffe, 0xffffffff, 0xffffffff) - - - //TEST - TEST_START("nextafterf4"); - DO_TEST(x1,958726589701NAR) - DO_TEST(x2,958726589702NAR) - DO_TEST(x3,958726589703NAR) - DO_TEST(x4,958726589704NAR) - DO_TEST(x5,958726589705NAR) - DO_TEST(x6,958726589706NAR) - DO_TEST(x7,958726589707NAR) - DO_TEST(x8,958726589708NAR) - DO_TEST(x9,958726589709NAR) - DO_TEST(x10,958726589710NAR) - DO_TEST(x11,958726589711NAR) - DO_TEST(x12,958726589712NAR) - DO_TEST(x13,958726589713NAR) - DO_TEST(x14,958726589714NAR) - DO_TEST(x15,958726589715NAR) - DO_TEST(x16,958726589716NAR) - DO_TEST(x17,958726589717NAR) - DO_TEST(x18,958726589718NAR) - DO_TEST(x19,958726589719NAR) - DO_TEST(x20,958726589720NAR) - DO_TEST(x21,958726589721NAR) - DO_TEST(x22,958726589722NAR) - DO_TEST(x23,958726589723NAR) - DO_TEST(x24,958726589724NAR) - - TEST_SET_DONE(); - - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/recipd2.c b/Extras/simdmathlibrary/spu/tests/recipd2.c deleted file mode 100644 index 573a69194..000000000 --- a/Extras/simdmathlibrary/spu/tests/recipd2.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Test recipd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040920095218EJL","EJL", "recipd2"); - - unsigned long long i6 = 0x7fd0000000000001ull; // 2^1022 + 1 ulp - unsigned long long i7 = 0xffd0000000000000ull; // -2^1022 - unsigned long long i7r = 0x8010000000000000ull; // -2^-1022 - unsigned long long i8 = 0x7606a4533cf5605eull; // random values - unsigned long long i8r = 0x09d69cea2b5b5b57ull; - unsigned long long i9 = 0x4c042c295376566eull; - unsigned long long i9r = 0x33d9618e87b961f4ull; - unsigned long long i10 = 0x39b3720562510408ull; - unsigned long long i10r = 0x462a54842d7f9b5dull; - unsigned long long i11 = 0x6911a64538a389aeull; - unsigned long long i11r = 0x16cd02637ed13ff2ull; - unsigned long long i12 = 0x1ac4d062d451c99dull; - unsigned long long i12r = 0x6518994c26ebbb3eull; - - double x0 = hide_double(-HUGE_VAL); // -Inf - double x1 = hide_double(HUGE_VAL); // Inf - double x2 = hide_double(0.0); // 0 - double x3 = hide_double(-0.0); // -0 - double x4 = hide_double(nan("")); // NaN - double x5 = hide_double(2.0); - double x5r = hide_double(0.5); - double x6 = hide_double(make_double(i6)); - double x7 = hide_double(make_double(i7)); - double x7r = hide_double(make_double(i7r)); - double x8 = hide_double(make_double(i8)); - double x8r = hide_double(make_double(i8r)); - double x9 = hide_double(make_double(i9)); - double x9r = hide_double(make_double(i9r)); - double x10 = hide_double(make_double(i10)); - double x10r = hide_double(make_double(i10r)); - double x11 = hide_double(make_double(i11)); - double x11r = hide_double(make_double(i11r)); - double x12 = hide_double(make_double(i12)); - double x12r = hide_double(make_double(i12r)); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 x1_v = spu_splats(x1); - vec_double2 x2_v = spu_splats(x2); - vec_double2 x3_v = spu_splats(x3); - vec_double2 x4_v = spu_splats(x4); - vec_double2 x5_v = spu_splats(x5); - vec_double2 x5r_v = spu_splats(x5r); - vec_double2 x6_v = spu_splats(x6); - vec_double2 x7_v = spu_splats(x7); - vec_double2 x7r_v = spu_splats(x7r); - vec_double2 x8_v = spu_splats(x8); - vec_double2 x8r_v = spu_splats(x8r); - vec_double2 x9_v = spu_splats(x9); - vec_double2 x9r_v = spu_splats(x9r); - vec_double2 x10_v = spu_splats(x10); - vec_double2 x10r_v = spu_splats(x10r); - vec_double2 x11_v = spu_splats(x11); - vec_double2 x11r_v = spu_splats(x11r); - vec_double2 x12_v = spu_splats(x12); - vec_double2 x12r_v = spu_splats(x12r); - - vec_double2 res_v; - - TEST_START("recipd2"); - res_v = recipd2(x0_v); - TEST_CHECK("20040920095224EJL", allnegzero_double2( res_v ), 0); - res_v = recipd2(x1_v); - TEST_CHECK("20040920095226EJL", allposzero_double2( res_v ), 0); - res_v = recipd2(x2_v); - TEST_CHECK("20040920095228EJL", allposinf_double2( res_v ), 0); - res_v = recipd2(x3_v); - TEST_CHECK("20040920095233EJL", allneginf_double2( res_v ), 0); - res_v = recipd2(x4_v); - TEST_CHECK("20040920095235EJL", allnan_double2( res_v ), 0); - res_v = recipd2(x5_v); - TEST_CHECK("20040920095237EJL", allequal_double2( res_v, x5r_v ), 0); - res_v = recipd2(x6_v); - TEST_CHECK("20040920095239EJL", allzerodenorm_double2( res_v ), 0); - res_v = recipd2(x7_v); - TEST_CHECK("20040920095242EJL", allequal_double2( res_v, x7r_v ), 0); - res_v = recipd2(x8_v); - TEST_CHECK("20040920095245EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0); - res_v = recipd2(x9_v); - TEST_CHECK("20040920095247EJL", allequal_ulps_double2( res_v, x9r_v, 1 ), 0); - res_v = recipd2(x10_v); - TEST_CHECK("20040920095248EJL", allequal_ulps_double2( res_v, x10r_v, 1 ), 0); - res_v = recipd2(x11_v); - TEST_CHECK("20040920095250EJL", allequal_ulps_double2( res_v, x11r_v, 1 ), 0); - res_v = recipd2(x12_v); - TEST_CHECK("20040920095252EJL", allequal_ulps_double2( res_v, x12r_v, 1 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/recipf4.c b/Extras/simdmathlibrary/spu/tests/recipf4.c deleted file mode 100644 index eb252c14c..000000000 --- a/Extras/simdmathlibrary/spu/tests/recipf4.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Test recipf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040920142553EJL","EJL", "recipf4"); - - unsigned int i0r = 0x7fffffff; - unsigned int i1 = 0xff000000; // -2^127 - unsigned int i2 = 0xfe7fffff; // -2^126 - 1 ulp - unsigned int i2r = 0x80800001; - unsigned int i3 = 0x75013340; // random values - unsigned int i3r = 0x09fd9f35; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x090d9277; - unsigned int i5 = 0x4c7fed5a; - unsigned int i5r = 0x32800954; - unsigned int i6 = 0x3a0731f0; - unsigned int i6r = 0x44f2602e; - unsigned int i7 = 0x69784a07; - unsigned int i7r = 0x1583f9a3; - - float x0 = hide_float(0.0f); - float x0r = hide_float(make_float(i0r)); - float x1 = hide_float(make_float(i1)); - float x1r = hide_float(0.0f); - float x2 = hide_float(make_float(i2)); - float x2r = hide_float(make_float(i2r)); - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 x0r_v = spu_splats(x0r); - vec_float4 x1_v = spu_splats(x1); - vec_float4 x1r_v = spu_splats(x1r); - vec_float4 x2_v = spu_splats(x2); - vec_float4 x2r_v = spu_splats(x2r); - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3r_v = spu_splats(x3r); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4r_v = spu_splats(x4r); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5r_v = spu_splats(x5r); - vec_float4 x6_v = spu_splats(x6); - vec_float4 x6r_v = spu_splats(x6r); - vec_float4 x7_v = spu_splats(x7); - vec_float4 x7r_v = spu_splats(x7r); - - vec_float4 res_v; - - TEST_START("recipf4"); - res_v = recipf4(x0_v); - TEST_CHECK("20040920142558EJL", allequal_float4( res_v, x0r_v ), 0); - res_v = recipf4(x1_v); - TEST_CHECK("20040920142600EJL", allequal_float4( res_v, x1r_v), 0); - res_v = recipf4(x2_v); - TEST_CHECK("20040920142602EJL", allequal_ulps_float4( res_v, x2r_v, 2 ), 0); - res_v = recipf4(x3_v); - TEST_CHECK("20040920142604EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = recipf4(x4_v); - TEST_CHECK("20040920142606EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = recipf4(x5_v); - TEST_CHECK("20040920142608EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = recipf4(x6_v); - TEST_CHECK("20040920142609EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = recipf4(x7_v); - TEST_CHECK("20040920142611EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/remainderd2.c b/Extras/simdmathlibrary/spu/tests/remainderd2.c deleted file mode 100644 index 8100c9ee7..000000000 --- a/Extras/simdmathlibrary/spu/tests/remainderd2.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Test remainderd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int yyy[2]; - unsigned long long int a_res[2]; -} TestVec64_RemqD; - -int main() -{ - TestVec64_RemqD test_a[] = { - { - // normal 2.5/1.5 29/3 - {0x4004000000000000ULL,0x403d000000000000ULL}, - {0x3ff8000000000000ULL,0x4008000000000000ULL}, - {0xbfe0000000000000ULL,0xbff0000000000000ULL} - },{ - // normal - {0x09d0000000000006ULL,0x1000000000000000ULL}, - {0x8010000000000005ULL,0x0010000000000007ULL}, - {0x800000000000007dULL,0x80037ffffffff1a5ULL} - },{ - // denorm - {0x0000000000000001ULL,0x800ffffffffffff3ULL}, - {0x8000000000000001ULL,0x8000000000000005ULL}, - {0x0000000000000000ULL,0x0000000000000002ULL} - },{ - // divide by inf - {0xFFEFFFFFFFFFFFFFULL,0x0001000000000000ULL}, - {0x7FF0000000000000ULL,0x7FF0000000000000ULL}, - {0xFFEFFFFFFFFFFFFFULL,0x0001000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - TestVec64_RemqD test_b[] = { - { - // divide by zero -> nan - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x7ff8000000000000ULL,0x7ff8000000000000ULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7ff8000000000000ULL,0x7ff8000000000000ULL} - },{ - // border - {0xFFE0000000000000ULL,0x7FEFFFFFFFFFFFFFULL}, - {0x0008000000000000ULL,0x0010000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060919210000NM","NM", "remquod2"); - - TEST_START("remquod2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - res_v = remainderd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_double2 *)&test_a[ii].yyy[0])); - sprintf(msg,"2006092621%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].a_res[0])), 0); - } - for (ii=0; ; ii++) { - if ( (test_b[ii].xxx[0] == 0) && (test_b[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - res_v = remainderd2 (*((vec_double2 *)&test_b[ii].xxx[0]), *((vec_double2 *)&test_b[ii].yyy[0])); - sprintf(msg,"2006092623%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_b[ii].a_res[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/remainderf4.c b/Extras/simdmathlibrary/spu/tests/remainderf4.c deleted file mode 100644 index 7f09e0d42..000000000 --- a/Extras/simdmathlibrary/spu/tests/remainderf4.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Test remainderf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040928191927EJL","EJL", "remainderf4"); - - unsigned int i0n = 0x449edbc6; - unsigned int i0d = 0x40cf799d; - unsigned int i0r = 0x3daa7300; - unsigned int i1n = 0x6bca107a; - unsigned int i1d = 0x6c4a107a; - unsigned int i1r = 0x6bca107a; - unsigned int i2n = 0x1c123605; - unsigned int i2d = 0x1c923602; - unsigned int i2r = 0x9c1235ff; - unsigned int i3n = 0x2b4c50fa; - unsigned int i3d = 0x253a3ae3; - unsigned int i3r = 0xa41873a8; - unsigned int i4n = 0x73addffc; - unsigned int i4d = 0x742ddffc; - unsigned int i4r = 0x73addffc; - unsigned int i5n = 0x29d4d97c; - unsigned int i5d = 0x2a546e77; - unsigned int i5r = 0xa9d40372; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0d_v = spu_splats(x0d); - vec_float4 x0r_v = spu_splats(x0r); - - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1d_v = spu_splats(x1d); - vec_float4 x1r_v = spu_splats(x1r); - - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2d_v = spu_splats(x2d); - vec_float4 x2r_v = spu_splats(x2r); - - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3d_v = spu_splats(x3d); - vec_float4 x3r_v = spu_splats(x3r); - - vec_float4 x4n_v = spu_splats(x4n); - vec_float4 x4d_v = spu_splats(x4d); - vec_float4 x4r_v = spu_splats(x4r); - - vec_float4 x5n_v = spu_splats(x5n); - vec_float4 x5d_v = spu_splats(x5d); - vec_float4 x5r_v = spu_splats(x5r); - - float res; - vec_float4 res_v; - - TEST_START("remainderf4"); - res_v = remainderf4(x0n_v, x0d_v); - TEST_CHECK("20040928191931EJL", allequal_ulps_float4( res_v, x0r_v, 1 ), 0); - res_v = remainderf4(x1n_v, x1d_v); - TEST_CHECK("20040928191933EJL", allequal_ulps_float4( res_v, x1r_v, 1 ), 0); - res_v = remainderf4(x2n_v, x2d_v); - TEST_CHECK("20040928191934EJL", allequal_ulps_float4( res_v, x2r_v, 1 ), 0); - res_v = remainderf4(x3n_v, x3d_v); - TEST_CHECK("20040928191936EJL", allequal_ulps_float4( res_v, x3r_v, 1 ), 0); - res_v = remainderf4(x4n_v, x4d_v); - TEST_CHECK("20040928191937EJL", allequal_ulps_float4( res_v, x4r_v, 1 ), 0); - res_v = remainderf4(x5n_v, x5d_v); - TEST_CHECK("20040928191938EJL", allequal_ulps_float4( res_v, x5r_v, 1 ), 0); - - TEST_START("remainderf"); - res = remainderf(x0n, x0d); - TEST_CHECK("20040928191941EJL", ulpDiff_f( res, x0r ) <= 1, 0); - res = remainderf(x1n, x1d); - TEST_CHECK("20040928191942EJL", ulpDiff_f( res, x1r ) <= 1, 0); - res = remainderf(x2n, x2d); - TEST_CHECK("20040928191943EJL", ulpDiff_f( res, x2r ) <= 1, 0); - res = remainderf(x3n, x3d); - TEST_CHECK("20040928191948EJL", ulpDiff_f( res, x3r ) <= 1, 0); - res = remainderf(x4n, x4d); - TEST_CHECK("20040928191949EJL", ulpDiff_f( res, x4r ) <= 1, 0); - res = remainderf(x5n, x5d); - TEST_CHECK("20040928191950EJL", ulpDiff_f( res, x5r ) <= 1, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/remquod2.c b/Extras/simdmathlibrary/spu/tests/remquod2.c deleted file mode 100644 index 4060ed09e..000000000 --- a/Extras/simdmathlibrary/spu/tests/remquod2.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test remquod2 for SPU - 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. - */ - -/* - * note: cannot calc too far numbers correctry - * ex. x=0xFFE0000000000000,y=0x0008000000000000 - */ - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int yyy[2]; - unsigned long long int quo[2]; - unsigned long long int a_res[2]; - unsigned long long int a_quo[2]; -} TestVec64_RemqD; - -int main() -{ - TestVec64_RemqD test_a[] = { - { - // normal 2.5/1.5 29/3 - {0x4004000000000000ULL,0x403d000000000000ULL}, - {0x3ff8000000000000ULL,0x4008000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0xbfe0000000000000ULL,0xbff0000000000000ULL}, - {0x0000000000000002ULL,0x0000000000000002ULL} - },{ - // normal - {0x09d0000000000006ULL,0x1000000000000000ULL}, - {0x8010000000000005ULL,0x0010000000000007ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0x800000000000007dULL,0x80037ffffffff1a5ULL}, - {0xFFFFFFFFFFFFFFFFULL,0x0000000000000003ULL} - },{ - // denorm - {0x0000000000000001ULL,0x800ffffffffffff3ULL}, - {0x8000000000000001ULL,0x8000000000000005ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000002ULL}, - {0xFFFFFFFFFFFFFFFFULL,0x0000000000000001ULL} - },{ - // divide by inf - {0xFFEFFFFFFFFFFFFFULL,0x0001000000000000ULL}, - {0x7FF0000000000000ULL,0x7FF0000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0xFFEFFFFFFFFFFFFFULL,0x0001000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - TestVec64_RemqD test_b[] = { - { - // divide by zero -> nan - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0x7ff8000000000000ULL,0x7ff8000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0x7ff8000000000000ULL,0x7ff8000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL} - },{ - // border - {0xFFE0000000000000ULL,0x7FEFFFFFFFFFFFFFULL}, - {0x0008000000000000ULL,0x0010000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x0000000000000000ULL,0x0000000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060919210000NM","NM", "remquod2"); - - TEST_START("remquod2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - res_v = remquod2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_double2 *)&test_a[ii].yyy[0]), ((vec_llong2 *)&test_a[ii].quo[0])); - sprintf(msg,"2006091921%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].a_res[0])), 0); - sprintf(msg,"2006091922%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( *((vec_llong2 *)&test_a[ii].quo[0]), *((vec_llong2 *)&test_a[ii].a_quo[0])), 0); - } - for (ii=0; ; ii++) { - if ( (test_b[ii].xxx[0] == 0) && (test_b[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - res_v = remquod2 (*((vec_double2 *)&test_b[ii].xxx[0]), *((vec_double2 *)&test_b[ii].yyy[0]), ((vec_llong2 *)&test_b[ii].quo[0])); - sprintf(msg,"2006091923%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_b[ii].a_res[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/remquof4.c b/Extras/simdmathlibrary/spu/tests/remquof4.c deleted file mode 100644 index c350efd1a..000000000 --- a/Extras/simdmathlibrary/spu/tests/remquof4.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Test remquof4 for SPU - 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. - */ - -/* - * copied test data from remainderf4 - * wrong quotient returns in scalar function - */ - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060912170027NM","NM", "remquof4"); - - unsigned int i0n = 0x449edbc6; - unsigned int i0d = 0x40cf799d; - unsigned int i0r = 0x3daa7300; - unsigned int i0q = 4; - unsigned int i1n = 0x6bca107a; - unsigned int i1d = 0x6c4a107a; - unsigned int i1r = 0x6bca107a; - unsigned int i1q = 0; - unsigned int i2n = 0x1c123605; - unsigned int i2d = 0x1c923602; - unsigned int i2r = 0x9c1235ff; - unsigned int i2q = 1; - unsigned int i3n = 0x2b4c50fa; - unsigned int i3d = 0x253a3ae3; - unsigned int i3r = 0xa41873a8; - unsigned int i3q = 6; - unsigned int i4n = 0x73addffc; - unsigned int i4d = 0x742ddffc; - unsigned int i4r = 0x73addffc; - unsigned int i4q = 0; - unsigned int i5n = 0x29d4d97c; - unsigned int i5d = 0x2a546e77; - unsigned int i5r = 0xa9d40372; - unsigned int i5q = 1; - - float x0n = hide_float(make_float(i0n)); - float x0d = hide_float(make_float(i0d)); - float x0r = hide_float(make_float(i0r)); - - float x1n = hide_float(make_float(i1n)); - float x1d = hide_float(make_float(i1d)); - float x1r = hide_float(make_float(i1r)); - - float x2n = hide_float(make_float(i2n)); - float x2d = hide_float(make_float(i2d)); - float x2r = hide_float(make_float(i2r)); - - float x3n = hide_float(make_float(i3n)); - float x3d = hide_float(make_float(i3d)); - float x3r = hide_float(make_float(i3r)); - - float x4n = hide_float(make_float(i4n)); - float x4d = hide_float(make_float(i4d)); - float x4r = hide_float(make_float(i4r)); - - float x5n = hide_float(make_float(i5n)); - float x5d = hide_float(make_float(i5d)); - float x5r = hide_float(make_float(i5r)); - - vec_float4 x0n_v = spu_splats(x0n); - vec_float4 x0d_v = spu_splats(x0d); - vec_float4 x0r_v = spu_splats(x0r); - - vec_float4 x1n_v = spu_splats(x1n); - vec_float4 x1d_v = spu_splats(x1d); - vec_float4 x1r_v = spu_splats(x1r); - - vec_float4 x2n_v = spu_splats(x2n); - vec_float4 x2d_v = spu_splats(x2d); - vec_float4 x2r_v = spu_splats(x2r); - - vec_float4 x3n_v = spu_splats(x3n); - vec_float4 x3d_v = spu_splats(x3d); - vec_float4 x3r_v = spu_splats(x3r); - - vec_float4 x4n_v = spu_splats(x4n); - vec_float4 x4d_v = spu_splats(x4d); - vec_float4 x4r_v = spu_splats(x4r); - - vec_float4 x5n_v = spu_splats(x5n); - vec_float4 x5d_v = spu_splats(x5d); - vec_float4 x5r_v = spu_splats(x5r); - - vec_float4 res_v; - vec_int4 quo_v; - - TEST_START("remquof4"); - res_v = remquof4(x0n_v, x0d_v, &quo_v); - TEST_CHECK("20060912170031NM", allequal_ulps_float4( res_v, x0r_v, 1 ), 0); - TEST_CHECK("20060912170131NM", allequal_int4( quo_v, spu_splats((int)i0q) ), 0); - res_v = remquof4(x1n_v, x1d_v, &quo_v); - TEST_CHECK("20060912170033NM", allequal_ulps_float4( res_v, x1r_v, 1 ), 0); - TEST_CHECK("20060912170133NM", allequal_int4( quo_v, spu_splats((int)i1q) ), 0); - res_v = remquof4(x2n_v, x2d_v, &quo_v); - TEST_CHECK("20060912170034NM", allequal_ulps_float4( res_v, x2r_v, 1 ), 0); - TEST_CHECK("20060912170134NM", allequal_int4( quo_v, spu_splats((int)i2q) ), 0); - res_v = remquof4(x3n_v, x3d_v, &quo_v); - TEST_CHECK("20060912170036NM", allequal_ulps_float4( res_v, x3r_v, 1 ), 0); - TEST_CHECK("20060912170136NM", allequal_int4( quo_v, spu_splats((int)i3q) ), 0); - res_v = remquof4(x4n_v, x4d_v, &quo_v); - TEST_CHECK("20060912170037NM", allequal_ulps_float4( res_v, x4r_v, 1 ), 0); - TEST_CHECK("20060912170137NM", allequal_int4( quo_v, spu_splats((int)i4q) ), 0); - res_v = remquof4(x5n_v, x5d_v, &quo_v); - TEST_CHECK("20060912170038NM", allequal_ulps_float4( res_v, x5r_v, 1 ), 0); - TEST_CHECK("20060912170138NM", allequal_int4( quo_v, spu_splats((int)i5q) ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/rintd2.c b/Extras/simdmathlibrary/spu/tests/rintd2.c deleted file mode 100644 index 7eeb40b18..000000000 --- a/Extras/simdmathlibrary/spu/tests/rintd2.c +++ /dev/null @@ -1,180 +0,0 @@ -/* Test rintd2 for SPU - 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. - */ -/** - * - *@@ rintd2 - Round the input to the nearest integer according to - * the current rounding mode. - * - *@brief - * boundary test for rintd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * add Denormalized handling - * changed over 0x4330000000000000(ABS) handling - * - * - **/ - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int ans0[2]; - unsigned long long int ans1[2]; - unsigned long long int ans2[2]; - unsigned long long int ans3[2]; -} TestVec64_NerI; - -int main() -{ - TestVec64_NerI test_a[] = { - { - // zero - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // border - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL}, - {0xc330000000000000ULL,0x4330000000000000ULL} - },{ - // MIN , MAX - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL} - },{ - // denotmalized - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x0000000000000000ULL}, - {0x8000000000000000ULL,0x3ff0000000000000ULL}, - {0xbff0000000000000ULL,0x0000000000000000ULL} - },{ - // denotmalized - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x3ff0000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0xbff0000000000000ULL} - },{ - // 1.0 - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL} - },{ - // 1.5 - {0x3ff8000000000000ULL,0xbff8000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x4000000000000000ULL,0xbff0000000000000ULL}, - {0x3ff0000000000000ULL,0xc000000000000000ULL} - },{ - // 2.5 - {0x4004000000000000ULL,0xc004000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x4000000000000000ULL,0xc000000000000000ULL}, - {0x4008000000000000ULL,0xc000000000000000ULL}, - {0x4000000000000000ULL,0xc008000000000000ULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060831210000NM","NM", "rintd2"); - - TEST_START("rintd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - spu_mtfpscr(((vec_uint4){0x0000,0,0,0})); - res_v = rintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006083121%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans0[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0500,0,0,0})); - res_v = rintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006083121%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans1[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0a00,0,0,0})); - res_v = rintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006083121%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans2[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0f00,0,0,0})); - res_v = rintd2 (*((vec_double2 *)&test_a[ii].xxx[0])); - sprintf(msg,"2006083121%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans3[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/rintf4.c b/Extras/simdmathlibrary/spu/tests/rintf4.c deleted file mode 100644 index c845240fd..000000000 --- a/Extras/simdmathlibrary/spu/tests/rintf4.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Test rintf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#define DEFINE_DATA(var,a,b) \ - float var = hide_float(a); \ - float var ## _out = hide_float(b); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -/* - */ -#define DEFINE_DATA_UNSIGNED(var,a,b)\ - unsigned int var ## _ina = a ; \ - unsigned int var ## _inb = b ; \ - float var = make_float(var ## _ina); \ - float var ## _out = make_float(var ## _inb); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -#define DO_TEST(var,id) \ - res_v = rintf4(var ## _v); \ - TEST_CHECK(" #id ", allequal_float4( res_v, var ## _out_v ), 0); - - -int main() -{ - vec_float4 res_v; - - TEST_SET_START("184604792300","RNT", "rintf4"); - - - - - //s=0, e=100, f=7fffff --> s=0, e=100, f=7fffff - DEFINE_DATA_UNSIGNED(x1,0x71ffffff,0x71ffffff) - //s=0, e=22, f=0x7fffff --> s=0,e=22,f=0x7ffffe - DEFINE_DATA_UNSIGNED(x2, 0x4affffff,0x4afffffe) - //s=0, e=23, f=0 --> s=0,e=23,f=0 - DEFINE_DATA_UNSIGNED(x3, 0x4b000000,0x4b000000) - //s=0, e=-126, f=0 --> 0 - DEFINE_DATA_UNSIGNED(x4, 0x800000,0x0) - DEFINE_DATA(x5, 1.001f, 1.f) - DEFINE_DATA(x6, -.05f, 0.f) - DEFINE_DATA(x7, 0.9999f, 0.f) - DEFINE_DATA(x8, 0.4999f, 0.f) - - TEST_START("rintf4"); - DO_TEST(x1,184604792301RNT) - DO_TEST(x2,184604792302RNT) - DO_TEST(x3,184604792303RNT) - DO_TEST(x4,184604792304RNT) - DO_TEST(x5,184604792305RNT) - DO_TEST(x6,184604792306RNT) - DO_TEST(x7,184604792307RNT) - DO_TEST(x8,184604792308RNT) - TEST_SET_DONE(); - - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/roundd2.c b/Extras/simdmathlibrary/spu/tests/roundd2.c deleted file mode 100644 index bdb780fe7..000000000 --- a/Extras/simdmathlibrary/spu/tests/roundd2.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Test roundd2 for SPU - 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. - */ -/** - * - *@@ roundd2 - Round the input to the nearest integer. - * - *@brief - * boundary test for nextafterd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef union { - struct { - double xxx[2]; - double ans[2]; - } dbl; - struct { - unsigned long long xxx[2]; - unsigned long long ans[2]; - } ull; -} TestVec_Roundd2; - -int main() -{ - TestVec_Roundd2 test_a[] = { - { - ull:{ - // 0 -> 0 , -0 -> -0 - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // -Inf -> -Inf , Inf -> Inf - {0xFFF0000000000000ULL,0x7FF0000000000000ULL}, - {0xFFF0000000000000ULL,0x7FF0000000000000ULL} - } - },{ - ull:{ - // MAX -> MAX , MIN -> MIN - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x0000000000000001ULL,0x8000000000000010ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x800FFFFFFFFFFFFFULL,0x000FFFFFFFFFFFFFULL}, - {0x8000000000000000ULL,0x0000000000000000ULL} - } - },{ - ull:{ - // border - {0x4320000000000001ULL,0xC320000000000001ULL}, - {0x4320000000000002ULL,0xC320000000000002ULL} - } - },{ - dbl:{ - {1.0, -1.0}, - {1.0, -1.0} - } - },{ - dbl:{ - {-2.5, 3.5}, - {-3.0, 4.0} - } - },{ - ull:{ - // Nan - {0xFFF0000000000001ULL,0x7FF0000000000001ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL} - } - },{ - ull:{ - {0ULL,0ULL}, - {0ULL,0ULL} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060831200000NM","NM", "roundd2"); - - TEST_START("roundd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ull.xxx[0] == 0) && (test_a[ii].ull.xxx[1] == 0) ) break; - - res_v = roundd2 (*((vec_double2 *)&test_a[ii].dbl.xxx[0]) ); - sprintf(msg,"2006083120%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, (vec_llong2)*((vec_double2 *)&test_a[ii].dbl.ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/roundf4.c b/Extras/simdmathlibrary/spu/tests/roundf4.c deleted file mode 100644 index 9bbbcbc97..000000000 --- a/Extras/simdmathlibrary/spu/tests/roundf4.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Test roundf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -// a: float b:float -#define DEFINE_DATA(var,a,b) \ - float var = hide_float(a); \ - float var ## _out = hide_float(b); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -// a: bit pattern b: bit pattern -#define DEFINE_DATA_UNSIGNED(var,a,b) \ - unsigned int var ## _ina = a ; \ - unsigned int var ## _inb = b ; \ - float var = make_float (var ## _ina); \ - float var ## _out = make_float(var ## _inb); \ - vec_float4 var ## _v = spu_splats(var); \ - vec_float4 var ## _out_v = spu_splats(var ## _out); - -#define DO_TEST(var,id) \ - res_v = roundf4(var ## _v); \ - TEST_CHECK(" #id ", allequal_float4( res_v, var ## _out_v ), 0); - - -int main() -{ - vec_float4 res_v; - - TEST_SET_START("164260798500","RUD", "roundf4"); - - - - //s=0 - DEFINE_DATA(x1, 1.0, 1.0f) - DEFINE_DATA(x2, -1.0,-1.0f) - //s=-1 - DEFINE_DATA(x3, 0.5, 1.0f) - DEFINE_DATA(x4, -0.5, -1.0f) - //s=-2 - DEFINE_DATA(x5, 0.25, 0.0f) - //s=-3 - DEFINE_DATA(x6, 0.125, 0.0f) - //s=0, e=128, f=7fffff --> s=0, e=128, f=7fffff - DEFINE_DATA_UNSIGNED(x7,0x7fffffff,0x7fffffff) - //s=0, e=-126, f=0 --> 0 - DEFINE_DATA_UNSIGNED(x8, 0x800000,0x0) - DEFINE_DATA(x9, 0.4999, 0.f) - DEFINE_DATA(x10, 0.9999, 1.f) - - //TEST - TEST_START("roundf4"); - DO_TEST(x1,164260798501RUD) - DO_TEST(x2,164260798502RUD) - DO_TEST(x3,164260798503RUD) - DO_TEST(x4,164260798504RUD) - DO_TEST(x5,164260798505RUD) - DO_TEST(x6,164260798506RUD) - DO_TEST(x7,164260798507RUD) - DO_TEST(x8,164260798508RUD) - DO_TEST(x9,164260798509RUD) - DO_TEST(x10,164260798510RUD) - TEST_SET_DONE(); - - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/rsqrtd2.c b/Extras/simdmathlibrary/spu/tests/rsqrtd2.c deleted file mode 100644 index 52247a304..000000000 --- a/Extras/simdmathlibrary/spu/tests/rsqrtd2.c +++ /dev/null @@ -1,126 +0,0 @@ -/* Test rsqrtd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040928174038EJL","EJL", "rsqrtd2"); - - unsigned long long i6 = 0x7464fff515d76f87ull; - unsigned long long i6r = 0x25b3c03b72dba06cull; - unsigned long long i7 = 0x7606a4533cf5605eull; - unsigned long long i7r = 0x24e3056f4b45f6a9ull; - unsigned long long i8 = 0x4beae58c6f48733eull; - unsigned long long i8r = 0x39f173b787396c5full; - unsigned long long i9 = 0x3999ed5c8316b00bull; - unsigned long long i9r = 0x43192359a70ec761ull; - unsigned long long i10 = 0x68f7885c4b84b793ull; - unsigned long long i10r = 0x2b6a62d48c269d90ull; - unsigned long long i11 = 0x1aabc083c5c26227ull; - unsigned long long i11r = 0x52912e543817fabbull; - - double x0 = hide_double(-HUGE_VAL); // -Inf -> NaN - double x1 = hide_double(HUGE_VAL); // Inf -> +0 - double x2 = hide_double(0.0); // +0 -> Inf - double x3 = hide_double(-0.0); // -0 -> -Inf - double x4 = hide_double(nan("")); // NaN -> NaN - double x5 = hide_double(4.0); - double x5r = hide_double(0.5); - double x6 = hide_double(make_double(i6)); - double x6r = hide_double(make_double(i6r)); - double x7 = hide_double(make_double(i7)); - double x7r = hide_double(make_double(i7r)); - double x8 = hide_double(make_double(i8)); - double x8r = hide_double(make_double(i8r)); - double x9 = hide_double(make_double(i9)); - double x9r = hide_double(make_double(i9r)); - double x10 = hide_double(make_double(i10)); - double x10r = hide_double(make_double(i10r)); - double x11 = hide_double(make_double(i11)); - double x11r = hide_double(make_double(i11r)); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 x1_v = spu_splats(x1); - vec_double2 x2_v = spu_splats(x2); - vec_double2 x3_v = spu_splats(x3); - vec_double2 x4_v = spu_splats(x4); - vec_double2 x5_v = spu_splats(x5); - vec_double2 x5r_v = spu_splats(x5r); - vec_double2 x6_v = spu_splats(x6); - vec_double2 x6r_v = spu_splats(x6r); - vec_double2 x7_v = spu_splats(x7); - vec_double2 x7r_v = spu_splats(x7r); - vec_double2 x8_v = spu_splats(x8); - vec_double2 x8r_v = spu_splats(x8r); - vec_double2 x9_v = spu_splats(x9); - vec_double2 x9r_v = spu_splats(x9r); - vec_double2 x10_v = spu_splats(x10); - vec_double2 x10r_v = spu_splats(x10r); - vec_double2 x11_v = spu_splats(x11); - vec_double2 x11r_v = spu_splats(x11r); - - vec_double2 res_v; - - TEST_START("rsqrtd2"); - res_v = rsqrtd2(x0_v); - TEST_CHECK("20040928174042EJL", allnan_double2( res_v ), 0); - res_v = rsqrtd2(x1_v); - TEST_CHECK("20040928174045EJL", allposzero_double2( res_v ), 0); - res_v = rsqrtd2(x2_v); - TEST_CHECK("20040928174047EJL", allposinf_double2( res_v ), 0); - res_v = rsqrtd2(x3_v); - TEST_CHECK("20040928174049EJL", allneginf_double2( res_v ), 0); - res_v = rsqrtd2(x4_v); - TEST_CHECK("20040928174054EJL", allnan_double2( res_v ), 0); - res_v = rsqrtd2(x5_v); - TEST_CHECK("20040928174058EJL", allequal_double2( res_v, x5r_v ), 0); - res_v = rsqrtd2(x6_v); - TEST_CHECK("20040928174101EJL", allequal_ulps_double2( res_v, x6r_v, 1 ), 0); - res_v = rsqrtd2(x7_v); - TEST_CHECK("20040928174104EJL", allequal_ulps_double2( res_v, x7r_v, 1 ), 0); - res_v = rsqrtd2(x8_v); - TEST_CHECK("20040928174106EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0); - res_v = rsqrtd2(x9_v); - TEST_CHECK("20040928174108EJL", allequal_ulps_double2( res_v, x9r_v, 1 ), 0); - res_v = rsqrtd2(x10_v); - TEST_CHECK("20040928174110EJL", allequal_ulps_double2( res_v, x10r_v, 1 ), 0); - res_v = rsqrtd2(x11_v); - TEST_CHECK("20040928174113EJL", allequal_ulps_double2( res_v, x11r_v, 1 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/rsqrtf4.c b/Extras/simdmathlibrary/spu/tests/rsqrtf4.c deleted file mode 100644 index 898ad5ba0..000000000 --- a/Extras/simdmathlibrary/spu/tests/rsqrtf4.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Test rsqrtf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040928182349EJL","EJL", "rsqrtf4"); - - unsigned int i3 = 0x742c4455; - unsigned int i3r = 0x251c099a; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x243e5fe2; - unsigned int i5 = 0x4baa9e3c; - unsigned int i5r = 0x395dbbeb; - unsigned int i6 = 0x39344296; - unsigned int i6r = 0x429889eb; - unsigned int i7 = 0x68a586b0; - unsigned int i7r = 0x2ae11e67; - - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3r_v = spu_splats(x3r); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4r_v = spu_splats(x4r); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5r_v = spu_splats(x5r); - vec_float4 x6_v = spu_splats(x6); - vec_float4 x6r_v = spu_splats(x6r); - vec_float4 x7_v = spu_splats(x7); - vec_float4 x7r_v = spu_splats(x7r); - - vec_float4 res_v; - - TEST_START("rsqrtf4"); - res_v = rsqrtf4(x3_v); - TEST_CHECK("20040928182352EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = rsqrtf4(x4_v); - TEST_CHECK("20040928182355EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = rsqrtf4(x5_v); - TEST_CHECK("20040928182357EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = rsqrtf4(x6_v); - TEST_CHECK("20040928182358EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = rsqrtf4(x7_v); - TEST_CHECK("20040928182401EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/scalbllnd2.c b/Extras/simdmathlibrary/spu/tests/scalbllnd2.c deleted file mode 100644 index e3484b371..000000000 --- a/Extras/simdmathlibrary/spu/tests/scalbllnd2.c +++ /dev/null @@ -1,251 +0,0 @@ -/* Test scalbllnd2 for SPU - 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. - */ -/** - * - *@@ scalbllnd2 - Multiply Double by 2 Raised to its Power - * For large elements of ex (overflow), returns HUGE_VALF - * For small elements of ex (underflow), returns 0. - * - *@brief - * boundary test for scalbllnd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * add Denormalized handling - * Round mode was passed because of spec. (underflow returns 0) - * - * - **/ - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -#undef SCALBLLND2_ROUND - - -typedef struct { - unsigned long long int xxx[2]; - unsigned long long int exp[2]; - unsigned long long int ans0[2]; - unsigned long long int ans1[2]; - unsigned long long int ans2[2]; - unsigned long long int ans3[2]; -} TestVec64_Ldexp; - -int main() -{ - TestVec64_Ldexp test_a[] = { - { - // zero - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000400ULL,0xFFFFFFFFFFFFFC00ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // MIN , MAX - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL}, - {0xFFEFFFFFFFFFFFFFULL,0x7FEFFFFFFFFFFFFFULL} - },{ - // Inf , -Inf - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL}, - {0x7FF0000000000000ULL,0xFFF0000000000000ULL} - },{ -#ifdef SCALBLLND2_ROUND - // denotmalized - {0x8000000000000003ULL,0x0000000000000003ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x8000000000000002ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000002ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000002ULL,0x0000000000000002ULL} - },{ - // denotmalized -54 - {0x0010000000000001ULL,0x8010000000000001ULL}, - {0xFFFFFFFFFFFFFFCAULL,0xFFFFFFFFFFFFFFCAULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFFFFFFF7CEULL,0xFFFFFFFFFFFFF7CEULL}, - {0x0000000000000001ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000001ULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFFFFFFF7CDULL,0xFFFFFFFFFFFFF7CDULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ -#else // SCALBLLND2_ROUND - // denotmalized - {0x8000000000000003ULL,0x0000000000000003ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL}, - {0x8000000000000001ULL,0x0000000000000001ULL} - },{ - -#endif // SCALBLLND2_ROUND - // denotmalized - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0008000000000000ULL,0x8008000000000000ULL} - },{ - // denotmalized - {0x0008000000000000ULL,0x8008000000000000ULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL}, - {0x0010000000000000ULL,0x8010000000000000ULL} - },{ - // 1.0 - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x00000000000003ffULL,0x00000000000003ffULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL}, - {0x7FE0000000000000ULL,0xFFE0000000000000ULL} - },{ - // 1.0 -> max - {0x3ff0000000000000ULL,0xbff0000000000000ULL}, - {0x0000000000000400ULL,0x0000000000000400ULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - },{ - // max -> ! - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0xFFFFFFFF00000000ULL,0xFFFFFFFF00000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - },{ - // min-> - {0x0000000000000001ULL,0x8000000000000001ULL}, - {0x0FFFFFFFFFFFFFFFULL,0x0FFFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - },{ - // NaN , -NaN - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x0000000000000001ULL,0x0000000000000001ULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL}, - {0x7FFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL} - },{ - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL}, - {0ULL,0ULL} - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060907180000NM","NM", "scalbllnd2"); - - TEST_START("scalbllnd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].xxx[0] == 0) && (test_a[ii].xxx[1] == 0) ) break; - - // set Floating point round mode - spu_mtfpscr(((vec_uint4){0x0100,0,0,0})); - res_v = scalbllnd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090718%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans0[0])), 0); - -#ifdef SCALBLLND2_ROUND - - spu_mtfpscr(((vec_uint4){0x0600,0,0,0})); - res_v = scalbllnd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090718%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans1[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0b00,0,0,0})); - res_v = scalbllnd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090718%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans2[0])), 0); - - spu_mtfpscr(((vec_uint4){0x0c00,0,0,0})); - res_v = scalbllnd2 (*((vec_double2 *)&test_a[ii].xxx[0]), *((vec_llong2 *)&test_a[ii].exp[0])); - sprintf(msg,"2006090718%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, *((vec_llong2 *)&test_a[ii].ans3[0])), 0); -#endif // SCALBLLND2_ROUND - - } - - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/scalbnf4.c b/Extras/simdmathlibrary/spu/tests/scalbnf4.c deleted file mode 100644 index 3961ebdf2..000000000 --- a/Extras/simdmathlibrary/spu/tests/scalbnf4.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test nextafterf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef union { - struct { - float xxx[4]; - int exp[4]; - float ans[4]; - } flt; - struct { - unsigned int xxx[4]; - unsigned int exp[4]; - unsigned int ans[4]; - } ui; -} TestVec_ScalF4; - - -int main() -{ - TestVec_ScalF4 test_a[] = { - { - ui:{ - // 0 -> 0 , -0 -> -0 - {0x00000000,0x80000000,0x80000000,0x00000000}, - {0x000000FF,0x00000001,0xFFFFFFFF,0xFFFFFF00}, - {0x00000000,0x80000000,0x80000000,0x00000000} - } - },{ - ui:{ - // Inf - {0xFF800000,0x7F800000,0x7F800000,0xFF800000}, - {0x000000FF,0x00000001,0xFFFFFFFF,0xFFFFFF00}, - {0xFFFFFFFF,0x7FFFFFFF,0x7F000000,0x80000000} - } - },{ - ui:{ - // MAX MIN - {0x7F7FFFFF,0xFF7FFFFF,0x7F7FFFFF,0xFF7FFFFF}, - {0x00000001,0x00000001,0xFFFFFFFF,0xFFFFFF00}, - {0x7FFFFFFF,0xFFFFFFFF,0x7EFFFFFF,0x00000000} - } - },{ - flt:{ - {-1.0, 1.0, -1.0, 1.0}, - { 1, 1, -1, -1}, - {-2.0, 2.0, -0.5, 0.5} - } - },{ - ui:{ - // - {0x80ffffff,0x80ffffff,0x00ffffff,0x00ffffff}, - {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}, - {0x80000000,0x80000000,0x00000000,0x00000000} - } - },{ - ui:{ - {0,0,0,0}, - {0,0,0,0}, - {0,0,0,0} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_float4 res_v; - - TEST_SET_START("20060907150000NM","NM", "scalbnf4"); - - TEST_START("scalbnf4"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ui.xxx[0] == 0) && (test_a[ii].ui.xxx[1] == 0) ) break; - - res_v = scalbnf4 (*((vec_float4 *)&test_a[ii].flt.xxx[0]), *((vec_int4 *)&test_a[ii].flt.exp[0]) ); - sprintf(msg,"2006090715%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_float4( res_v, *((vec_float4 *)&test_a[ii].flt.ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/signbitd2.c b/Extras/simdmathlibrary/spu/tests/signbitd2.c deleted file mode 100644 index b81d0b98b..000000000 --- a/Extras/simdmathlibrary/spu/tests/signbitd2.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Test signbitd2 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060829000000AAN","AAN", "signbitd2"); - - //-Nan - double x0 = hide_double(-nan("")); - unsigned long long r0 = 0xffffffffffffffffull; - - //-Inf - double x1 = hide_double(-HUGE_VAL); - unsigned long long r1 = 0xffffffffffffffffull; - - //-Smax - double x2 = hide_double(-DBL_MAX); - unsigned long long r2 = 0xffffffffffffffffull; - - //-Norm - double x3 = hide_double(-168.97345223013); - unsigned long long r3 = 0xffffffffffffffffull; - - //-Denorm - double x4 = hide_double(make_double(0x803AAAAAAAAAAAAAull)); - unsigned long long r4 = 0xffffffffffffffffull; - - //-Smin - double x5 = hide_double(-DBL_MIN); - unsigned long long r5 = 0xffffffffffffffffull; - - //-Unf - double x6 = hide_double(-1.0e-999); - unsigned long long r6 = 0xffffffffffffffffull; - - // -0 - double x7 = hide_double(-0.0); - unsigned long long r7 = 0xffffffffffffffffull; - - // 0 - double x8 = hide_double( 0.0); - unsigned long long r8 = 0x0000000000000000ull; - - //+Unf - double x9 = hide_double( 1.0e-999); - unsigned long long r9 = 0x0000000000000000ull; - - //+Smin - double x10 = hide_double( DBL_MIN); - unsigned long long r10 = 0x0000000000000000ull; - - //+Denorm - double x11 = hide_double(make_double(0x007AAAAAAAAAAAAAull)); - unsigned long long r11 = 0x0000000000000000ull; - - //+Norm - double x12 = hide_double( 672953.74593); - unsigned long long r12 = 0x0000000000000000ull; - - //+Smax - double x13 = hide_double( DBL_MAX); - unsigned long long r13 = 0x0000000000000000ull; - - //+Inf - double x14 = hide_double(HUGE_VAL); - unsigned long long r14 = 0x0000000000000000ull; - - //+NaN - double x15 = hide_double( nan("")); - unsigned long long r15 = 0x0000000000000000ull; - - vec_double2 x0_v = spu_splats(x0); - vec_ullong2 r0_v = spu_splats(r0); - - vec_double2 x1_v = spu_splats(x1); - vec_ullong2 r1_v = spu_splats(r1); - - vec_double2 x2_v = spu_splats(x2); - vec_ullong2 r2_v = spu_splats(r2); - - vec_double2 x3_v = spu_splats(x3); - vec_ullong2 r3_v = spu_splats(r3); - - vec_double2 x4_v = spu_splats(x4); - vec_ullong2 r4_v = spu_splats(r4); - - vec_double2 x5_v = spu_splats(x5); - vec_ullong2 r5_v = spu_splats(r5); - - vec_double2 x6_v = spu_splats(x6); - vec_ullong2 r6_v = spu_splats(r6); - - vec_double2 x7_v = spu_splats(x7); - vec_ullong2 r7_v = spu_splats(r7); - - vec_double2 x8_v = spu_splats(x8); - vec_ullong2 r8_v = spu_splats(r8); - - vec_double2 x9_v = spu_splats(x9); - vec_ullong2 r9_v = spu_splats(r9); - - vec_double2 x10_v = spu_splats(x10); - vec_ullong2 r10_v = spu_splats(r10); - - vec_double2 x11_v = spu_splats(x11); - vec_ullong2 r11_v = spu_splats(r11); - - vec_double2 x12_v = spu_splats(x12); - vec_ullong2 r12_v = spu_splats(r12); - - vec_double2 x13_v = spu_splats(x13); - vec_ullong2 r13_v = spu_splats(r13); - - vec_double2 x14_v = spu_splats(x14); - vec_ullong2 r14_v = spu_splats(r14); - - vec_double2 x15_v = spu_splats(x15); - vec_ullong2 r15_v = spu_splats(r15); - - vec_ullong2 res_v; - - TEST_START("signbitd2"); - - res_v = (vec_ullong2)signbitd2(x0_v); - TEST_CHECK("20060829000000AAN", allequal_ullong2( res_v, r0_v ), 0); - res_v = (vec_ullong2)signbitd2(x1_v); - TEST_CHECK("20060829000001AAN", allequal_ullong2( res_v, r1_v ), 0); - res_v = (vec_ullong2)signbitd2(x2_v); - TEST_CHECK("20060829000002AAN", allequal_ullong2( res_v, r2_v ), 0); - res_v = (vec_ullong2)signbitd2(x3_v); - TEST_CHECK("20060829000003AAN", allequal_ullong2( res_v, r3_v ), 0); - res_v = (vec_ullong2)signbitd2(x4_v); - TEST_CHECK("20060829000004AAN", allequal_ullong2( res_v, r4_v ), 0); - res_v = (vec_ullong2)signbitd2(x5_v); - TEST_CHECK("20060829000005AAN", allequal_ullong2( res_v, r5_v ), 0); - res_v = (vec_ullong2)signbitd2(x6_v); - TEST_CHECK("20060829000006AAN", allequal_ullong2( res_v, r6_v ), 0); - res_v = (vec_ullong2)signbitd2(x7_v); - TEST_CHECK("20060829000007AAN", allequal_ullong2( res_v, r7_v ), 0); - res_v = (vec_ullong2)signbitd2(x8_v); - TEST_CHECK("20060829000008AAN", allequal_ullong2( res_v, r8_v ), 0); - res_v = (vec_ullong2)signbitd2(x9_v); - TEST_CHECK("20060829000009AAN", allequal_ullong2( res_v, r9_v ), 0); - res_v = (vec_ullong2)signbitd2(x10_v); - TEST_CHECK("20060829000010AAN", allequal_ullong2( res_v, r10_v ), 0); - res_v = (vec_ullong2)signbitd2(x11_v); - TEST_CHECK("20060829000011AAN", allequal_ullong2( res_v, r11_v ), 0); - res_v = (vec_ullong2)signbitd2(x12_v); - TEST_CHECK("20060829000012AAN", allequal_ullong2( res_v, r12_v ), 0); - res_v = (vec_ullong2)signbitd2(x13_v); - TEST_CHECK("20060829000013AAN", allequal_ullong2( res_v, r13_v ), 0); - res_v = (vec_ullong2)signbitd2(x14_v); - TEST_CHECK("20060829000014AAN", allequal_ullong2( res_v, r14_v ), 0); - res_v = (vec_ullong2)signbitd2(x15_v); - TEST_CHECK("20060829000015AAN", allequal_ullong2( res_v, r15_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/signbitf4.c b/Extras/simdmathlibrary/spu/tests/signbitf4.c deleted file mode 100644 index 156cc2d6e..000000000 --- a/Extras/simdmathlibrary/spu/tests/signbitf4.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Test signbitf4 for SPU - 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. - */ - - -#include -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20060829000000AAN","AAN", "signbitf4"); - - //-Nan - float x0 = hide_float(-NANF); - unsigned int r0 = 0xffffffff; - - //-Inf - float x1 = hide_float(-HUGE_VAL); - unsigned int r1 = 0xffffffff; - - //-Smax - float x2 = hide_float(-FLT_MAX); - unsigned int r2 = 0xffffffff; - - //-Norm - float x3 = hide_float(-168.97345223013f); - unsigned int r3 = 0xffffffff; - - //-Denorm - float x4 = hide_float(make_float(0x803AAAAA)); - unsigned int r4 = 0xffffffff; - - //-Smin - float x5 = hide_float(-FLT_MIN); - unsigned int r5 = 0xffffffff; - - //-Unf - float x6 = hide_float(-1.0e-999); - unsigned int r6 = 0xffffffff; - - // -0 - float x7 = hide_float(-0.0f); - unsigned int r7 = 0xffffffff; - - // 0 - float x8 = hide_float( 0.0f); - unsigned int r8 = 0x00000000; - - //+Unf - float x9 = hide_float( 1.0e-999); - unsigned int r9 = 0x00000000; - - //+Smin - float x10 = hide_float( FLT_MIN); - unsigned int r10 = 0x00000000; - - //+Denorm - float x11 = hide_float(make_float(0x007AAAAA)); - unsigned int r11 = 0x00000000; - - //+Norm - float x12 = hide_float( 672953.74593f); - unsigned int r12 = 0x00000000; - - //+Smax - float x13 = hide_float( FLT_MAX); - unsigned int r13 = 0x00000000; - - //+Inf - float x14 = hide_float(HUGE_VAL); - unsigned int r14 = 0x00000000; - - //+NaN - float x15 = hide_float(NANF); - unsigned int r15 = 0x00000000; - - vec_float4 x0_v = spu_splats(x0); - vec_uint4 r0_v = spu_splats(r0); - - vec_float4 x1_v = spu_splats(x1); - vec_uint4 r1_v = spu_splats(r1); - - vec_float4 x2_v = spu_splats(x2); - vec_uint4 r2_v = spu_splats(r2); - - vec_float4 x3_v = spu_splats(x3); - vec_uint4 r3_v = spu_splats(r3); - - vec_float4 x4_v = spu_splats(x4); - vec_uint4 r4_v = spu_splats(r4); - - vec_float4 x5_v = spu_splats(x5); - vec_uint4 r5_v = spu_splats(r5); - - vec_float4 x6_v = spu_splats(x6); - vec_uint4 r6_v = spu_splats(r6); - - vec_float4 x7_v = spu_splats(x7); - vec_uint4 r7_v = spu_splats(r7); - - vec_float4 x8_v = spu_splats(x8); - vec_uint4 r8_v = spu_splats(r8); - - vec_float4 x9_v = spu_splats(x9); - vec_uint4 r9_v = spu_splats(r9); - - vec_float4 x10_v = spu_splats(x10); - vec_uint4 r10_v = spu_splats(r10); - - vec_float4 x11_v = spu_splats(x11); - vec_uint4 r11_v = spu_splats(r11); - - vec_float4 x12_v = spu_splats(x12); - vec_uint4 r12_v = spu_splats(r12); - - vec_float4 x13_v = spu_splats(x13); - vec_uint4 r13_v = spu_splats(r13); - - vec_float4 x14_v = spu_splats(x14); - vec_uint4 r14_v = spu_splats(r14); - - vec_float4 x15_v = spu_splats(x15); - vec_uint4 r15_v = spu_splats(r15); - - vec_uint4 res_v; - - TEST_START("signbitf4"); - - res_v = (vec_uint4)signbitf4(x0_v); - TEST_CHECK("20060829000000AAN", allequal_uint4( res_v, r0_v ), 0); - res_v = (vec_uint4)signbitf4(x1_v); - TEST_CHECK("20060829000001AAN", allequal_uint4( res_v, r1_v ), 0); - res_v = (vec_uint4)signbitf4(x2_v); - TEST_CHECK("20060829000002AAN", allequal_uint4( res_v, r2_v ), 0); - res_v = (vec_uint4)signbitf4(x3_v); - TEST_CHECK("20060829000003AAN", allequal_uint4( res_v, r3_v ), 0); - res_v = (vec_uint4)signbitf4(x4_v); - TEST_CHECK("20060829000004AAN", allequal_uint4( res_v, r4_v ), 0); - res_v = (vec_uint4)signbitf4(x5_v); - TEST_CHECK("20060829000005AAN", allequal_uint4( res_v, r5_v ), 0); - res_v = (vec_uint4)signbitf4(x6_v); - TEST_CHECK("20060829000006AAN", allequal_uint4( res_v, r6_v ), 0); - res_v = (vec_uint4)signbitf4(x7_v); - TEST_CHECK("20060829000007AAN", allequal_uint4( res_v, r7_v ), 0); - res_v = (vec_uint4)signbitf4(x8_v); - TEST_CHECK("20060829000008AAN", allequal_uint4( res_v, r8_v ), 0); - res_v = (vec_uint4)signbitf4(x9_v); - TEST_CHECK("20060829000009AAN", allequal_uint4( res_v, r9_v ), 0); - res_v = (vec_uint4)signbitf4(x10_v); - TEST_CHECK("20060829000010AAN", allequal_uint4( res_v, r10_v ), 0); - res_v = (vec_uint4)signbitf4(x11_v); - TEST_CHECK("20060829000011AAN", allequal_uint4( res_v, r11_v ), 0); - res_v = (vec_uint4)signbitf4(x12_v); - TEST_CHECK("20060829000012AAN", allequal_uint4( res_v, r12_v ), 0); - res_v = (vec_uint4)signbitf4(x13_v); - TEST_CHECK("20060829000013AAN", allequal_uint4( res_v, r13_v ), 0); - res_v = (vec_uint4)signbitf4(x14_v); - TEST_CHECK("20060829000014AAN", allequal_uint4( res_v, r14_v ), 0); - res_v = (vec_uint4)signbitf4(x15_v); - TEST_CHECK("20060829000015AAN", allequal_uint4( res_v, r15_v ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/sqrtd2.c b/Extras/simdmathlibrary/spu/tests/sqrtd2.c deleted file mode 100644 index 0863949fa..000000000 --- a/Extras/simdmathlibrary/spu/tests/sqrtd2.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Test sqrtd2 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - - -int main() -{ - TEST_SET_START("20040928181417EJL","EJL", "sqrtd2"); - - unsigned long long i6 = 0x7464fff515d76f87ull; - unsigned long long i6r = 0x5a29ec408d8da268ull; - unsigned long long i7 = 0x7606a4533cf5605eull; - unsigned long long i7r = 0x5afaead3b0ed2de5ull; - unsigned long long i8 = 0x4beae58c6f48733eull; - unsigned long long i8r = 0x45ed566b9c6464d6ull; - unsigned long long i9 = 0x3999ed5c8316b00bull; - unsigned long long i9r = 0x3cc45e14871d1b1full; - unsigned long long i10 = 0x68f7885c4b84b793ull; - unsigned long long i10r = 0x54736778e6778980ull; - unsigned long long i11 = 0x1aabc083c5c26227ull; - unsigned long long i11r = 0x2d4dcce790f64a35ull; - - double x0 = hide_double(-HUGE_VAL); // -Inf -> NaN - double x1 = hide_double(HUGE_VAL); // Inf -> Inf - double x2 = hide_double(0.0); // +0 -> +0 - double x3 = hide_double(-0.0); // -0 -> -0 - double x4 = hide_double(nan("")); // NaN -> NaN - double x5 = hide_double(4.0); - double x5r = hide_double(2.0); - double x6 = hide_double(make_double(i6)); - double x6r = hide_double(make_double(i6r)); - double x7 = hide_double(make_double(i7)); - double x7r = hide_double(make_double(i7r)); - double x8 = hide_double(make_double(i8)); - double x8r = hide_double(make_double(i8r)); - double x9 = hide_double(make_double(i9)); - double x9r = hide_double(make_double(i9r)); - double x10 = hide_double(make_double(i10)); - double x10r = hide_double(make_double(i10r)); - double x11 = hide_double(make_double(i11)); - double x11r = hide_double(make_double(i11r)); - - vec_double2 x0_v = spu_splats(x0); - vec_double2 x1_v = spu_splats(x1); - vec_double2 x2_v = spu_splats(x2); - vec_double2 x3_v = spu_splats(x3); - vec_double2 x4_v = spu_splats(x4); - vec_double2 x5_v = spu_splats(x5); - vec_double2 x5r_v = spu_splats(x5r); - vec_double2 x6_v = spu_splats(x6); - vec_double2 x6r_v = spu_splats(x6r); - vec_double2 x7_v = spu_splats(x7); - vec_double2 x7r_v = spu_splats(x7r); - vec_double2 x8_v = spu_splats(x8); - vec_double2 x8r_v = spu_splats(x8r); - vec_double2 x9_v = spu_splats(x9); - vec_double2 x9r_v = spu_splats(x9r); - vec_double2 x10_v = spu_splats(x10); - vec_double2 x10r_v = spu_splats(x10r); - vec_double2 x11_v = spu_splats(x11); - vec_double2 x11r_v = spu_splats(x11r); - - vec_double2 res_v; - - TEST_START("sqrtd2"); - res_v = sqrtd2(x0_v); - TEST_CHECK("20040928181422EJL", allnan_double2( res_v ), 0); - res_v = sqrtd2(x1_v); - TEST_CHECK("20040928181424EJL", allposinf_double2( res_v ), 0); - res_v = sqrtd2(x2_v); - TEST_CHECK("20040928181426EJL", allposzero_double2( res_v ), 0); - res_v = sqrtd2(x3_v); - TEST_CHECK("20040928181430EJL", allnegzero_double2( res_v ), 0); - res_v = sqrtd2(x4_v); - TEST_CHECK("20040928181432EJL", allnan_double2( res_v ), 0); - res_v = sqrtd2(x5_v); - TEST_CHECK("20040928181434EJL", allequal_double2( res_v, x5r_v ), 0); - res_v = sqrtd2(x6_v); - TEST_CHECK("20040928181436EJL", allequal_ulps_double2( res_v, x6r_v, 1 ), 0); - res_v = sqrtd2(x7_v); - TEST_CHECK("20040928181438EJL", allequal_ulps_double2( res_v, x7r_v, 1 ), 0); - res_v = sqrtd2(x8_v); - TEST_CHECK("20040928181440EJL", allequal_ulps_double2( res_v, x8r_v, 1 ), 0); - res_v = sqrtd2(x9_v); - TEST_CHECK("20040928181442EJL", allequal_ulps_double2( res_v, x9r_v, 1 ), 0); - res_v = sqrtd2(x10_v); - TEST_CHECK("20040928181444EJL", allequal_ulps_double2( res_v, x10r_v, 1 ), 0); - res_v = sqrtd2(x11_v); - TEST_CHECK("20040928181446EJL", allequal_ulps_double2( res_v, x11r_v, 1 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/sqrtf4.c b/Extras/simdmathlibrary/spu/tests/sqrtf4.c deleted file mode 100644 index 736f8120e..000000000 --- a/Extras/simdmathlibrary/spu/tests/sqrtf4.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Test sqrtf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -int main() -{ - TEST_SET_START("20040928182549EJL","EJL", "sqrtf4"); - - unsigned int i3 = 0x742c4455; - unsigned int i3r = 0x59d20034; - unsigned int i4 = 0x75e7753f; - unsigned int i4r = 0x5aac1fb5; - unsigned int i5 = 0x4baa9e3c; - unsigned int i5r = 0x4593c7d8; - unsigned int i6 = 0x39344296; - unsigned int i6r = 0x3c56d14c; - unsigned int i7 = 0x68a586b0; - unsigned int i7r = 0x54118f09; - - float x3 = hide_float(make_float(i3)); - float x3r = hide_float(make_float(i3r)); - float x4 = hide_float(make_float(i4)); - float x4r = hide_float(make_float(i4r)); - float x5 = hide_float(make_float(i5)); - float x5r = hide_float(make_float(i5r)); - float x6 = hide_float(make_float(i6)); - float x6r = hide_float(make_float(i6r)); - float x7 = hide_float(make_float(i7)); - float x7r = hide_float(make_float(i7r)); - - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3r_v = spu_splats(x3r); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4r_v = spu_splats(x4r); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5r_v = spu_splats(x5r); - vec_float4 x6_v = spu_splats(x6); - vec_float4 x6r_v = spu_splats(x6r); - vec_float4 x7_v = spu_splats(x7); - vec_float4 x7r_v = spu_splats(x7r); - - vec_float4 res_v; - - TEST_START("sqrtf4"); - res_v = sqrtf4(x3_v); - TEST_CHECK("20040928182552EJL", allequal_ulps_float4( res_v, x3r_v, 2 ), 0); - res_v = sqrtf4(x4_v); - TEST_CHECK("20040928182554EJL", allequal_ulps_float4( res_v, x4r_v, 2 ), 0); - res_v = sqrtf4(x5_v); - TEST_CHECK("20040928182556EJL", allequal_ulps_float4( res_v, x5r_v, 2 ), 0); - res_v = sqrtf4(x6_v); - TEST_CHECK("20040928182557EJL", allequal_ulps_float4( res_v, x6r_v, 2 ), 0); - res_v = sqrtf4(x7_v); - TEST_CHECK("20040928182559EJL", allequal_ulps_float4( res_v, x7r_v, 2 ), 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/simdmathlibrary/spu/tests/testutils.c b/Extras/simdmathlibrary/spu/tests/testutils.c deleted file mode 100644 index 58af0dfc9..000000000 --- a/Extras/simdmathlibrary/spu/tests/testutils.c +++ /dev/null @@ -1,321 +0,0 @@ -/* Common part of testsuite for SPU SIMD Math library - 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. - */ - - -#include -#include -#include -#include "testutils.h" - -typedef union { - unsigned int ui; - float f; -} conv4_t; - -typedef union { - unsigned long long ull; - double df; -} conv8_t; - -unsigned int -hide_uint( unsigned int x ) -{ - return x; -} - -int -hide_int( int x ) -{ - return x; -} - -float -hide_float( float x ) -{ - return x; -} - -double -hide_double( double x ) -{ - return x; -} - -float -make_float( unsigned int x ) -{ - conv4_t val; - val.ui = x; - return val.f; -} - -unsigned int -make_uint( float x ) -{ - conv4_t val; - val.f = x; - return val.ui; -} - -double -make_double( unsigned long long x ) -{ - conv8_t val; - val.ull = x; - return val.df; -} - -unsigned long long -make_ulonglong( double x ) -{ - conv8_t val; - val.df = x; - return val.ull; -} - -vec_uint4 bitDiff_f4(vec_float4 ref, vec_float4 vals) { - vec_int4 refi = (vec_int4)ref; - vec_int4 valsi = (vec_int4)vals; - vec_int4 diff = spu_sub(refi, valsi); - vec_int4 negdiff = spu_sub(spu_splats((int)0), diff); - - return spu_sub((vec_uint4)spu_splats(32), spu_cntlz(spu_sel(negdiff, diff, spu_cmpgt(diff, 0)))); -} - -unsigned int bitDiff_f(float ref, float val) { - return spu_extract(bitDiff_f4(spu_promote(ref,0), spu_promote(val,0)), 0); -} - -vec_ullong2 bitDiff_d2(vec_double2 ref, vec_double2 vals) { - double ref0, ref1, vals0, vals1; - long long refi0, refi1, valsi0, valsi1, diff0, diff1; - vec_ullong2 bits; - - ref0 = spu_extract(ref,0); - ref1 = spu_extract(ref,1); - vals0 = spu_extract(vals,0); - vals1 = spu_extract(vals,1); - - refi0 = make_ulonglong(ref0); - refi1 = make_ulonglong(ref1); - valsi0 = make_ulonglong(vals0); - valsi1 = make_ulonglong(vals1); - - diff0 = refi0 - valsi0; - diff1 = refi1 - valsi1; - - if ( diff0 < 0 ) - { - diff0 = valsi0 - refi0; - } - - if ( diff1 < 0 ) - { - diff1 = valsi1 - refi1; - } - - bits = spu_promote( (unsigned long long)ceil(log2((double)diff0)), 0 ); - bits = spu_insert( (unsigned long long)ceil(log2((double)diff1)), bits, 1 ); - - return bits; -} - -unsigned long long bitDiff_d(double ref, double val) { - return spu_extract(bitDiff_d2(spu_promote(ref,0), spu_promote(val,0)), 0); -} - -vec_uint4 ulpDiff_f4(vec_float4 ref, vec_float4 vals) { - vec_int4 refi = (vec_int4)ref; - vec_int4 valsi = (vec_int4)vals; - vec_int4 diff = spu_sub(refi, valsi); - vec_int4 negdiff = spu_sub(spu_splats((int)0), diff); - - return (vec_uint4)(spu_sel(negdiff, diff, spu_cmpgt(diff, 0))); -} - -unsigned int ulpDiff_f(float ref, float val) { - return spu_extract(ulpDiff_f4(spu_promote(ref,0), spu_promote(val,0)), 0); -} - -vec_ullong2 ulpDiff_d2(vec_double2 ref, vec_double2 vals) { - double ref0, ref1, vals0, vals1; - long long refi0, refi1, valsi0, valsi1, diff0, diff1; - vec_ullong2 ulps; - - ref0 = spu_extract(ref,0); - ref1 = spu_extract(ref,1); - vals0 = spu_extract(vals,0); - vals1 = spu_extract(vals,1); - - refi0 = make_ulonglong(ref0); - refi1 = make_ulonglong(ref1); - valsi0 = make_ulonglong(vals0); - valsi1 = make_ulonglong(vals1); - - diff0 = refi0 - valsi0; - diff1 = refi1 - valsi1; - - if ( diff0 < 0 ) - { - diff0 = valsi0 - refi0; - } - - if ( diff1 < 0 ) - { - diff1 = valsi1 - refi1; - } - - ulps = spu_promote( (unsigned long long)diff0, 0 ); - ulps = spu_insert( (unsigned long long)diff1, ulps, 1 ); - - return ulps; -} - -unsigned long long ulpDiff_d(double ref, double val) { - return spu_extract(ulpDiff_d2(spu_promote(ref,0), spu_promote(val,0)), 0); -} - -vec_ullong2 cmpposzerod2( vec_double2 x ) -{ - vec_ullong2 cmp; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - - cmp = (vec_ullong2)spu_cmpeq( (vec_int4)x, spu_splats(0) ); - cmp = spu_and( spu_shuffle( cmp, cmp, even ), spu_shuffle( cmp, cmp, odd ) ); - - return cmp; -} - -vec_ullong2 cmpnegzerod2( vec_double2 x ) -{ - vec_ullong2 cmp; - vec_uchar16 even = (vec_uchar16)(vec_uint4){ 0x00010203, 0x00010203, 0x08090a0b, 0x08090a0b }; - vec_uchar16 odd = (vec_uchar16)(vec_uint4){ 0x04050607, 0x04050607, 0x0c0d0e0f, 0x0c0d0e0f }; - - cmp = (vec_ullong2)spu_cmpeq( (vec_int4)x, (vec_int4)spu_splats(0x8000000000000000ull) ); - cmp = spu_and( spu_shuffle( cmp, cmp, even ), spu_shuffle( cmp, cmp, odd ) ); - - return cmp; -} - -int allequal_int4( vec_int4 x, vec_int4 y ) -{ - return ( spu_extract( spu_gather( spu_cmpeq( x, y ) ), 0 ) == 0xf ); -} -int allequal_llong2( vec_llong2 x, vec_llong2 y ) -{ - return spu_extract( spu_gather( spu_cmpeq ((vec_int4)(x - y), spu_splats((int)0) )), 0) == 0xF; -} - -int allequal_float4( vec_float4 x, vec_float4 y ) -{ - return ( spu_extract( spu_gather( (vec_uint4)spu_cmpeq( x, y ) ), 0 ) == 0xf ); -} - -int allequal_double2( vec_double2 x, vec_double2 y ) -{ - return ( spu_extract(x,0) == spu_extract(y,0) && spu_extract(x,1) == spu_extract(y,1) ); -} - -int allequal_llroundf4( llroundf4_t x, llroundf4_t y ) -{ - return ( spu_extract(x.vll[0],0) == spu_extract(y.vll[0],0) && - spu_extract(x.vll[0],1) == spu_extract(y.vll[0],1) && - spu_extract(x.vll[1],0) == spu_extract(y.vll[1],0) && - spu_extract(x.vll[1],1) == spu_extract(y.vll[1],1) ); -} - -int allequal_ulps_float4( vec_float4 x, vec_float4 y, int tolerance ) -{ - vec_uint4 ulps = ulpDiff_f4( x, y ); - return ( (int)spu_extract(ulps,0) <= tolerance && - (int)spu_extract(ulps,1) <= tolerance && - (int)spu_extract(ulps,2) <= tolerance && - (int)spu_extract(ulps,3) <= tolerance ); -} - -int allequal_ulps_double2( vec_double2 x, vec_double2 y, int tolerance ) -{ - vec_ullong2 ulps = ulpDiff_d2( x, y ); - return ( (int)spu_extract(ulps,0) <= tolerance && (int)spu_extract(ulps,1) <= tolerance ); -} - -int allequal_bits_float4( vec_float4 x, vec_float4 y, int tolerance ) -{ - vec_uint4 bits = bitDiff_f4( x, y ); - return ( (int)spu_extract(bits,0) <= tolerance && - (int)spu_extract(bits,1) <= tolerance && - (int)spu_extract(bits,2) <= tolerance && - (int)spu_extract(bits,3) <= tolerance ); -} - -int allequal_bits_double2( vec_double2 x, vec_double2 y, int tolerance ) -{ - vec_ullong2 bits = bitDiff_d2( x, y ); - return ( (int)spu_extract(bits,0) <= tolerance && (int)spu_extract(bits,1) <= tolerance ); -} - -int allposinf_double2( vec_double2 x ) -{ - vec_ullong2 posinf = spu_andc( isinfd2 ( x ), signbitd2 ( x ) ); - return ( spu_extract(posinf,0) != 0 && spu_extract(posinf,1) != 0 ); -} - -int allneginf_double2( vec_double2 x ) -{ - vec_ullong2 neginf = spu_and( isinfd2 ( x ), signbitd2 ( x ) ); - return ( spu_extract(neginf,0) != 0 && spu_extract(neginf,1) != 0 ); -} - -int allzerodenorm_double2( vec_double2 x ) -{ - vec_ullong2 zero = is0denormd2 ( x ); - return ( spu_extract(zero,0) != 0 && spu_extract(zero,1) != 0 ); -} - -int allposzero_double2( vec_double2 x ) -{ - vec_ullong2 poszero = cmpposzerod2( x ); - return ( spu_extract(poszero,0) != 0 && spu_extract(poszero,1) != 0 ); -} - -int allnegzero_double2( vec_double2 x ) -{ - vec_ullong2 negzero = cmpnegzerod2( x ); - return ( spu_extract(negzero,0) != 0 && spu_extract(negzero,1) != 0 ); -} - -int allnan_double2( vec_double2 x ) -{ - vec_ullong2 nan = isnand2 ( x ); - return ( spu_extract(nan,0) != 0 && spu_extract(nan,1) != 0 ); -} - - diff --git a/Extras/simdmathlibrary/spu/tests/testutils.h b/Extras/simdmathlibrary/spu/tests/testutils.h deleted file mode 100644 index b557b7601..000000000 --- a/Extras/simdmathlibrary/spu/tests/testutils.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Common part for SPU SIMD Math library testsuite - 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 _TESTUTILS_H_ - -#include - -#define NANF __builtin_nanf("") - -extern unsigned int hide_uint( unsigned int x ); -extern int hide_int( int x ); -extern float hide_float( float x ); -extern double hide_double( double x ); - -extern float make_float( unsigned int x ); -extern unsigned int make_uint( float x ); -extern double make_double( unsigned long long x ); -extern unsigned long long make_ulonglong( double x ); - -extern vec_uint4 bitDiff_f4(vec_float4 ref, vec_float4 vals); -extern unsigned int bitDiff_f(float ref, float val); - -extern vec_ullong2 bitDiff_d2(vec_double2 ref, vec_double2 vals); -extern unsigned long long bitDiff_d(double ref, double val); - -extern vec_uint4 ulpDiff_f4(vec_float4 ref, vec_float4 vals); -extern unsigned int ulpDiff_f(float ref, float val); - -extern vec_ullong2 ulpDiff_d2(vec_double2 ref, vec_double2 vals); -extern unsigned long long ulpDiff_d(double ref, double val); - -extern vec_ullong2 cmpposzerod2( vec_double2 x ); -extern vec_ullong2 cmpnegzerod2( vec_double2 x ); -extern int allequal_int4( vec_int4 x, vec_int4 y ); -static inline int allequal_uint4( vec_uint4 x, vec_uint4 y ) -{ - return allequal_int4 ((vec_int4)x, (vec_int4)y); -} -extern int allequal_llong2( vec_llong2 x, vec_llong2 y ); -static inline int allequal_ullong2( vec_ullong2 x, vec_ullong2 y ) -{ - return allequal_llong2((vec_llong2)x, (vec_llong2)y); -} -extern int allequal_float4( vec_float4 x, vec_float4 y ); -extern int allequal_double2( vec_double2 x, vec_double2 y ); -extern int allequal_llroundf4( llroundf4_t x, llroundf4_t y ); -extern int allequal_ulps_float4( vec_float4 x, vec_float4 y, int tolerance ); -extern int allequal_ulps_double2( vec_double2 x, vec_double2 y, int tolerance ); -extern int allequal_bits_float4( vec_float4 x, vec_float4 y, int tolerance ); -extern int allequal_bits_double2( vec_double2 x, vec_double2 y, int tolerance ); -extern int allposinf_double2( vec_double2 x ); -extern int allneginf_double2( vec_double2 x ); -extern int allzerodenorm_double2( vec_double2 x ); -extern int allposzero_double2( vec_double2 x ); -extern int allnegzero_double2( vec_double2 x ); -extern int allnan_double2( vec_double2 x ); - -#endif diff --git a/Extras/simdmathlibrary/spu/tests/truncd2.c b/Extras/simdmathlibrary/spu/tests/truncd2.c deleted file mode 100644 index 105a72441..000000000 --- a/Extras/simdmathlibrary/spu/tests/truncd2.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Test truncd2 for SPU - 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. - */ -/** - * - *@@ truncd2 - Round the input to the nearest integer. - * Always rounds towards 0. - * - *@brief - * boundary test for nextafterd2. - * - * - *@pre - * - *@criteria - * Run this program and check no error will be occurred. - * - *@note - * - * - **/ - -#include -#include -#include -//#include -#include - -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - -typedef union { - struct { - double xxx[2]; - double ans[2]; - } dbl; - struct { - unsigned long long xxx[2]; - unsigned long long ans[2]; - } ull; -} TestVec_TruncD2; - -int main() -{ - TestVec_TruncD2 test_a[] = { - { - ull:{ - // 0 -> 0 , -0 -> -0 - {0x0000000000000000ULL,0x8000000000000000ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // -Inf -> -Inf , Inf -> Inf - {0xFFF0000000000000ULL,0x7FF0000000000000ULL}, - {0xFFF0000000000000ULL,0x7FF0000000000000ULL} - } - },{ - ull:{ - // MAX -> MAX , MIN -> MIN - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL}, - {0x7FEFFFFFFFFFFFFFULL,0xFFEFFFFFFFFFFFFFULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x0000000000000001ULL,0x8000000000000010ULL}, - {0x0000000000000000ULL,0x8000000000000000ULL} - } - },{ - ull:{ - // Denormalize -> 0 - {0x800FFFFFFFFFFFFFULL,0x000FFFFFFFFFFFFFULL}, - {0x8000000000000000ULL,0x0000000000000000ULL} - } - },{ - dbl:{ - {1.0, -1.0}, - {1.0, -1.0} - } - },{ - dbl:{ - {-2.5, 3.5}, - {-2.0, 3.0} - } - },{ - ull:{ - // Nan - {0xFFF0000000000001ULL,0x7FF0000000000001ULL}, - {0xFFF0000000000001ULL,0x7FF0000000000001ULL} - } - },{ - ull:{ - {0ULL,0ULL}, - {0ULL,0ULL} - } - } - }; - int ii, test_ctr = 1; - char msg[80]; - vec_double2 res_v; - - TEST_SET_START("20060831180000NM","NM", "truncd2"); - - TEST_START("truncd2"); - - for (ii=0; ; ii++) { - if ( (test_a[ii].ull.xxx[0] == 0) && (test_a[ii].ull.xxx[1] == 0) ) break; - - res_v = truncd2 (*((vec_double2 *)&test_a[ii].dbl.xxx[0]) ); - sprintf(msg,"2006083118%04dNM", test_ctr++); - TEST_CHECK(msg, allequal_llong2( (vec_llong2)res_v, (vec_llong2)*((vec_double2 *)&test_a[ii].dbl.ans[0])), 0); - } - - TEST_SET_DONE(); - - TEST_EXIT(); - -} diff --git a/Extras/simdmathlibrary/spu/tests/truncf4.c b/Extras/simdmathlibrary/spu/tests/truncf4.c deleted file mode 100644 index 7085ddd4a..000000000 --- a/Extras/simdmathlibrary/spu/tests/truncf4.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Test trunf4 for SPU - 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. - */ - - -#include -#include -#include -#include "simdmath.h" -#include "common-test.h" -#include "testutils.h" - - -int main() -{ - TEST_SET_START("20040916100012EJL","EJL", "truncf"); - - unsigned int i3 = 0x4affffff; // 2^23 - 0.5, largest truncatable value. - unsigned int i3i = 0x4afffffe; - unsigned int i4 = 0x4b000000; // 2^23, no fractional part. - unsigned int i5 = 0xcf000001; // -2^31, one more large, and negative, value. - - float x0 = hide_float(0.91825f); - float x0i = hide_float(0.0f); - float x1 = hide_float(-0.12958f); - float x1i = hide_float(0.0f); - float x2 = hide_float(-79615.1875f); - float x2i = hide_float(-79615.0f); - float x3 = hide_float(make_float(i3)); - float x3i = hide_float(make_float(i3i)); - float x4 = hide_float(make_float(i4)); - float x4i = hide_float(make_float(i4)); - float x5 = hide_float(make_float(i5)); - float x5i = hide_float(make_float(i5)); - - vec_float4 x0_v = spu_splats(x0); - vec_float4 x0i_v = spu_splats(x0i); - vec_float4 x1_v = spu_splats(x1); - vec_float4 x1i_v = spu_splats(x1i); - vec_float4 x2_v = spu_splats(x2); - vec_float4 x2i_v = spu_splats(x2i); - vec_float4 x3_v = spu_splats(x3); - vec_float4 x3i_v = spu_splats(x3i); - vec_float4 x4_v = spu_splats(x4); - vec_float4 x4i_v = spu_splats(x4i); - vec_float4 x5_v = spu_splats(x5); - vec_float4 x5i_v = spu_splats(x5i); - - float res; - vec_float4 res_v; - - TEST_START("truncf4"); - res_v = truncf4(x0_v); - TEST_CHECK("20040916100023EJL", allequal_float4( res_v, x0i_v ), 0); - res_v = truncf4(x1_v); - TEST_CHECK("20040916100034EJL", allequal_float4( res_v, x1i_v ), 0); - res_v = truncf4(x2_v); - TEST_CHECK("20040916100043EJL", allequal_float4( res_v, x2i_v ), 0); - res_v = truncf4(x3_v); - TEST_CHECK("20040916100054EJL", allequal_float4( res_v, x3i_v ), 0); - res_v = truncf4(x4_v); - TEST_CHECK("20040916100103EJL", allequal_float4( res_v, x4i_v ), 0); - res_v = truncf4(x5_v); - TEST_CHECK("20040916100111EJL", allequal_float4( res_v, x5i_v ), 0); - - TEST_START("truncf"); - res = truncf(x0); - TEST_CHECK("20040916100121EJL", res == x0i, 0); - res = truncf(x1); - TEST_CHECK("20040916100129EJL", res == x1i, 0); - res = truncf(x2); - TEST_CHECK("20040916100136EJL", res == x2i, 0); - res = truncf(x3); - TEST_CHECK("20040916100144EJL", res == x3i, 0); - res = truncf(x4); - TEST_CHECK("20040916100153EJL", res == x4i, 0); - res = truncf(x5); - TEST_CHECK("20040916100200EJL", res == x5i, 0); - - TEST_SET_DONE(); - - TEST_EXIT(); -} diff --git a/Extras/software_cache/cache/CommonPublicLicense-1.0 b/Extras/software_cache/cache/CommonPublicLicense-1.0 deleted file mode 100644 index c9990a7ea..000000000 --- a/Extras/software_cache/cache/CommonPublicLicense-1.0 +++ /dev/null @@ -1,213 +0,0 @@ -Common Public License Version 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and - - b) in the case of each subsequent Contributor: - - i) changes to the Program, and - - ii) additions to the Program; - - where such changes and/or additions to the Program originate from and are -distributed by that particular Contributor. A Contribution 'originates' from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include additions to -the Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) are not -derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors. - -2. GRANT OF RIGHTS - - a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form. - - b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents to make, use, sell, offer to sell, import and otherwise transfer the -Contribution of such Contributor, if any, in source code and object code form. -This patent license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, such -addition of the Contribution causes such combination to be covered by the -Licensed Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed hereunder. - - c) Recipient understands that although each Contributor grants the licenses -to its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - - d) Each Contributor represents that to its knowledge it has sufficient -copyright rights in its Contribution, if any, to grant the copyright license set -forth in this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its -own license agreement, provided that: - - a) it complies with the terms and conditions of this Agreement; and - - b) its license agreement: - - i) effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title and -non-infringement, and implied warranties or conditions of merchantability and -fitness for a particular purpose; - - ii) effectively excludes on behalf of all Contributors all liability for -damages, including direct, indirect, special, incidental and consequential -damages, such as lost profits; - - iii) states that any provisions which differ from this Agreement are offered -by that Contributor alone and not by any other party; and - - iv) states that source code for the Program is available from such -Contributor, and informs licensees how to obtain it in a reasonable manner on or -through a medium customarily used for software exchange. - -When the Program is made available in source code form: - - a) it must be made available under this Agreement; and - - b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the -Program. - -Each Contributor must identify itself as the originator of its Contribution, if -any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor to -control, and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may participate in -any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR -IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement, including but not limited to the risks and costs of -program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with respect to -a patent applicable to software (including a cross-claim or counterclaim in a -lawsuit), then any patent licenses granted by that Contributor to such Recipient -under this Agreement shall terminate as of the date such litigation is filed. In -addition, if Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -IBM is the initial Agreement Steward. IBM may assign the responsibility to serve -as the Agreement Steward to a suitable separate entity. Each new version of the -Agreement will be given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the Agreement -under which it was received. In addition, after a new version of the Agreement -is published, Contributor may elect to distribute the Program (including its -Contributions) under the new version. Except as expressly stated in Sections -2(a) and 2(b) above, Recipient receives no rights or licenses to the -intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation. diff --git a/Extras/software_cache/cache/include/Makefile b/Extras/software_cache/cache/include/Makefile deleted file mode 100644 index 51c620275..000000000 --- a/Extras/software_cache/cache/include/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# --------------------------------------------------------------- -# PLEASE DO NOT MODIFY THIS SECTION -# This prolog section is automatically generated. -# -# (C) Copyright 2001,2006, -# International Business Machines Corporation, -# -# All Rights Reserved. -# --------------------------------------------------------------- -# PROLOG END TAG zYx - -######################################################################## -# Common Makefile -######################################################################## - -INSTALL_DIR = $(SDKINC_spu)/cache - -INSTALL_FILES := api.h \ - defs.h \ - dma.h \ - nway.h \ - nway-lookup.h \ - nway-miss.h \ - nway-opt.h \ - nway-replace.h \ - spe_cache.h - -include ../../../../../make.footer diff --git a/Extras/software_cache/cache/include/README b/Extras/software_cache/cache/include/README deleted file mode 100644 index 85268b860..000000000 --- a/Extras/software_cache/cache/include/README +++ /dev/null @@ -1,32 +0,0 @@ -%% --------------------------------------------------------------- -%% PLEASE DO NOT MODIFY THIS SECTION -%% This prolog section is automatically generated. -%% -%% (C) Copyright 2001,2006, -%% International Business Machines Corporation, -%% -%% All Rights Reserved. -%% --------------------------------------------------------------- -%% PROLOG END TAG zYx -This directory contains implementation of software managed cache for -SPE. Whenever possible, the cache interfaces are implemented as macros -or inline-able functions. - -Depending on compile-time settings, different cache implementations can -be selected. - -The include file heirarchy is: - - + spe_cache.h Top level header. - | - + defs.h Common definitions. - + dma.h Initiate DMA transfers. - + nway.h Top level n-way header. - | - + nway-lookup.h n-way lookup operations. - + nway-miss.h n-way cache miss handler. - + nway-replace.h n-way cache replace handler. - + nway-opt.h "optimized" n-way interfaces. - | - + api.h Basic application interfaces. - diff --git a/Extras/software_cache/cache/include/api.h b/Extras/software_cache/cache/include/api.h deleted file mode 100644 index 85f70f986..000000000 --- a/Extras/software_cache/cache/include/api.h +++ /dev/null @@ -1,31 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* api.h - * - * Copyright (C) 2005 IBM Corp. - * - * Simple API for software managed cache on SPEs. - * A sophisticated application would not use these, - * but rather use the low-level lookup functions. - */ - -#ifndef __SPE_CACHE_API_H__ -#define __SPE_CACHE_API_H__ - -typedef void *spe_cache_entry_t; - -#define spe_cache_rd(ea) _spe_cache_lookup_xfer_wait_(ea, 0, 1) -#define spe_cache_tr(ea) _spe_cache_lookup_xfer_(ea, 0, 1) -#define spe_cache_lr(ea) _spe_cache_lookup_(ea, 0) - -#define spe_cache_wait(entry) _spe_cache_wait_(entry) - -#endif diff --git a/Extras/software_cache/cache/include/cbe_mfc.h b/Extras/software_cache/cache/include/cbe_mfc.h deleted file mode 100644 index a5ed207a5..000000000 --- a/Extras/software_cache/cache/include/cbe_mfc.h +++ /dev/null @@ -1,245 +0,0 @@ -/* @(#)17 1.4 src/include/cbe_mfc.h, sw.includes, sdk_pub 10/11/05 16:00:25 */ -/* -------------------------------------------------------------- */ -/* (C) Copyright 2001,2005, */ -/* International Business Machines Corporation, */ -/* Sony Computer Entertainment Incorporated, */ -/* Toshiba Corporation. */ -/* */ -/* All Rights Reserved. */ -/* -------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -#ifndef _CBEA_MFC_H_ -#define _CBEA_MFC_H_ - -/* This header file contains various definitions related to the Memory Flow - * Controller (MFC) portion of the Cell Broadband Engine Architecture (CBEA). - */ - -/**************************************/ -/* MFC DMA Command Opcode Definitions */ -/**************************************/ - -/****************************************************************************/ -/* MFC DMA Command flags which identify classes of operations. */ -/****************************************************************************/ -/* Note: These flags may be used in conjunction with the base command types - * (i.e. MFC_PUT_CMD, MFC_PUTR_CMD, MFC_GET_CMD, and MFC_SNDSIG_CMD) - * to construct the various command permutations. - */ - -#define MFC_BARRIER_ENABLE 0x01 -#define MFC_FENCE_ENABLE 0x02 -#define MFC_LIST_ENABLE 0x04 /* SPU Only */ -#define MFC_START_ENABLE 0x08 /* proxy Only */ -#define MFC_RESULT_ENABLE 0x10 - -/****************************************************************************/ -/* MFC DMA Put Commands */ -/****************************************************************************/ - -#define MFC_PUT_CMD 0x20 -#define MFC_PUTS_CMD 0x28 /* proxy Only */ -#define MFC_PUTR_CMD 0x30 -#define MFC_PUTF_CMD 0x22 -#define MFC_PUTB_CMD 0x21 -#define MFC_PUTFS_CMD 0x2A /* proxy Only */ -#define MFC_PUTBS_CMD 0x29 /* proxy Only */ -#define MFC_PUTRF_CMD 0x32 -#define MFC_PUTRB_CMD 0x31 -#define MFC_PUTL_CMD 0x24 /* SPU Only */ -#define MFC_PUTRL_CMD 0x34 /* SPU Only */ -#define MFC_PUTLF_CMD 0x26 /* SPU Only */ -#define MFC_PUTLB_CMD 0x25 /* SPU Only */ -#define MFC_PUTRLF_CMD 0x36 /* SPU Only */ -#define MFC_PUTRLB_CMD 0x35 /* SPU Only */ - -/****************************************************************************/ -/* MFC DMA Get Commands */ -/****************************************************************************/ - -#define MFC_GET_CMD 0x40 -#define MFC_GETS_CMD 0x48 /* proxy Only */ -#define MFC_GETF_CMD 0x42 -#define MFC_GETB_CMD 0x41 -#define MFC_GETFS_CMD 0x4A /* proxy Only */ -#define MFC_GETBS_CMD 0x49 /* proxy Only */ -#define MFC_GETL_CMD 0x44 /* SPU Only */ -#define MFC_GETLF_CMD 0x46 /* SPU Only */ -#define MFC_GETLB_CMD 0x45 /* SPU Only */ - -/****************************************************************************/ -/* MFC DMA Storage Control Commands */ -/****************************************************************************/ -/* Note: These are only supported on implementations with a SL1 cache - * They are no-ops on the initial (CBE) implementation. - */ - -#define MFC_SDCRT_CMD 0x80 -#define MFC_SDCRTST_CMD 0x81 -#define MFC_SDCRZ_CMD 0x89 -#define MFC_SDCRS_CMD 0x8D -#define MFC_SDCRF_CMD 0x8F - -/****************************************************************************/ -/* MFC Synchronization Commands */ -/****************************************************************************/ - -#define MFC_GETLLAR_CMD 0xD0 /* SPU Only */ -#define MFC_PUTLLC_CMD 0xB4 /* SPU Only */ -#define MFC_PUTLLUC_CMD 0xB0 /* SPU Only */ -#define MFC_PUTQLLUC_CMD 0xB8 /* SPU Only */ - -#define MFC_SNDSIG_CMD 0xA0 -#define MFC_SNDSIGB_CMD 0xA1 -#define MFC_SNDSIGF_CMD 0xA2 -#define MFC_BARRIER_CMD 0xC0 -#define MFC_EIEIO_CMD 0xC8 -#define MFC_SYNC_CMD 0xCC - - -/****************************************************************************/ -/* Definitions for constructing a 32-bit command word including the transfer - * and replacement class id and the command opcode. - */ -/****************************************************************************/ -#define MFC_TCLASS(_tid) ((_tid) << 24) -#define MFC_RCLASS(_rid) ((_rid) << 16) - -#define MFC_CMD_WORD(_tid, _rid, _cmd) (MFC_TCLASS(_tid) | MFC_RCLASS(_rid) | (_cmd)) - -/****************************************************************************/ -/* Definitions for constructing a 64-bit command word including the size, tag, - * transfer and replacement class id and the command opcode. - */ -/****************************************************************************/ -#define MFC_SIZE(_size) ((unsigned long long)(_size) << 48) -#define MFC_TAG(_tag_id) ((unsigned long long)(_tag_id) << 32) -#define MFC_TR_CMD(_trcmd) ((unsigned long long)(_trcmd)) - -#define MFC_CMD_DWORD(_size, _tag_id, _trcmd) (MFC_SIZE(_size) | MFC_TAG(_tag_id) | MFC_TR_CMD(_trcmd)) - -/****************************************************************************/ -/* Mask definitions for obtaining DMA commands and class ids from packed words. - */ -/****************************************************************************/ -#define MFC_CMD_MASK 0x0000FFFF -#define MFC_CLASS_MASK 0x000000FF - -/****************************************************************************/ -/* DMA max/min size definitions. */ -/****************************************************************************/ -#define MFC_MIN_DMA_SIZE_SHIFT 4 /* 16 bytes */ -#define MFC_MAX_DMA_SIZE_SHIFT 14 /* 16384 bytes */ - -#define MFC_MIN_DMA_SIZE (1 << MFC_MIN_DMA_SIZE_SHIFT) -#define MFC_MAX_DMA_SIZE (1 << MFC_MAX_DMA_SIZE_SHIFT) - -#define MFC_MIN_DMA_SIZE_MASK (MFC_MIN_DMA_SIZE - 1) -#define MFC_MAX_DMA_SIZE_MASK (MFC_MAX_DMA_SIZE - 1) - -#define MFC_MIN_DMA_LIST_SIZE 0x0008 /* 8 bytes */ -#define MFC_MAX_DMA_LIST_SIZE 0x4000 /* 16K bytes */ - -/****************************************************************************/ -/* Mask definition for checking proper address alignment. */ -/****************************************************************************/ -#define MFC_ADDR_MATCH_MASK 0xF -#define MFC_BEST_ADDR_ALIGNMENT 0x80 - -/****************************************************************************/ -/* Definitions related to the Proxy DMA Command Status register (DMA_CMDStatus). - */ -/****************************************************************************/ -#define MFC_PROXY_DMA_CMD_ENQUEUE_SUCCESSFUL 0x00 -#define MFC_PROXY_DMA_CMD_SEQUENCE_ERROR 0x01 -#define MFC_PROXY_DMA_QUEUE_FULL 0x02 - -/****************************************************************************/ -/* Definitions related to the DMA Queue Status register (DMA_QStatus). */ -/****************************************************************************/ -#define MFC_PROXY_MAX_QUEUE_SPACE 0x08 -#define MFC_PROXY_DMA_Q_EMPTY 0x80000000 -#define MFC_PROXY_DMA_Q_FREE_SPACE_MASK 0x0000FFFF - -#define MFC_SPU_MAX_QUEUE_SPACE 0x10 - -/****************************************************************************/ -/* Definitions related to the Proxy Tag-Group Query-Type register - * (Prxy_QueryType). - */ -/****************************************************************************/ -#define MFC_PROXY_DMA_QUERYTYPE_ANY 0x1 -#define MFC_PROXY_DMA_QUERYTYPE_ALL 0x2 - -/****************************************************************************/ -/* Definitions related to the Proxy Tag-Group Query-Mask (Prxy_QueryMask) - * and PU Tag Status (DMA_TagStatus) registers. - * - * NOTE: The only use the bottom 5 bits of the tag id value passed to insure - * a valid tag id is used. - */ -/****************************************************************************/ - -#define MFC_TAGID_TO_TAGMASK(tag_id) (1 << (tag_id & 0x1F)) - -/****************************************************************************/ -/* Definitions related to the Mailbox Status register (SPU_Mbox_Stat) and the - * depths of the outbound Mailbox Register (SPU_OutMbox), the outbound - * interrupting Mailbox Register (SPU_OutIntrMbox), and the inbound Mailbox - * Register (SPU_In_Mbox). - */ -/****************************************************************************/ -#define MFC_SPU_OUT_MBOX_COUNT_STATUS_MASK 0x000000FF -#define MFC_SPU_OUT_MBOX_COUNT_STATUS_SHIFT 0x0 -#define MFC_SPU_IN_MBOX_COUNT_STATUS_MASK 0x0000FF00 -#define MFC_SPU_IN_MBOX_COUNT_STATUS_SHIFT 0x8 -#define MFC_SPU_OUT_INTR_MBOX_COUNT_STATUS_MASK 0x00FF0000 -#define MFC_SPU_OUT_INTR_MBOX_COUNT_STATUS_SHIFT 0x10 - -/****************************************************************************/ -/* Definitions related to the SPC Multi Source Syncronization register - * (MFC_MSSync). - */ -/****************************************************************************/ -#define MFC_SPC_MSS_STATUS_MASK 0x1 -#define MFC_SPC_MSS_COMPLETE 0x0 -#define MFC_SPC_MSS_NOT_COMPLETE 0x1 - - -/******************************************* - * Channel Defines - *******************************************/ - -/* Events Defines for channels: - * 0 (SPU_RdEventStat), - * 1 (SPU_WrEventMask), and - * 2 (SPU_WrEventAck). - */ -#define MFC_TAG_STATUS_UPDATE_EVENT 0x00000001 -#define MFC_LIST_STALL_NOTIFY_EVENT 0x00000002 -#define MFC_COMMAND_QUEUE_AVAILABLE_EVENT 0x00000008 -#define MFC_IN_MBOX_AVAILABLE_EVENT 0x00000010 -#define MFC_DECREMENTER_EVENT 0x00000020 -#define MFC_OUT_INTR_MBOX_AVAILABLE_EVENT 0x00000040 -#define MFC_OUT_MBOX_AVAILABLE_EVENT 0x00000080 -#define MFC_SIGNAL_NOTIFY_2_EVENT 0x00000100 -#define MFC_SIGNAL_NOTIFY_1_EVENT 0x00000200 -#define MFC_LLR_LOST_EVENT 0x00000400 -#define MFC_PRIV_ATTN_EVENT 0x00000800 -#define MFC_MULTI_SRC_SYNC_EVENT 0x00001000 - - - -/* Tag Status Update defines for channel 23 (MFC_WrTagUpdate) - */ -#define MFC_TAG_UPDATE_IMMEDIATE 0x0 -#define MFC_TAG_UPDATE_ANY 0x1 -#define MFC_TAG_UPDATE_ALL 0x2 - -/* Atomic Command Status defines for channel 27 (MFC_RdAtomicStat) - */ -#define MFC_PUTLLC_STATUS 0x00000001 -#define MFC_PUTLLUC_STATUS 0x00000002 -#define MFC_GETLLAR_STATUS 0x00000004 - -#endif /* _CBEA_MFC_H_ */ diff --git a/Extras/software_cache/cache/include/defs.h b/Extras/software_cache/cache/include/defs.h deleted file mode 100644 index 6b22224a7..000000000 --- a/Extras/software_cache/cache/include/defs.h +++ /dev/null @@ -1,149 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* spe_cache_defs.h - * - * Copyright (C) 2005 IBM Corp. - * - * Internal definitions for software managed cache. - */ - -#ifndef __SPE_CACHE_DEFS_H__ -#define __SPE_CACHE_DEFS_H__ - -/** - ** Defn's for number of cache sets. - ** Default is 64 sets. - */ -#if (SPE_CACHE_NSETS==1024) -#define SPE_CACHE_NSETS_SHIFT 10 -#elif (SPE_CACHE_NSETS==512) -#define SPE_CACHE_NSETS_SHIFT 9 -#elif (SPE_CACHE_NSETS==256) -#define SPE_CACHE_NSETS_SHIFT 8 -#elif (SPE_CACHE_NSETS==128) -#define SPE_CACHE_NSETS_SHIFT 7 -#elif (SPE_CACHE_NSETS==64) -#define SPE_CACHE_NSETS_SHIFT 6 -#elif (SPE_CACHE_NSETS==32) -#define SPE_CACHE_NSETS_SHIFT 5 -#elif (SPE_CACHE_NSETS==16) -#define SPE_CACHE_NSETS_SHIFT 4 -#elif (SPE_CACHE_NSETS==8) -#define SPE_CACHE_NSETS_SHIFT 3 -#elif (SPE_CACHE_NSETS==4) -#define SPE_CACHE_NSETS_SHIFT 2 -#elif (SPE_CACHE_NSETS==2) -#define SPE_CACHE_NSETS_SHIFT 1 -#else -#undef SPE_CACHE_NSETS -#define SPE_CACHE_NSETS 64 -#define SPE_CACHE_NSETS_SHIFT 6 -#endif - -/** - ** Defn's for cachline size (bytes). - ** Default is 128 bytes. - */ -#if (SPE_CACHELINE_SIZE==512) -#define SPE_CACHELINE_SHIFT 9 -#elif (SPE_CACHELINE_SIZE==256) -#define SPE_CACHELINE_SHIFT 8 -#elif (SPE_CACHELINE_SIZE==128) -#define SPE_CACHELINE_SHIFT 7 -#elif (SPE_CACHELINE_SIZE==64) -#define SPE_CACHELINE_SHIFT 6 -#elif (SPE_CACHELINE_SIZE==32) -#define SPE_CACHELINE_SHIFT 5 -#else -#undef SPE_CACHELINE_SIZE -#define SPE_CACHELINE_SIZE 128 -#define SPE_CACHELINE_SHIFT 7 -#endif - -/** - ** Defn's derived from above settings. - */ -#define SPE_CACHE_NSETS_MASK (SPE_CACHE_NSETS - 1) -#define SPE_CACHELINE_MASK (SPE_CACHELINE_SIZE - 1) - -/** - ** Defn's for managing cacheline state. - */ -#define SPE_CACHELINE_DIRTY 0x1 -#define SPE_CACHELINE_LOCKED 0x2 -#define SPE_CACHELINE_STATE_MASK (SPE_CACHELINE_DIRTY | SPE_CACHELINE_LOCKED) - -#ifdef _XLC -/** - * FIXME: For now disable manual branch hints - * on XLC due to performance degradation. - */ -#ifndef likely -#define likely(_c) (_c) -#define unlikely(_c) (_c) -#endif - -#else /* !_XLC */ - -#ifndef likely -#define likely(_c) __builtin_expect((_c), 1) -#define unlikely(_c) __builtin_expect((_c), 0) -#endif -#endif - - -/** - ** Debug controls. Set -DNDEBUG to - ** disable both panic and assert. - */ -#include -#define _spe_cache_panic_(c) assert(c) -#ifdef SPE_CACHE_DBG -#define _spe_cache_assert_(c) assert(c) -#else -#define _spe_cache_assert_(c) /* No-op. */ -#endif - -#define _spe_cacheline_byte_offset_(ea) \ - ((ea) & SPE_CACHELINE_MASK) - -#define _spe_cacheline_byte_offset_x4(ea) \ - spu_and ((ea), SPE_CACHELINE_MASK) - -#endif - -static __inline vector unsigned int _load_vec_uint4(unsigned int ui1, unsigned int ui2, unsigned int ui3, unsigned int ui4) -{ - vector unsigned int result; - vector unsigned int iv1, iv2, iv3, iv4; - - vector unsigned char shuffle = VEC_LITERAL(vector unsigned char, - 0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); - iv1 = spu_promote(ui1, 0); - iv2 = spu_promote(ui2, 0); - iv3 = spu_promote(ui3, 0); - iv4 = spu_promote(ui4, 0); - - result = spu_or(spu_shuffle(iv1, iv2, shuffle), spu_shuffle(iv3, iv4, spu_rlqwbyte(shuffle, 8))); - return (result); -} - -static __inline vector unsigned int _pack_vec_uint4(vector unsigned int ui1, vector unsigned int ui2, vector unsigned int ui3, vector unsigned int ui4) -{ - vector unsigned int result; - vector unsigned char shuffle = VEC_LITERAL(vector unsigned char, - 0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80); - - result = spu_or(spu_shuffle(ui1, ui2, shuffle), spu_shuffle(ui3, ui4, spu_rlqwbyte(shuffle, 8))); - return (result); -} diff --git a/Extras/software_cache/cache/include/dma.h b/Extras/software_cache/cache/include/dma.h deleted file mode 100644 index e4ee89131..000000000 --- a/Extras/software_cache/cache/include/dma.h +++ /dev/null @@ -1,40 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* dma.h - * - * Copyright (C) 2005 IBM Corp. - * - * Internal DMA utilities for software - * managed cache. - */ - -#ifndef __SPE_CACHE_DMA_H__ -#define __SPE_CACHE_DMA_H__ - -#define SPE_CACHE_TAGID_SHIFT (SPE_CACHELINE_SHIFT + SPE_CACHE_NWAY_SHIFT) - -#define _SPE_CACHELINE_TAGID(_ptr) (16) -#define _SPE_CACHELINE_TAGMASK(_ptr) (1 << 16) - -#define SPE_CACHELINE_TAGID(_line) \ - _SPE_CACHELINE_TAGID(&spe_cache_mem[_line]) -#define SPE_CACHELINE_TAGMASK(_line) \ - _SPE_CACHELINE_TAGMASK(&spe_cache_mem[_line]) - -#ifndef SPE_CACHE_SET_TAGID -#define SPE_CACHE_SET_TAGID(set) ((set) & 0x1f) -#endif -#define SPE_CACHE_SET_TAGMASK(set) (1 << SPE_CACHE_SET_TAGID(set)) - -#define SPE_CACHE_PUT MFC_PUTF_CMD -#define SPE_CACHE_GET MFC_GET_CMD - -#endif diff --git a/Extras/software_cache/cache/include/ilog2.h b/Extras/software_cache/cache/include/ilog2.h deleted file mode 100644 index 37fa2c6f0..000000000 --- a/Extras/software_cache/cache/include/ilog2.h +++ /dev/null @@ -1,35 +0,0 @@ -/* @(#)12 1.5 src/lib/math/ilog2.h, sw.lib, sdk_pub 10/11/05 15:35:56 */ -/* -------------------------------------------------------------- */ -/* (C) Copyright 2001,2005, */ -/* International Business Machines Corporation, */ -/* Sony Computer Entertainment Incorporated, */ -/* Toshiba Corporation. */ -/* */ -/* All Rights Reserved. */ -/* -------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -#ifndef _ILOG2_H_ -#define _ILOG2_H_ 1 - -/* - * FUNCTION - * signed int _ilog2(signed int x) - * - * DESCRIPTION - * _ilog2 computes ceiling of log (base 2) of the input value x. - * The input value, x, must be a non-zero positive value. - */ - -static __inline signed int _ilog2(signed int x) -{ -#ifdef __SPU__ - return (32 - spu_extract(spu_cntlz(spu_promote(x - 1, 0)), 0)); -#else - signed int result; - - for (result=0, x--; x > 0; result++, x>>=1); - return (result); -#endif -} - -#endif /* _ILOG2_H_ */ diff --git a/Extras/software_cache/cache/include/memset.h b/Extras/software_cache/cache/include/memset.h deleted file mode 100644 index 5dbdbacf5..000000000 --- a/Extras/software_cache/cache/include/memset.h +++ /dev/null @@ -1,68 +0,0 @@ -/* @(#)85 1.4 src/lib/c/memset.h, sw.lib, sdk_pub 10/13/05 10:17:09 */ -/* -------------------------------------------------------------- */ -/* (C) Copyright 2001,2005, */ -/* International Business Machines Corporation, */ -/* Sony Computer Entertainment Incorporated, */ -/* Toshiba Corporation. */ -/* */ -/* All Rights Reserved. */ -/* -------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -#include -#include - -/* Fills the first n bytes of the memory area pointed to by s - * with the constant byte c. Returns a pointer to the memory area s. - */ -static __inline void * _memset(void *s, int c, size_t n) -{ - int skip, cnt, i; - vec_uchar16 *vs; - vec_uchar16 vc, mask; - - vs = (vec_uchar16 *)(s); - vc = spu_splats((unsigned char)c); - cnt = (int)(n); - - /* Handle any leading partial quadwords as well a - * very short settings (ie, such that the n characters - * all reside in a single quadword. - */ - skip = (int)(s) & 15; - if (skip) { - mask = spu_rlmaskqwbyte((vec_uchar16)(-1), 0-skip); - cnt -= 16 - skip; - if (cnt < 0) { - mask = spu_and(mask, spu_slqwbyte((vec_uchar16)(-1), (unsigned int)(-cnt))); - } - *vs = spu_sel(*vs, vc, mask); - vs++; - } - - /* Handle 8 quadwords at a time - */ - for (i=127; i 0) { - mask = spu_slqwbyte((vec_uchar16)(-1), (unsigned int)(16-cnt)); - *vs = spu_sel(*vs, vc, mask); - } - - return (s); -} diff --git a/Extras/software_cache/cache/include/nway-lookup.h b/Extras/software_cache/cache/include/nway-lookup.h deleted file mode 100644 index c12218fcd..000000000 --- a/Extras/software_cache/cache/include/nway-lookup.h +++ /dev/null @@ -1,194 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* nway-lookup.h - * - * Copyright (C) 2005 IBM Corp. - * - * Internal lookup operations for software - * managed cache. - * - * See nway-opt.h for "optimized" nway - * lookup operations. - */ - -#ifndef __SPE_CACHE_NWAY_LOOKUP_H_ -#define __SPE_CACHE_NWAY_LOOKUP_H_ - - -/** - * _decl_set_entries_ - * Load up set entries (by 4) from an n-way - * set associative cache. Mask off the dirty - * bit, as needed. - */ -#define _decl_set_entries_(set, name, index) \ - vec_uint4 name = *((vec_uint4 *) &spe_cache_dir[set][index]) - - -#define _spe_cache_4_way_lookup_(set, ea) \ -({ \ - _decl_set_entries_(set, e0123, 0); \ - spu_gather(spu_cmpeq(e0123, ea)); \ -}) - -/** - * _spe_cache_set_lookup_ - * Compare 'ea' against all entries of - * a set, and return a result that is - * consistent with spu_gather(). - */ -#define _spe_cache_set_lookup_(set, ea) \ - _spe_cache_4_way_lookup_(set, ea) - - -/** - * _spe_cache_nway_lookup_x4_ - * Declare local variables and lookup four addresses - * in the n-way set associative cache. Upon return, - * 'idx_x4' contains the matching elements in the sets, - * or -1 if not found. - */ -#define _spe_cache_nway_lookup_x4(ea_x4, set_x4, idx_x4) \ -({ \ - vector unsigned int ea_aligned_x4 = spu_and ((ea_x4), ~SPE_CACHELINE_MASK); \ - vector unsigned char splat0 = VEC_LITERAL(vector unsigned char, \ - 0x00, 0x01, 0x02, 0x03, \ - 0x00, 0x01, 0x02, 0x03, \ - 0x00, 0x01, 0x02, 0x03, \ - 0x00, 0x01, 0x02, 0x03); \ - vector unsigned char splat1 = VEC_LITERAL(vector unsigned char, \ - 0x04, 0x05, 0x06, 0x07, \ - 0x04, 0x05, 0x06, 0x07, \ - 0x04, 0x05, 0x06, 0x07, \ - 0x04, 0x05, 0x06, 0x07); \ - vector unsigned char splat2 = VEC_LITERAL(vector unsigned char, \ - 0x08, 0x09, 0x0a, 0x0b, \ - 0x08, 0x09, 0x0a, 0x0b, \ - 0x08, 0x09, 0x0a, 0x0b, \ - 0x08, 0x09, 0x0a, 0x0b); \ - vector unsigned char splat3 = VEC_LITERAL(vector unsigned char, \ - 0x0c, 0x0d, 0x0e, 0x0f, \ - 0x0c, 0x0d, 0x0e, 0x0f, \ - 0x0c, 0x0d, 0x0e, 0x0f, \ - 0x0c, 0x0d, 0x0e, 0x0f); \ - vec_uint4 ea_aligned0 = spu_shuffle(ea_aligned_x4, ea_aligned_x4, splat0); \ - vec_uint4 ea_aligned1 = spu_shuffle(ea_aligned_x4, ea_aligned_x4, splat1); \ - vec_uint4 ea_aligned2 = spu_shuffle(ea_aligned_x4, ea_aligned_x4, splat2); \ - vec_uint4 ea_aligned3 = spu_shuffle(ea_aligned_x4, ea_aligned_x4, splat3); \ - vec_uint4 found0, found1, found2, found3; \ - vec_uint4 found_x4; \ - (set_x4) = _spe_cache_set_num_x4(ea_x4); \ - found0 = _spe_cache_set_lookup_(spu_extract (set_x4, 0), ea_aligned0); \ - found1 = _spe_cache_set_lookup_(spu_extract (set_x4, 1), ea_aligned1); \ - found2 = _spe_cache_set_lookup_(spu_extract (set_x4, 2), ea_aligned2); \ - found3 = _spe_cache_set_lookup_(spu_extract (set_x4, 3), ea_aligned3); \ - found_x4 = _pack_vec_uint4 (found0, found1, found2, found3); \ - (idx_x4) = (vector signed int)_spe_cache_idx_num_x4(found_x4); \ -}) - -#define _spe_cache_nway_lookup_(ea, set, idx) \ -({ \ - unsigned int ea_aligned = (ea) & ~SPE_CACHELINE_MASK; \ - vec_uint4 ea_aligned4 = spu_splats(ea_aligned); \ - vec_uint4 found; \ - (set) = _spe_cache_set_num_(ea); \ - found = _spe_cache_set_lookup_(set, ea_aligned4); \ - (idx) = _spe_cache_idx_num_(found); \ -}) - -/** - * _spe_cache_lookup_ - * Lookup and return the LSA of an EA - * that is known to be in the cache. - */ -#define _spe_cache_lookup_(ea, is_write) \ -({ \ - int set, idx, line, byte; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - \ - line = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - (void *) &spe_cache_mem[line + byte]; \ -}) - -/** - * _spe_cache_wait_ - * Wait for transfer of a cache line - * to complete. - */ -#define _spe_cache_wait_(_lsa) \ -({ \ - spu_writech(22, _SPE_CACHELINE_TAGMASK(_lsa)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ -}) - -/** - * _spe_cache_lookup_wait_ - * Lookup and return the LSA of an EA - * that is known to be in the cache, - * and guarantee that its transfer is - * complete. - */ -#define _spe_cache_lookup_wait_(ea, is_write) \ -({ \ - int set, idx, line, byte; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - \ - line = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - spu_writech(22, SPE_CACHE_SET_TAGMASK(set)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ - (void *) &spe_cache_mem[line + byte]; \ -}) - -/** - * _spe_cache_lookup_xfer_ - * Lookup and return the LSA of an EA, where - * the line may either be in the cache or not. - * If not, initiate transfer but do not wait - * for completion. - */ -#define _spe_cache_lookup_xfer_(ea, is_write, rb) \ -({ \ - int set, idx, line, byte; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - \ - if (unlikely(idx < 0)) { \ - idx = _spe_cache_miss_(ea, set, -1); \ - } \ - line = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - (void *) &spe_cache_mem[line + byte]; \ -}) - -/** - * _spe_cache_lookup_xfer_wait_ - * Lookup and return the LSA of an EA, where - * the line may either be in the cache or not. - * If not, initiate transfer and guarantee - * completion. - */ -#define _spe_cache_lookup_xfer_wait_(ea, is_write, rb) \ -({ \ - int set, idx, line, byte; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - \ - if (unlikely(idx < 0)) { \ - idx = _spe_cache_miss_(ea, set, -1); \ - spu_writech(22, SPE_CACHE_SET_TAGMASK(set)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ - } \ - line = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - (void *) &spe_cache_mem[line + byte]; \ -}) - -#endif diff --git a/Extras/software_cache/cache/include/nway-miss.h b/Extras/software_cache/cache/include/nway-miss.h deleted file mode 100644 index dfe50f2ae..000000000 --- a/Extras/software_cache/cache/include/nway-miss.h +++ /dev/null @@ -1,51 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* nway-miss.h - * - * Copyright (C) 2005 IBM Corp. - * - * Internal handler for cache misses. - */ - -#ifndef __SPE_CACHE_NWAY_MISS_H__ -#define __SPE_CACHE_NWAY_MISS_H__ - -static int _spe_cache_miss_(unsigned int ea, int set, int avail) -{ - unsigned int ea_aligned = ea & ~SPE_CACHELINE_MASK; - vec_uint4 slot; - vec_uint4 exists = _spe_cache_set_lookup_(set, ea_aligned); - int idx, line; - - /* Double check to make sure that the entry has not - * already been allocated in this set. This condition - * might occur if multiple lookups are being perfomed - * simultaneously. - */ - if (unlikely(spu_extract(exists, 0) != 0)) { - return _spe_cache_idx_num_(exists); - } - - /* Now check to see if there are empty slots - * that are available in the set. - */ - slot = _spe_cache_replace_(set, avail); - idx = _spe_cache_idx_num_(slot); - line = _spe_cacheline_num_(set, idx); - - spu_mfcdma32(&spe_cache_mem[line], ea_aligned, SPE_CACHELINE_SIZE, - SPE_CACHE_SET_TAGID(set), SPE_CACHE_GET); - - spe_cache_dir[set][SPE_CACHE_NWAY_MASK - idx] = ea_aligned; - - return idx; -} -#endif diff --git a/Extras/software_cache/cache/include/nway-opt.h b/Extras/software_cache/cache/include/nway-opt.h deleted file mode 100644 index ec3993acb..000000000 --- a/Extras/software_cache/cache/include/nway-opt.h +++ /dev/null @@ -1,153 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* nway-opt.h - * - * Copyright (C) 2006 IBM Corp. - * - * "Optimized" lookup operations for n-way set associative - * software managed cache. - */ -#include - -#ifndef __SPE_CACHE_NWAY_OPT_H_ -#define __SPE_CACHE_NWAY_OPT_H_ - -/* __spe_cache_rd - * Look up and return data from the cache. If the data - * is not currently in cache then transfer it from main - * storage. - * - * This code uses a conditional branch to the cache miss - * handler in the event that the requested data is not - * in the cache. A branch hint is used to avoid paying - * the branch stall penalty. - */ -#define __spe_cache_rd(type, ea) \ -({ \ - int set, idx, lnum, byte; \ - type ret; \ - _spe_cache_nway_lookup_(ea, set, idx); \ - if (unlikely(idx < 0)) { \ - idx = _spe_cache_miss_(ea, set, -1); \ - spu_writech(22, SPE_CACHE_SET_TAGMASK(set)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ - } \ - lnum = _spe_cacheline_num_(set, idx); \ - byte = _spe_cacheline_byte_offset_(ea); \ - ret = *((type *) (&spe_cache_mem[lnum + byte])); \ - ret; \ -}) - -/** - * __spe_cache_rd_x4 - * Fetch four data elements from the cache. - * - * This code uses one conditional branch in - * the event that any of the four elements - * are missing. - * - * On a miss, light weight locking is used to - * avoid casting out entries that were found. - * Further, we wait just once for the transfers, - * allowing for parallel [rather than serial] - * transfers. - */ - -#define __spe_cache_rd_x4(type, ea_x4) \ -({ \ - vector unsigned int missing; \ - unsigned int ms; \ - vector unsigned int cindex; \ - unsigned int d0, d1, d2, d3; \ - vector unsigned int s_x4; \ - vector signed int i_x4; \ - vector unsigned int ibyte, iline; \ - vector unsigned int ret; \ - unsigned int idx0, idx1, idx2, idx3; \ - \ - _spe_cache_nway_lookup_x4(ea_x4, s_x4, i_x4); \ - missing = spu_rlmask ((vector unsigned int)i_x4, -8); \ - ms = spu_extract (spu_gather (missing), 0); \ - \ - ibyte = _spe_cacheline_byte_offset_x4(ea_x4); \ - \ - iline = _spe_cacheline_num_x4(s_x4, \ - (vector unsigned int)i_x4); \ - \ - cindex = spu_add (iline, ibyte); \ - \ - idx0 = spu_extract (cindex, 0); \ - idx1 = spu_extract (cindex, 1); \ - idx2 = spu_extract (cindex, 2); \ - idx3 = spu_extract (cindex, 3); \ - \ - d0 = *((type *) (&spe_cache_mem[idx0])); \ - d1 = *((type *) (&spe_cache_mem[idx1])); \ - d2 = *((type *) (&spe_cache_mem[idx2])); \ - d3 = *((type *) (&spe_cache_mem[idx3])); \ - \ - ret = _load_vec_uint4 (d0, d1, d2, d3); \ - \ - if (unlikely(ms)) { \ - int b0 = spu_extract (ibyte, 0); \ - int b1 = spu_extract (ibyte, 1); \ - int b2 = spu_extract (ibyte, 2); \ - int b3 = spu_extract (ibyte, 3); \ - int lnum0; \ - int lnum1; \ - int lnum2; \ - int lnum3; \ - int s0 = spu_extract (s_x4, 0); \ - int s1 = spu_extract (s_x4, 1); \ - int s2 = spu_extract (s_x4, 2); \ - int s3 = spu_extract (s_x4, 3); \ - int i0 = spu_extract (i_x4, 0); \ - int i1 = spu_extract (i_x4, 1); \ - int i2 = spu_extract (i_x4, 2); \ - int i3 = spu_extract (i_x4, 3); \ - unsigned int ea0 = spu_extract(ea_x4, 0); \ - unsigned int ea1 = spu_extract(ea_x4, 1); \ - unsigned int ea2 = spu_extract(ea_x4, 2); \ - unsigned int ea3 = spu_extract(ea_x4, 3); \ - int avail = -1; \ - \ - avail &= ~(((i0 < 0) ? 0 : (1 << i0)) | \ - ((i1 < 0) ? 0 : (1 << i1)) | \ - ((i2 < 0) ? 0 : (1 << i2)) | \ - ((i3 < 0) ? 0 : (1 << i3))); \ - \ - i0 = _spe_cache_miss_(ea0, s0, avail); \ - avail &= ~(1 << i0); \ - i1 = _spe_cache_miss_(ea1, s1, avail); \ - avail &= ~(1 << i1); \ - i2 = _spe_cache_miss_(ea2, s2, avail); \ - avail &= ~(1 << i2); \ - i3 = _spe_cache_miss_(ea3, s3, avail); \ - \ - lnum0 = _spe_cacheline_num_(s0, i0); \ - lnum1 = _spe_cacheline_num_(s1, i1); \ - lnum2 = _spe_cacheline_num_(s2, i2); \ - lnum3 = _spe_cacheline_num_(s3, i3); \ - \ - spu_writech(22, SPE_CACHE_SET_TAGMASK(set)); \ - spu_mfcstat(MFC_TAG_UPDATE_ALL); \ - \ - d0 = *((type *) (&spe_cache_mem[lnum0 + b0])); \ - d1 = *((type *) (&spe_cache_mem[lnum1 + b1])); \ - d2 = *((type *) (&spe_cache_mem[lnum2 + b2])); \ - d3 = *((type *) (&spe_cache_mem[lnum3 + b3])); \ - \ - ret = _load_vec_uint4 (d0, d1, d2, d3); \ - } \ - ret; \ -}) - -#endif /* _SPE_CACHE_NWAY_OPT_H_ */ diff --git a/Extras/software_cache/cache/include/nway-replace.h b/Extras/software_cache/cache/include/nway-replace.h deleted file mode 100644 index 213301c2d..000000000 --- a/Extras/software_cache/cache/include/nway-replace.h +++ /dev/null @@ -1,38 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* nway-replace.h - * - * Copyright (C) 2005 IBM Corp. - * - * Implement replacement for software - * managed cache. - */ - -#ifndef __SPE_CACHE_NWAY_REPLACE_H_ -#define __SPE_CACHE_NWAY_REPLACE_H_ - -static vec_uint4 spe_cache_replace_cntr[SPE_CACHE_NSETS+1]; - -static inline vec_uint4 _spe_cache_replace_(int set, int avail) -{ - unsigned int mask = ((1 << SPE_CACHE_NWAY) - 1) & avail; - unsigned int curr, currbit, next; - - curr = spu_extract(spe_cache_replace_cntr[set], 0) & SPE_CACHE_NWAY_MASK; - currbit = (1 << curr); - next = (curr + 1) & SPE_CACHE_NWAY_MASK; - spe_cache_replace_cntr[set] = (vec_uint4) spu_promote(next, 0); - mask = (mask & currbit) ? currbit : mask; - - return (vec_uint4) spu_promote(mask, 0); -} - -#endif diff --git a/Extras/software_cache/cache/include/nway.h b/Extras/software_cache/cache/include/nway.h deleted file mode 100644 index 0b37817b0..000000000 --- a/Extras/software_cache/cache/include/nway.h +++ /dev/null @@ -1,105 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* nway.h - * - * Copyright (C) 2005 IBM Corp. - * - * Support for n-way set associative software - * managed cache. The 4-way associative cache - * is the only interface exposed currently. - */ - -#ifndef __SPE_CACHE_NWAY_H_ -#define __SPE_CACHE_NWAY_H_ - -/** - ** Defn's for n-way set associativity. - ** Default is 4-way. - */ -#define SPE_CACHE_NWAY 4 -#define SPE_CACHE_NWAY_SHIFT 2 - -#define SPE_CACHE_NWAY_MASK (SPE_CACHE_NWAY - 1) -#define SPE_CACHE_NENTRIES (SPE_CACHE_NWAY * SPE_CACHE_NSETS) -#define SPE_CACHE_MEM_SIZE (SPE_CACHE_NENTRIES * SPE_CACHELINE_SIZE) - -#define _spe_cache_set_num_(ea) \ -({ \ - unsigned int ead, eadm, ret; \ - ead = ((ea) >> SPE_CACHELINE_SHIFT); \ - eadm = ((ea) >> (SPE_CACHELINE_SHIFT+2)); \ - ret = (ead ^ eadm) & SPE_CACHE_NSETS_MASK; \ - ret; \ -}) - -#define _spe_cache_set_num_x4(ea_x4) \ -({ \ - vector unsigned int tmp0; \ - vector unsigned int tmp1; \ - tmp0 = spu_rlmask (ea_x4, -SPE_CACHELINE_SHIFT); \ - tmp1 = spu_rlmask (ea_x4, -(SPE_CACHELINE_SHIFT+1)); \ - spu_and (spu_xor (tmp0, tmp1), SPE_CACHE_NSETS_MASK); \ -}) - -#define _spe_cache_idx_num_x4(found) \ - spu_sub((unsigned int) 31, spu_cntlz(found)) - -#define _spe_cache_idx_num_(found) \ - spu_extract(spu_sub((unsigned int) 31, spu_cntlz(found)), 0) - -#define _spe_cacheline_num_(set, idx) \ - (((set << SPE_CACHE_NWAY_SHIFT) + idx) << SPE_CACHELINE_SHIFT) - -#define _spe_cacheline_num_x4(set, idx) \ - spu_sl (spu_add (spu_sl (set, SPE_CACHE_NWAY_SHIFT), idx), SPE_CACHELINE_SHIFT) - -#define _spe_cacheline_is_dirty_(set, idx) \ - (spe_cache_dir[set][SPE_CACHE_NWAY_MASK-(idx)] & SPE_CACHELINE_DIRTY) - -#define _spe_cacheline_is_locked_(set, idx) \ - (spe_cache_dir[set][SPE_CACHE_NWAY_MASK-(idx)] & SPE_CACHELINE_LOCKED) - -#define _spe_lock_cacheline_(set, idx) \ - spe_cache_dir[set][SPE_CACHE_NWAY_MASK-(idx)] |= SPE_CACHELINE_LOCKED - -#define _spe_unlock_cacheline_(set, idx) \ - spe_cache_dir[set][SPE_CACHE_NWAY_MASK-(idx)] &= ~SPE_CACHELINE_LOCKED - - -/** - * spe_cache_dir - * This is the n-way set associative cache - * directory. Entries are either zero (unused) - * or non-zero (used). - * - * State for one additional (dummy) set is - * allocated to improve efficiency of cache - * line locking. - * volatile seems not to be necessary here, the SCE toolchain guarantees a barrier after dma transfer - */ -static unsigned int spe_cache_dir[SPE_CACHE_NSETS+1][SPE_CACHE_NWAY] - __attribute__ ((aligned(16))); - -/** - * spe_cache_mem - * A contiguous set of cachelines in LS memory, - * one line for each entry in the cache. - * volatile seems not to be necessary here, the SCE toolchain guarantees a barrier after dma transfer - */ -static char spe_cache_mem[SPE_CACHE_MEM_SIZE] - __attribute__ ((aligned(128))); - -#include "nway-lookup.h" -#include "nway-replace.h" -#include "nway-miss.h" -#include "nway-opt.h" - -#endif diff --git a/Extras/software_cache/cache/include/spe_cache.h b/Extras/software_cache/cache/include/spe_cache.h deleted file mode 100644 index 89b0bbb4a..000000000 --- a/Extras/software_cache/cache/include/spe_cache.h +++ /dev/null @@ -1,32 +0,0 @@ -/* --------------------------------------------------------------- */ -/* PLEASE DO NOT MODIFY THIS SECTION */ -/* This prolog section is automatically generated. */ -/* */ -/* (C) Copyright 2001,2006, */ -/* International Business Machines Corporation, */ -/* */ -/* All Rights Reserved. */ -/* --------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -/* spe_cache.h - * - * Copyright (C) 2005 IBM Corp. - * - * Top level include file implementing - * software managed cache. - */ - -#ifndef __SPE_CACHE_H__ -#define __SPE_CACHE_H__ 1 - -#include "vec_literal.h" -#include "ilog2.h" -#include "memset.h" -//#include - -#include "defs.h" -#include "dma.h" -#include "nway.h" -#include "api.h" - -#endif diff --git a/Extras/software_cache/cache/include/vec_literal.h b/Extras/software_cache/cache/include/vec_literal.h deleted file mode 100644 index c58e1b552..000000000 --- a/Extras/software_cache/cache/include/vec_literal.h +++ /dev/null @@ -1,74 +0,0 @@ -/* @(#)86 1.3 src/include/vec_literal.h, sw.includes, sdk_pub 10/11/05 16:00:27 */ -/* -------------------------------------------------------------- */ -/* (C) Copyright 2001,2005, */ -/* International Business Machines Corporation, */ -/* Sony Computer Entertainment Incorporated, */ -/* Toshiba Corporation. */ -/* */ -/* All Rights Reserved. */ -/* -------------------------------------------------------------- */ -/* PROLOG END TAG zYx */ -#ifndef _VEC_LITERAL_H_ -#define _VEC_LITERAL_H_ - -/* This header files provides an abstraction for the various implementations - * of vector literal construction. The two formats are: - * - * 1) Altivec styled using parenthesis - * 2) C grammer friendly styled using curly braces - * - * The macro, VEC_LITERAL has been developed to provide some portability - * in these two styles. To achieve true portability, user must specify all - * elements of the vector being initialized. A single element can be provided - * but only the first element guarenteed across both construction styles. - * - * The VEC_SPLAT_* macros have been provided for portability of vector literal - * construction when all the elements of the vector contain the same value. - */ - -#ifdef __SPU__ -#include -#endif - - -#ifdef __ALTIVEC_LITERAL_STYLE__ -/* Use altivec style. - */ -#define VEC_LITERAL(_type, ...) ((_type)(__VA_ARGS__)) - -#define VEC_SPLAT_U8(_val) ((vector unsigned char)(_val)) -#define VEC_SPLAT_S8(_val) ((vector signed char)(_val)) - -#define VEC_SPLAT_U16(_val) ((vector unsigned short)(_val)) -#define VEC_SPLAT_S16(_val) ((vector signed short)(_val)) - -#define VEC_SPLAT_U32(_val) ((vector unsigned int)(_val)) -#define VEC_SPLAT_S32(_val) ((vector signed int)(_val)) -#define VEC_SPLAT_F32(_val) ((vector float)(_val)) - -#define VEC_SPLAT_U64(_val) ((vector unsigned long long)(_val)) -#define VEC_SPLAT_S64(_val) ((vector signed long long)(_val)) -#define VEC_SPLAT_F64(_val) ((vector double)(_val)) - -#else -/* Use curly brace style. - */ -#define VEC_LITERAL(_type, ...) ((_type){__VA_ARGS__}) - -#define VEC_SPLAT_U8(_val) ((vector unsigned char){_val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val}) -#define VEC_SPLAT_S8(_val) ((vector signed char){_val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val, _val}) - -#define VEC_SPLAT_U16(_val) ((vector unsigned short){_val, _val, _val, _val, _val, _val, _val, _val}) -#define VEC_SPLAT_S16(_val) ((vector signed short){_val, _val, _val, _val, _val, _val, _val, _val}) - -#define VEC_SPLAT_U32(_val) ((vector unsigned int){_val, _val, _val, _val}) -#define VEC_SPLAT_S32(_val) ((vector signed int){_val, _val, _val, _val}) -#define VEC_SPLAT_F32(_val) ((vector float){_val, _val, _val, _val}) - -#define VEC_SPLAT_U64(_val) ((vector unsigned long long){_val, _val}) -#define VEC_SPLAT_S64(_val) ((vector signed long long){_val, _val}) -#define VEC_SPLAT_F64(_val) ((vector double){_val, _val}) - -#endif - -#endif /* _VEC_LITERAL_H_ */ diff --git a/Extras/vectormathlibrary/LICENSE b/Extras/vectormathlibrary/LICENSE deleted file mode 100644 index 296fb8f3f..000000000 --- a/Extras/vectormathlibrary/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ - Vector Math library for 3-D linear algebra (vector, matrix, quaternion) - SIMD support for SSE, PowerPC (PPU) and the SPU. - Also includes generic multi-platform scalar version. - - 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. - diff --git a/Extras/vectormathlibrary/Makefile b/Extras/vectormathlibrary/Makefile deleted file mode 100644 index e0afd1f0a..000000000 --- a/Extras/vectormathlibrary/Makefile +++ /dev/null @@ -1,119 +0,0 @@ -# Makefile for vector math library. -# -# 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. - -# How to build: -# -# Nothing to do (The all of the library is implemented as inline). -# -# How to install: -# -# To install the library: -# -# make ARCH= install -# -# where must be one of: -# -# ppu (PowerPC) -# spu -# SSE -# scalar (generic) -# -# e.g.) make ARCH=cell install -# - -topdir = . -ARCH = scalar - -prefix_spu = /usr/spu - -ARCH_DIRS = $(ARCH) -ARCH_INSTALL= $(ARCH_INSTALL_$(ARCH)) -ARCH_CHECK= $(ARCH_CHECK_$(ARCH)) - -prefix = $(if $(prefix_$(ARCH)),$(prefix_$(ARCH)),/usr) -DESTDIR = - -COMMON_DIRS = scalar - -INSTALL = install - -LIB_MAJOR_VERSION = 1 -LIB_MINOR_VERSION = 0 -LIB_RELEASE = 1 -LIB_FULL_VERSION = $(LIB_MAJOR_VERSION).$(LIB_MINOR_VERSION).$(LIB_RELEASE) - -LIB_BASE = vectormath - -TAR_NAME = $(LIB_BASE)-$(LIB_FULL_VERSION) -TAR_BALL = $(TAR_NAME).tar.gz - -all: - @true - -install: - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/c - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/cpp - $(INSTALL) -m 644 include/vectormath/c/*.h $(DESTDIR)$(prefix)/include/vectormath/c/ - $(INSTALL) -m 644 include/vectormath/cpp/*.h $(DESTDIR)$(prefix)/include/vectormath/cpp/ - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/cpp - for _d in $(ARCH_DIRS) $(COMMON_DIRS); do \ - if test -d include/vectormath/$$_d/c; then \ - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/$$_d/c && \ - $(INSTALL) -m 644 include/vectormath/$$_d/c/*.h \ - $(DESTDIR)$(prefix)/include/vectormath/$$_d/c/ || exit 1; \ - fi; \ - if test -d include/vectormath/$$_d/cpp; then \ - $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)/include/vectormath/$$_d/cpp && \ - $(INSTALL) -m 644 include/vectormath/$$_d/cpp/*.h \ - $(DESTDIR)$(prefix)/include/vectormath/$$_d/cpp/ || exit 1; \ - fi; \ - done - -check: - $(MAKE) -C tests ARCH=$(ARCH) check - -clean: - $(MAKE) -C tests clean - -rm -f $(TAR_BALL) - -distclean: - $(MAKE) -C tests distclean - -dist: - -rm -rf .dist - mkdir -p .dist/$(TAR_NAME) - find . -name .dist -prune -o \ - -name .CVS -prune -o -name .svn -prune -o \ - -name .pc -prune -o -name patches -prune -o \ - '(' -name README -o -name LICENSE -o \ - -name Makefile -o -name '*.[ch]' -o -name '*.cpp' -o \ - -name '*.pl' -o -name '*.txt' -o -name '*.pdf' -o -name '*.spec' ')' \ - -print | tar -T - -cf - | tar xf - -C .dist/$(TAR_NAME) - tar zcf $(TAR_BALL) -C .dist $(TAR_NAME) - -rm -rf .dist diff --git a/Extras/vectormathlibrary/README b/Extras/vectormathlibrary/README deleted file mode 100644 index 842caaea1..000000000 --- a/Extras/vectormathlibrary/README +++ /dev/null @@ -1,86 +0,0 @@ - Vector math library - - -* Overview - - The Vector math library provides 3-D/4-D vector operations including - addition, outer product, multiply by a matrix, etc. - - -* License - - This library is licensed under the terms in the file 'LICENSE' in - this directory. - - -* Installing - - To install this library, run following commands: - - - PowerPC with VMX (fully supported) - - $ make ARCH=ppu install - - - SPU (Cell Broadband Engine Synergistic Processor Unit) - - $ make ARCH=spu install - - - x86 with SSE (partially supported) - - $ make ARCH=SSE install - - - Other architectures (partially supported) - - $ make install - - - By default, files in the library will be placed as below: - - - headers - - /usr/include/vectormath/c/ (C headers) - /usr/include/vectormath/cpp/ (C++ headers) - - - SPU headers - - /usr/spu/include/vectormath/c/ (C headers) - /usr/spu/include/vectormath/cpp/ (C++ headers) - - No shared library, static library nor executable is installed, - because all functions in this library are provided as inline - functions. - - -* Packaging - - By running following command in this directory, a source tarball - 'vectormath-.tar.gz' can be created: - - $ make dist - - You can also create RPM packages by executing the command below with - the tarball: - - $ rpmbuild -tb vectormath-1.0.1.tar.gz --target=ppc - - One or two packages, vectormath-devel (and, in addition, - spu-vectormath-devel for PowerPC target), will be created. - - -* Usage - - See the documents `doc/*.pdf'. - - -* Contacting the project - - Module maintainer: Erwin Coumans - - Feedback and patches: - http://www.bulletphysics.com/Bullet/phpBB2/viewforum.php?f=18 - - Main repository URL: - http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/vectormathlibrary - ---- -EOF diff --git a/Extras/vectormathlibrary/doc/Vector_Math_Library-Overview.pdf b/Extras/vectormathlibrary/doc/Vector_Math_Library-Overview.pdf deleted file mode 100644 index 8ac1928ce..000000000 Binary files a/Extras/vectormathlibrary/doc/Vector_Math_Library-Overview.pdf and /dev/null differ diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h deleted file mode 100644 index a11f72a54..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/boolInVec.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - Copyright (C) 2006, 2010 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 - -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 diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h deleted file mode 100644 index 4c9682410..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/floatInVec.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - Copyright (C) 2006, 2010 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 -#include - -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 diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h deleted file mode 100644 index 5b2b71410..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/mat_aos.h +++ /dev/null @@ -1,2190 +0,0 @@ -/* - Copyright (C) 2006, 2010 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_MAT_AOS_CPP_H -#define _VECTORMATH_MAT_AOS_CPP_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) -#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) -#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -__forceinline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -__forceinline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -__forceinline Matrix3::Matrix3( const floatInVec &scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -__forceinline Matrix3::Matrix3( const Quat &unitQuat ) -{ - __m128 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - __declspec(align(16)) unsigned int sx[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int sz[4] = {0, 0, 0xffffffff, 0}; - __m128 select_x = _mm_load_ps((float *)sx); - __m128 select_z = _mm_load_ps((float *)sz); - - xyzw_2 = _mm_add_ps( unitQuat.get128(), unitQuat.get128() ); - wwww = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,3,3,3) ); - yzxw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,0,2,1) ); - zxyw = _mm_shuffle_ps( unitQuat.get128(), unitQuat.get128(), _MM_SHUFFLE(3,1,0,2) ); - yzxw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,0,2,1) ); - zxyw_2 = _mm_shuffle_ps( xyzw_2, xyzw_2, _MM_SHUFFLE(3,1,0,2) ); - - tmp0 = _mm_mul_ps( yzxw_2, wwww ); // tmp0 = 2yw, 2zw, 2xw, 2w2 - tmp1 = _mm_sub_ps( _mm_set1_ps(1.0f), _mm_mul_ps(yzxw, yzxw_2) ); // tmp1 = 1 - 2y2, 1 - 2z2, 1 - 2x2, 1 - 2w2 - tmp2 = _mm_mul_ps( yzxw, xyzw_2 ); // tmp2 = 2xy, 2yz, 2xz, 2w2 - tmp0 = _mm_add_ps( _mm_mul_ps(zxyw, xyzw_2), tmp0 ); // tmp0 = 2yw + 2zx, 2zw + 2xy, 2xw + 2yz, 2w2 + 2w2 - tmp1 = _mm_sub_ps( tmp1, _mm_mul_ps(zxyw, zxyw_2) ); // tmp1 = 1 - 2y2 - 2z2, 1 - 2z2 - 2x2, 1 - 2x2 - 2y2, 1 - 2w2 - 2w2 - tmp2 = _mm_sub_ps( tmp2, _mm_mul_ps(zxyw_2, wwww) ); // tmp2 = 2xy - 2zw, 2yz - 2xw, 2xz - 2yw, 2w2 -2w2 - - tmp3 = vec_sel( tmp0, tmp1, select_x ); - tmp4 = vec_sel( tmp1, tmp2, select_x ); - tmp5 = vec_sel( tmp2, tmp0, select_x ); - mCol0 = Vector3( vec_sel( tmp3, tmp2, select_z ) ); - mCol1 = Vector3( vec_sel( tmp4, tmp0, select_z ) ); - mCol2 = Vector3( vec_sel( tmp5, tmp1, select_z ) ); -} - -__forceinline Matrix3::Matrix3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -__forceinline Matrix3 & Matrix3::setCol0( const Vector3 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -__forceinline Matrix3 & Matrix3::setCol1( const Vector3 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -__forceinline Matrix3 & Matrix3::setCol2( const Vector3 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -__forceinline Matrix3 & Matrix3::setCol( int col, const Vector3 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -__forceinline Matrix3 & Matrix3::setRow( int row, const Vector3 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -__forceinline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -__forceinline Matrix3 & Matrix3::setElem( int col, int row, const floatInVec &val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -__forceinline const floatInVec Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -__forceinline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -__forceinline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -__forceinline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -__forceinline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -__forceinline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -__forceinline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -__forceinline const Matrix3 transpose( const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, res0, res1, res2; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - res0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - //res1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - res1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - res1 = vec_sel(res1, mat.getCol1().get128(), select_y); - //res2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - res2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - res2 = vec_sel(res2, vec_splat(mat.getCol1().get128(), 2), select_y); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -__forceinline const Matrix3 inverse( const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); - tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); - tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); - dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tmp1, select_y); - //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); - inv0 = vec_mul( inv0, invdet ); - inv1 = vec_mul( inv1, invdet ); - inv2 = vec_mul( inv2, invdet ); - return Matrix3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ) - ); -} - -__forceinline const floatInVec determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -__forceinline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -__forceinline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -__forceinline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -__forceinline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -__forceinline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -__forceinline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -__forceinline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -__forceinline const Matrix3 Matrix3::operator *( const floatInVec &scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -__forceinline Matrix3 & Matrix3::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -__forceinline Matrix3 & Matrix3::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return floatInVec(scalar) * mat; -} - -__forceinline const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -__forceinline const Vector3 Matrix3::operator *( const Vector3 &vec ) const -{ - __m128 res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_mul( mCol0.get128(), xxxx ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -__forceinline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -__forceinline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -__forceinline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -__forceinline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -__forceinline const Matrix3 Matrix3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -__forceinline const Matrix3 Matrix3::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -__forceinline const Matrix3 Matrix3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -__forceinline const Matrix3 Matrix3::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ) - ); -} - -__forceinline const Matrix3 Matrix3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -__forceinline const Matrix3 Matrix3::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - __m128 zero; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ) - ); -} - -__forceinline const Matrix3 Matrix3::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Matrix3( - Vector3( vec_mul( Z0, Y0 ) ), - Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ) - ); -} - -__forceinline const Matrix3 Matrix3::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -__forceinline const Matrix3 Matrix3::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); - axisS = vec_mul( axis, s ); - negAxisS = negatef4( axisS ); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); - tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); - //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); - //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); - tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); - tmp0 = vec_sel( tmp0, c, select_x ); - tmp1 = vec_sel( tmp1, c, select_y ); - tmp2 = vec_sel( tmp2, c, select_z ); - return Matrix3( - Vector3( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector3( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector3( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ) - ); -} - -__forceinline const Matrix3 Matrix3::rotation( const Quat &unitQuat ) -{ - return Matrix3( unitQuat ); -} - -__forceinline const Matrix3 Matrix3::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Matrix3( - Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ) - ); -} - -__forceinline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -__forceinline const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -__forceinline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -__forceinline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -__forceinline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -__forceinline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -__forceinline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -__forceinline Matrix4::Matrix4( const floatInVec &scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -__forceinline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -__forceinline Matrix4::Matrix4( const Vector4 &_col0, const Vector4 &_col1, const Vector4 &_col2, const Vector4 &_col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -__forceinline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 &translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -__forceinline Matrix4::Matrix4( const Quat &unitQuat, const Vector3 &translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -__forceinline Matrix4 & Matrix4::setCol0( const Vector4 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -__forceinline Matrix4 & Matrix4::setCol1( const Vector4 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -__forceinline Matrix4 & Matrix4::setCol2( const Vector4 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -__forceinline Matrix4 & Matrix4::setCol3( const Vector4 &_col3 ) -{ - mCol3 = _col3; - return *this; -} - -__forceinline Matrix4 & Matrix4::setCol( int col, const Vector4 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -__forceinline Matrix4 & Matrix4::setRow( int row, const Vector4 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -__forceinline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -__forceinline Matrix4 & Matrix4::setElem( int col, int row, const floatInVec &val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -__forceinline const floatInVec Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -__forceinline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -__forceinline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -__forceinline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -__forceinline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -__forceinline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -__forceinline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -__forceinline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -__forceinline const Matrix4 transpose( const Matrix4 & mat ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergeh( mat.getCol1().get128(), mat.getCol3().get128() ); - tmp2 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp3 = vec_mergel( mat.getCol1().get128(), mat.getCol3().get128() ); - res0 = vec_mergeh( tmp0, tmp1 ); - res1 = vec_mergel( tmp0, tmp1 ); - res2 = vec_mergeh( tmp2, tmp3 ); - res3 = vec_mergel( tmp2, tmp3 ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4( res2 ), - Vector4( res3 ) - ); -} - -// TODO: Tidy -static __declspec(align(16)) const unsigned int _vmathPNPN[4] = {0x00000000, 0x80000000, 0x00000000, 0x80000000}; -static __declspec(align(16)) const unsigned int _vmathNPNP[4] = {0x80000000, 0x00000000, 0x80000000, 0x00000000}; -static __declspec(align(16)) const float _vmathZERONE[4] = {1.0f, 0.0f, 0.0f, 1.0f}; - -__forceinline const Matrix4 inverse( const Matrix4 & mat ) -{ - __m128 Va,Vb,Vc; - __m128 r1,r2,r3,tt,tt2; - __m128 sum,Det,RDet; - __m128 trns0,trns1,trns2,trns3; - - __m128 _L1 = mat.getCol0().get128(); - __m128 _L2 = mat.getCol1().get128(); - __m128 _L3 = mat.getCol2().get128(); - __m128 _L4 = mat.getCol3().get128(); - // Calculating the minterms for the first line. - - // _mm_ror_ps is just a macro using _mm_shuffle_ps(). - tt = _L4; tt2 = _mm_ror_ps(_L3,1); - Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3'·V4 - Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3'·V4" - Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3'·V4^ - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3"·V4^ - V3^·V4" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^·V4' - V3'·V4^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3'·V4" - V3"·V4' - - tt = _L2; - Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); - Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); - Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); - - // Calculating the determinant. - Det = _mm_mul_ps(sum,_L1); - Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); - - const __m128 Sign_PNPN = _mm_load_ps((float *)_vmathPNPN); - const __m128 Sign_NPNP = _mm_load_ps((float *)_vmathNPNP); - - __m128 mtL1 = _mm_xor_ps(sum,Sign_PNPN); - - // Calculating the minterms of the second line (using previous results). - tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL2 = _mm_xor_ps(sum,Sign_NPNP); - - // Testing the determinant. - Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); - - // Calculating the minterms of the third line. - tt = _mm_ror_ps(_L1,1); - Va = _mm_mul_ps(tt,Vb); // V1'·V2" - Vb = _mm_mul_ps(tt,Vc); // V1'·V2^ - Vc = _mm_mul_ps(tt,_L2); // V1'·V2 - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V1"·V2^ - V1^·V2" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V1^·V2' - V1'·V2^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V1'·V2" - V1"·V2' - - tt = _mm_ror_ps(_L4,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL3 = _mm_xor_ps(sum,Sign_PNPN); - - // Dividing is FASTER than rcp_nr! (Because rcp_nr causes many register-memory RWs). - RDet = _mm_div_ss(_mm_load_ss((float *)&_vmathZERONE), Det); // TODO: just 1.0f? - RDet = _mm_shuffle_ps(RDet,RDet,0x00); - - // Devide the first 12 minterms with the determinant. - mtL1 = _mm_mul_ps(mtL1, RDet); - mtL2 = _mm_mul_ps(mtL2, RDet); - mtL3 = _mm_mul_ps(mtL3, RDet); - - // Calculate the minterms of the forth line and devide by the determinant. - tt = _mm_ror_ps(_L3,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - __m128 mtL4 = _mm_xor_ps(sum,Sign_NPNP); - mtL4 = _mm_mul_ps(mtL4, RDet); - - // Now we just have to transpose the minterms matrix. - trns0 = _mm_unpacklo_ps(mtL1,mtL2); - trns1 = _mm_unpacklo_ps(mtL3,mtL4); - trns2 = _mm_unpackhi_ps(mtL1,mtL2); - trns3 = _mm_unpackhi_ps(mtL3,mtL4); - _L1 = _mm_movelh_ps(trns0,trns1); - _L2 = _mm_movehl_ps(trns1,trns0); - _L3 = _mm_movelh_ps(trns2,trns3); - _L4 = _mm_movehl_ps(trns3,trns2); - - return Matrix4( - Vector4( _L1 ), - Vector4( _L2 ), - Vector4( _L3 ), - Vector4( _L4 ) - ); -} - -__forceinline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -__forceinline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -__forceinline const floatInVec determinant( const Matrix4 & mat ) -{ - __m128 Va,Vb,Vc; - __m128 r1,r2,r3,tt,tt2; - __m128 sum,Det; - - __m128 _L1 = mat.getCol0().get128(); - __m128 _L2 = mat.getCol1().get128(); - __m128 _L3 = mat.getCol2().get128(); - __m128 _L4 = mat.getCol3().get128(); - // Calculating the minterms for the first line. - - // _mm_ror_ps is just a macro using _mm_shuffle_ps(). - tt = _L4; tt2 = _mm_ror_ps(_L3,1); - Vc = _mm_mul_ps(tt2,_mm_ror_ps(tt,0)); // V3'·V4 - Va = _mm_mul_ps(tt2,_mm_ror_ps(tt,2)); // V3'·V4" - Vb = _mm_mul_ps(tt2,_mm_ror_ps(tt,3)); // V3'·V4^ - - r1 = _mm_sub_ps(_mm_ror_ps(Va,1),_mm_ror_ps(Vc,2)); // V3"·V4^ - V3^·V4" - r2 = _mm_sub_ps(_mm_ror_ps(Vb,2),_mm_ror_ps(Vb,0)); // V3^·V4' - V3'·V4^ - r3 = _mm_sub_ps(_mm_ror_ps(Va,0),_mm_ror_ps(Vc,1)); // V3'·V4" - V3"·V4' - - tt = _L2; - Va = _mm_ror_ps(tt,1); sum = _mm_mul_ps(Va,r1); - Vb = _mm_ror_ps(tt,2); sum = _mm_add_ps(sum,_mm_mul_ps(Vb,r2)); - Vc = _mm_ror_ps(tt,3); sum = _mm_add_ps(sum,_mm_mul_ps(Vc,r3)); - - // Calculating the determinant. - Det = _mm_mul_ps(sum,_L1); - Det = _mm_add_ps(Det,_mm_movehl_ps(Det,Det)); - - // Calculating the minterms of the second line (using previous results). - tt = _mm_ror_ps(_L1,1); sum = _mm_mul_ps(tt,r1); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r2)); - tt = _mm_ror_ps(tt,1); sum = _mm_add_ps(sum,_mm_mul_ps(tt,r3)); - - // Testing the determinant. - Det = _mm_sub_ss(Det,_mm_shuffle_ps(Det,Det,1)); - return floatInVec(Det, 0); -} - -__forceinline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -__forceinline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -__forceinline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -__forceinline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -__forceinline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -__forceinline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -__forceinline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -__forceinline const Matrix4 Matrix4::operator *( const floatInVec &scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -__forceinline Matrix4 & Matrix4::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -__forceinline Matrix4 & Matrix4::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return floatInVec(scalar) * mat; -} - -__forceinline const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -__forceinline const Vector4 Matrix4::operator *( const Vector4 &vec ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2))), _mm_mul_ps(mCol3.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(3,3,3,3))))) - ); -} - -__forceinline const Vector4 Matrix4::operator *( const Vector3 &vec ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(vec.get128(), vec.get128(), _MM_SHUFFLE(2,2,2,2)))) - ); -} - -__forceinline const Vector4 Matrix4::operator *( const Point3 &pnt ) const -{ - return Vector4( - _mm_add_ps( - _mm_add_ps(_mm_mul_ps(mCol0.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(0,0,0,0))), _mm_mul_ps(mCol1.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(1,1,1,1)))), - _mm_add_ps(_mm_mul_ps(mCol2.get128(), _mm_shuffle_ps(pnt.get128(), pnt.get128(), _MM_SHUFFLE(2,2,2,2))), mCol3.get128())) - ); -} - -__forceinline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -__forceinline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -__forceinline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -__forceinline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -__forceinline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -__forceinline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -__forceinline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -__forceinline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -__forceinline Matrix4 & Matrix4::setTranslation( const Vector3 &translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -__forceinline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -__forceinline const Matrix4 Matrix4::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -__forceinline const Matrix4 Matrix4::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4::xAxis( ), - Vector4( res1 ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 Matrix4::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -__forceinline const Matrix4 Matrix4::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4( res0 ), - Vector4::yAxis( ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 Matrix4::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -__forceinline const Matrix4 Matrix4::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - __m128 zero; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 Matrix4::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Matrix4( - Vector4( vec_mul( Z0, Y0 ) ), - Vector4( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector4( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 Matrix4::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -__forceinline const Matrix4 Matrix4::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - __m128 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( _mm_set1_ps(1.0f), c ); - axisS = vec_mul( axis, s ); - negAxisS = negatef4( axisS ); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp0 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,2,0) ); - tmp0 = vec_sel(tmp0, vec_splat(negAxisS, 1), select_z); - //tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp1 = vec_sel( vec_splat(axisS, 0), vec_splat(negAxisS, 2), select_x ); - //tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp2 = _mm_shuffle_ps( axisS, axisS, _MM_SHUFFLE(0,0,0,1) ); - tmp2 = vec_sel(tmp2, vec_splat(negAxisS, 0), select_y); - tmp0 = vec_sel( tmp0, c, select_x ); - tmp1 = vec_sel( tmp1, c, select_y ); - tmp2 = vec_sel( tmp2, c, select_z ); - __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - axis = vec_and( axis, _mm_load_ps( (float *)select_xyz ) ); - tmp0 = vec_and( tmp0, _mm_load_ps( (float *)select_xyz ) ); - tmp1 = vec_and( tmp1, _mm_load_ps( (float *)select_xyz ) ); - tmp2 = vec_and( tmp2, _mm_load_ps( (float *)select_xyz ) ); - return Matrix4( - Vector4( vec_madd( vec_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector4( vec_madd( vec_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector4( vec_madd( vec_mul( axis, zzzz ), oneMinusC, tmp2 ) ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 Matrix4::rotation( const Quat &unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -__forceinline const Matrix4 Matrix4::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Matrix4( - Vector4( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector4( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector4( vec_sel( zero, scaleVec.get128(), select_z ) ), - Vector4::wAxis( ) - ); -} - -__forceinline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -__forceinline const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -__forceinline const Matrix4 Matrix4::translation( const Vector3 &translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -__forceinline const Matrix4 Matrix4::lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -__forceinline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - __m128 zero, col0, col1, col2, col3; - union { __m128 v; float s[4]; } tmp; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = _mm_setzero_ps(); - tmp.v = zero; - tmp.s[0] = f / aspect; - col0 = tmp.v; - tmp.v = zero; - tmp.s[1] = f; - col1 = tmp.v; - tmp.v = zero; - tmp.s[2] = ( zNear + zFar ) * rangeInv; - tmp.s[3] = -1.0f; - col2 = tmp.v; - tmp.v = zero; - tmp.s[2] = zNear * zFar * rangeInv * 2.0f; - col3 = tmp.v; - return Matrix4( - Vector4( col0 ), - Vector4( col1 ), - Vector4( col2 ), - Vector4( col3 ) - ); -} - -__forceinline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - __m128 lbf, rtn; - __m128 diff, sum, inv_diff; - __m128 diagonal, column, near2; - __m128 zero = _mm_setzero_ps(); - union { __m128 v; float s[4]; } l, f, r, n, b, t; // TODO: Union? - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = vec_splat( n.v, 0 ); - near2 = vec_add( near2, near2 ); - diagonal = vec_mul( near2, inv_diff ); - column = vec_mul( sum, inv_diff ); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - return Matrix4( - Vector4( vec_sel( zero, diagonal, select_x ) ), - Vector4( vec_sel( zero, diagonal, select_y ) ), - Vector4( vec_sel( column, _mm_set1_ps(-1.0f), select_w ) ), - Vector4( vec_sel( zero, vec_mul( diagonal, vec_splat( f.v, 0 ) ), select_z ) ) - ); -} - -__forceinline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - __m128 lbf, rtn; - __m128 diff, sum, inv_diff, neg_inv_diff; - __m128 diagonal, column; - __m128 zero = _mm_setzero_ps(); - union { __m128 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = vec_add( inv_diff, inv_diff ); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - column = vec_mul( sum, vec_sel( neg_inv_diff, inv_diff, select_z ) ); // TODO: no madds with zero - return Matrix4( - Vector4( vec_sel( zero, diagonal, select_x ) ), - Vector4( vec_sel( zero, diagonal, select_y ) ), - Vector4( vec_sel( zero, diagonal, select_z ) ), - Vector4( vec_sel( column, _mm_set1_ps(1.0f), select_w ) ) - ); -} - -__forceinline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -__forceinline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -__forceinline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -__forceinline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -__forceinline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -__forceinline Transform3::Transform3( const floatInVec &scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -__forceinline Transform3::Transform3( const Vector3 &_col0, const Vector3 &_col1, const Vector3 &_col2, const Vector3 &_col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -__forceinline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -__forceinline Transform3::Transform3( const Quat &unitQuat, const Vector3 &translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -__forceinline Transform3 & Transform3::setCol0( const Vector3 &_col0 ) -{ - mCol0 = _col0; - return *this; -} - -__forceinline Transform3 & Transform3::setCol1( const Vector3 &_col1 ) -{ - mCol1 = _col1; - return *this; -} - -__forceinline Transform3 & Transform3::setCol2( const Vector3 &_col2 ) -{ - mCol2 = _col2; - return *this; -} - -__forceinline Transform3 & Transform3::setCol3( const Vector3 &_col3 ) -{ - mCol3 = _col3; - return *this; -} - -__forceinline Transform3 & Transform3::setCol( int col, const Vector3 &vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -__forceinline Transform3 & Transform3::setRow( int row, const Vector4 &vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -__forceinline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -__forceinline Transform3 & Transform3::setElem( int col, int row, const floatInVec &val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -__forceinline const floatInVec Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -__forceinline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -__forceinline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -__forceinline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -__forceinline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -__forceinline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -__forceinline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -__forceinline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -__forceinline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -__forceinline const Transform3 inverse( const Transform3 & tfrm ) -{ - __m128 inv0, inv1, inv2, inv3; - __m128 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - __m128 xxxx, yyyy, zzzz; - tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); - tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); - tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - xxxx = vec_splat( inv3, 0 ); - //inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp3, tmp3, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tmp1, select_y); - //inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp4, tmp4, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tmp1, 2), select_y); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_mul( inv0, xxxx ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - inv0 = vec_mul( inv0, invdet ); - inv1 = vec_mul( inv1, invdet ); - inv2 = vec_mul( inv2, invdet ); - inv3 = vec_mul( inv3, invdet ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -__forceinline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - __m128 inv0, inv1, inv2, inv3; - __m128 tmp0, tmp1; - __m128 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - tmp1 = vec_mergel( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - inv0 = vec_mergeh( tmp0, tfrm.getCol1().get128() ); - xxxx = vec_splat( inv3, 0 ); - //inv1 = vec_perm( tmp0, tfrm.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - inv1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - inv1 = vec_sel(inv1, tfrm.getCol1().get128(), select_y); - //inv2 = vec_perm( tmp1, tfrm.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - inv2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - inv2 = vec_sel(inv2, vec_splat(tfrm.getCol1().get128(), 2), select_y); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_mul( inv0, xxxx ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -__forceinline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -__forceinline const Vector3 Transform3::operator *( const Vector3 &vec ) const -{ - __m128 res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_mul( mCol0.get128(), xxxx ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -__forceinline const Point3 Transform3::operator *( const Point3 &pnt ) const -{ - __m128 tmp0, tmp1, res; - __m128 xxxx, yyyy, zzzz; - xxxx = vec_splat( pnt.get128(), 0 ); - yyyy = vec_splat( pnt.get128(), 1 ); - zzzz = vec_splat( pnt.get128(), 2 ); - tmp0 = vec_mul( mCol0.get128(), xxxx ); - tmp1 = vec_mul( mCol1.get128(), yyyy ); - tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = vec_add( mCol3.get128(), tmp1 ); - res = vec_add( tmp0, tmp1 ); - return Point3( res ); -} - -__forceinline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -__forceinline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -__forceinline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -__forceinline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -__forceinline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -__forceinline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -__forceinline Transform3 & Transform3::setTranslation( const Vector3 &translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -__forceinline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -__forceinline const Transform3 Transform3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -__forceinline const Transform3 Transform3::rotationX( const floatInVec &radians ) -{ - __m128 s, c, res1, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ), - Vector3( _mm_setzero_ps() ) - ); -} - -__forceinline const Transform3 Transform3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -__forceinline const Transform3 Transform3::rotationY( const floatInVec &radians ) -{ - __m128 s, c, res0, res2; - __m128 zero; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -__forceinline const Transform3 Transform3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -__forceinline const Transform3 Transform3::rotationZ( const floatInVec &radians ) -{ - __m128 s, c, res0, res1; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __m128 zero = _mm_setzero_ps(); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Transform3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -__forceinline const Transform3 Transform3::rotationZYX( const Vector3 &radiansXYZ ) -{ - __m128 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - __declspec(align(16)) unsigned int select_xyz[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0}; - Z1 = vec_and( Z1, _mm_load_ps( (float *)select_xyz ) ); - Y0 = _mm_shuffle_ps( c, negS, _MM_SHUFFLE(0,1,1,1) ); - Y1 = _mm_shuffle_ps( s, c, _MM_SHUFFLE(0,1,1,1) ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_mul( Z0, Y1 ); - return Transform3( - Vector3( vec_mul( Z0, Y0 ) ), - Vector3( vec_madd( Z1, X1, vec_mul( tmp, X0 ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_mul( tmp, X1 ) ) ), - Vector3( 0.0f ) - ); -} - -__forceinline const Transform3 Transform3::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -__forceinline const Transform3 Transform3::rotation( const floatInVec &radians, const Vector3 &unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -__forceinline const Transform3 Transform3::rotation( const Quat &unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -__forceinline const Transform3 Transform3::scale( const Vector3 &scaleVec ) -{ - __m128 zero = _mm_setzero_ps(); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - return Transform3( - Vector3( vec_sel( zero, scaleVec.get128(), select_x ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_y ) ), - Vector3( vec_sel( zero, scaleVec.get128(), select_z ) ), - Vector3( 0.0f ) - ); -} - -__forceinline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -__forceinline const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -__forceinline const Transform3 Transform3::translation( const Vector3 &translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -__forceinline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -__forceinline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -__forceinline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -__forceinline Quat::Quat( const Matrix3 & tfrm ) -{ - __m128 res; - __m128 col0, col1, col2; - __m128 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - __m128 zy_xz_yx, yz_zx_xy, sum, diff; - __m128 radicand, invSqrt, scale; - __m128 res0, res1, res2, res3; - __m128 xx, yy, zz; - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - __declspec(align(16)) unsigned int select_w[4] = {0, 0, 0, 0xffffffff}; - - col0 = tfrm.getCol0().get128(); - col1 = tfrm.getCol1().get128(); - col2 = tfrm.getCol2().get128(); - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = vec_sel( col0, col1, select_y ); - //xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); - //yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); - //zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); - xx_yy_zz_xx = _mm_shuffle_ps( xx_yy, xx_yy, _MM_SHUFFLE(0,0,1,0) ); - xx_yy_zz_xx = vec_sel( xx_yy_zz_xx, col2, select_z ); // TODO: Ck - yy_zz_xx_yy = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(1,0,2,1) ); - zz_xx_yy_zz = _mm_shuffle_ps( xx_yy_zz_xx, xx_yy_zz_xx, _MM_SHUFFLE(2,1,0,2) ); - - diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), _mm_set1_ps(1.0f) ); - // invSqrt = rsqrtf4( radicand ); - invSqrt = newtonrapson_rsqrt4( radicand ); - - - - zy_xz_yx = vec_sel( col0, col1, select_z ); // zy_xz_yx = 00 01 12 03 - //zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); - zy_xz_yx = _mm_shuffle_ps( zy_xz_yx, zy_xz_yx, _MM_SHUFFLE(0,1,2,2) ); // zy_xz_yx = 12 12 01 00 - zy_xz_yx = vec_sel( zy_xz_yx, vec_splat(col2, 0), select_y ); // zy_xz_yx = 12 20 01 00 - yz_zx_xy = vec_sel( col0, col1, select_x ); // yz_zx_xy = 10 01 02 03 - //yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); - yz_zx_xy = _mm_shuffle_ps( yz_zx_xy, yz_zx_xy, _MM_SHUFFLE(0,0,2,0) ); // yz_zx_xy = 10 02 10 10 - yz_zx_xy = vec_sel( yz_zx_xy, vec_splat(col2, 1), select_x ); // yz_zx_xy = 21 02 10 10 - - sum = vec_add( zy_xz_yx, yz_zx_xy ); - diff = vec_sub( zy_xz_yx, yz_zx_xy ); - - scale = vec_mul( invSqrt, _mm_set1_ps(0.5f) ); - - //res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); - res0 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,1,2,0) ); - res0 = vec_sel( res0, vec_splat(diff, 0), select_w ); // TODO: Ck - //res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); - res1 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,2) ); - res1 = vec_sel( res1, vec_splat(diff, 1), select_w ); // TODO: Ck - //res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); - res2 = _mm_shuffle_ps( sum, sum, _MM_SHUFFLE(0,0,0,1) ); - res2 = vec_sel( res2, vec_splat(diff, 2), select_w ); // TODO: Ck - res3 = diff; - res0 = vec_sel( res0, radicand, select_x ); - res1 = vec_sel( res1, radicand, select_y ); - res2 = vec_sel( res2, radicand, select_z ); - res3 = vec_sel( res3, radicand, select_w ); - res0 = vec_mul( res0, vec_splat( scale, 0 ) ); - res1 = vec_mul( res1, vec_splat( scale, 1 ) ); - res2 = vec_mul( res2, vec_splat( scale, 2 ) ); - res3 = vec_mul( res3, vec_splat( scale, 3 ) ); - - /* determine case and select answer */ - - xx = vec_splat( col0, 0 ); - yy = vec_splat( col1, 1 ); - zz = vec_splat( col2, 2 ); - res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); - res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); - res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), _mm_setzero_ps() ) ); - mVec128 = res; -} - -__forceinline const Matrix3 outer( const Vector3 &tfrm0, const Vector3 &tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -__forceinline const Matrix4 outer( const Vector4 &tfrm0, const Vector4 &tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -__forceinline const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ) -{ - __m128 tmp0, tmp1, mcol0, mcol1, mcol2, res; - __m128 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - xxxx = vec_splat( vec.get128(), 0 ); - mcol0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - //mcol1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - mcol1 = _mm_shuffle_ps( tmp0, tmp0, _MM_SHUFFLE(0,3,2,2)); - mcol1 = vec_sel(mcol1, mat.getCol1().get128(), select_y); - //mcol2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - mcol2 = _mm_shuffle_ps( tmp1, tmp1, _MM_SHUFFLE(0,1,1,0)); - mcol2 = vec_sel(mcol2, vec_splat(mat.getCol1().get128(), 2), select_y); - yyyy = vec_splat( vec.get128(), 1 ); - res = vec_mul( mcol0, xxxx ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mcol1, yyyy, res ); - res = vec_madd( mcol2, zzzz, res ); - return Vector3( res ); -} - -__forceinline const Matrix3 crossMatrix( const Vector3 &vec ) -{ - __m128 neg, res0, res1, res2; - neg = negatef4( vec.get128() ); - __declspec(align(16)) unsigned int select_x[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) unsigned int select_y[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) unsigned int select_z[4] = {0, 0, 0xffffffff, 0}; - //res0 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_XZBX ); - res0 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,2,2,0) ); - res0 = vec_sel(res0, vec_splat(neg, 1), select_z); - //res1 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_CXXX ); - res1 = vec_sel(vec_splat(vec.get128(), 0), vec_splat(neg, 2), select_x); - //res2 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_YAXX ); - res2 = _mm_shuffle_ps( vec.get128(), vec.get128(), _MM_SHUFFLE(0,0,1,1) ); - res2 = vec_sel(res2, vec_splat(neg, 0), select_y); - __declspec(align(16)) unsigned int filter_x[4] = {0, 0xffffffff, 0xffffffff, 0xffffffff}; - __declspec(align(16)) unsigned int filter_y[4] = {0xffffffff, 0, 0xffffffff, 0xffffffff}; - __declspec(align(16)) unsigned int filter_z[4] = {0xffffffff, 0xffffffff, 0, 0xffffffff}; - res0 = vec_and( res0, _mm_load_ps((float *)filter_x ) ); - res1 = vec_and( res1, _mm_load_ps((float *)filter_y ) ); - res2 = vec_and( res2, _mm_load_ps((float *)filter_z ) ); // TODO: Use selects? - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -__forceinline const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h deleted file mode 100644 index 081cb3a4d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/quat_aos.h +++ /dev/null @@ -1,568 +0,0 @@ -/* - Copyright (C) 2006, 2010 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 { - -__forceinline void Quat::set128(vec_float4 vec) -{ - mVec128 = vec; -} - -__forceinline 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() ) ); -} - -__forceinline Quat::Quat( const Vector3 &xyz, float _w ) -{ - mVec128 = xyz.get128(); - _vmathVfSetElement(mVec128, _w, 3); -} - - - -__forceinline Quat::Quat(const Quat& quat) -{ - mVec128 = quat.get128(); -} - -__forceinline Quat::Quat( float _x, float _y, float _z, float _w ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, _w); -} - - - - - -__forceinline Quat::Quat( const Vector3 &xyz, const floatInVec &_w ) -{ - mVec128 = xyz.get128(); - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); -} - -__forceinline Quat::Quat( const Vector4 &vec ) -{ - mVec128 = vec.get128(); -} - -__forceinline Quat::Quat( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -__forceinline Quat::Quat( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -__forceinline Quat::Quat( __m128 vf4 ) -{ - mVec128 = vf4; -} - -__forceinline const Quat Quat::identity( ) -{ - return Quat( _VECTORMATH_UNIT_0001 ); -} - -__forceinline const Quat lerp( float t, const Quat &quat0, const Quat &quat1 ) -{ - return lerp( floatInVec(t), quat0, quat1 ); -} - -__forceinline const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -__forceinline const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 ) -{ - return slerp( floatInVec(t), unitQuat0, unitQuat1 ); -} - -__forceinline 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 ) ) ); -} - -__forceinline 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 ); -} - -__forceinline 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 ) ); -} - -__forceinline __m128 Quat::get128( ) const -{ - return mVec128; -} - -__forceinline Quat & Quat::operator =( const Quat &quat ) -{ - mVec128 = quat.mVec128; - return *this; -} - -__forceinline Quat & Quat::setXYZ( const Vector3 &vec ) -{ - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; - mVec128 = vec_sel( vec.get128(), mVec128, sw ); - return *this; -} - -__forceinline const Vector3 Quat::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -__forceinline Quat & Quat::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -__forceinline Quat & Quat::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -__forceinline const floatInVec Quat::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -__forceinline Quat & Quat::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -__forceinline Quat & Quat::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -__forceinline const floatInVec Quat::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -__forceinline Quat & Quat::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -__forceinline Quat & Quat::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -__forceinline const floatInVec Quat::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -__forceinline Quat & Quat::setW( float _w ) -{ - _vmathVfSetElement(mVec128, _w, 3); - return *this; -} - -__forceinline Quat & Quat::setW( const floatInVec &_w ) -{ - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); - return *this; -} - -__forceinline const floatInVec Quat::getW( ) const -{ - return floatInVec( mVec128, 3 ); -} - -__forceinline Quat & Quat::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -__forceinline Quat & Quat::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -__forceinline const floatInVec Quat::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline VecIdx Quat::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -__forceinline const floatInVec Quat::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline const Quat Quat::operator +( const Quat &quat ) const -{ - return Quat( _mm_add_ps( mVec128, quat.mVec128 ) ); -} - - -__forceinline const Quat Quat::operator -( const Quat &quat ) const -{ - return Quat( _mm_sub_ps( mVec128, quat.mVec128 ) ); -} - -__forceinline const Quat Quat::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -__forceinline const Quat Quat::operator *( const floatInVec &scalar ) const -{ - return Quat( _mm_mul_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Quat & Quat::operator +=( const Quat &quat ) -{ - *this = *this + quat; - return *this; -} - -__forceinline Quat & Quat::operator -=( const Quat &quat ) -{ - *this = *this - quat; - return *this; -} - -__forceinline Quat & Quat::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline Quat & Quat::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline const Quat Quat::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -__forceinline const Quat Quat::operator /( const floatInVec &scalar ) const -{ - return Quat( _mm_div_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Quat & Quat::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline Quat & Quat::operator /=( const floatInVec &scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline const Quat Quat::operator -( ) const -{ - return Quat(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); -} - -__forceinline const Quat operator *( float scalar, const Quat &quat ) -{ - return floatInVec(scalar) * quat; -} - -__forceinline const Quat operator *( const floatInVec &scalar, const Quat &quat ) -{ - return quat * scalar; -} - -__forceinline const floatInVec dot( const Quat &quat0, const Quat &quat1 ) -{ - return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); -} - -__forceinline const floatInVec norm( const Quat &quat ) -{ - return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); -} - -__forceinline const floatInVec length( const Quat &quat ) -{ - return floatInVec( _mm_sqrt_ps(_vmathVfDot4( quat.get128(), quat.get128() )), 0 ); -} - -__forceinline const Quat normalize( const Quat &quat ) -{ - vec_float4 dot =_vmathVfDot4( quat.get128(), quat.get128()); - return Quat( _mm_mul_ps( quat.get128(), newtonrapson_rsqrt4( dot ) ) ); -} - - -__forceinline 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 ); - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; - res = vec_sel( res, vec_mul( cosHalfAngleX2, _mm_set1_ps(0.5f) ), sw ); - return Quat( res ); -} - -__forceinline const Quat Quat::rotation( float radians, const Vector3 &unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -__forceinline 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 ); - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; - res = vec_sel( vec_mul( unitVec.get128(), s ), c, sw ); - return Quat( res ); -} - -__forceinline const Quat Quat::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -__forceinline 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 ); - __declspec(align(16)) unsigned int xsw[4] = {0xffffffff, 0, 0, 0}; - __declspec(align(16)) 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 ); -} - -__forceinline const Quat Quat::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -__forceinline 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 ); - __declspec(align(16)) unsigned int ysw[4] = {0, 0xffffffff, 0, 0}; - __declspec(align(16)) 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 ); -} - -__forceinline const Quat Quat::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -__forceinline 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 ); - __declspec(align(16)) unsigned int zsw[4] = {0, 0, 0xffffffff, 0}; - __declspec(align(16)) 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 ); -} - -__forceinline 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 ) ); - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; - return Quat( vec_sel( qv, qw, sw ) ); -} - -__forceinline Quat & Quat::operator *=( const Quat &quat ) -{ - *this = *this * quat; - return *this; -} - -__forceinline 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 ); -} - -__forceinline const Quat conj( const Quat &quat ) -{ - __declspec(align(16)) unsigned int sw[4] = {0x80000000,0x80000000,0x80000000,0}; - return Quat( vec_xor( quat.get128(), _mm_load_ps((float *)sw) ) ); -} - -__forceinline const Quat select( const Quat &quat0, const Quat &quat1, bool select1 ) -{ - return select( quat0, quat1, boolInVec(select1) ); -} - -//__forceinline const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 ) -//{ -// return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) ); -//} - -__forceinline void loadXYZW(Quat& quat, const float* fptr) -{ -#ifdef USE_SSE2_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 - - -} - -#ifdef _VECTORMATH_DEBUG - -__forceinline 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] ); -} - -__forceinline 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 diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/readme_e.txt b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/readme_e.txt deleted file mode 100644 index 6f30b2507..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/readme_e.txt +++ /dev/null @@ -1 +0,0 @@ -This folder contains an SSE implementation of the c++ aos component of the vectormath library as used by PSSG. \ No newline at end of file diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h deleted file mode 100644 index 98f560738..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vec_aos.h +++ /dev/null @@ -1,1431 +0,0 @@ -/* - Copyright (C) 2006, 2010 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H - -//----------------------------------------------------------------------------- -// Constants -// for permutes words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } -#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } -#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } -#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } -#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } -#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } -#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } -#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } -#define _VECTORMATH_UNIT_1000 _mm_setr_ps(1.0f,0.0f,0.0f,0.0f) // (__m128){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 _mm_setr_ps(0.0f,1.0f,0.0f,0.0f) // (__m128){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 _mm_setr_ps(0.0f,0.0f,1.0f,0.0f) // (__m128){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 _mm_setr_ps(0.0f,0.0f,0.0f,1.0f) // (__m128){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f -//_VECTORMATH_SLERP_TOLF - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#define _vmath_shufps(a, b, immx, immy, immz, immw) _mm_shuffle_ps(a, b, _MM_SHUFFLE(immw, immz, immy, immx)) -static __forceinline __m128 _vmathVfDot3( __m128 vec0, __m128 vec1 ) -{ - __m128 result = _mm_mul_ps( vec0, vec1); - return _mm_add_ps( vec_splat( result, 0 ), _mm_add_ps( vec_splat( result, 1 ), vec_splat( result, 2 ) ) ); -} - -static __forceinline __m128 _vmathVfDot4( __m128 vec0, __m128 vec1 ) -{ - __m128 result = _mm_mul_ps(vec0, vec1); - return _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(0,0,0,0)), - _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(1,1,1,1)), - _mm_add_ps(_mm_shuffle_ps(result, result, _MM_SHUFFLE(2,2,2,2)), _mm_shuffle_ps(result, result, _MM_SHUFFLE(3,3,3,3))))); -} - -static __forceinline __m128 _vmathVfCross( __m128 vec0, __m128 vec1 ) -{ - __m128 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,0,2,1) ); - tmp1 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,1,0,2) ); - tmp2 = _mm_shuffle_ps( vec0, vec0, _MM_SHUFFLE(3,1,0,2) ); - tmp3 = _mm_shuffle_ps( vec1, vec1, _MM_SHUFFLE(3,0,2,1) ); - result = vec_mul( tmp0, tmp1 ); - result = vec_nmsub( tmp2, tmp3, result ); - return result; -} -/* -static __forceinline vec_uint4 _vmathVfToHalfFloatsUnpacked(__m128 v) -{ -#if 0 - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = (vec_uint4)(0x00007c00u); - const vec_uint4 mergeMant = (vec_uint4)(0x000003ffu); - const vec_uint4 mergeSign = (vec_uint4)(0x00008000u); - - sign = vec_sr((vec_uint4)v, (vec_uint4)16); - mant = vec_sr((vec_uint4)v, (vec_uint4)13); - bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4)23), (vec_int4)0xff); - - notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4)112); - isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4)142); - - bexp = _mm_add_ps(bexp, (vec_int4)-112); - bexp = vec_sl(bexp, (vec_uint4)10); - - hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = vec_sel((vec_uint4)(0), hfloat, notZero); - hfloat = vec_sel(hfloat, hfloatInf, isInf); - hfloat = vec_sel(hfloat, sign, mergeSign); - - return hfloat; -#else - assert(0); - return _mm_setzero_ps(); -#endif -} - -static __forceinline vec_ushort8 _vmath2VfToHalfFloats(__m128 u, __m128 v) -{ -#if 0 - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); -#else - assert(0); - return _mm_setzero_si128(); -#endif -} -*/ - -static __forceinline __m128 _vmathVfInsert(__m128 dst, __m128 src, int slot) -{ - SSEFloat s; - s.m128 = src; - SSEFloat d; - d.m128 = dst; - d.f[slot] = s.f[slot]; - return d.m128; -} - -#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar - -static __forceinline __m128 _vmathVfSplatScalar(float scalar) -{ - return _mm_set1_ps(scalar); -} - -#endif - -namespace Vectormath { -namespace Aos { - - -#ifdef _VECTORMATH_NO_SCALAR_CAST -__forceinline VecIdx::operator floatInVec() const -{ - return floatInVec(ref, i); -} - -__forceinline float VecIdx::getAsFloat() const -#else -__forceinline VecIdx::operator float() const -#endif -{ - return ((float *)&ref)[i]; -} - -__forceinline float VecIdx::operator =( float scalar ) -{ - _vmathVfSetElement(ref, scalar, i); - return scalar; -} - -__forceinline floatInVec VecIdx::operator =( const floatInVec &scalar ) -{ - ref = _vmathVfInsert(ref, scalar.get128(), i); - return scalar; -} - -__forceinline floatInVec VecIdx::operator =( const VecIdx& scalar ) -{ - return *this = floatInVec(scalar.ref, scalar.i); -} - -__forceinline floatInVec VecIdx::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -__forceinline floatInVec VecIdx::operator *=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) * scalar; -} - -__forceinline floatInVec VecIdx::operator /=( float scalar ) -{ - return *this /= floatInVec(scalar); -} - -inline floatInVec VecIdx::operator /=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) / scalar; -} - -__forceinline floatInVec VecIdx::operator +=( float scalar ) -{ - return *this += floatInVec(scalar); -} - -__forceinline floatInVec VecIdx::operator +=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) + scalar; -} - -__forceinline floatInVec VecIdx::operator -=( float scalar ) -{ - return *this -= floatInVec(scalar); -} - -__forceinline floatInVec VecIdx::operator -=( const floatInVec &scalar ) -{ - return *this = floatInVec(ref, i) - scalar; -} - -__forceinline Vector3::Vector3(const Vector3& vec) -{ - set128(vec.get128()); -} - -__forceinline void Vector3::set128(vec_float4 vec) -{ - mVec128 = vec; -} - - -__forceinline Vector3::Vector3( float _x, float _y, float _z ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); -} - -__forceinline Vector3::Vector3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) -{ - __m128 xz = _mm_unpacklo_ps( _x.get128(), _z.get128() ); - mVec128 = _mm_unpacklo_ps( xz, _y.get128() ); -} - -__forceinline Vector3::Vector3( const Point3 &pnt ) -{ - mVec128 = pnt.get128(); -} - -__forceinline Vector3::Vector3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -__forceinline Vector3::Vector3( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -__forceinline Vector3::Vector3( __m128 vf4 ) -{ - mVec128 = vf4; -} - -__forceinline const Vector3 Vector3::xAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_1000 ); -} - -__forceinline const Vector3 Vector3::yAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0100 ); -} - -__forceinline const Vector3 Vector3::zAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0010 ); -} - -__forceinline const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -__forceinline const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -__forceinline const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -__forceinline const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ) -{ - __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); - angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t - angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t - angles = _mm_mul_ps( angles, angle ); - 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 Vector3( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); -} - -__forceinline __m128 Vector3::get128( ) const -{ - return mVec128; -} - -__forceinline void loadXYZ(Vector3& vec, const float* fptr) -{ -#ifdef USE_SSE2_LDDQU - vec = Vector3( 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]; - vec = Vector3( fl.m128); -#endif //USE_SSE2_LDDQU - -} - -__forceinline void storeXYZ( const Vector3 &vec, __m128 * quad ) -{ - __m128 dstVec = *quad; - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize - dstVec = vec_sel(vec.get128(), dstVec, sw); - *quad = dstVec; -} - -__forceinline void storeXYZ(const Vector3& vec, float* fptr) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - - -__forceinline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ) -{ - const float *quads = (float *)threeQuads; - vec0 = Vector3( _mm_load_ps(quads) ); - vec1 = Vector3( _mm_loadu_ps(quads + 3) ); - vec2 = Vector3( _mm_loadu_ps(quads + 6) ); - vec3 = Vector3( _mm_loadu_ps(quads + 9) ); -} - -__forceinline void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ) -{ - __m128 xxxx = _mm_shuffle_ps( vec1.get128(), vec1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); - __m128 zzzz = _mm_shuffle_ps( vec2.get128(), vec2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); - __declspec(align(16)) unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; - __declspec(align(16)) unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; - threeQuads[0] = vec_sel( vec0.get128(), xxxx, xsw ); - threeQuads[1] = _mm_shuffle_ps( vec1.get128(), vec2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); - threeQuads[2] = vec_sel( _mm_shuffle_ps( vec3.get128(), vec3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); -} -/* -__forceinline void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ) -{ - assert(0); -#if 0 - __m128 xyz0[3]; - __m128 xyz1[3]; - storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -#endif -} -*/ -__forceinline Vector3 & Vector3::operator =( const Vector3 &vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -__forceinline Vector3 & Vector3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -__forceinline Vector3 & Vector3::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -__forceinline const floatInVec Vector3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -__forceinline Vector3 & Vector3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -__forceinline Vector3 & Vector3::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -__forceinline const floatInVec Vector3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -__forceinline Vector3 & Vector3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -__forceinline Vector3 & Vector3::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -__forceinline const floatInVec Vector3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -__forceinline Vector3 & Vector3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -__forceinline Vector3 & Vector3::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -__forceinline const floatInVec Vector3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline VecIdx Vector3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -__forceinline const floatInVec Vector3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline const Vector3 Vector3::operator +( const Vector3 &vec ) const -{ - return Vector3( _mm_add_ps( mVec128, vec.mVec128 ) ); -} - -__forceinline const Vector3 Vector3::operator -( const Vector3 &vec ) const -{ - return Vector3( _mm_sub_ps( mVec128, vec.mVec128 ) ); -} - -__forceinline const Point3 Vector3::operator +( const Point3 &pnt ) const -{ - return Point3( _mm_add_ps( mVec128, pnt.get128() ) ); -} - -__forceinline const Vector3 Vector3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -__forceinline const Vector3 Vector3::operator *( const floatInVec &scalar ) const -{ - return Vector3( _mm_mul_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Vector3 & Vector3::operator +=( const Vector3 &vec ) -{ - *this = *this + vec; - return *this; -} - -__forceinline Vector3 & Vector3::operator -=( const Vector3 &vec ) -{ - *this = *this - vec; - return *this; -} - -__forceinline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline Vector3 & Vector3::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline const Vector3 Vector3::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -__forceinline const Vector3 Vector3::operator /( const floatInVec &scalar ) const -{ - return Vector3( _mm_div_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline Vector3 & Vector3::operator /=( const floatInVec &scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline const Vector3 Vector3::operator -( ) const -{ - //return Vector3(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); - - __declspec(align(16)) static const int array[] = {0x80000000, 0x80000000, 0x80000000, 0x80000000}; - __m128 NEG_MASK = SSEFloat(*(const vec_float4*)array).vf; - return Vector3(_mm_xor_ps(get128(),NEG_MASK)); -} - -__forceinline const Vector3 operator *( float scalar, const Vector3 &vec ) -{ - return floatInVec(scalar) * vec; -} - -__forceinline const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ) -{ - return vec * scalar; -} - -__forceinline const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_div_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const Vector3 recipPerElem( const Vector3 &vec ) -{ - return Vector3( _mm_rcp_ps( vec.get128() ) ); -} - -__forceinline const Vector3 absPerElem( const Vector3 &vec ) -{ - return Vector3( fabsf4( vec.get128() ) ); -} - -__forceinline const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Vector3( _mm_or_ps( - _mm_and_ps ( vmask, vec0.get128() ), // Value - _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs -} - -__forceinline const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_max_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const floatInVec maxElem( const Vector3 &vec ) -{ - return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -__forceinline const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _mm_min_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const floatInVec minElem( const Vector3 &vec ) -{ - return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -__forceinline const floatInVec sum( const Vector3 &vec ) -{ - return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), vec_splat( vec.get128(), 2 ) ) ); -} - -__forceinline const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return floatInVec( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); -} - -__forceinline const floatInVec lengthSqr( const Vector3 &vec ) -{ - return floatInVec( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); -} - -__forceinline const floatInVec length( const Vector3 &vec ) -{ - return floatInVec( _mm_sqrt_ps(_vmathVfDot3( vec.get128(), vec.get128() )), 0 ); -} - - -__forceinline const Vector3 normalizeApprox( const Vector3 &vec ) -{ - return Vector3( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); -} - -__forceinline const Vector3 normalize( const Vector3 &vec ) -{ - return Vector3( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot3( vec.get128(), vec.get128() ) ) ) ); -} - -__forceinline const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ) -{ - return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - - -__forceinline const Vector4 select(const Vector4& vec0, const Vector4& vec1, const boolInVec& select1) -{ - return Vector4(vec_sel(vec0.get128(), vec1.get128(), select1.get128())); -} - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Vector3 &vec ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -__forceinline void print( const Vector3 &vec, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -__forceinline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, _w); - } - -__forceinline Vector4::Vector4( 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() ) ); -} - -__forceinline Vector4::Vector4( const Vector3 &xyz, float _w ) -{ - mVec128 = xyz.get128(); - _vmathVfSetElement(mVec128, _w, 3); -} - -__forceinline Vector4::Vector4( const Vector3 &xyz, const floatInVec &_w ) -{ - mVec128 = xyz.get128(); - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); -} - -__forceinline Vector4::Vector4( const Vector3 &vec ) -{ - mVec128 = vec.get128(); - mVec128 = _vmathVfInsert(mVec128, _mm_setzero_ps(), 3); -} - -__forceinline Vector4::Vector4( const Point3 &pnt ) -{ - mVec128 = pnt.get128(); - mVec128 = _vmathVfInsert(mVec128, _mm_set1_ps(1.0f), 3); -} - -__forceinline Vector4::Vector4( const Quat &quat ) -{ - mVec128 = quat.get128(); -} - -__forceinline Vector4::Vector4( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -__forceinline Vector4::Vector4( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -__forceinline Vector4::Vector4( __m128 vf4 ) -{ - mVec128 = vf4; -} - -__forceinline const Vector4 Vector4::xAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_1000 ); -} - -__forceinline const Vector4 Vector4::yAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0100 ); -} - -__forceinline const Vector4 Vector4::zAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0010 ); -} - -__forceinline const Vector4 Vector4::wAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0001 ); -} - -__forceinline const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -__forceinline const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -__forceinline const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -__forceinline const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ) -{ - __m128 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); - __m128 selectMask = _mm_cmpgt_ps( _mm_set1_ps(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = _mm_sub_ps( _mm_set1_ps(1.0f), tttt ); - angles = _mm_unpacklo_ps( _mm_set1_ps(1.0f), tttt ); // angles = 1, t, 1, t - angles = _mm_unpacklo_ps( angles, oneMinusT ); // angles = 1, 1-t, t, 1-t - angles = _mm_mul_ps( angles, angle ); - 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 Vector4( vec_madd( unitVec0.get128(), scale0, _mm_mul_ps( unitVec1.get128(), scale1 ) ) ); -} - -__forceinline __m128 Vector4::get128( ) const -{ - return mVec128; -} -/* -__forceinline void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); -} -*/ -__forceinline Vector4 & Vector4::operator =( const Vector4 &vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -__forceinline Vector4 & Vector4::setXYZ( const Vector3 &vec ) -{ - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; - mVec128 = vec_sel( vec.get128(), mVec128, sw ); - return *this; -} - -__forceinline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -__forceinline Vector4 & Vector4::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -__forceinline Vector4 & Vector4::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -__forceinline const floatInVec Vector4::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -__forceinline Vector4 & Vector4::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -__forceinline Vector4 & Vector4::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -__forceinline const floatInVec Vector4::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -__forceinline Vector4 & Vector4::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -__forceinline Vector4 & Vector4::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -__forceinline const floatInVec Vector4::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -__forceinline Vector4 & Vector4::setW( float _w ) -{ - _vmathVfSetElement(mVec128, _w, 3); - return *this; -} - -__forceinline Vector4 & Vector4::setW( const floatInVec &_w ) -{ - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); - return *this; -} - -__forceinline const floatInVec Vector4::getW( ) const -{ - return floatInVec( mVec128, 3 ); -} - -__forceinline Vector4 & Vector4::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -__forceinline Vector4 & Vector4::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -__forceinline const floatInVec Vector4::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline VecIdx Vector4::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -__forceinline const floatInVec Vector4::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline const Vector4 Vector4::operator +( const Vector4 &vec ) const -{ - return Vector4( _mm_add_ps( mVec128, vec.mVec128 ) ); -} - -__forceinline const Vector4 Vector4::operator -( const Vector4 &vec ) const -{ - return Vector4( _mm_sub_ps( mVec128, vec.mVec128 ) ); -} - -__forceinline const Vector4 Vector4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -__forceinline const Vector4 Vector4::operator *( const floatInVec &scalar ) const -{ - return Vector4( _mm_mul_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Vector4 & Vector4::operator +=( const Vector4 &vec ) -{ - *this = *this + vec; - return *this; -} - -__forceinline Vector4 & Vector4::operator -=( const Vector4 &vec ) -{ - *this = *this - vec; - return *this; -} - -__forceinline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline Vector4 & Vector4::operator *=( const floatInVec &scalar ) -{ - *this = *this * scalar; - return *this; -} - -__forceinline const Vector4 Vector4::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -__forceinline const Vector4 Vector4::operator /( const floatInVec &scalar ) const -{ - return Vector4( _mm_div_ps( mVec128, scalar.get128() ) ); -} - -__forceinline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline Vector4 & Vector4::operator /=( const floatInVec &scalar ) -{ - *this = *this / scalar; - return *this; -} - -__forceinline const Vector4 Vector4::operator -( ) const -{ - return Vector4(_mm_sub_ps( _mm_setzero_ps(), mVec128 ) ); -} - -__forceinline const Vector4 operator *( float scalar, const Vector4 &vec ) -{ - return floatInVec(scalar) * vec; -} - -__forceinline const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ) -{ - return vec * scalar; -} - -__forceinline const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_mul_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_div_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const Vector4 recipPerElem( const Vector4 &vec ) -{ - return Vector4( _mm_rcp_ps( vec.get128() ) ); -} - -__forceinline const Vector4 absPerElem( const Vector4 &vec ) -{ - return Vector4( fabsf4( vec.get128() ) ); -} - -__forceinline const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Vector4( _mm_or_ps( - _mm_and_ps ( vmask, vec0.get128() ), // Value - _mm_andnot_ps( vmask, vec1.get128() ) ) ); // Signs -} - -__forceinline const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_max_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const floatInVec maxElem( const Vector4 &vec ) -{ - return floatInVec( _mm_max_ps( - _mm_max_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_max_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -__forceinline const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return Vector4( _mm_min_ps( vec0.get128(), vec1.get128() ) ); -} - -__forceinline const floatInVec minElem( const Vector4 &vec ) -{ - return floatInVec( _mm_min_ps( - _mm_min_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_min_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -__forceinline const floatInVec sum( const Vector4 &vec ) -{ - return floatInVec( _mm_add_ps( - _mm_add_ps( vec_splat( vec.get128(), 0 ), vec_splat( vec.get128(), 1 ) ), - _mm_add_ps( vec_splat( vec.get128(), 2 ), vec_splat( vec.get128(), 3 ) ) ) ); -} - -__forceinline const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ) -{ - return floatInVec( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); -} - -__forceinline const floatInVec lengthSqr( const Vector4 &vec ) -{ - return floatInVec( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); -} - -__forceinline const floatInVec length( const Vector4 &vec ) -{ - return floatInVec( _mm_sqrt_ps(_vmathVfDot4( vec.get128(), vec.get128() )), 0 ); -} - -__forceinline const Vector4 normalizeApprox( const Vector4 &vec ) -{ - return Vector4( _mm_mul_ps( vec.get128(), _mm_rsqrt_ps( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); -} - -__forceinline const Vector4 normalize( const Vector4 &vec ) -{ - return Vector4( _mm_mul_ps( vec.get128(), newtonrapson_rsqrt4( _vmathVfDot4( vec.get128(), vec.get128() ) ) ) ); -} - -__forceinline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Vector4 &vec ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -__forceinline void print( const Vector4 &vec, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -__forceinline Point3::Point3( float _x, float _y, float _z ) -{ - mVec128 = _mm_setr_ps(_x, _y, _z, 0.0f); -} - -__forceinline Point3::Point3( const floatInVec &_x, const floatInVec &_y, const floatInVec &_z ) -{ - mVec128 = _mm_unpacklo_ps( _mm_unpacklo_ps( _x.get128(), _z.get128() ), _y.get128() ); -} - -__forceinline Point3::Point3( const Vector3 &vec ) -{ - mVec128 = vec.get128(); -} - -__forceinline Point3::Point3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -__forceinline Point3::Point3( const floatInVec &scalar ) -{ - mVec128 = scalar.get128(); -} - -__forceinline Point3::Point3( __m128 vf4 ) -{ - mVec128 = vf4; -} - -__forceinline const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ) -{ - return lerp( floatInVec(t), pnt0, pnt1 ); -} - -__forceinline const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -__forceinline __m128 Point3::get128( ) const -{ - return mVec128; -} - -__forceinline void storeXYZ( const Point3 &pnt, __m128 * quad ) -{ - __m128 dstVec = *quad; - __declspec(align(16)) unsigned int sw[4] = {0, 0, 0, 0xffffffff}; // TODO: Centralize - dstVec = vec_sel(pnt.get128(), dstVec, sw); - *quad = dstVec; -} - -__forceinline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ) -{ - const float *quads = (float *)threeQuads; - pnt0 = Point3( _mm_load_ps(quads) ); - pnt1 = Point3( _mm_loadu_ps(quads + 3) ); - pnt2 = Point3( _mm_loadu_ps(quads + 6) ); - pnt3 = Point3( _mm_loadu_ps(quads + 9) ); -} - -__forceinline void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ) -{ - __m128 xxxx = _mm_shuffle_ps( pnt1.get128(), pnt1.get128(), _MM_SHUFFLE(0, 0, 0, 0) ); - __m128 zzzz = _mm_shuffle_ps( pnt2.get128(), pnt2.get128(), _MM_SHUFFLE(2, 2, 2, 2) ); - __declspec(align(16)) unsigned int xsw[4] = {0, 0, 0, 0xffffffff}; - __declspec(align(16)) unsigned int zsw[4] = {0xffffffff, 0, 0, 0}; - threeQuads[0] = vec_sel( pnt0.get128(), xxxx, xsw ); - threeQuads[1] = _mm_shuffle_ps( pnt1.get128(), pnt2.get128(), _MM_SHUFFLE(1, 0, 2, 1) ); - threeQuads[2] = vec_sel( _mm_shuffle_ps( pnt3.get128(), pnt3.get128(), _MM_SHUFFLE(2, 1, 0, 3) ), zzzz, zsw ); -} -/* -__forceinline void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ) -{ -#if 0 - __m128 xyz0[3]; - __m128 xyz1[3]; - storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -#else - assert(0); -#endif -} -*/ -__forceinline Point3 & Point3::operator =( const Point3 &pnt ) -{ - mVec128 = pnt.mVec128; - return *this; -} - -__forceinline Point3 & Point3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -__forceinline Point3 & Point3::setX( const floatInVec &_x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -__forceinline const floatInVec Point3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -__forceinline Point3 & Point3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -__forceinline Point3 & Point3::setY( const floatInVec &_y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -__forceinline const floatInVec Point3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -__forceinline Point3 & Point3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -__forceinline Point3 & Point3::setZ( const floatInVec &_z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -__forceinline const floatInVec Point3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -__forceinline Point3 & Point3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -__forceinline Point3 & Point3::setElem( int idx, const floatInVec &value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -__forceinline const floatInVec Point3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline VecIdx Point3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -__forceinline const floatInVec Point3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -__forceinline const Vector3 Point3::operator -( const Point3 &pnt ) const -{ - return Vector3( _mm_sub_ps( mVec128, pnt.mVec128 ) ); -} - -__forceinline const Point3 Point3::operator +( const Vector3 &vec ) const -{ - return Point3( _mm_add_ps( mVec128, vec.get128() ) ); -} - -__forceinline const Point3 Point3::operator -( const Vector3 &vec ) const -{ - return Point3( _mm_sub_ps( mVec128, vec.get128() ) ); -} - -__forceinline Point3 & Point3::operator +=( const Vector3 &vec ) -{ - *this = *this + vec; - return *this; -} - -__forceinline Point3 & Point3::operator -=( const Vector3 &vec ) -{ - *this = *this - vec; - return *this; -} - -__forceinline const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_mul_ps( pnt0.get128(), pnt1.get128() ) ); -} - -__forceinline const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_div_ps( pnt0.get128(), pnt1.get128() ) ); -} - -__forceinline const Point3 recipPerElem( const Point3 &pnt ) -{ - return Point3( _mm_rcp_ps( pnt.get128() ) ); -} - -__forceinline const Point3 absPerElem( const Point3 &pnt ) -{ - return Point3( fabsf4( pnt.get128() ) ); -} - -__forceinline const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - __m128 vmask = toM128(0x7fffffff); - return Point3( _mm_or_ps( - _mm_and_ps ( vmask, pnt0.get128() ), // Value - _mm_andnot_ps( vmask, pnt1.get128() ) ) ); // Signs -} - -__forceinline const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_max_ps( pnt0.get128(), pnt1.get128() ) ); -} - -__forceinline const floatInVec maxElem( const Point3 &pnt ) -{ - return floatInVec( _mm_max_ps( _mm_max_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -__forceinline const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return Point3( _mm_min_ps( pnt0.get128(), pnt1.get128() ) ); -} - -__forceinline const floatInVec minElem( const Point3 &pnt ) -{ - return floatInVec( _mm_min_ps( _mm_min_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -__forceinline const floatInVec sum( const Point3 &pnt ) -{ - return floatInVec( _mm_add_ps( _mm_add_ps( vec_splat( pnt.get128(), 0 ), vec_splat( pnt.get128(), 1 ) ), vec_splat( pnt.get128(), 2 ) ) ); -} - -__forceinline const Point3 scale( const Point3 &pnt, float scaleVal ) -{ - return scale( pnt, floatInVec( scaleVal ) ); -} - -__forceinline const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -__forceinline const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -__forceinline const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ) -{ - return floatInVec( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); -} - -__forceinline const floatInVec distSqrFromOrigin( const Point3 &pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -__forceinline const floatInVec distFromOrigin( const Point3 &pnt ) -{ - return length( Vector3( pnt ) ); -} - -__forceinline const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -__forceinline const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -__forceinline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ) -{ - return select( pnt0, pnt1, boolInVec(select1) ); -} - -__forceinline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ) -{ - return Point3( vec_sel( pnt0.get128(), pnt1.get128(), select1.get128() ) ); -} - - - -#ifdef _VECTORMATH_DEBUG - -__forceinline void print( const Point3 &pnt ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -__forceinline void print( const Point3 &pnt, const char * name ) -{ - union { __m128 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h deleted file mode 100644 index 703790f96..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vecidx_aos.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2006, 2010 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. -// - -__declspec(align(16)) 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 diff --git a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h deleted file mode 100644 index 131c754a6..000000000 --- a/Extras/vectormathlibrary/include/vectormath/SSE/cpp/vectormath_aos.h +++ /dev/null @@ -1,2527 +0,0 @@ -/* - Copyright (C) 2006, 2010 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_AOS_CPP_SSE_H -#define _VECTORMATH_AOS_CPP_SSE_H - -#include -#include -#include -#include - -#define USE_SSE2_LDDQU -#ifdef USE_SSE2_LDDQU -#include //used for _mm_lddqu_si128 -#endif //USE_SSE2_LDDQU - -// TODO: Tidy -typedef __m128 vec_float4; -typedef __m128 vec_uint4; -typedef __m128 vec_int4; -typedef __m128i vec_uchar16; -typedef __m128i vec_ushort8; - -#define vec_splat(x, e) _mm_shuffle_ps(x, x, _MM_SHUFFLE(e,e,e,e)) - -#define _mm_ror_ps(vec,i) \ - (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(i+3)%4,(unsigned char)(i+2)%4,(unsigned char)(i+1)%4,(unsigned char)(i+0)%4))) : (vec)) -#define _mm_rol_ps(vec,i) \ - (((i)%4) ? (_mm_shuffle_ps(vec,vec, _MM_SHUFFLE((unsigned char)(7-i)%4,(unsigned char)(6-i)%4,(unsigned char)(5-i)%4,(unsigned char)(4-i)%4))) : (vec)) - -#define vec_sld(vec,vec2,x) _mm_ror_ps(vec, ((x)/4)) - -#define _mm_abs_ps(vec) _mm_andnot_ps(_MASKSIGN_,vec) -#define _mm_neg_ps(vec) _mm_xor_ps(_MASKSIGN_,vec) - -#define vec_madd(a, b, c) _mm_add_ps(c, _mm_mul_ps(a, b) ) - -union SSEFloat -{ - __m128i vi; - __m128 m128; - __m128 vf; - unsigned int ui[4]; - unsigned short s[8]; - float f[4]; - SSEFloat(__m128 v) : m128(v) {} - SSEFloat(__m128i v) : vi(v) {} - SSEFloat() {}//uninitialized -}; - -static __forceinline __m128 vec_sel(__m128 a, __m128 b, __m128 mask) -{ - return _mm_or_ps(_mm_and_ps(mask, b), _mm_andnot_ps(mask, a)); -} -static __forceinline __m128 vec_sel(__m128 a, __m128 b, const unsigned int *_mask) -{ - return vec_sel(a, b, _mm_load_ps((float *)_mask)); -} -static __forceinline __m128 vec_sel(__m128 a, __m128 b, unsigned int _mask) -{ - return vec_sel(a, b, _mm_set1_ps(*(float *)&_mask)); -} - -static __forceinline __m128 toM128(unsigned int x) -{ - return _mm_set1_ps( *(float *)&x ); -} - -static __forceinline __m128 fabsf4(__m128 x) -{ - return _mm_and_ps( x, toM128( 0x7fffffff ) ); -} -/* -union SSE64 -{ - __m128 m128; - struct - { - __m64 m01; - __m64 m23; - } m64; -}; - -static __forceinline __m128 vec_cts(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - SSE64 sse64; - sse64.m64.m01 = _mm_cvttps_pi32(x); - sse64.m64.m23 = _mm_cvttps_pi32(_mm_ror_ps(x,2)); - _mm_empty(); - return sse64.m128; -} - -static __forceinline __m128 vec_ctf(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - SSE64 sse64; - sse64.m128 = x; - __m128 result =_mm_movelh_ps( - _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m01), - _mm_cvt_pi2ps(_mm_setzero_ps(), sse64.m64.m23)); - _mm_empty(); - return result; -} -*/ -static __forceinline __m128 vec_cts(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - __m128i result = _mm_cvtps_epi32(x); - return (__m128 &)result; -} - -static __forceinline __m128 vec_ctf(__m128 x, int a) -{ - assert(a == 0); // Only 2^0 supported - (void)a; - return _mm_cvtepi32_ps((__m128i &)x); -} - -#define vec_nmsub(a,b,c) _mm_sub_ps( c, _mm_mul_ps( a, b ) ) -#define vec_sub(a,b) _mm_sub_ps( a, b ) -#define vec_add(a,b) _mm_add_ps( a, b ) -#define vec_mul(a,b) _mm_mul_ps( a, b ) -#define vec_xor(a,b) _mm_xor_ps( a, b ) -#define vec_and(a,b) _mm_and_ps( a, b ) -#define vec_cmpeq(a,b) _mm_cmpeq_ps( a, b ) -#define vec_cmpgt(a,b) _mm_cmpgt_ps( a, b ) - -#define vec_mergeh(a,b) _mm_unpacklo_ps( a, b ) -#define vec_mergel(a,b) _mm_unpackhi_ps( a, b ) - -#define vec_andc(a,b) _mm_andnot_ps( b, a ) - -#define sqrtf4(x) _mm_sqrt_ps( x ) -#define rsqrtf4(x) _mm_rsqrt_ps( x ) -#define recipf4(x) _mm_rcp_ps( x ) -#define negatef4(x) _mm_sub_ps( _mm_setzero_ps(), x ) - -static __forceinline __m128 newtonrapson_rsqrt4( const __m128 v ) -{ -#define _half4 _mm_setr_ps(.5f,.5f,.5f,.5f) -#define _three _mm_setr_ps(3.f,3.f,3.f,3.f) -const __m128 approx = _mm_rsqrt_ps( v ); -const __m128 muls = _mm_mul_ps(_mm_mul_ps(v, approx), approx); -return _mm_mul_ps(_mm_mul_ps(_half4, approx), _mm_sub_ps(_three, muls) ); -} - -static __forceinline __m128 acosf4(__m128 x) -{ - __m128 xabs = fabsf4(x); - __m128 select = _mm_cmplt_ps( x, _mm_setzero_ps() ); - __m128 t1 = sqrtf4(vec_sub(_mm_set1_ps(1.0f), xabs)); - - /* Instruction counts can be reduced if the polynomial was - * computed entirely from nested (dependent) fma's. However, - * to reduce the number of pipeline stalls, the polygon is evaluated - * in two halves (hi amd lo). - */ - __m128 xabs2 = _mm_mul_ps(xabs, xabs); - __m128 xabs4 = _mm_mul_ps(xabs2, xabs2); - __m128 hi = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0012624911f), - xabs, _mm_set1_ps(0.0066700901f)), - xabs, _mm_set1_ps(-0.0170881256f)), - xabs, _mm_set1_ps( 0.0308918810f)); - __m128 lo = vec_madd(vec_madd(vec_madd(_mm_set1_ps(-0.0501743046f), - xabs, _mm_set1_ps(0.0889789874f)), - xabs, _mm_set1_ps(-0.2145988016f)), - xabs, _mm_set1_ps( 1.5707963050f)); - - __m128 result = vec_madd(hi, xabs4, lo); - - // Adjust the result if x is negactive. - return vec_sel( - vec_mul(t1, result), // Positive - vec_nmsub(t1, result, _mm_set1_ps(3.1415926535898f)), // Negative - select); -} - -static __forceinline __m128 sinf4(vec_float4 x) -{ - -// -// Common constants used to evaluate sinf4/cosf4/tanf4 -// -#define _SINCOS_CC0 -0.0013602249f -#define _SINCOS_CC1 0.0416566950f -#define _SINCOS_CC2 -0.4999990225f -#define _SINCOS_SC0 -0.0001950727f -#define _SINCOS_SC1 0.0083320758f -#define _SINCOS_SC2 -0.1666665247f - -#define _SINCOS_KC1 1.57079625129f -#define _SINCOS_KC2 7.54978995489e-8f - - vec_float4 xl,xl2,xl3,res; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - vec_int4 q = vec_cts(xl,0); - - // Compute an offset based on the quadrant that the angle falls in - // - vec_int4 offset = _mm_and_ps(q,toM128(0x3)); - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = vec_ctf(q,0); - xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); - - // Compute x^2 and x^3 - // - xl2 = vec_mul(xl,xl); - xl3 = vec_mul(xl2,xl); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - - vec_float4 cx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); - vec_float4 sx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - res = vec_sel(cx,sx,vec_cmpeq(vec_and(offset, - toM128(0x1)), - _mm_setzero_ps())); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - return vec_sel( - vec_xor(toM128(0x80000000U), res), // Negative - res, // Positive - vec_cmpeq(vec_and(offset,toM128(0x2)),_mm_setzero_ps())); -} - -static __forceinline void sincosf4(vec_float4 x, vec_float4* s, vec_float4* c) -{ - vec_float4 xl,xl2,xl3; - vec_int4 offsetSin, offsetCos; - - // Range reduction using : xl = angle * TwoOverPi; - // - xl = vec_mul(x, _mm_set1_ps(0.63661977236f)); - - // Find the quadrant the angle falls in - // using: q = (int) (ceil(abs(xl))*sign(xl)) - // - //vec_int4 q = vec_cts(vec_add(xl,vec_sel(_mm_set1_ps(0.5f),xl,(0x80000000))),0); - vec_int4 q = vec_cts(xl,0); - - // Compute the offset based on the quadrant that the angle falls in. - // Add 1 to the offset for the cosine. - // - offsetSin = vec_and(q,toM128((int)0x3)); - __m128i temp = _mm_add_epi32(_mm_set1_epi32(1),(__m128i &)offsetSin); - offsetCos = (__m128 &)temp; - - // Remainder in range [-pi/4..pi/4] - // - vec_float4 qf = vec_ctf(q,0); - xl = vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC2),vec_nmsub(qf,_mm_set1_ps(_SINCOS_KC1),x)); - - // Compute x^2 and x^3 - // - xl2 = vec_mul(xl,xl); - xl3 = vec_mul(xl2,xl); - - // Compute both the sin and cos of the angles - // using a polynomial expression: - // cx = 1.0f + xl2 * ((C0 * xl2 + C1) * xl2 + C2), and - // sx = xl + xl3 * ((S0 * xl2 + S1) * xl2 + S2) - // - vec_float4 cx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_CC0),xl2,_mm_set1_ps(_SINCOS_CC1)),xl2,_mm_set1_ps(_SINCOS_CC2)),xl2,_mm_set1_ps(1.0f)); - vec_float4 sx = - vec_madd( - vec_madd( - vec_madd(_mm_set1_ps(_SINCOS_SC0),xl2,_mm_set1_ps(_SINCOS_SC1)),xl2,_mm_set1_ps(_SINCOS_SC2)),xl3,xl); - - // Use the cosine when the offset is odd and the sin - // when the offset is even - // - vec_uint4 sinMask = (vec_uint4)vec_cmpeq(vec_and(offsetSin,toM128(0x1)),_mm_setzero_ps()); - vec_uint4 cosMask = (vec_uint4)vec_cmpeq(vec_and(offsetCos,toM128(0x1)),_mm_setzero_ps()); - *s = vec_sel(cx,sx,sinMask); - *c = vec_sel(cx,sx,cosMask); - - // Flip the sign of the result when (offset mod 4) = 1 or 2 - // - sinMask = vec_cmpeq(vec_and(offsetSin,toM128(0x2)),_mm_setzero_ps()); - cosMask = vec_cmpeq(vec_and(offsetCos,toM128(0x2)),_mm_setzero_ps()); - - *s = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*s),*s,sinMask); - *c = vec_sel((vec_float4)vec_xor(toM128(0x80000000),(vec_uint4)*c),*c,cosMask); -} - -#include "vecidx_aos.h" -#include "floatInVec.h" -#include "boolInVec.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - __m128 mVec128; - - __forceinline void set128(vec_float4 vec); - - __forceinline vec_float4& get128Ref(); - -public: - // Default constructor; does no initialization - // - __forceinline Vector3( ) { }; - - // Default copy constructor - // - __forceinline Vector3(const Vector3& vec); - - // Construct a 3-D vector from x, y, and z elements - // - __forceinline Vector3( float x, float y, float z ); - - // Construct a 3-D vector from x, y, and z elements (scalar data contained in vector data type) - // - __forceinline Vector3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit __forceinline Vector3( const Point3 &pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit __forceinline Vector3( float scalar ); - - // Set all elements of a 3-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Vector3( const floatInVec &scalar ); - - // Set vector float data in a 3-D vector - // - explicit __forceinline Vector3( __m128 vf4 ); - - // Get vector float data from a 3-D vector - // - __forceinline __m128 get128( ) const; - - // Assign one 3-D vector to another - // - __forceinline Vector3 & operator =( const Vector3 &vec ); - - // Set the x element of a 3-D vector - // - __forceinline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - __forceinline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - __forceinline Vector3 & setZ( float z ); - - // Set the x element of a 3-D vector (scalar data contained in vector data type) - // - __forceinline Vector3 & setX( const floatInVec &x ); - - // Set the y element of a 3-D vector (scalar data contained in vector data type) - // - __forceinline Vector3 & setY( const floatInVec &y ); - - // Set the z element of a 3-D vector (scalar data contained in vector data type) - // - __forceinline Vector3 & setZ( const floatInVec &z ); - - // Get the x element of a 3-D vector - // - __forceinline const floatInVec getX( ) const; - - // Get the y element of a 3-D vector - // - __forceinline const floatInVec getY( ) const; - - // Get the z element of a 3-D vector - // - __forceinline const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - __forceinline Vector3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D vector by index (scalar data contained in vector data type) - // - __forceinline Vector3 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, or z element of a 3-D vector by index - // - __forceinline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - __forceinline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - __forceinline const floatInVec operator []( int idx ) const; - - // Add two 3-D vectors - // - __forceinline const Vector3 operator +( const Vector3 &vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - __forceinline const Vector3 operator -( const Vector3 &vec ) const; - - // Add a 3-D vector to a 3-D point - // - __forceinline const Point3 operator +( const Point3 &pnt ) const; - - // Multiply a 3-D vector by a scalar - // - __forceinline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - __forceinline const Vector3 operator /( float scalar ) const; - - // Multiply a 3-D vector by a scalar (scalar data contained in vector data type) - // - __forceinline const Vector3 operator *( const floatInVec &scalar ) const; - - // Divide a 3-D vector by a scalar (scalar data contained in vector data type) - // - __forceinline const Vector3 operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - __forceinline Vector3 & operator +=( const Vector3 &vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - __forceinline Vector3 & operator -=( const Vector3 &vec ); - - // Perform compound assignment and multiplication by a scalar - // - __forceinline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - __forceinline Vector3 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - __forceinline Vector3 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - __forceinline Vector3 & operator /=( const floatInVec &scalar ); - - // Negate all elements of a 3-D vector - // - __forceinline const Vector3 operator -( ) const; - - // Construct x axis - // - static __forceinline const Vector3 xAxis( ); - - // Construct y axis - // - static __forceinline const Vector3 yAxis( ); - - // Construct z axis - // - static __forceinline const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -__forceinline const Vector3 operator *( float scalar, const Vector3 &vec ); - -// Multiply a 3-D vector by a scalar (scalar data contained in vector data type) -// -__forceinline const Vector3 operator *( const floatInVec &scalar, const Vector3 &vec ); - -// Multiply two 3-D vectors per element -// -__forceinline const Vector3 mulPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -__forceinline const Vector3 divPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -__forceinline const Vector3 recipPerElem( const Vector3 &vec ); - -// Compute the absolute value of a 3-D vector per element -// -__forceinline const Vector3 absPerElem( const Vector3 &vec ); - -// Copy sign from one 3-D vector to another, per element -// -__forceinline const Vector3 copySignPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Maximum of two 3-D vectors per element -// -__forceinline const Vector3 maxPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Minimum of two 3-D vectors per element -// -__forceinline const Vector3 minPerElem( const Vector3 &vec0, const Vector3 &vec1 ); - -// Maximum element of a 3-D vector -// -__forceinline const floatInVec maxElem( const Vector3 &vec ); - -// Minimum element of a 3-D vector -// -__forceinline const floatInVec minElem( const Vector3 &vec ); - -// Compute the sum of all elements of a 3-D vector -// -__forceinline const floatInVec sum( const Vector3 &vec ); - -// Compute the dot product of two 3-D vectors -// -__forceinline const floatInVec dot( const Vector3 &vec0, const Vector3 &vec1 ); - -// Compute the square of the length of a 3-D vector -// -__forceinline const floatInVec lengthSqr( const Vector3 &vec ); - -// Compute the length of a 3-D vector -// -__forceinline const floatInVec length( const Vector3 &vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -__forceinline const Vector3 normalize( const Vector3 &vec ); - -// Compute cross product of two 3-D vectors -// -__forceinline const Vector3 cross( const Vector3 &vec0, const Vector3 &vec1 ); - -// Outer product of two 3-D vectors -// -__forceinline const Matrix3 outer( const Vector3 &vec0, const Vector3 &vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// NOTE: -// Slower than column post-multiply. -// -__forceinline const Vector3 rowMul( const Vector3 &vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -__forceinline const Matrix3 crossMatrix( const Vector3 &vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -__forceinline const Matrix3 crossMatrixMul( const Vector3 &vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Vector3 lerp( float t, const Vector3 &vec0, const Vector3 &vec1 ); - -// Linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Vector3 lerp( const floatInVec &t, const Vector3 &vec0, const Vector3 &vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -__forceinline const Vector3 slerp( float t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); - -// Spherical linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -__forceinline const Vector3 slerp( const floatInVec &t, const Vector3 &unitVec0, const Vector3 &unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, bool select1 ); - -// Conditionally select between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Vector3 select( const Vector3 &vec0, const Vector3 &vec1, const boolInVec &select1 ); - -// Store x, y, and z elements of 3-D vector in first three words of a quadword, preserving fourth word -// -__forceinline void storeXYZ( const Vector3 &vec, __m128 * quad ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -__forceinline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const __m128 * threeQuads ); - -// Store four 3-D vectors in three quadwords -// -__forceinline void storeXYZArray( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, __m128 * threeQuads ); - -// Store eight 3-D vectors as half-floats -// -__forceinline void storeHalfFloats( const Vector3 &vec0, const Vector3 &vec1, const Vector3 &vec2, const Vector3 &vec3, const Vector3 &vec4, const Vector3 &vec5, const Vector3 &vec6, const Vector3 &vec7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Vector3 &vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Vector3 &vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - __forceinline Vector4( ) { }; - - // Construct a 4-D vector from x, y, z, and w elements - // - __forceinline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from x, y, z, and w elements (scalar data contained in vector data type) - // - __forceinline Vector4( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - __forceinline Vector4( const Vector3 &xyz, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar (scalar data contained in vector data type) - // - __forceinline Vector4( const Vector3 &xyz, const floatInVec &w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit __forceinline Vector4( const Vector3 &vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit __forceinline Vector4( const Point3 &pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit __forceinline Vector4( const Quat &quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit __forceinline Vector4( float scalar ); - - // Set all elements of a 4-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Vector4( const floatInVec &scalar ); - - // Set vector float data in a 4-D vector - // - explicit __forceinline Vector4( __m128 vf4 ); - - // Get vector float data from a 4-D vector - // - __forceinline __m128 get128( ) const; - - // Assign one 4-D vector to another - // - __forceinline Vector4 & operator =( const Vector4 &vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - __forceinline Vector4 & setXYZ( const Vector3 &vec ); - - // Get the x, y, and z elements of a 4-D vector - // - __forceinline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - __forceinline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - __forceinline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - __forceinline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - __forceinline Vector4 & setW( float w ); - - // Set the x element of a 4-D vector (scalar data contained in vector data type) - // - __forceinline Vector4 & setX( const floatInVec &x ); - - // Set the y element of a 4-D vector (scalar data contained in vector data type) - // - __forceinline Vector4 & setY( const floatInVec &y ); - - // Set the z element of a 4-D vector (scalar data contained in vector data type) - // - __forceinline Vector4 & setZ( const floatInVec &z ); - - // Set the w element of a 4-D vector (scalar data contained in vector data type) - // - __forceinline Vector4 & setW( const floatInVec &w ); - - // Get the x element of a 4-D vector - // - __forceinline const floatInVec getX( ) const; - - // Get the y element of a 4-D vector - // - __forceinline const floatInVec getY( ) const; - - // Get the z element of a 4-D vector - // - __forceinline const floatInVec getZ( ) const; - - // Get the w element of a 4-D vector - // - __forceinline const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - __forceinline Vector4 & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a 4-D vector by index (scalar data contained in vector data type) - // - __forceinline Vector4 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - __forceinline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - __forceinline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - __forceinline const floatInVec operator []( int idx ) const; - - // Add two 4-D vectors - // - __forceinline const Vector4 operator +( const Vector4 &vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - __forceinline const Vector4 operator -( const Vector4 &vec ) const; - - // Multiply a 4-D vector by a scalar - // - __forceinline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - __forceinline const Vector4 operator /( float scalar ) const; - - // Multiply a 4-D vector by a scalar (scalar data contained in vector data type) - // - __forceinline const Vector4 operator *( const floatInVec &scalar ) const; - - // Divide a 4-D vector by a scalar (scalar data contained in vector data type) - // - __forceinline const Vector4 operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - __forceinline Vector4 & operator +=( const Vector4 &vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - __forceinline Vector4 & operator -=( const Vector4 &vec ); - - // Perform compound assignment and multiplication by a scalar - // - __forceinline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - __forceinline Vector4 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - __forceinline Vector4 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - __forceinline Vector4 & operator /=( const floatInVec &scalar ); - - // Negate all elements of a 4-D vector - // - __forceinline const Vector4 operator -( ) const; - - // Construct x axis - // - static __forceinline const Vector4 xAxis( ); - - // Construct y axis - // - static __forceinline const Vector4 yAxis( ); - - // Construct z axis - // - static __forceinline const Vector4 zAxis( ); - - // Construct w axis - // - static __forceinline const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -__forceinline const Vector4 operator *( float scalar, const Vector4 &vec ); - -// Multiply a 4-D vector by a scalar (scalar data contained in vector data type) -// -__forceinline const Vector4 operator *( const floatInVec &scalar, const Vector4 &vec ); - -// Multiply two 4-D vectors per element -// -__forceinline const Vector4 mulPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -__forceinline const Vector4 divPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -__forceinline const Vector4 recipPerElem( const Vector4 &vec ); - -// Compute the absolute value of a 4-D vector per element -// -__forceinline const Vector4 absPerElem( const Vector4 &vec ); - -// Copy sign from one 4-D vector to another, per element -// -__forceinline const Vector4 copySignPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Maximum of two 4-D vectors per element -// -__forceinline const Vector4 maxPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Minimum of two 4-D vectors per element -// -__forceinline const Vector4 minPerElem( const Vector4 &vec0, const Vector4 &vec1 ); - -// Maximum element of a 4-D vector -// -__forceinline const floatInVec maxElem( const Vector4 &vec ); - -// Minimum element of a 4-D vector -// -__forceinline const floatInVec minElem( const Vector4 &vec ); - -// Compute the sum of all elements of a 4-D vector -// -__forceinline const floatInVec sum( const Vector4 &vec ); - -// Compute the dot product of two 4-D vectors -// -__forceinline const floatInVec dot( const Vector4 &vec0, const Vector4 &vec1 ); - -// Compute the square of the length of a 4-D vector -// -__forceinline const floatInVec lengthSqr( const Vector4 &vec ); - -// Compute the length of a 4-D vector -// -__forceinline const floatInVec length( const Vector4 &vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -__forceinline const Vector4 normalize( const Vector4 &vec ); - -// Outer product of two 4-D vectors -// -__forceinline const Matrix4 outer( const Vector4 &vec0, const Vector4 &vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Vector4 lerp( float t, const Vector4 &vec0, const Vector4 &vec1 ); - -// Linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Vector4 lerp( const floatInVec &t, const Vector4 &vec0, const Vector4 &vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -__forceinline const Vector4 slerp( float t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); - -// Spherical linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -__forceinline const Vector4 slerp( const floatInVec &t, const Vector4 &unitVec0, const Vector4 &unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, bool select1 ); - -// Conditionally select between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Vector4 select( const Vector4 &vec0, const Vector4 &vec1, const boolInVec &select1 ); - -// Store four 4-D vectors as half-floats -// -__forceinline void storeHalfFloats( const Vector4 &vec0, const Vector4 &vec1, const Vector4 &vec2, const Vector4 &vec3, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Vector4 &vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Vector4 &vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - __forceinline Point3( ) { }; - - // Construct a 3-D point from x, y, and z elements - // - __forceinline Point3( float x, float y, float z ); - - // Construct a 3-D point from x, y, and z elements (scalar data contained in vector data type) - // - __forceinline Point3( const floatInVec &x, const floatInVec &y, const floatInVec &z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit __forceinline Point3( const Vector3 &vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit __forceinline Point3( float scalar ); - - // Set all elements of a 3-D point to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Point3( const floatInVec &scalar ); - - // Set vector float data in a 3-D point - // - explicit __forceinline Point3( __m128 vf4 ); - - // Get vector float data from a 3-D point - // - __forceinline __m128 get128( ) const; - - // Assign one 3-D point to another - // - __forceinline Point3 & operator =( const Point3 &pnt ); - - // Set the x element of a 3-D point - // - __forceinline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - __forceinline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - __forceinline Point3 & setZ( float z ); - - // Set the x element of a 3-D point (scalar data contained in vector data type) - // - __forceinline Point3 & setX( const floatInVec &x ); - - // Set the y element of a 3-D point (scalar data contained in vector data type) - // - __forceinline Point3 & setY( const floatInVec &y ); - - // Set the z element of a 3-D point (scalar data contained in vector data type) - // - __forceinline Point3 & setZ( const floatInVec &z ); - - // Get the x element of a 3-D point - // - __forceinline const floatInVec getX( ) const; - - // Get the y element of a 3-D point - // - __forceinline const floatInVec getY( ) const; - - // Get the z element of a 3-D point - // - __forceinline const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - __forceinline Point3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D point by index (scalar data contained in vector data type) - // - __forceinline Point3 & setElem( int idx, const floatInVec &value ); - - // Get an x, y, or z element of a 3-D point by index - // - __forceinline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - __forceinline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - __forceinline const floatInVec operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - __forceinline const Vector3 operator -( const Point3 &pnt ) const; - - // Add a 3-D point to a 3-D vector - // - __forceinline const Point3 operator +( const Vector3 &vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - __forceinline const Point3 operator -( const Vector3 &vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - __forceinline Point3 & operator +=( const Vector3 &vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - __forceinline Point3 & operator -=( const Vector3 &vec ); - -}; - -// Multiply two 3-D points per element -// -__forceinline const Point3 mulPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -__forceinline const Point3 divPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -__forceinline const Point3 recipPerElem( const Point3 &pnt ); - -// Compute the absolute value of a 3-D point per element -// -__forceinline const Point3 absPerElem( const Point3 &pnt ); - -// Copy sign from one 3-D point to another, per element -// -__forceinline const Point3 copySignPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Maximum of two 3-D points per element -// -__forceinline const Point3 maxPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Minimum of two 3-D points per element -// -__forceinline const Point3 minPerElem( const Point3 &pnt0, const Point3 &pnt1 ); - -// Maximum element of a 3-D point -// -__forceinline const floatInVec maxElem( const Point3 &pnt ); - -// Minimum element of a 3-D point -// -__forceinline const floatInVec minElem( const Point3 &pnt ); - -// Compute the sum of all elements of a 3-D point -// -__forceinline const floatInVec sum( const Point3 &pnt ); - -// Apply uniform scale to a 3-D point -// -__forceinline const Point3 scale( const Point3 &pnt, float scaleVal ); - -// Apply uniform scale to a 3-D point (scalar data contained in vector data type) -// -__forceinline const Point3 scale( const Point3 &pnt, const floatInVec &scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -__forceinline const Point3 scale( const Point3 &pnt, const Vector3 &scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -__forceinline const floatInVec projection( const Point3 &pnt, const Vector3 &unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -__forceinline const floatInVec distSqrFromOrigin( const Point3 &pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -__forceinline const floatInVec distFromOrigin( const Point3 &pnt ); - -// Compute the square of the distance between two 3-D points -// -__forceinline const floatInVec distSqr( const Point3 &pnt0, const Point3 &pnt1 ); - -// Compute the distance between two 3-D points -// -__forceinline const floatInVec dist( const Point3 &pnt0, const Point3 &pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Point3 lerp( float t, const Point3 &pnt0, const Point3 &pnt1 ); - -// Linear interpolation between two 3-D points (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Point3 lerp( const floatInVec &t, const Point3 &pnt0, const Point3 &pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, bool select1 ); - -// Conditionally select between two 3-D points (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Point3 select( const Point3 &pnt0, const Point3 &pnt1, const boolInVec &select1 ); - -// Store x, y, and z elements of 3-D point in first three words of a quadword, preserving fourth word -// -__forceinline void storeXYZ( const Point3 &pnt, __m128 * quad ); - -// Load four three-float 3-D points, stored in three quadwords -// -__forceinline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const __m128 * threeQuads ); - -// Store four 3-D points in three quadwords -// -__forceinline void storeXYZArray( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, __m128 * threeQuads ); - -// Store eight 3-D points as half-floats -// -__forceinline void storeHalfFloats( const Point3 &pnt0, const Point3 &pnt1, const Point3 &pnt2, const Point3 &pnt3, const Point3 &pnt4, const Point3 &pnt5, const Point3 &pnt6, const Point3 &pnt7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Point3 &pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Point3 &pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - __m128 mVec128; - -public: - // Default constructor; does no initialization - // - __forceinline Quat( ) { }; - - __forceinline Quat::Quat(const Quat& quat); - - // Construct a quaternion from x, y, z, and w elements - // - __forceinline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from x, y, z, and w elements (scalar data contained in vector data type) - // - __forceinline Quat( const floatInVec &x, const floatInVec &y, const floatInVec &z, const floatInVec &w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - __forceinline Quat( const Vector3 &xyz, float w ); - - // Construct a quaternion from a 3-D vector and a scalar (scalar data contained in vector data type) - // - __forceinline Quat( const Vector3 &xyz, const floatInVec &w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit __forceinline Quat( const Vector4 &vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit __forceinline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit __forceinline Quat( float scalar ); - - // Set all elements of a quaternion to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Quat( const floatInVec &scalar ); - - // Set vector float data in a quaternion - // - explicit __forceinline Quat( __m128 vf4 ); - - // Get vector float data from a quaternion - // - __forceinline __m128 get128( ) const; - - // Set a quaterion from vector float data - // - __forceinline void set128(vec_float4 vec); - - // Assign one quaternion to another - // - __forceinline Quat & operator =( const Quat &quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - __forceinline Quat & setXYZ( const Vector3 &vec ); - - // Get the x, y, and z elements of a quaternion - // - __forceinline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - __forceinline Quat & setX( float x ); - - // Set the y element of a quaternion - // - __forceinline Quat & setY( float y ); - - // Set the z element of a quaternion - // - __forceinline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - __forceinline Quat & setW( float w ); - - // Set the x element of a quaternion (scalar data contained in vector data type) - // - __forceinline Quat & setX( const floatInVec &x ); - - // Set the y element of a quaternion (scalar data contained in vector data type) - // - __forceinline Quat & setY( const floatInVec &y ); - - // Set the z element of a quaternion (scalar data contained in vector data type) - // - __forceinline Quat & setZ( const floatInVec &z ); - - // Set the w element of a quaternion (scalar data contained in vector data type) - // - __forceinline Quat & setW( const floatInVec &w ); - - // Get the x element of a quaternion - // - __forceinline const floatInVec getX( ) const; - - // Get the y element of a quaternion - // - __forceinline const floatInVec getY( ) const; - - // Get the z element of a quaternion - // - __forceinline const floatInVec getZ( ) const; - - // Get the w element of a quaternion - // - __forceinline const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - __forceinline Quat & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a quaternion by index (scalar data contained in vector data type) - // - __forceinline Quat & setElem( int idx, const floatInVec &value ); - - // Get an x, y, z, or w element of a quaternion by index - // - __forceinline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - __forceinline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - __forceinline const floatInVec operator []( int idx ) const; - - // Add two quaternions - // - __forceinline const Quat operator +( const Quat &quat ) const; - - // Subtract a quaternion from another quaternion - // - __forceinline const Quat operator -( const Quat &quat ) const; - - // Multiply two quaternions - // - __forceinline const Quat operator *( const Quat &quat ) const; - - // Multiply a quaternion by a scalar - // - __forceinline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - __forceinline const Quat operator /( float scalar ) const; - - // Multiply a quaternion by a scalar (scalar data contained in vector data type) - // - __forceinline const Quat operator *( const floatInVec &scalar ) const; - - // Divide a quaternion by a scalar (scalar data contained in vector data type) - // - __forceinline const Quat operator /( const floatInVec &scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - __forceinline Quat & operator +=( const Quat &quat ); - - // Perform compound assignment and subtraction by a quaternion - // - __forceinline Quat & operator -=( const Quat &quat ); - - // Perform compound assignment and multiplication by a quaternion - // - __forceinline Quat & operator *=( const Quat &quat ); - - // Perform compound assignment and multiplication by a scalar - // - __forceinline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - __forceinline Quat & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - __forceinline Quat & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - __forceinline Quat & operator /=( const floatInVec &scalar ); - - // Negate all elements of a quaternion - // - __forceinline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static __forceinline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static __forceinline const Quat rotation( const Vector3 &unitVec0, const Vector3 &unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static __forceinline const Quat rotation( float radians, const Vector3 &unitVec ); - - // Construct a quaternion to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static __forceinline const Quat rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static __forceinline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static __forceinline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static __forceinline const Quat rotationZ( float radians ); - - // Construct a quaternion to rotate around the x axis (scalar data contained in vector data type) - // - static __forceinline const Quat rotationX( const floatInVec &radians ); - - // Construct a quaternion to rotate around the y axis (scalar data contained in vector data type) - // - static __forceinline const Quat rotationY( const floatInVec &radians ); - - // Construct a quaternion to rotate around the z axis (scalar data contained in vector data type) - // - static __forceinline const Quat rotationZ( const floatInVec &radians ); - -}; - -// Multiply a quaternion by a scalar -// -__forceinline const Quat operator *( float scalar, const Quat &quat ); - -// Multiply a quaternion by a scalar (scalar data contained in vector data type) -// -__forceinline const Quat operator *( const floatInVec &scalar, const Quat &quat ); - -// Compute the conjugate of a quaternion -// -__forceinline const Quat conj( const Quat &quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -__forceinline const Vector3 rotate( const Quat &unitQuat, const Vector3 &vec ); - -// Compute the dot product of two quaternions -// -__forceinline const floatInVec dot( const Quat &quat0, const Quat &quat1 ); - -// Compute the norm of a quaternion -// -__forceinline const floatInVec norm( const Quat &quat ); - -// Compute the length of a quaternion -// -__forceinline const floatInVec length( const Quat &quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -__forceinline const Quat normalize( const Quat &quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Quat lerp( float t, const Quat &quat0, const Quat &quat1 ); - -// Linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -__forceinline const Quat lerp( const floatInVec &t, const Quat &quat0, const Quat &quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -__forceinline const Quat slerp( float t, const Quat &unitQuat0, const Quat &unitQuat1 ); - -// Spherical linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -__forceinline const Quat slerp( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1 ); - -// Spherical quadrangle interpolation -// -__forceinline const Quat squad( float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); - -// Spherical quadrangle interpolation (scalar data contained in vector data type) -// -__forceinline const Quat squad( const floatInVec &t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Quat select( const Quat &quat0, const Quat &quat1, bool select1 ); - -// Conditionally select between two quaternions (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Quat select( const Quat &quat0, const Quat &quat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Quat &quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Quat &quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - __forceinline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - __forceinline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - __forceinline Matrix3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit __forceinline Matrix3( const Quat &unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit __forceinline Matrix3( float scalar ); - - // Set all elements of a 3x3 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Matrix3( const floatInVec &scalar ); - - // Assign one 3x3 matrix to another - // - __forceinline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - __forceinline Matrix3 & setCol0( const Vector3 &col0 ); - - // Set column 1 of a 3x3 matrix - // - __forceinline Matrix3 & setCol1( const Vector3 &col1 ); - - // Set column 2 of a 3x3 matrix - // - __forceinline Matrix3 & setCol2( const Vector3 &col2 ); - - // Get column 0 of a 3x3 matrix - // - __forceinline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - __forceinline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - __forceinline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - __forceinline Matrix3 & setCol( int col, const Vector3 &vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - __forceinline Matrix3 & setRow( int row, const Vector3 &vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - __forceinline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - __forceinline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - __forceinline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - __forceinline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - __forceinline Matrix3 & setElem( int col, int row, float val ); - - // Set the element of a 3x3 matrix referred to by column and row indices (scalar data contained in vector data type) - // - __forceinline Matrix3 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - __forceinline const floatInVec getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - __forceinline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - __forceinline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - __forceinline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - __forceinline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) - // - __forceinline const Matrix3 operator *( const floatInVec &scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - __forceinline const Vector3 operator *( const Vector3 &vec ) const; - - // Multiply two 3x3 matrices - // - __forceinline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - __forceinline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - __forceinline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - __forceinline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - __forceinline Matrix3 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - __forceinline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static __forceinline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static __forceinline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static __forceinline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static __forceinline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static __forceinline const Matrix3 rotationX( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static __forceinline const Matrix3 rotationY( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static __forceinline const Matrix3 rotationZ( const floatInVec &radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static __forceinline const Matrix3 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static __forceinline const Matrix3 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static __forceinline const Matrix3 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static __forceinline const Matrix3 rotation( const Quat &unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static __forceinline const Matrix3 scale( const Vector3 &scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -__forceinline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) -// -__forceinline const Matrix3 operator *( const floatInVec &scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Matrix3 prependScale( const Vector3 &scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -__forceinline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -__forceinline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -__forceinline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -__forceinline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -__forceinline const floatInVec determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -// Conditionally select between two 3x3 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - __forceinline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - __forceinline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - __forceinline Matrix4( const Vector4 &col0, const Vector4 &col1, const Vector4 &col2, const Vector4 &col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit __forceinline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - __forceinline Matrix4( const Matrix3 & mat, const Vector3 &translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - __forceinline Matrix4( const Quat &unitQuat, const Vector3 &translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit __forceinline Matrix4( float scalar ); - - // Set all elements of a 4x4 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Matrix4( const floatInVec &scalar ); - - // Assign one 4x4 matrix to another - // - __forceinline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - __forceinline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - __forceinline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - __forceinline Matrix4 & setTranslation( const Vector3 &translateVec ); - - // Get the translation component of a 4x4 matrix - // - __forceinline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - __forceinline Matrix4 & setCol0( const Vector4 &col0 ); - - // Set column 1 of a 4x4 matrix - // - __forceinline Matrix4 & setCol1( const Vector4 &col1 ); - - // Set column 2 of a 4x4 matrix - // - __forceinline Matrix4 & setCol2( const Vector4 &col2 ); - - // Set column 3 of a 4x4 matrix - // - __forceinline Matrix4 & setCol3( const Vector4 &col3 ); - - // Get column 0 of a 4x4 matrix - // - __forceinline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - __forceinline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - __forceinline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - __forceinline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - __forceinline Matrix4 & setCol( int col, const Vector4 &vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - __forceinline Matrix4 & setRow( int row, const Vector4 &vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - __forceinline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - __forceinline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - __forceinline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - __forceinline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - __forceinline Matrix4 & setElem( int col, int row, float val ); - - // Set the element of a 4x4 matrix referred to by column and row indices (scalar data contained in vector data type) - // - __forceinline Matrix4 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - __forceinline const floatInVec getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - __forceinline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - __forceinline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - __forceinline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - __forceinline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) - // - __forceinline const Matrix4 operator *( const floatInVec &scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - __forceinline const Vector4 operator *( const Vector4 &vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - __forceinline const Vector4 operator *( const Vector3 &vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - __forceinline const Vector4 operator *( const Point3 &pnt ) const; - - // Multiply two 4x4 matrices - // - __forceinline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - __forceinline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - __forceinline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - __forceinline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - __forceinline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - __forceinline Matrix4 & operator *=( const floatInVec &scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - __forceinline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - __forceinline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static __forceinline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static __forceinline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static __forceinline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static __forceinline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static __forceinline const Matrix4 rotationX( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static __forceinline const Matrix4 rotationY( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static __forceinline const Matrix4 rotationZ( const floatInVec &radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static __forceinline const Matrix4 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static __forceinline const Matrix4 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static __forceinline const Matrix4 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static __forceinline const Matrix4 rotation( const Quat &unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static __forceinline const Matrix4 scale( const Vector3 &scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static __forceinline const Matrix4 translation( const Vector3 &translateVec ); - - // Construct viewing matrix based on eye, position looked at, and up direction - // - static __forceinline const Matrix4 lookAt( const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec ); - - // Construct a perspective projection matrix - // - static __forceinline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static __forceinline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static __forceinline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -__forceinline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) -// -__forceinline const Matrix4 operator *( const floatInVec &scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Matrix4 prependScale( const Vector3 &scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -__forceinline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -__forceinline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -__forceinline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -__forceinline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -__forceinline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -__forceinline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -__forceinline const floatInVec determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -// Conditionally select between two 4x4 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - __forceinline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - __forceinline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - __forceinline Transform3( const Vector3 &col0, const Vector3 &col1, const Vector3 &col2, const Vector3 &col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - __forceinline Transform3( const Matrix3 & tfrm, const Vector3 &translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - __forceinline Transform3( const Quat &unitQuat, const Vector3 &translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit __forceinline Transform3( float scalar ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value (scalar data contained in vector data type) - // - explicit __forceinline Transform3( const floatInVec &scalar ); - - // Assign one 3x4 transformation matrix to another - // - __forceinline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - __forceinline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - __forceinline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - __forceinline Transform3 & setTranslation( const Vector3 &translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - __forceinline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - __forceinline Transform3 & setCol0( const Vector3 &col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - __forceinline Transform3 & setCol1( const Vector3 &col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - __forceinline Transform3 & setCol2( const Vector3 &col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - __forceinline Transform3 & setCol3( const Vector3 &col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - __forceinline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - __forceinline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - __forceinline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - __forceinline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - __forceinline Transform3 & setCol( int col, const Vector3 &vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - __forceinline Transform3 & setRow( int row, const Vector4 &vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - __forceinline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - __forceinline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - __forceinline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - __forceinline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - __forceinline Transform3 & setElem( int col, int row, float val ); - - // Set the element of a 3x4 transformation matrix referred to by column and row indices (scalar data contained in vector data type) - // - __forceinline Transform3 & setElem( int col, int row, const floatInVec &val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - __forceinline const floatInVec getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - __forceinline const Vector3 operator *( const Vector3 &vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - __forceinline const Point3 operator *( const Point3 &pnt ) const; - - // Multiply two 3x4 transformation matrices - // - __forceinline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - __forceinline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static __forceinline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static __forceinline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static __forceinline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static __forceinline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x axis (scalar data contained in vector data type) - // - static __forceinline const Transform3 rotationX( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis (scalar data contained in vector data type) - // - static __forceinline const Transform3 rotationY( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis (scalar data contained in vector data type) - // - static __forceinline const Transform3 rotationZ( const floatInVec &radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static __forceinline const Transform3 rotationZYX( const Vector3 &radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static __forceinline const Transform3 rotation( float radians, const Vector3 &unitVec ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static __forceinline const Transform3 rotation( const floatInVec &radians, const Vector3 &unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static __forceinline const Transform3 rotation( const Quat &unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static __forceinline const Transform3 scale( const Vector3 &scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static __forceinline const Transform3 translation( const Vector3 &translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 &scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -__forceinline const Transform3 prependScale( const Vector3 &scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -__forceinline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -__forceinline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -__forceinline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -__forceinline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -__forceinline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -// Conditionally select between two 3x4 transformation matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -__forceinline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, const boolInVec &select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -__forceinline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos.h deleted file mode 100644 index 329f07abc..000000000 --- a/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - 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_AOS_C_H -#define _VECTORMATH_AOS_C_H - -#if defined(__SPU__) -# include "../spu/c/vectormath_aos.h" -#elif defined(__ALTIVEC__) -# include "../ppu/c/vectormath_aos.h" -#else -# include "../scalar/c/vectormath_aos.h" -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h b/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h deleted file mode 100644 index 83368fafa..000000000 --- a/Extras/vectormathlibrary/include/vectormath/c/vectormath_aos_v.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - 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_AOS_C_V_H -#define _VECTORMATH_AOS_C_V_H - -#if defined(__SPU__) -# include "../spu/c/vectormath_aos_v.h" -#elif defined(__ALTIVEC__) -# include "../ppu/c/vectormath_aos_v.h" -#else -# include "../scalar/c/vectormath_aos_v.h" -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa.h deleted file mode 100644 index 42d079220..000000000 --- a/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - 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_SOA_C_H -#define _VECTORMATH_SOA_C_H - -#if defined(__SPU__) -# include "../spu/c/vectormath_soa.h" -#elif defined(__ALTIVEC__) -# include "../ppu/c/vectormath_soa.h" -#else -# error "Not implemented." -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h b/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h deleted file mode 100644 index ade2eeea0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/c/vectormath_soa_v.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - 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_SOA_C_V_H -#define _VECTORMATH_SOA_C_V_H - -#if defined(__SPU__) -# include "../spu/c/vectormath_soa_v.h" -#elif defined(__ALTIVEC__) -# include "../ppu/c/vectormath_soa_v.h" -#else -# error "Not implemented." -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h deleted file mode 100644 index 1d5088f8f..000000000 --- a/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_aos.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - 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_AOS_CPP_H -#define _VECTORMATH_AOS_CPP_H - -#if defined(__SPU__) -# include "../spu/cpp/vectormath_aos.h" -#elif defined(__ALTIVEC__) -# include "../ppu/cpp/vectormath_aos.h" -#elif defined(__SSE__) -# include "../SSE/cpp/vectormath_aos.h" -#else -# include "../scalar/cpp/vectormath_aos.h" -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h deleted file mode 100644 index 287915f0f..000000000 --- a/Extras/vectormathlibrary/include/vectormath/cpp/vectormath_soa.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - 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_SOA_CPP_H -#define _VECTORMATH_SOA_CPP_H - -#if defined(__SPU__) -# include "../spu/cpp/vectormath_soa.h" -#elif defined(__ALTIVEC__) -# include "../ppu/cpp/vectormath_soa.h" -#else -# error "Not implemented." -#endif - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h deleted file mode 100644 index 13f482150..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos.h +++ /dev/null @@ -1,1833 +0,0 @@ -/* - 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_MAT_AOS_C_H -#define _VECTORMATH_MAT_AOS_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) -#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) -#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( &result->col0, &mat->col0 ); - vmathV3Copy( &result->col1, &mat->col1 ); - vmathV3Copy( &result->col2, &mat->col2 ); -} - -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); -} - -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - vec_uint4 select_x = _VECTORMATH_MASK_0xF000; - vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; - xyzw_2 = vec_add( unitQuat->vec128, unitQuat->vec128 ); - wwww = vec_splat( unitQuat->vec128, 3 ); - yzxw = vec_perm( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_PERM_YZXW ); - zxyw = vec_perm( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_PERM_ZXYW ); - yzxw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_YZXW ); - zxyw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_ZXYW ); - tmp0 = vec_madd( yzxw_2, wwww, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_nmsub( yzxw, yzxw_2, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - tmp2 = vec_madd( yzxw, xyzw_2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp0 = vec_madd( zxyw, xyzw_2, tmp0 ); - tmp1 = vec_nmsub( zxyw, zxyw_2, tmp1 ); - tmp2 = vec_nmsub( zxyw_2, wwww, tmp2 ); - tmp3 = vec_sel( tmp0, tmp1, select_x ); - tmp4 = vec_sel( tmp1, tmp2, select_x ); - tmp5 = vec_sel( tmp2, tmp0, select_x ); - result->col0.vec128 = vec_sel( tmp3, tmp2, select_z ); - result->col1.vec128 = vec_sel( tmp4, tmp0, select_z ); - result->col2.vec128 = vec_sel( tmp5, tmp1, select_z ); -} - -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); -} - -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathM3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, mat, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col0 ); -} - -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col1 ); -} - -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col2 ); -} - -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) -{ - vmathV3Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) -{ - vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); -} - -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, res0, res1, res2; - tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); - tmp1 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); - res0 = vec_mergeh( tmp0, mat->col1.vec128 ); - res1 = vec_perm( tmp0, mat->col1.vec128, _VECTORMATH_PERM_ZBWX ); - res2 = vec_perm( tmp1, mat->col1.vec128, _VECTORMATH_PERM_XCYX ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp2 = _vmathVfCross( mat->col0.vec128, mat->col1.vec128 ); - tmp0 = _vmathVfCross( mat->col1.vec128, mat->col2.vec128 ); - tmp1 = _vmathVfCross( mat->col2.vec128, mat->col0.vec128 ); - dot = _vmathVfDot3( tmp2, mat->col2.vec128 ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv0 = vec_madd( inv0, invdet, zero ); - inv1 = vec_madd( inv1, invdet, zero ); - inv2 = vec_madd( inv2, invdet, zero ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; -} - -static inline float vmathM3Determinant( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0; - vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); - return vmathV3Dot( &mat->col2, &tmpV3_0 ); -} - -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Neg( &result->col0, &mat->col0 ); - vmathV3Neg( &result->col1, &mat->col1 ); - vmathV3Neg( &result->col2, &mat->col2 ); -} - -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3AbsPerElem( &result->col0, &mat->col0 ); - vmathV3AbsPerElem( &result->col1, &mat->col1 ); - vmathV3AbsPerElem( &result->col2, &mat->col2 ); -} - -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); -} - -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec->vec128, 0 ); - yyyy = vec_splat( vec->vec128, 1 ); - zzzz = vec_splat( vec->vec128, 2 ); - res = vec_madd( mat->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( mat->col1.vec128, yyyy, res ); - res = vec_madd( mat->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - VmathMatrix3 tmpResult; - vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM3Copy( result, &tmpResult ); -} - -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - vmathV3MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV3MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; -} - -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) -{ - VmathVector4 tmpV4_0; - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); - angles = tmpV4_0.vec128; - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - result->col0.vec128 = vec_madd( Z0, Y0, zero ); - result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); - result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); -} - -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - axis = unitVec->vec128; - sincosf4( (vec_float4){radians,radians,radians,radians}, &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - axisS = vec_madd( axis, s, zero ); - negAxisS = negatef4( axisS ); - tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); - tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); - tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); - result->col0.vec128 = vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ); - result->col1.vec128 = vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ); - result->col2.vec128 = vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ); -} - -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - vmathM3MakeFromQ( result, unitQuat ); -} - -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); - result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); - result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); -} - -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); -} - -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) -{ - vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); -} - -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathM3GetRow( &tmpV3_0, mat, 0 ); - vmathV3Print( &tmpV3_0 ); - vmathM3GetRow( &tmpV3_1, mat, 1 ); - vmathV3Print( &tmpV3_1 ); - vmathM3GetRow( &tmpV3_2, mat, 2 ); - vmathV3Print( &tmpV3_2 ); -} - -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM3Print( mat ); -} - -#endif - -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( &result->col0, &mat->col0 ); - vmathV4Copy( &result->col1, &mat->col1 ); - vmathV4Copy( &result->col2, &mat->col2 ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) -{ - vmathV4MakeFromScalar( &result->col0, scalar ); - vmathV4MakeFromScalar( &result->col1, scalar ); - vmathV4MakeFromScalar( &result->col2, scalar ); - vmathV4MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); -} - -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col0, _col0 ); - vmathV4Copy( &result->col1, _col1 ); - vmathV4Copy( &result->col2, _col2 ); - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 mat; - vmathM3MakeFromQ( &mat, unitQuat ); - vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) -{ - vmathV4Copy( &result->col0, _col0 ); -} - -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) -{ - vmathV4Copy( &result->col1, _col1 ); -} - -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) -{ - vmathV4Copy( &result->col2, _col2 ); -} - -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) -{ - vmathV4Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) -{ - vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) -{ - VmathVector4 tmpV3_0; - vmathM4GetCol( &tmpV3_0, result, col ); - vmathV4SetElem( &tmpV3_0, row, val ); - vmathM4SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) -{ - VmathVector4 tmpV4_0; - vmathM4GetCol( &tmpV4_0, mat, col ); - return vmathV4GetElem( &tmpV4_0, row ); -} - -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col0 ); -} - -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col1 ); -} - -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col2 ); -} - -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col3 ); -} - -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) -{ - vmathV4Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) -{ - vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); -} - -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); - tmp1 = vec_mergeh( mat->col1.vec128, mat->col3.vec128 ); - tmp2 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); - tmp3 = vec_mergel( mat->col1.vec128, mat->col3.vec128 ); - res0 = vec_mergeh( tmp0, tmp1 ); - res1 = vec_mergel( tmp0, tmp1 ); - res2 = vec_mergeh( tmp2, tmp3 ); - res3 = vec_mergel( tmp2, tmp3 ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; - result->col3.vec128 = res3; -} - -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vector float in0, in1, in2, in3; - vector float tmp0, tmp1, tmp2, tmp3; - vector float cof0, cof1, cof2, cof3; - vector float t0, t1, t2, t3; - vector float t01, t02, t03, t12, t23; - vector float t1r, t2r; - vector float t01r, t02r, t03r, t12r, t23r; - vector float t1r3, t1r3r; - vector float det, det0, det1, det2, det3, invdet; - vector float vzero = (vector float){0.0}; - in0 = mat->col0.vec128; - in1 = mat->col1.vec128; - in2 = mat->col2.vec128; - in3 = mat->col3.vec128; - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ - tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ - tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ - tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ - t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ - t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ - t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ - t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ - t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ - cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ - cof1 = vec_nmsub(t0, t23, vzero); /* -(AGP ECL IOH MKD) */ - t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ - cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ - cof1 = vec_madd(t0, t23r, cof1); /* AOH EKD IGP MCL + cof1 */ - cof1 = vec_sld(cof1, cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ - t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ - t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ - cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - cof3 = vec_madd(t0, t12, vzero); /* ANG EJC IFO MBK */ - t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ - cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - cof3 = vec_nmsub(t0, t12r, cof3); /* cof3 - AFO EBK ING MJC */ - cof3 = vec_sld(cof3, cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ - t1r = vec_sld(t1, t1, 8); /* B F J N */ - t2r = vec_sld(t2, t2, 8); /* K O C G */ - t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ - t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ - cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - cof2 = vec_madd(t0, t1r3, vzero); /* AFP EBL INH MJD */ - t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ - cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - cof2 = vec_nmsub(t0, t1r3r, cof2); /* cof2 - ANH EJD IFP MBL */ - cof2 = vec_sld(cof2, cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ - t01 = vec_madd(t0, t1, vzero); /* AJ EN IB MF */ - t01 = vec_perm(t01, t01, _VECTORMATH_PERM_YXWZ); /* EN AJ MF IB */ - cof2 = vec_nmsub(t3, t01, cof2); /* cof2 - LEN PAJ DMF HIB */ - cof3 = vec_madd(t2r, t01, cof3); /* KEN OAJ CMF GIB + cof3 */ - t01r = vec_sld(t01, t01, 8); /* MF IB EN AJ */ - cof2 = vec_madd(t3, t01r, cof2); /* LMF PIB DEN HAJ + cof2 */ - cof3 = vec_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ - t03 = vec_madd(t0, t3, vzero); /* AL EP ID MH */ - t03 = vec_perm(t03, t03, _VECTORMATH_PERM_YXWZ); /* EP AL MH ID */ - cof1 = vec_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ - cof2 = vec_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ - t03r = vec_sld(t03, t03, 8); /* MH ID EP AL */ - cof1 = vec_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ - cof2 = vec_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ - t02 = vec_madd(t0, t2r, vzero); /* AK EO IC MG */ - t02 = vec_perm(t02, t02, _VECTORMATH_PERM_YXWZ); /* E0 AK MG IC */ - cof1 = vec_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ - cof3 = vec_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ - t02r = vec_sld(t02, t02, 8); /* MG IC EO AK */ - cof1 = vec_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ - cof3 = vec_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ - /* Compute the determinant of the matrix - * - * det = sum_across(t0 * cof0); - * - * We perform a sum across the entire vector so that - * we don't have to splat the result when multiplying the - * cofactors by the inverse of the determinant. - */ - det = vec_madd(t0, cof0, vzero); - det0 = vec_splat(det, 0); - det1 = vec_splat(det, 1); - det2 = vec_splat(det, 2); - det3 = vec_splat(det, 3); - det = vec_add(det0, det1); - det2 = vec_add(det2, det3); - det = vec_add(det, det2); - /* Compute the reciprocal of the determinant. - */ - invdet = recipf4(det); - /* Multiply the cofactors by the reciprocal of the determinant. - */ - result->col0.vec128 = vec_madd(cof0, invdet, vzero); - result->col1.vec128 = vec_madd(cof1, invdet, vzero); - result->col2.vec128 = vec_madd(cof2, invdet, vzero); - result->col3.vec128 = vec_madd(cof3, invdet, vzero); -} - -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3Inverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3OrthoInverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline float vmathM4Determinant( const VmathMatrix4 *mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vector float in0, in1, in2, in3; - vector float tmp0, tmp1, tmp2, tmp3; - vector float cof0; - vector float t0, t1, t2, t3; - vector float t12, t23; - vector float t1r, t2r; - vector float t12r, t23r; - vector float t1r3, t1r3r; - vector float vzero = (vector float){0.0}; - union { vec_float4 v; float s[4]; } tmp; - in0 = mat->col0.vec128; - in1 = mat->col1.vec128; - in2 = mat->col2.vec128; - in3 = mat->col3.vec128; - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ - tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ - tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ - tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ - t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ - t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ - t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ - t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ - t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ - cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ - t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ - cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ - t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ - t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ - cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ - cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - t1r = vec_sld(t1, t1, 8); /* B F J N */ - t2r = vec_sld(t2, t2, 8); /* K O C G */ - t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ - t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ - cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ - cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - tmp.v = _vmathVfDot4(t0,cof0); - return tmp.s[0]; -} - -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Neg( &result->col0, &mat->col0 ); - vmathV4Neg( &result->col1, &mat->col1 ); - vmathV4Neg( &result->col2, &mat->col2 ); - vmathV4Neg( &result->col3, &mat->col3 ); -} - -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4AbsPerElem( &result->col0, &mat->col0 ); - vmathV4AbsPerElem( &result->col1, &mat->col1 ); - vmathV4AbsPerElem( &result->col2, &mat->col2 ); - vmathV4AbsPerElem( &result->col3, &mat->col3 ); -} - -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); - vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); -} - -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz, wwww; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( vec->vec128, 0 ); - yyyy = vec_splat( vec->vec128, 1 ); - zzzz = vec_splat( vec->vec128, 2 ); - wwww = vec_splat( vec->vec128, 3 ); - tmp0 = vec_madd( mat->col0.vec128, xxxx, zero ); - tmp1 = vec_madd( mat->col1.vec128, yyyy, zero ); - tmp0 = vec_madd( mat->col2.vec128, zzzz, tmp0 ); - tmp1 = vec_madd( mat->col3.vec128, wwww, tmp1 ); - res = vec_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec->vec128, 0 ); - yyyy = vec_splat( vec->vec128, 1 ); - zzzz = vec_splat( vec->vec128, 2 ); - res = vec_madd( mat->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( mat->col1.vec128, yyyy, res ); - res = vec_madd( mat->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( pnt->vec128, 0 ); - yyyy = vec_splat( pnt->vec128, 1 ); - zzzz = vec_splat( pnt->vec128, 2 ); - tmp0 = vec_madd( mat->col0.vec128, xxxx, zero ); - tmp1 = vec_madd( mat->col1.vec128, yyyy, zero ); - tmp0 = vec_madd( mat->col2.vec128, zzzz, tmp0 ); - tmp1 = vec_add( mat->col3.vec128, tmp1 ); - res = vec_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - VmathMatrix4 tmpResult; - vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) -{ - VmathMatrix4 tmpResult; - VmathPoint3 tmpP3_0; - vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); - vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); - vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) -{ - vmathV4SetXYZ( &result->col0, &mat3->col0 ); - vmathV4SetXYZ( &result->col1, &mat3->col1 ); - vmathV4SetXYZ( &result->col2, &mat3->col2 ); -} - -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( &result->col0, &mat->col0 ); - vmathV4GetXYZ( &result->col1, &mat->col1 ); - vmathV4GetXYZ( &result->col2, &mat->col2 ); -} - -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4SetXYZ( &result->col3, translateVec ); -} - -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( result, &mat->col3 ); -} - -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - vmathV4MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV4MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) -{ - VmathVector4 tmpV4_0; - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); - angles = tmpV4_0.vec128; - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - result->col0.vec128 = vec_madd( Z0, Y0, zero ); - result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); - result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - axis = unitVec->vec128; - sincosf4( (vec_float4){radians,radians,radians,radians}, &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - axisS = vec_madd( axis, s, zero ); - negAxisS = negatef4( axisS ); - tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); - tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); - tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); - zeroW = (vec_float4)_VECTORMATH_MASK_0x000F; - axis = vec_andc( axis, zeroW ); - tmp0 = vec_andc( tmp0, zeroW ); - tmp1 = vec_andc( tmp1, zeroW ); - tmp2 = vec_andc( tmp2, zeroW ); - result->col0.vec128 = vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ); - result->col1.vec128 = vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ); - result->col2.vec128 = vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) -{ - VmathTransform3 tmpT3_0; - vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); - result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); - result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) -{ - VmathVector4 scale4; - vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); - vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); - vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); - vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); - vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); -} - -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) -{ - VmathMatrix4 m4EyeFrame; - VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathV3Normalize( &v3Y, upVec ); - vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); - vmathV3Normalize( &v3Z, &tmpV3_0 ); - vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); - vmathV3Normalize( &v3X, &tmpV3_1 ); - vmathV3Cross( &v3Y, &v3Z, &v3X ); - vmathV4MakeFromV3( &tmpV4_0, &v3X ); - vmathV4MakeFromV3( &tmpV4_1, &v3Y ); - vmathV4MakeFromV3( &tmpV4_2, &v3Z ); - vmathV4MakeFromP3( &tmpV4_3, eyePos ); - vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); - vmathM4OrthoInverse( result, &m4EyeFrame ); -} - -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - vec_float4 zero, col0, col1, col2, col3; - union { vec_float4 v; float s[4]; } tmp; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp.v = zero; - tmp.s[0] = f / aspect; - col0 = tmp.v; - tmp.v = zero; - tmp.s[1] = f; - col1 = tmp.v; - tmp.v = zero; - tmp.s[2] = ( zNear + zFar ) * rangeInv; - tmp.s[3] = -1.0f; - col2 = tmp.v; - tmp.v = zero; - tmp.s[2] = zNear * zFar * rangeInv * 2.0f; - col3 = tmp.v; - result->col0.vec128 = col0; - result->col1.vec128 = col1; - result->col2.vec128 = col2; - result->col3.vec128 = col3; -} - -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff; - vec_float4 diagonal, column, near2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - union { vec_float4 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = vec_splat( n.v, 0 ); - near2 = vec_add( near2, near2 ); - diagonal = vec_madd( near2, inv_diff, zero ); - column = vec_madd( sum, inv_diff, zero ); - result->col0.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ); - result->col1.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ); - result->col2.vec128 = vec_sel( column, ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}), _VECTORMATH_MASK_0x000F ); - result->col3.vec128 = vec_sel( zero, vec_madd( diagonal, vec_splat( f.v, 0 ), zero ), _VECTORMATH_MASK_0x00F0 ); -} - -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff, neg_inv_diff; - vec_float4 diagonal, column; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - union { vec_float4 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = vec_add( inv_diff, inv_diff ); - column = vec_madd( sum, vec_sel( neg_inv_diff, inv_diff, _VECTORMATH_MASK_0x00F0 ), zero ); - result->col0.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ); - result->col1.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ); - result->col2.vec128 = vec_sel( zero, diagonal, _VECTORMATH_MASK_0x00F0 ); - result->col3.vec128 = vec_sel( column, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), _VECTORMATH_MASK_0x000F ); -} - -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) -{ - vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); - vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print( const VmathMatrix4 *mat ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathM4GetRow( &tmpV4_0, mat, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathM4GetRow( &tmpV4_1, mat, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathM4GetRow( &tmpV4_2, mat, 2 ); - vmathV4Print( &tmpV4_2 ); - vmathM4GetRow( &tmpV4_3, mat, 3 ); - vmathV4Print( &tmpV4_3 ); -} - -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM4Print( mat ); -} - -#endif - -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); - vmathV3MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) -{ - vmathT3SetUpper3x3( result, tfrm ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 tmpM3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathT3SetUpper3x3( result, &tmpM3_0 ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathT3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, tfrm, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col0 ); -} - -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col1 ); -} - -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col2 ); -} - -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) -{ - vmathV3Copy( result, (&tfrm->col0 + col) ); -} - -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) -{ - vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); -} - -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp2 = _vmathVfCross( tfrm->col0.vec128, tfrm->col1.vec128 ); - tmp0 = _vmathVfCross( tfrm->col1.vec128, tfrm->col2.vec128 ); - tmp1 = _vmathVfCross( tfrm->col2.vec128, tfrm->col0.vec128 ); - inv3 = negatef4( tfrm->col3.vec128 ); - dot = _vmathVfDot3( tmp2, tfrm->col2.vec128 ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - xxxx = vec_splat( inv3, 0 ); - inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_madd( inv0, xxxx, zero ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - inv0 = vec_madd( inv0, invdet, zero ); - inv1 = vec_madd( inv1, invdet, zero ); - inv2 = vec_madd( inv2, invdet, zero ); - inv3 = vec_madd( inv3, invdet, zero ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; - result->col3.vec128 = inv3; -} - -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1; - vec_float4 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( tfrm->col0.vec128, tfrm->col2.vec128 ); - tmp1 = vec_mergel( tfrm->col0.vec128, tfrm->col2.vec128 ); - inv3 = negatef4( tfrm->col3.vec128 ); - inv0 = vec_mergeh( tmp0, tfrm->col1.vec128 ); - xxxx = vec_splat( inv3, 0 ); - inv1 = vec_perm( tmp0, tfrm->col1.vec128, _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp1, tfrm->col1.vec128, _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_madd( inv0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; - result->col3.vec128 = inv3; -} - -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); - vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); - vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); - vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec->vec128, 0 ); - yyyy = vec_splat( vec->vec128, 1 ); - zzzz = vec_splat( vec->vec128, 2 ); - res = vec_madd( tfrm->col0.vec128, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( tfrm->col1.vec128, yyyy, res ); - res = vec_madd( tfrm->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( pnt->vec128, 0 ); - yyyy = vec_splat( pnt->vec128, 1 ); - zzzz = vec_splat( pnt->vec128, 2 ); - tmp0 = vec_madd( tfrm->col0.vec128, xxxx, zero ); - tmp1 = vec_madd( tfrm->col1.vec128, yyyy, zero ); - tmp0 = vec_madd( tfrm->col2.vec128, zzzz, tmp0 ); - tmp1 = vec_add( tfrm->col3.vec128, tmp1 ); - res = vec_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - VmathTransform3 tmpResult; - VmathPoint3 tmpP3_0, tmpP3_1; - vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); - vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); - vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); - vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); - vmathT3Copy( result, &tmpResult ); -} - -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); - vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); - vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); - vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); -} - -static inline void vmathT3MakeIdentity( VmathTransform3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); -} - -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) -{ - vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); -} - -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - vmathV3MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV3MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( _vmathVfSplatScalar(radians), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) -{ - VmathVector4 tmpV4_0; - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - vmathV4MakeFromV3Scalar( &tmpV4_0, radiansXYZ, 0.0f ); - angles = tmpV4_0.vec128; - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - result->col0.vec128 = vec_madd( Z0, Y0, zero ); - result->col1.vec128 = vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ); - result->col2.vec128 = vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - result->col0.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0xF000 ); - result->col1.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x0F00 ); - result->col2.vec128 = vec_sel( zero, scaleVec->vec128, _VECTORMATH_MASK_0x00F0 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) -{ - vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); - vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); -} - -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); - vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); - vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); - vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print( const VmathTransform3 *tfrm ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; - vmathT3GetRow( &tmpV4_0, tfrm, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathT3GetRow( &tmpV4_1, tfrm, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathT3GetRow( &tmpV4_2, tfrm, 2 ); - vmathV4Print( &tmpV4_2 ); -} - -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) -{ - printf("%s:\n", name); - vmathT3Print( tfrm ); -} - -#endif - -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) -{ - vec_float4 res; - vec_float4 col0, col1, col2; - vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; - vec_float4 radicand, invSqrt, scale; - vec_float4 res0, res1, res2, res3; - vec_float4 xx, yy, zz; - vec_uint4 select_x = _VECTORMATH_MASK_0xF000; - vec_uint4 select_y = _VECTORMATH_MASK_0x0F00; - vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; - vec_uint4 select_w = _VECTORMATH_MASK_0x000F; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - - col0 = tfrm->col0.vec128; - col1 = tfrm->col1.vec128; - col2 = tfrm->col2.vec128; - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = vec_sel( col0, col1, select_y ); - xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); - yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); - zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); - - diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - invSqrt = rsqrtf4( radicand ); - - zy_xz_yx = vec_sel( col0, col1, select_z ); - zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); - yz_zx_xy = vec_sel( col0, col1, select_x ); - yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); - - sum = vec_add( zy_xz_yx, yz_zx_xy ); - diff = vec_sub( zy_xz_yx, yz_zx_xy ); - - scale = vec_madd( invSqrt, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), zero ); - res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); - res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); - res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); - res3 = diff; - res0 = vec_sel( res0, radicand, select_x ); - res1 = vec_sel( res1, radicand, select_y ); - res2 = vec_sel( res2, radicand, select_z ); - res3 = vec_sel( res3, radicand, select_w ); - res0 = vec_madd( res0, vec_splat( scale, 0 ), zero ); - res1 = vec_madd( res1, vec_splat( scale, 1 ), zero ); - res2 = vec_madd( res2, vec_splat( scale, 2 ), zero ); - res3 = vec_madd( res3, vec_splat( scale, 3 ), zero ); - - /* determine case and select answer */ - - xx = vec_splat( col0, 0 ); - yy = vec_splat( col1, 1 ); - zz = vec_splat( col2, 2 ); - res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); - res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); - res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), zero ) ); - result->vec128 = res; -} - -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) -{ - vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); - vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); - vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); -} - -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) -{ - vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); - vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); - vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); - vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); -} - -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; - vec_float4 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( mat->col0.vec128, mat->col2.vec128 ); - tmp1 = vec_mergel( mat->col0.vec128, mat->col2.vec128 ); - xxxx = vec_splat( vec->vec128, 0 ); - mcol0 = vec_mergeh( tmp0, mat->col1.vec128 ); - mcol1 = vec_perm( tmp0, mat->col1.vec128, _VECTORMATH_PERM_ZBWX ); - mcol2 = vec_perm( tmp1, mat->col1.vec128, _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( vec->vec128, 1 ); - res = vec_madd( mcol0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zzzz = vec_splat( vec->vec128, 2 ); - res = vec_madd( mcol1, yyyy, res ); - res = vec_madd( mcol2, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) -{ - vec_float4 neg, res0, res1, res2; - neg = negatef4( vec->vec128 ); - res0 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_XZBX ); - res1 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_CXXX ); - res2 = vec_perm( vec->vec128, neg, _VECTORMATH_PERM_YAXX ); - res0 = vec_andc( res0, (vec_float4)_VECTORMATH_MASK_0xF000 ); - res1 = vec_andc( res1, (vec_float4)_VECTORMATH_MASK_0x0F00 ); - res2 = vec_andc( res2, (vec_float4)_VECTORMATH_MASK_0x00F0 ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); - vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); - vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); - vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h deleted file mode 100644 index 47c683abe..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_aos_v.h +++ /dev/null @@ -1,1026 +0,0 @@ -/* - 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_MAT_AOS_V_C_H -#define _VECTORMATH_MAT_AOS_V_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) -#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) -#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) -{ - VmathMatrix3 result; - vmathM3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeFromQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) -{ - VmathMatrix3 result; - vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); - return result; -} - -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) -{ - vmathM3SetCol0(result, &_col0); -} - -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) -{ - vmathM3SetCol1(result, &_col1); -} - -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) -{ - vmathM3SetCol2(result, &_col2); -} - -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) -{ - vmathM3SetCol(result, col, &vec); -} - -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) -{ - vmathM3SetRow(result, row, &vec); -} - -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) -{ - vmathM3SetElem(result, col, row, val); -} - -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) -{ - return vmathM3GetElem(&mat, col, row); -} - -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol0(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol1(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol2(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) -{ - VmathVector3 result; - vmathM3GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) -{ - VmathVector3 result; - vmathM3GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Inverse(&result, &mat); - return result; -} - -static inline float vmathM3Determinant_V( VmathMatrix3 mat ) -{ - return vmathM3Determinant(&mat); -} - -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Neg(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) -{ - VmathMatrix3 result; - vmathM3ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathM3MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MakeIdentity_V( ) -{ - VmathMatrix3 result; - vmathM3MakeIdentity(&result); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix3 result; - vmathM3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) -{ - VmathMatrix3 result; - vmathM3Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print_V( VmathMatrix3 mat ) -{ - vmathM3Print(&mat); -} - -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) -{ - vmathM3Prints(&mat, name); -} - -#endif - -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) -{ - VmathMatrix4 result; - vmathM4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) -{ - VmathMatrix4 result; - vmathM4MakeFromT3(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) -{ - VmathMatrix4 result; - vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromM3V3(&result, &mat, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) -{ - vmathM4SetCol0(result, &_col0); -} - -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) -{ - vmathM4SetCol1(result, &_col1); -} - -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) -{ - vmathM4SetCol2(result, &_col2); -} - -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) -{ - vmathM4SetCol3(result, &_col3); -} - -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) -{ - vmathM4SetCol(result, col, &vec); -} - -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) -{ - vmathM4SetRow(result, row, &vec); -} - -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) -{ - vmathM4SetElem(result, col, row, val); -} - -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) -{ - return vmathM4GetElem(&mat, col, row); -} - -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol0(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol1(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol2(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol3(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) -{ - VmathVector4 result; - vmathM4GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) -{ - VmathVector4 result; - vmathM4GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Inverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AffineInverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4OrthoInverse(&result, &mat); - return result; -} - -static inline float vmathM4Determinant_V( VmathMatrix4 mat ) -{ - return vmathM4Determinant(&mat); -} - -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Neg(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) -{ - VmathMatrix4 result; - vmathM4ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) -{ - VmathVector4 result; - vmathM4MulV4(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) -{ - VmathVector4 result; - vmathM4MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathM4MulP3(&result, &mat, &pnt); - return result; -} - -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) -{ - VmathMatrix4 result; - vmathM4MulT3(&result, &mat, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MakeIdentity_V( ) -{ - VmathMatrix4 result; - vmathM4MakeIdentity(&result); - return result; -} - -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) -{ - vmathM4SetUpper3x3(result, &mat3); -} - -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) -{ - VmathMatrix3 result; - vmathM4GetUpper3x3(&result, &mat); - return result; -} - -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) -{ - vmathM4SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) -{ - VmathVector3 result; - vmathM4GetTranslation(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix4 result; - vmathM4MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix4 result; - vmathM4MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) -{ - VmathMatrix4 result; - vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) -{ - VmathMatrix4 result; - vmathM4Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print_V( VmathMatrix4 mat ) -{ - vmathM4Print(&mat); -} - -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) -{ - vmathM4Prints(&mat, name); -} - -#endif - -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) -{ - VmathTransform3 result; - vmathT3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) -{ - VmathTransform3 result; - vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) -{ - vmathT3SetCol0(result, &_col0); -} - -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) -{ - vmathT3SetCol1(result, &_col1); -} - -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) -{ - vmathT3SetCol2(result, &_col2); -} - -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) -{ - vmathT3SetCol3(result, &_col3); -} - -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) -{ - vmathT3SetCol(result, col, &vec); -} - -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) -{ - vmathT3SetRow(result, row, &vec); -} - -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) -{ - vmathT3SetElem(result, col, row, val); -} - -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) -{ - return vmathT3GetElem(&tfrm, col, row); -} - -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol0(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol1(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol2(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol3(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) -{ - VmathVector3 result; - vmathT3GetCol(&result, &tfrm, col); - return result; -} - -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) -{ - VmathVector4 result; - vmathT3GetRow(&result, &tfrm, row); - return result; -} - -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3Inverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3OrthoInverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3AbsPerElem(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) -{ - VmathVector3 result; - vmathT3MulV3(&result, &tfrm, &vec); - return result; -} - -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathT3MulP3(&result, &tfrm, &pnt); - return result; -} - -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3Mul(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3MulPerElem(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MakeIdentity_V( ) -{ - VmathTransform3 result; - vmathT3MakeIdentity(&result); - return result; -} - -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) -{ - vmathT3SetUpper3x3(result, &tfrm); -} - -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) -{ - VmathMatrix3 result; - vmathT3GetUpper3x3(&result, &tfrm); - return result; -} - -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) -{ - vmathT3SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetTranslation(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationX(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationY(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathTransform3 result; - vmathT3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathTransform3 result; - vmathT3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathTransform3 result; - vmathT3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3AppendScale(&result, &tfrm, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3PrependScale(&result, &scaleVec, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) -{ - VmathTransform3 result; - vmathT3Select(&result, &tfrm0, &tfrm1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print_V( VmathTransform3 tfrm ) -{ - vmathT3Print(&tfrm); -} - -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) -{ - vmathT3Prints(&tfrm, name); -} - -#endif - -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) -{ - VmathQuat result; - vmathQMakeFromM3(&result, &tfrm); - return result; -} - -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) -{ - VmathMatrix3 result; - vmathV3Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) -{ - VmathMatrix4 result; - vmathV4Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathV3RowMul(&result, &vec, &mat); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) -{ - VmathMatrix3 result; - vmathV3CrossMatrix(&result, &vec); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathV3CrossMatrixMul(&result, &vec, &mat); - return result; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h deleted file mode 100644 index 3b673c4eb..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa.h +++ /dev/null @@ -1,1493 +0,0 @@ -/* - 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_MAT_SOA_C_H -#define _VECTORMATH_MAT_SOA_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( &result->col0, &mat->col0 ); - vmathSoaV3Copy( &result->col1, &mat->col1 ); - vmathSoaV3Copy( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ) -{ - vmathSoaV3MakeFromScalar( &result->col0, scalar ); - vmathSoaV3MakeFromScalar( &result->col1, scalar ); - vmathSoaV3MakeFromScalar( &result->col2, scalar ); -} - -static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) -{ - vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat->x; - qy = unitQuat->y; - qz = unitQuat->z; - qw = unitQuat->w; - qx2 = vec_add( qx, qx ); - qy2 = vec_add( qy, qy ); - qz2 = vec_add( qz, qz ); - qxqx2 = vec_madd( qx, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqy2 = vec_madd( qx, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqz2 = vec_madd( qx, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqw2 = vec_madd( qw, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqy2 = vec_madd( qy, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqz2 = vec_madd( qy, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqw2 = vec_madd( qw, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qzqz2 = vec_madd( qz, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qzqw2 = vec_madd( qw, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col0, vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qyqy2 ), qzqz2 ), vec_add( qxqy2, qzqw2 ), vec_sub( qxqz2, qyqw2 ) ); - vmathSoaV3MakeFromElems( &result->col1, vec_sub( qxqy2, qzqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qzqz2 ), vec_add( qyqz2, qxqw2 ) ); - vmathSoaV3MakeFromElems( &result->col2, vec_add( qxqz2, qyqw2 ), vec_sub( qyqz2, qxqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qyqy2 ) ); -} - -static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); - vmathSoaV3Copy( &result->col1, _col1 ); - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathSoaV3MakeFromAos( &result->col0, &mat->col0 ); - vmathSoaV3MakeFromAos( &result->col1, &mat->col1 ); - vmathSoaV3MakeFromAos( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ) -{ - vmathSoaV3MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); - vmathSoaV3MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); - vmathSoaV3MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); -} - -static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) -{ - vmathSoaV3Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV3Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV3Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); -} - -static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col1 ) -{ - vmathSoaV3Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ) -{ - vmathSoaV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ) -{ - vmathSoaV3SetElem( &result->col0, row, vmathSoaV3GetElem( vec, 0 ) ); - vmathSoaV3SetElem( &result->col1, row, vmathSoaV3GetElem( vec, 1 ) ); - vmathSoaV3SetElem( &result->col2, row, vmathSoaV3GetElem( vec, 2 ) ); -} - -static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaM3GetCol( &tmpV3_0, result, col ); - vmathSoaV3SetElem( &tmpV3_0, row, val ); - vmathSoaM3SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaM3GetCol( &tmpV3_0, mat, col ); - return vmathSoaV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col0 ); -} - -static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col1 ); -} - -static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col2 ); -} - -static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ) -{ - vmathSoaV3Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ) -{ - vmathSoaV3MakeFromElems( result, vmathSoaV3GetElem( &mat->col0, row ), vmathSoaV3GetElem( &mat->col1, row ), vmathSoaV3GetElem( &mat->col2, row ) ); -} - -static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - VmathSoaMatrix3 tmpResult; - vmathSoaV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); - vmathSoaV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); - vmathSoaV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); - vmathSoaM3Copy( result, &tmpResult ); -} - -static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmp0, tmp1, tmp2; - vec_float4 detinv; - vmathSoaV3Cross( &tmp0, &mat->col1, &mat->col2 ); - vmathSoaV3Cross( &tmp1, &mat->col2, &mat->col0 ); - vmathSoaV3Cross( &tmp2, &mat->col0, &mat->col1 ); - detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( &mat->col2, &tmp2 ) ); - vmathSoaV3MakeFromElems( &result->col0, vec_madd( tmp0.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &result->col1, vec_madd( tmp0.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &result->col2, vec_madd( tmp0.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); - return vmathSoaV3Dot( &mat->col2, &tmpV3_0 ); -} - -static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3Add( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Neg( &result->col0, &mat->col0 ); - vmathSoaV3Neg( &result->col1, &mat->col1 ); - vmathSoaV3Neg( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3AbsPerElem( &result->col0, &mat->col0 ); - vmathSoaV3AbsPerElem( &result->col1, &mat->col1 ); - vmathSoaV3AbsPerElem( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ) -{ - vmathSoaV3ScalarMul( &result->col0, &mat->col0, scalar ); - vmathSoaV3ScalarMul( &result->col1, &mat->col1, scalar ); - vmathSoaV3ScalarMul( &result->col2, &mat->col2, scalar ); -} - -static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - VmathSoaMatrix3 tmpResult; - vmathSoaM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); - vmathSoaM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); - vmathSoaM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); - vmathSoaM3Copy( result, &tmpResult ); -} - -static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); -} - -static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ); - vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ); -} - -static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); -} - -static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeZAxis( &result->col2 ); -} - -static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ); - vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - vmathSoaV3MakeFromElems( &result->col0, vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ) ); -} - -static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) -{ - vmathSoaM3MakeFromQ( result, unitQuat ); -} - -static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z ); -} - -static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); -} - -static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3MulPerElem( &result->col0, &mat->col0, scaleVec ); - vmathSoaV3MulPerElem( &result->col1, &mat->col1, scaleVec ); - vmathSoaV3MulPerElem( &result->col2, &mat->col2, scaleVec ); -} - -static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ) -{ - vmathSoaV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathSoaV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathSoaV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ) -{ - VmathMatrix3 mat0, mat1, mat2, mat3; - vmathSoaM3Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathM3Print( &mat0 ); - printf("slot 1:\n"); - vmathM3Print( &mat1 ); - printf("slot 2:\n"); - vmathM3Print( &mat2 ); - printf("slot 3:\n"); - vmathM3Print( &mat3 ); -} - -static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathSoaM3Print( mat ); -} - -#endif - -static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( &result->col0, &mat->col0 ); - vmathSoaV4Copy( &result->col1, &mat->col1 ); - vmathSoaV4Copy( &result->col2, &mat->col2 ); - vmathSoaV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ) -{ - vmathSoaV4MakeFromScalar( &result->col0, scalar ); - vmathSoaV4MakeFromScalar( &result->col1, scalar ); - vmathSoaV4MakeFromScalar( &result->col2, scalar ); - vmathSoaV4MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ) -{ - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, &mat->col3, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0, const VmathSoaVector4 *_col1, const VmathSoaVector4 *_col2, const VmathSoaVector4 *_col3 ) -{ - vmathSoaV4Copy( &result->col0, _col0 ); - vmathSoaV4Copy( &result->col1, _col1 ); - vmathSoaV4Copy( &result->col2, _col2 ); - vmathSoaV4Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) -{ - VmathSoaMatrix3 mat; - vmathSoaM3MakeFromQ( &mat, unitQuat ); - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat.col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat.col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat.col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathSoaV4MakeFromAos( &result->col0, &mat->col0 ); - vmathSoaV4MakeFromAos( &result->col1, &mat->col1 ); - vmathSoaV4MakeFromAos( &result->col2, &mat->col2 ); - vmathSoaV4MakeFromAos( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ) -{ - vmathSoaV4MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); - vmathSoaV4MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); - vmathSoaV4MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); - vmathSoaV4MakeFrom4Aos( &result->col3, &mat0->col3, &mat1->col3, &mat2->col3, &mat3->col3 ); -} - -static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) -{ - vmathSoaV4Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV4Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV4Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); - vmathSoaV4Get4Aos( &mat->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); -} - -static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0 ) -{ - vmathSoaV4Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col1 ) -{ - vmathSoaV4Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col2 ) -{ - vmathSoaV4Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col3 ) -{ - vmathSoaV4Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ) -{ - vmathSoaV4Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ) -{ - vmathSoaV4SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); - vmathSoaV4SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); - vmathSoaV4SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); - vmathSoaV4SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); -} - -static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector4 tmpV3_0; - vmathSoaM4GetCol( &tmpV3_0, result, col ); - vmathSoaV4SetElem( &tmpV3_0, row, val ); - vmathSoaM4SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ) -{ - VmathSoaVector4 tmpV4_0; - vmathSoaM4GetCol( &tmpV4_0, mat, col ); - return vmathSoaV4GetElem( &tmpV4_0, row ); -} - -static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col0 ); -} - -static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col1 ); -} - -static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col2 ); -} - -static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col3 ); -} - -static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ) -{ - vmathSoaV4Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ) -{ - vmathSoaV4MakeFromElems( result, vmathSoaV4GetElem( &mat->col0, row ), vmathSoaV4GetElem( &mat->col1, row ), vmathSoaV4GetElem( &mat->col2, row ), vmathSoaV4GetElem( &mat->col3, row ) ); -} - -static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaMatrix4 tmpResult; - vmathSoaV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); - vmathSoaV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); - vmathSoaV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); - vmathSoaV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaVector4 res0, res1, res2, res3; - vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetX( &res0, vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV4SetY( &res0, vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV4SetZ( &res0, vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV4SetW( &res0, vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - detInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_add( vec_add( vec_add( vec_madd( mA, res0.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, res0.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, res0.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, res0.w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - vmathSoaV4SetX( &res1, vec_madd( mI, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetY( &res1, vec_madd( mM, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetZ( &res1, vec_madd( mA, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetW( &res1, vec_madd( mE, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetX( &res3, vec_madd( mI, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetY( &res3, vec_madd( mM, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetZ( &res3, vec_madd( mA, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetW( &res3, vec_madd( mE, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetX( &res2, vec_madd( mI, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetY( &res2, vec_madd( mM, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetZ( &res2, vec_madd( mA, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetW( &res2, vec_madd( mE, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp0 = vec_sub( vec_madd( mI, mB, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mJ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mM, mF, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mN, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mI, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mM, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mI, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mM, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4SetX( &res2, vec_add( vec_sub( vec_madd( mL, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.x ) ); - vmathSoaV4SetY( &res2, vec_add( vec_sub( vec_madd( mP, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.y ) ); - vmathSoaV4SetZ( &res2, vec_sub( vec_sub( vec_madd( mB, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mD, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.z ) ); - vmathSoaV4SetW( &res2, vec_sub( vec_sub( vec_madd( mF, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mH, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.w ) ); - vmathSoaV4SetX( &res3, vec_add( vec_sub( vec_madd( mJ, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mK, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.x ) ); - vmathSoaV4SetY( &res3, vec_add( vec_sub( vec_madd( mN, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mO, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.y ) ); - vmathSoaV4SetZ( &res3, vec_sub( vec_sub( vec_madd( mC, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.z ) ); - vmathSoaV4SetW( &res3, vec_sub( vec_sub( vec_madd( mG, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.w ) ); - vmathSoaV4SetX( &res1, vec_sub( vec_sub( vec_madd( mK, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.x ) ); - vmathSoaV4SetY( &res1, vec_sub( vec_sub( vec_madd( mO, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.y ) ); - vmathSoaV4SetZ( &res1, vec_add( vec_sub( vec_madd( mD, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.z ) ); - vmathSoaV4SetW( &res1, vec_add( vec_sub( vec_madd( mH, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.w ) ); - vmathSoaV4ScalarMul( &result->col0, &res0, detInv ); - vmathSoaV4ScalarMul( &result->col1, &res1, detInv ); - vmathSoaV4ScalarMul( &result->col2, &res2, detInv ); - vmathSoaV4ScalarMul( &result->col3, &res3, detInv ); -} - -static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaTransform3 affineMat, tmpT3_0; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); - vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); - vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); - vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); - vmathSoaT3Inverse( &tmpT3_0, &affineMat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaTransform3 affineMat, tmpT3_0; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); - vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); - vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); - vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); - vmathSoaT3OrthoInverse( &tmpT3_0, &affineMat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ) -{ - vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dx = vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dy = vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dz = vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dw = vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return vec_add( vec_add( vec_add( vec_madd( mA, dx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, dy, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, dz, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, dw, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4Add( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4Add( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Neg( &result->col0, &mat->col0 ); - vmathSoaV4Neg( &result->col1, &mat->col1 ); - vmathSoaV4Neg( &result->col2, &mat->col2 ); - vmathSoaV4Neg( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4AbsPerElem( &result->col0, &mat->col0 ); - vmathSoaV4AbsPerElem( &result->col1, &mat->col1 ); - vmathSoaV4AbsPerElem( &result->col2, &mat->col2 ); - vmathSoaV4AbsPerElem( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ) -{ - vmathSoaV4ScalarMul( &result->col0, &mat->col0, scalar ); - vmathSoaV4ScalarMul( &result->col1, &mat->col1, scalar ); - vmathSoaV4ScalarMul( &result->col2, &mat->col2, scalar ); - vmathSoaV4ScalarMul( &result->col3, &mat->col3, scalar ); -} - -static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = vec_add( vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.x, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_add( vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.y, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_add( vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.z, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpW = vec_add( vec_add( vec_add( vec_madd( mat->col0.w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col3.w, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ) -{ - result->x = vec_add( vec_add( vec_madd( mat->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->y = vec_add( vec_add( vec_madd( mat->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->z = vec_add( vec_add( vec_madd( mat->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->w = vec_add( vec_add( vec_madd( mat->col0.w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ) -{ - result->x = vec_add( vec_add( vec_add( vec_madd( mat->col0.x, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.x, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.x, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.x ); - result->y = vec_add( vec_add( vec_add( vec_madd( mat->col0.y, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.y, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.y, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.y ); - result->z = vec_add( vec_add( vec_add( vec_madd( mat->col0.z, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.z, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.z, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.z ); - result->w = vec_add( vec_add( vec_add( vec_madd( mat->col0.w, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mat->col1.w, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mat->col2.w, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mat->col3.w ); -} - -static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - VmathSoaMatrix4 tmpResult; - vmathSoaM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); - vmathSoaM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); - vmathSoaM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); - vmathSoaM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm1 ) -{ - VmathSoaMatrix4 tmpResult; - VmathSoaPoint3 tmpP3_0; - vmathSoaM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); - vmathSoaM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); - vmathSoaM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); - vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathSoaM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ) -{ - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ) -{ - vmathSoaV4SetXYZ( &result->col0, &mat3->col0 ); - vmathSoaV4SetXYZ( &result->col1, &mat3->col1 ); - vmathSoaV4SetXYZ( &result->col2, &mat3->col2 ); -} - -static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4GetXYZ( &result->col0, &mat->col0 ); - vmathSoaV4GetXYZ( &result->col1, &mat->col1 ); - vmathSoaV4GetXYZ( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4SetXYZ( &result->col3, translateVec ); -} - -static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4GetXYZ( result, &mat->col3 ); -} - -static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - vmathSoaV4MakeFromElems( &result->col0, vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ) -{ - VmathSoaTransform3 tmpT3_0; - vmathSoaT3MakeRotationQ( &tmpT3_0, unitQuat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV4MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV4ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV4ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV4ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); - vmathSoaV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ) -{ - VmathSoaVector4 scale4; - vmathSoaV4MakeFromV3Scalar( &scale4, scaleVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - vmathSoaV4MulPerElem( &result->col0, &mat->col0, &scale4 ); - vmathSoaV4MulPerElem( &result->col1, &mat->col1, &scale4 ); - vmathSoaV4MulPerElem( &result->col2, &mat->col2, &scale4 ); - vmathSoaV4MulPerElem( &result->col3, &mat->col3, &scale4 ); -} - -static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ) -{ - VmathSoaMatrix4 m4EyeFrame; - VmathSoaVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathSoaV3Normalize( &v3Y, upVec ); - vmathSoaP3Sub( &tmpV3_0, eyePos, lookAtPos ); - vmathSoaV3Normalize( &v3Z, &tmpV3_0 ); - vmathSoaV3Cross( &tmpV3_1, &v3Y, &v3Z ); - vmathSoaV3Normalize( &v3X, &tmpV3_1 ); - vmathSoaV3Cross( &v3Y, &v3Z, &v3X ); - vmathSoaV4MakeFromV3( &tmpV4_0, &v3X ); - vmathSoaV4MakeFromV3( &tmpV4_1, &v3Y ); - vmathSoaV4MakeFromV3( &tmpV4_2, &v3Z ); - vmathSoaV4MakeFromP3( &tmpV4_3, eyePos ); - vmathSoaM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); - vmathSoaM4OrthoInverse( result, &m4EyeFrame ); -} - -static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 f, rangeInv; - f = tanf4( vec_sub( ((vec_float4){_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2}), vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), fovyRadians, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - rangeInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - vmathSoaV4MakeFromElems( &result->col0, divf4( f, aspect ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), f, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_add( zNear, zFar ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ); - vmathSoaV4MakeFromElems( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( vec_madd( zNear, zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = vec_add( right, left ); - sum_tb = vec_add( top, bottom ); - sum_nf = vec_add( zNear, zFar ); - inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); - inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); - inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - n2 = vec_add( zNear, zNear ); - vmathSoaV4MakeFromElems( &result->col0, vec_madd( n2, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( n2, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, vec_madd( sum_rl, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_tb, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ); - vmathSoaV4MakeFromElems( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( n2, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = vec_add( right, left ); - sum_tb = vec_add( top, bottom ); - sum_nf = vec_add( zNear, zFar ); - inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); - inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); - inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - vmathSoaV4MakeFromElems( &result->col0, vec_add( inv_rl, inv_rl ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_tb, inv_tb ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_nf, inv_nf ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV4MakeFromElems( &result->col3, vec_madd( negatef4( sum_rl ), inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( negatef4( sum_tb ), inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ) -{ - vmathSoaV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathSoaV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathSoaV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); - vmathSoaV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ) -{ - VmathMatrix4 mat0, mat1, mat2, mat3; - vmathSoaM4Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathM4Print( &mat0 ); - printf("slot 1:\n"); - vmathM4Print( &mat1 ); - printf("slot 2:\n"); - vmathM4Print( &mat2 ); - printf("slot 3:\n"); - vmathM4Print( &mat3 ); -} - -static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathSoaM4Print( mat ); -} - -#endif - -static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( &result->col0, &tfrm->col0 ); - vmathSoaV3Copy( &result->col1, &tfrm->col1 ); - vmathSoaV3Copy( &result->col2, &tfrm->col2 ); - vmathSoaV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ) -{ - vmathSoaV3MakeFromScalar( &result->col0, scalar ); - vmathSoaV3MakeFromScalar( &result->col1, scalar ); - vmathSoaV3MakeFromScalar( &result->col2, scalar ); - vmathSoaV3MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2, const VmathSoaVector3 *_col3 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); - vmathSoaV3Copy( &result->col1, _col1 ); - vmathSoaV3Copy( &result->col2, _col2 ); - vmathSoaV3Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ) -{ - vmathSoaT3SetUpper3x3( result, tfrm ); - vmathSoaT3SetTranslation( result, translateVec ); -} - -static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) -{ - VmathSoaMatrix3 tmpM3_0; - vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathSoaT3SetUpper3x3( result, &tmpM3_0 ); - vmathSoaT3SetTranslation( result, translateVec ); -} - -static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathSoaV3MakeFromAos( &result->col0, &tfrm->col0 ); - vmathSoaV3MakeFromAos( &result->col1, &tfrm->col1 ); - vmathSoaV3MakeFromAos( &result->col2, &tfrm->col2 ); - vmathSoaV3MakeFromAos( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ) -{ - vmathSoaV3MakeFrom4Aos( &result->col0, &tfrm0->col0, &tfrm1->col0, &tfrm2->col0, &tfrm3->col0 ); - vmathSoaV3MakeFrom4Aos( &result->col1, &tfrm0->col1, &tfrm1->col1, &tfrm2->col1, &tfrm3->col1 ); - vmathSoaV3MakeFrom4Aos( &result->col2, &tfrm0->col2, &tfrm1->col2, &tfrm2->col2, &tfrm3->col2 ); - vmathSoaV3MakeFrom4Aos( &result->col3, &tfrm0->col3, &tfrm1->col3, &tfrm2->col3, &tfrm3->col3 ); -} - -static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) -{ - vmathSoaV3Get4Aos( &tfrm->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV3Get4Aos( &tfrm->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV3Get4Aos( &tfrm->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); - vmathSoaV3Get4Aos( &tfrm->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); -} - -static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *_col1 ) -{ - vmathSoaV3Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *_col3 ) -{ - vmathSoaV3Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ) -{ - vmathSoaV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ) -{ - vmathSoaV3SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); - vmathSoaV3SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); - vmathSoaV3SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); - vmathSoaV3SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); -} - -static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaT3GetCol( &tmpV3_0, result, col ); - vmathSoaV3SetElem( &tmpV3_0, row, val ); - vmathSoaT3SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaT3GetCol( &tmpV3_0, tfrm, col ); - return vmathSoaV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col0 ); -} - -static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col1 ); -} - -static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col2 ); -} - -static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ) -{ - vmathSoaV3Copy( result, (&tfrm->col0 + col) ); -} - -static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ) -{ - vmathSoaV4MakeFromElems( result, vmathSoaV3GetElem( &tfrm->col0, row ), vmathSoaV3GetElem( &tfrm->col1, row ), vmathSoaV3GetElem( &tfrm->col2, row ), vmathSoaV3GetElem( &tfrm->col3, row ) ); -} - -static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - VmathSoaVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - vec_float4 detinv; - vmathSoaV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); - vmathSoaV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); - vmathSoaV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); - detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( &tfrm->col2, &tmp2 ) ); - vmathSoaV3MakeFromElems( &inv0, vec_madd( tmp0.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.x, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &inv1, vec_madd( tmp0.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.y, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &inv2, vec_madd( tmp0.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.z, detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3Copy( &result->col0, &inv0 ); - vmathSoaV3Copy( &result->col1, &inv1 ); - vmathSoaV3Copy( &result->col2, &inv2 ); - vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathSoaV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - VmathSoaVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - vmathSoaV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); - vmathSoaV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); - vmathSoaV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); - vmathSoaV3Copy( &result->col0, &inv0 ); - vmathSoaV3Copy( &result->col1, &inv1 ); - vmathSoaV3Copy( &result->col2, &inv2 ); - vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathSoaV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3AbsPerElem( &result->col0, &tfrm->col0 ); - vmathSoaV3AbsPerElem( &result->col1, &tfrm->col1 ); - vmathSoaV3AbsPerElem( &result->col2, &tfrm->col2 ); - vmathSoaV3AbsPerElem( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = vec_add( vec_add( vec_madd( tfrm->col0.x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_add( vec_add( vec_madd( tfrm->col0.y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_add( vec_add( vec_madd( tfrm->col0.z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.x, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.x, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.x, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.x ); - tmpY = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.y, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.y, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.y, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.y ); - tmpZ = vec_add( vec_add( vec_add( vec_madd( tfrm->col0.z, pnt->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tfrm->col1.z, pnt->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tfrm->col2.z, pnt->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), tfrm->col3.z ); - vmathSoaP3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) -{ - VmathSoaTransform3 tmpResult; - VmathSoaPoint3 tmpP3_0, tmpP3_1; - vmathSoaT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); - vmathSoaT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); - vmathSoaT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); - vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathSoaT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); - vmathSoaV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); - vmathSoaT3Copy( result, &tmpResult ); -} - -static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) -{ - vmathSoaV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); - vmathSoaV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); - vmathSoaV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); - vmathSoaV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); -} - -static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm ) -{ - vmathSoaV3Copy( &result->col0, &tfrm->col0 ); - vmathSoaV3Copy( &result->col1, &tfrm->col1 ); - vmathSoaV3Copy( &result->col2, &tfrm->col2 ); -} - -static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); -} - -static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV3Copy( &result->col3, translateVec ); -} - -static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ); - vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeFromElems( &result->col2, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col0, vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ); - vmathSoaV3MakeFromElems( &result->col1, vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( &result->col2, vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - VmathSoaMatrix3 tmpM3_0; - VmathSoaVector3 tmpV3_0; - vmathSoaM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); - vmathSoaV3MakeFromScalar( &tmpV3_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ) -{ - VmathSoaMatrix3 tmpM3_0; - VmathSoaVector3 tmpV3_0; - vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathSoaV3MakeFromScalar( &tmpV3_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathSoaV3MakeFromElems( &result->col2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec->z ); - vmathSoaV3MakeFromScalar( &result->col3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3ScalarMul( &result->col0, &tfrm->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col1, &tfrm->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col2, &tfrm->col2, vmathSoaV3GetZ( scaleVec ) ); - vmathSoaV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); - vmathSoaV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); - vmathSoaV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); - vmathSoaV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); -} - -static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3Copy( &result->col3, translateVec ); -} - -static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ) -{ - vmathSoaV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); - vmathSoaV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); - vmathSoaV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); - vmathSoaV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ) -{ - VmathTransform3 mat0, mat1, mat2, mat3; - vmathSoaT3Get4Aos( tfrm, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathT3Print( &mat0 ); - printf("slot 1:\n"); - vmathT3Print( &mat1 ); - printf("slot 2:\n"); - vmathT3Print( &mat2 ); - printf("slot 3:\n"); - vmathT3Print( &mat3 ); -} - -static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ) -{ - printf("%s:\n", name); - vmathSoaT3Print( tfrm ); -} - -#endif - -static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *tfrm ) -{ - vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - vec_uint4 negTrace, ZgtX, ZgtY, YgtX; - vec_uint4 largestXorY, largestYorZ, largestZorX; - - xx = tfrm->col0.x; - yx = tfrm->col0.y; - zx = tfrm->col0.z; - xy = tfrm->col1.x; - yy = tfrm->col1.y; - zy = tfrm->col1.z; - xz = tfrm->col2.x; - yz = tfrm->col2.y; - zz = tfrm->col2.z; - - trace = vec_add( vec_add( xx, yy ), zz ); - - negTrace = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), trace ); - ZgtX = (vec_uint4)vec_cmpgt( zz, xx ); - ZgtY = (vec_uint4)vec_cmpgt( zz, yy ); - YgtX = (vec_uint4)vec_cmpgt( yy, xx ); - largestXorY = vec_andc( negTrace, vec_and( ZgtX, ZgtY ) ); - largestYorZ = vec_and( negTrace, vec_or( YgtX, ZgtX ) ); - largestZorX = vec_andc( negTrace, vec_andc( YgtX, ZgtY ) ); - - zz = vec_sel( zz, negatef4(zz), largestXorY ); - xy = vec_sel( xy, negatef4(xy), largestXorY ); - xx = vec_sel( xx, negatef4(xx), largestYorZ ); - yz = vec_sel( yz, negatef4(yz), largestYorZ ); - yy = vec_sel( yy, negatef4(yy), largestZorX ); - zx = vec_sel( zx, negatef4(zx), largestZorX ); - - radicand = vec_add( vec_add( vec_add( xx, yy ), zz ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - scale = vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( radicand ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - - tmpx = vec_madd( vec_sub( zy, yz ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpy = vec_madd( vec_sub( xz, zx ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpz = vec_madd( vec_sub( yx, xy ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpw = vec_madd( radicand, scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - qx = vec_sel( qx, tmpw, largestXorY ); - qy = vec_sel( qy, tmpz, largestXorY ); - qz = vec_sel( qz, tmpy, largestXorY ); - qw = vec_sel( qw, tmpx, largestXorY ); - tmpx = qx; - tmpz = qz; - qx = vec_sel( qx, qy, largestYorZ ); - qy = vec_sel( qy, tmpx, largestYorZ ); - qz = vec_sel( qz, qw, largestYorZ ); - qw = vec_sel( qw, tmpz, largestYorZ ); - - result->x = qx; - result->y = qy; - result->z = qz; - result->w = qw; -} - -static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *tfrm0, const VmathSoaVector3 *tfrm1 ) -{ - vmathSoaV3ScalarMul( &result->col0, tfrm0, vmathSoaV3GetX( tfrm1 ) ); - vmathSoaV3ScalarMul( &result->col1, tfrm0, vmathSoaV3GetY( tfrm1 ) ); - vmathSoaV3ScalarMul( &result->col2, tfrm0, vmathSoaV3GetZ( tfrm1 ) ); -} - -static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *tfrm0, const VmathSoaVector4 *tfrm1 ) -{ - vmathSoaV4ScalarMul( &result->col0, tfrm0, vmathSoaV4GetX( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col1, tfrm0, vmathSoaV4GetY( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col2, tfrm0, vmathSoaV4GetZ( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col3, tfrm0, vmathSoaV4GetW( tfrm1 ) ); -} - -static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = vec_add( vec_add( vec_madd( vec->x, mat->col0.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col0.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col0.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_add( vec_add( vec_madd( vec->x, mat->col1.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col1.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col1.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_add( vec_add( vec_madd( vec->x, mat->col2.x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec->y, mat->col2.y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec->z, mat->col2.z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ) -{ - vmathSoaV3MakeFromElems( &result->col0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec->z, negatef4( vec->y ) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( vec->z ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec->x ); - vmathSoaV3MakeFromElems( &result->col2, vec->y, negatef4( vec->x ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathSoaV3Cross( &tmpV3_0, vec, &mat->col0 ); - vmathSoaV3Cross( &tmpV3_1, vec, &mat->col1 ); - vmathSoaV3Cross( &tmpV3_2, vec, &mat->col2 ); - vmathSoaM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h deleted file mode 100644 index c8401e3d0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/mat_soa_v.h +++ /dev/null @@ -1,1063 +0,0 @@ -/* - 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_MAT_SOA_V_C_H -#define _VECTORMATH_MAT_SOA_V_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromCols(&result, &_col0, &_col1, &_col2); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromAos(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); - return result; -} - -static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) -{ - vmathSoaM3Get4Aos(&mat, result0, result1, result2, result3); -} - -static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col0 ) -{ - vmathSoaM3SetCol0(result, &_col0); -} - -static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col1 ) -{ - vmathSoaM3SetCol1(result, &_col1); -} - -static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col2 ) -{ - vmathSoaM3SetCol2(result, &_col2); -} - -static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ) -{ - vmathSoaM3SetCol(result, col, &vec); -} - -static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ) -{ - vmathSoaM3SetRow(result, row, &vec); -} - -static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) -{ - vmathSoaM3SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ) -{ - return vmathSoaM3GetElem(&mat, col, row); -} - -static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol0(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol1(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol2(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol(&result, &mat, col); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ) -{ - VmathSoaVector3 result; - vmathSoaM3GetRow(&result, &mat, row); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Transpose(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Inverse(&result, &mat); - return result; -} - -static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ) -{ - return vmathSoaM3Determinant(&mat); -} - -static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Neg(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3AbsPerElem(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ) -{ - VmathSoaMatrix3 result; - vmathSoaM3ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaM3MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeIdentity(&result); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ) -{ - vmathSoaM3Print(&mat); -} - -static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ) -{ - vmathSoaM3Prints(&mat, name); -} - -#endif - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromT3(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 _col0, VmathSoaVector4 _col1, VmathSoaVector4 _col2, VmathSoaVector4 _col3 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromM3V3(&result, &mat, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromAos(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); - return result; -} - -static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) -{ - vmathSoaM4Get4Aos(&mat, result0, result1, result2, result3); -} - -static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col0 ) -{ - vmathSoaM4SetCol0(result, &_col0); -} - -static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col1 ) -{ - vmathSoaM4SetCol1(result, &_col1); -} - -static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col2 ) -{ - vmathSoaM4SetCol2(result, &_col2); -} - -static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col3 ) -{ - vmathSoaM4SetCol3(result, &_col3); -} - -static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ) -{ - vmathSoaM4SetCol(result, col, &vec); -} - -static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ) -{ - vmathSoaM4SetRow(result, row, &vec); -} - -static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) -{ - vmathSoaM4SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ) -{ - return vmathSoaM4GetElem(&mat, col, row); -} - -static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol0(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol1(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol2(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol3(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol(&result, &mat, col); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ) -{ - VmathSoaVector4 result; - vmathSoaM4GetRow(&result, &mat, row); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Transpose(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Inverse(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AffineInverse(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4OrthoInverse(&result, &mat); - return result; -} - -static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ) -{ - return vmathSoaM4Determinant(&mat); -} - -static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Neg(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AbsPerElem(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaM4MulV4(&result, &mat, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ) -{ - VmathSoaVector4 result; - vmathSoaM4MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ) -{ - VmathSoaVector4 result; - vmathSoaM4MulP3(&result, &mat, &pnt); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MulT3(&result, &mat, &tfrm1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeIdentity(&result); - return result; -} - -static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ) -{ - vmathSoaM4SetUpper3x3(result, &mat3); -} - -static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM4GetUpper3x3(&result, &mat); - return result; -} - -static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ) -{ - vmathSoaM4SetTranslation(result, &translateVec); -} - -static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector3 result; - vmathSoaM4GetTranslation(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ) -{ - vmathSoaM4Print(&mat); -} - -static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ) -{ - vmathSoaM4Prints(&mat, name); -} - -#endif - -static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2, VmathSoaVector3 _col3 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromM3V3(&result, &tfrm, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromAos(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFrom4Aos(&result, &tfrm0, &tfrm1, &tfrm2, &tfrm3); - return result; -} - -static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) -{ - vmathSoaT3Get4Aos(&tfrm, result0, result1, result2, result3); -} - -static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 _col0 ) -{ - vmathSoaT3SetCol0(result, &_col0); -} - -static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 _col1 ) -{ - vmathSoaT3SetCol1(result, &_col1); -} - -static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 _col2 ) -{ - vmathSoaT3SetCol2(result, &_col2); -} - -static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 _col3 ) -{ - vmathSoaT3SetCol3(result, &_col3); -} - -static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ) -{ - vmathSoaT3SetCol(result, col, &vec); -} - -static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ) -{ - vmathSoaT3SetRow(result, row, &vec); -} - -static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) -{ - vmathSoaT3SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ) -{ - return vmathSoaT3GetElem(&tfrm, col, row); -} - -static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol0(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol1(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol2(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol3(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol(&result, &tfrm, col); - return result; -} - -static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ) -{ - VmathSoaVector4 result; - vmathSoaT3GetRow(&result, &tfrm, row); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3Inverse(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3OrthoInverse(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3AbsPerElem(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaT3MulV3(&result, &tfrm, &vec); - return result; -} - -static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaT3MulP3(&result, &tfrm, &pnt); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3Mul(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MulPerElem(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeIdentity(&result); - return result; -} - -static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 tfrm ) -{ - vmathSoaT3SetUpper3x3(result, &tfrm); -} - -static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaMatrix3 result; - vmathSoaT3GetUpper3x3(&result, &tfrm); - return result; -} - -static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ) -{ - vmathSoaT3SetTranslation(result, &translateVec); -} - -static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetTranslation(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3AppendScale(&result, &tfrm, &scaleVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3PrependScale(&result, &scaleVec, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3Select(&result, &tfrm0, &tfrm1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ) -{ - vmathSoaT3Print(&tfrm); -} - -static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ) -{ - vmathSoaT3Prints(&tfrm, name); -} - -#endif - -static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 tfrm ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromM3(&result, &tfrm); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 tfrm0, VmathSoaVector3 tfrm1 ) -{ - VmathSoaMatrix3 result; - vmathSoaV3Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 tfrm0, VmathSoaVector4 tfrm1 ) -{ - VmathSoaMatrix4 result; - vmathSoaV4Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaV3RowMul(&result, &vec, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ) -{ - VmathSoaMatrix3 result; - vmathSoaV3CrossMatrix(&result, &vec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaV3CrossMatrixMul(&result, &vec, &mat); - return result; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h deleted file mode 100644 index 2915f4f07..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos.h +++ /dev/null @@ -1,379 +0,0 @@ -/* - 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_C_H -#define _VECTORMATH_QUAT_AOS_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & - __builtin_constant_p(_z) & __builtin_constant_p(_w)) { - result->vec128 = (vec_float4){_x, _y, _z, _w}; - } else { - float *pf = (float *)&result->vec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - pf[3] = _w; - } -} - -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) -{ - result->vec128 = xyz->vec128; - _vmathVfSetElement(result->vec128, _w, 3); -} - -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) -{ - result->vec128 = _vmathVfSplatScalar(scalar); -} - -static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathQMakeIdentity( VmathQuat *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0001; -} - -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - VmathQuat tmpQ_0, tmpQ_1; - vmathQSub( &tmpQ_0, quat1, quat0 ); - vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); - vmathQAdd( result, quat0, &tmpQ_1 ); -} - -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) -{ - VmathQuat start; - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle ); - cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start.vec128 = vec_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = _vmathVfSplatScalar(t); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( sines, vec_splat( sines, 0 ) ); - scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); - scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); - result->vec128 = vec_madd( start.vec128, scale0, vec_madd( unitQuat1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) -{ - VmathQuat tmp0, tmp1; - vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); - vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); - vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); -} - -static inline vec_float4 vmathQGet128( const VmathQuat *quat ) -{ - return quat->vec128; -} - -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) -{ - result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F ); -} - -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathQSetX( VmathQuat *result, float _x ) -{ - _vmathVfSetElement(result->vec128, _x, 0); -} - -static inline float vmathQGetX( const VmathQuat *quat ) -{ - return _vmathVfGetElement(quat->vec128, 0); -} - -static inline void vmathQSetY( VmathQuat *result, float _y ) -{ - _vmathVfSetElement(result->vec128, _y, 1); -} - -static inline float vmathQGetY( const VmathQuat *quat ) -{ - return _vmathVfGetElement(quat->vec128, 1); -} - -static inline void vmathQSetZ( VmathQuat *result, float _z ) -{ - _vmathVfSetElement(result->vec128, _z, 2); -} - -static inline float vmathQGetZ( const VmathQuat *quat ) -{ - return _vmathVfGetElement(quat->vec128, 2); -} - -static inline void vmathQSetW( VmathQuat *result, float _w ) -{ - _vmathVfSetElement(result->vec128, _w, 3); -} - -static inline float vmathQGetW( const VmathQuat *quat ) -{ - return _vmathVfGetElement(quat->vec128, 3); -} - -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) -{ - _vmathVfSetElement(result->vec128, value, idx); -} - -static inline float vmathQGetElem( const VmathQuat *quat, int idx ) -{ - return _vmathVfGetElement(quat->vec128, idx); -} - -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->vec128 = vec_add( quat0->vec128, quat1->vec128 ); -} - -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->vec128 = vec_sub( quat0->vec128, quat1->vec128 ); -} - -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->vec128 = vec_madd( quat->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->vec128 = divf4( quat->vec128, _vmathVfSplatScalar(scalar) ); -} - -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = negatef4( quat->vec128 ); -} - -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - vec_float4 result = _vmathVfDot4( quat0->vec128, quat1->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathQNorm( const VmathQuat *quat ) -{ - vec_float4 result = _vmathVfDot4( quat->vec128, quat->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathQLength( const VmathQuat *quat ) -{ - return sqrtf( vmathQNorm( quat ) ); -} - -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) -{ - vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 ); - result->vec128 = vec_madd( quat->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - VmathVector3 crossVec, tmpV3_0; - vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; - cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = vec_splat( cosAngle, 0 ); - cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) ); - recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); - cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); - crossVec = tmpV3_0; - res = vec_madd( crossVec.vec128, recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( vec_madd( unitVec->vec128, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( _vmathVfSplatScalar(radians), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - result->vec128 = res; -} - -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; - vec_float4 product, l_wxyz, r_wxyz, xy, qw; - ldata = quat0->vec128; - rdata = quat1->vec128; - tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW ); - qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); - qv = vec_madd( tmp0, tmp1, qv ); - qv = vec_nmsub( tmp2, tmp3, qv ); - product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - 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 ) ); - result->vec128 = vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ); -} - -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) -{ - vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; - qdata = quat->vec128; - vdata = vec->vec128; - tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW ); - wwww = vec_splat( qdata, 3 ); - qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qv = vec_madd( tmp0, tmp1, qv ); - qv = vec_nmsub( tmp2, tmp3, qv ); - product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); - qw = vec_add( vec_sld( product, product, 8 ), qw ); - tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW ); - res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( wwww, qv, res ); - res = vec_madd( tmp0, tmp1, res ); - res = vec_nmsub( tmp2, tmp3, res ); - result->vec128 = res; -} - -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = vec_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ); -} - -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) -{ - unsigned int tmp; - tmp = (unsigned int)-(select1 > 0); - result->vec128 = vec_sel( quat0->vec128, quat1->vec128, _vmathVuiSplatScalar(tmp) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint( const VmathQuat *quat ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = quat->vec128; - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -static inline void vmathQPrints( const VmathQuat *quat, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = quat->vec128; - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h deleted file mode 100644 index 04cf6ccf9..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_aos_v.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - 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_V_C_H -#define _VECTORMATH_QUAT_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathQuat result; - vmathQMakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathQuat result; - vmathQMakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) -{ - VmathQuat result; - vmathQMakeFromV4(&result, &vec); - return result; -} - -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) -{ - VmathQuat result; - vmathQMakeFromScalar(&result, scalar); - return result; -} - -static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) -{ - VmathQuat result; - vmathQMakeFrom128(&result, vf4); - return result; -} - -static inline VmathQuat vmathQMakeIdentity_V( ) -{ - VmathQuat result; - vmathQMakeIdentity(&result); - return result; -} - -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQLerp(&result, t, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) -{ - VmathQuat result; - vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); - return result; -} - -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) -{ - VmathQuat result; - vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); - return result; -} - -static inline vec_float4 vmathQGet128_V( VmathQuat quat ) -{ - return vmathQGet128(&quat); -} - -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) -{ - vmathQSetXYZ(result, &vec); -} - -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) -{ - VmathVector3 result; - vmathQGetXYZ(&result, &quat); - return result; -} - -static inline void vmathQSetX_V( VmathQuat *result, float _x ) -{ - vmathQSetX(result, _x); -} - -static inline float vmathQGetX_V( VmathQuat quat ) -{ - return vmathQGetX(&quat); -} - -static inline void vmathQSetY_V( VmathQuat *result, float _y ) -{ - vmathQSetY(result, _y); -} - -static inline float vmathQGetY_V( VmathQuat quat ) -{ - return vmathQGetY(&quat); -} - -static inline void vmathQSetZ_V( VmathQuat *result, float _z ) -{ - vmathQSetZ(result, _z); -} - -static inline float vmathQGetZ_V( VmathQuat quat ) -{ - return vmathQGetZ(&quat); -} - -static inline void vmathQSetW_V( VmathQuat *result, float _w ) -{ - vmathQSetW(result, _w); -} - -static inline float vmathQGetW_V( VmathQuat quat ) -{ - return vmathQGetW(&quat); -} - -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) -{ - vmathQSetElem(result, idx, value); -} - -static inline float vmathQGetElem_V( VmathQuat quat, int idx ) -{ - return vmathQGetElem(&quat, idx); -} - -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQAdd(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQSub(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarMul(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarDiv(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQNeg_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNeg(&result, &quat); - return result; -} - -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) -{ - return vmathQDot(&quat0, &quat1); -} - -static inline float vmathQNorm_V( VmathQuat quat ) -{ - return vmathQNorm(&quat); -} - -static inline float vmathQLength_V( VmathQuat quat ) -{ - return vmathQLength(&quat); -} - -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNormalize(&result, &quat); - return result; -} - -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathQuat result; - vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); - return result; -} - -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathQuat result; - vmathQMakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathQuat vmathQMakeRotationX_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationX(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationY_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationY(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationZ_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationZ(&result, radians); - return result; -} - -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQMul(&result, &quat0, &quat1); - return result; -} - -static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathQRotate(&result, &quat, &vec); - return result; -} - -static inline VmathQuat vmathQConj_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQConj(&result, &quat); - return result; -} - -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) -{ - VmathQuat result; - vmathQSelect(&result, &quat0, &quat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint_V( VmathQuat quat ) -{ - vmathQPrint(&quat); -} - -static inline void vmathQPrints_V( VmathQuat quat, const char *name ) -{ - vmathQPrints(&quat, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h deleted file mode 100644 index 334c17b01..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - 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_SOA_C_H -#define _VECTORMATH_QUAT_SOA_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w ) -{ - vmathSoaQSetXYZ( result, xyz ); - vmathSoaQSetW( result, _w ); -} - -static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ) -{ - vec_float4 vec128 = quat->vec128; - result->x = vec_splat( vec128, 0 ); - result->y = vec_splat( vec128, 1 ); - result->z = vec_splat( vec128, 2 ); - result->w = vec_splat( vec128, 3 ); -} - -static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( quat0->vec128, quat2->vec128 ); - tmp1 = vec_mergeh( quat1->vec128, quat3->vec128 ); - tmp2 = vec_mergel( quat0->vec128, quat2->vec128 ); - tmp3 = vec_mergel( quat1->vec128, quat3->vec128 ); - result->x = vec_mergeh( tmp0, tmp1 ); - result->y = vec_mergel( tmp0, tmp1 ); - result->z = vec_mergeh( tmp2, tmp3 ); - result->w = vec_mergel( tmp2, tmp3 ); -} - -static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ) -{ - vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - VmathSoaQuat tmpQ_0, tmpQ_1; - vmathSoaQSub( &tmpQ_0, quat1, quat0 ); - vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t ); - vmathSoaQAdd( result, quat0, &tmpQ_1 ); -} - -static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ) -{ - VmathSoaQuat start, tmpQ_0, tmpQ_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle ); - cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); - vmathSoaQSetX( &start, vec_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) ); - vmathSoaQSetY( &start, vec_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) ); - vmathSoaQSetZ( &start, vec_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) ); - vmathSoaQSetW( &start, vec_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - vmathSoaQScalarMul( &tmpQ_0, &start, scale0 ); - vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 ); - vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 ); -} - -static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ) -{ - VmathSoaQuat tmp0, tmp1; - vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); - vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); - vmathSoaQSlerp( result, vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), &tmp0, &tmp1 ); -} - -static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( quat->x, quat->z ); - tmp1 = vec_mergeh( quat->y, quat->w ); - tmp2 = vec_mergel( quat->x, quat->z ); - tmp3 = vec_mergel( quat->y, quat->w ); - vmathQMakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) ); - vmathQMakeFrom128( result1, vec_mergel( tmp0, tmp1 ) ); - vmathQMakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) ); - vmathQMakeFrom128( result3, vec_mergel( tmp2, tmp3 ) ); -} - -static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ) -{ - vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z ); -} - -static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ) -{ - return quat->x; -} - -static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ) -{ - return quat->y; -} - -static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ) -{ - return quat->z; -} - -static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w ) -{ - result->w = _w; -} - -static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ) -{ - return quat->w; -} - -static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ) -{ - return *(&quat->x + idx); -} - -static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - result->x = vec_add( quat0->x, quat1->x ); - result->y = vec_add( quat0->y, quat1->y ); - result->z = vec_add( quat0->z, quat1->z ); - result->w = vec_add( quat0->w, quat1->w ); -} - -static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - result->x = vec_sub( quat0->x, quat1->x ); - result->y = vec_sub( quat0->y, quat1->y ); - result->z = vec_sub( quat0->z, quat1->z ); - result->w = vec_sub( quat0->w, quat1->w ); -} - -static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) -{ - result->x = vec_madd( quat->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( quat->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( quat->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->w = vec_madd( quat->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) -{ - result->x = divf4( quat->x, scalar ); - result->y = divf4( quat->y, scalar ); - result->z = divf4( quat->z, scalar ); - result->w = divf4( quat->w, scalar ); -} - -static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - result->x = negatef4( quat->x ); - result->y = negatef4( quat->y ); - result->z = negatef4( quat->z ); - result->w = negatef4( quat->w ); -} - -static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - vec_float4 result; - result = vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ) -{ - vec_float4 result; - result = vec_madd( quat->x, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( quat->y, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat->z, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat->w, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ) -{ - return sqrtf4( vmathSoaQNorm( quat ) ); -} - -static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaQNorm( quat ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - result->x = vec_madd( quat->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( quat->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( quat->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->w = vec_madd( quat->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vmathSoaV3Dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 ); - vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); - vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - VmathSoaVector3 tmpV3_0; - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s ); - vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c ); -} - -static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); -} - -static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); -} - -static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c ); -} - -static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->y, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_sub( vec_add( vec_add( vec_madd( quat0->w, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->z, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->x, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpW = vec_sub( vec_sub( vec_sub( vec_madd( quat0->w, quat1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat0->x, quat1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->y, quat1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat0->z, quat1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = vec_sub( vec_add( vec_madd( quat->w, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_sub( vec_add( vec_madd( quat->w, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->z, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->x, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_sub( vec_add( vec_madd( quat->w, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->x, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->y, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpW = vec_add( vec_add( vec_madd( quat->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->x = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->y = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result->z = vec_add( vec_sub( vec_add( vec_madd( tmpW, quat->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w ); -} - -static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ) -{ - result->x = vec_sel( quat0->x, quat1->x, select1 ); - result->y = vec_sel( quat0->y, quat1->y, select1 ); - result->z = vec_sel( quat0->z, quat1->z, select1 ); - result->w = vec_sel( quat0->w, quat1->w, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaQPrint( const VmathSoaQuat *quat ) -{ - VmathQuat vec0, vec1, vec2, vec3; - vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathQPrint( &vec0 ); - printf("slot 1:\n"); - vmathQPrint( &vec1 ); - printf("slot 2:\n"); - vmathQPrint( &vec2 ); - printf("slot 3:\n"); - vmathQPrint( &vec3 ); -} - -static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ) -{ - VmathQuat vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathQPrint( &vec0 ); - printf("slot 1:\n"); - vmathQPrint( &vec1 ); - printf("slot 2:\n"); - vmathQPrint( &vec2 ); - printf("slot 3:\n"); - vmathQPrint( &vec3 ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h deleted file mode 100644 index 601d9da92..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/quat_soa_v.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - 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_SOA_V_C_H -#define _VECTORMATH_QUAT_SOA_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromV4(&result, &vec); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromAos(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) -{ - VmathSoaQuat result; - vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) -{ - VmathSoaQuat result; - vmathSoaQMakeIdentity(&result); - return result; -} - -static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQLerp(&result, t, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) -{ - VmathSoaQuat result; - vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) -{ - VmathSoaQuat result; - vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); - return result; -} - -static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) -{ - vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); -} - -static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) -{ - vmathSoaQSetXYZ(result, &vec); -} - -static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) -{ - VmathSoaVector3 result; - vmathSoaQGetXYZ(&result, &quat); - return result; -} - -static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) -{ - vmathSoaQSetX(result, _x); -} - -static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetX(&quat); -} - -static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) -{ - vmathSoaQSetY(result, _y); -} - -static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetY(&quat); -} - -static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) -{ - vmathSoaQSetZ(result, _z); -} - -static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetZ(&quat); -} - -static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) -{ - vmathSoaQSetW(result, _w); -} - -static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetW(&quat); -} - -static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) -{ - vmathSoaQSetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) -{ - return vmathSoaQGetElem(&quat, idx); -} - -static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQAdd(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQSub(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQScalarMul(&result, &quat, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQScalarDiv(&result, &quat, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQNeg(&result, &quat); - return result; -} - -static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - return vmathSoaQDot(&quat0, &quat1); -} - -static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) -{ - return vmathSoaQNorm(&quat); -} - -static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) -{ - return vmathSoaQLength(&quat); -} - -static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQNormalize(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQMul(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaQRotate(&result, &quat, &vec); - return result; -} - -static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQConj(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) -{ - VmathSoaQuat result; - vmathSoaQSelect(&result, &quat0, &quat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) -{ - vmathSoaQPrint(&quat); -} - -static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) -{ - vmathSoaQPrints(&quat, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h deleted file mode 100644 index 58427a224..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos.h +++ /dev/null @@ -1,1125 +0,0 @@ -/* - 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_VEC_AOS_C_H -#define _VECTORMATH_VEC_AOS_C_H -#include -#include -#include -#include "vec_types.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for permutes words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } -#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } -#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } -#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } -#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } -#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } -#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } -#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); - return vec_madd( vec_sld( vec0, vec0, 8 ), vec_sld( vec1, vec1, 8 ), result ); -} - -static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); - return vec_add( vec_sld( result, result, 8 ), result ); -} - -static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = vec_perm( vec0, vec0, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( vec1, vec1, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( vec0, vec0, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( vec1, vec1, _VECTORMATH_PERM_YZXW ); - result = vec_madd( tmp0, tmp1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_nmsub( tmp2, tmp3, result ); - return result; -} - -static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) -{ - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = (vec_uint4){0x00007c00u,0x00007c00u,0x00007c00u,0x00007c00u}; - const vec_uint4 mergeMant = (vec_uint4){0x000003ffu,0x000003ffu,0x000003ffu,0x000003ffu}; - const vec_uint4 mergeSign = (vec_uint4){0x00008000u,0x00008000u,0x00008000u,0x00008000u}; - - sign = vec_sr((vec_uint4)v, (vec_uint4){16,16,16,16}); - mant = vec_sr((vec_uint4)v, (vec_uint4){13,13,13,13}); - bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4){23,23,23,23}), (vec_int4){0xff,0xff,0xff,0xff}); - - notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4){112,112,112,112}); - isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4){142,142,142,142}); - - bexp = vec_add(bexp, (vec_int4){-112,-112,-112,-112}); - bexp = vec_sl(bexp, (vec_uint4){10,10,10,10}); - - hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = vec_sel((vec_uint4){0,0,0,0}, hfloat, notZero); - hfloat = vec_sel(hfloat, hfloatInf, isInf); - hfloat = vec_sel(hfloat, sign, mergeSign); - - return hfloat; -} - -static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) -{ - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); -} - -#ifndef __GNUC__ -#define __builtin_constant_p(x) 0 -#endif - -static inline vec_float4 _vmathVfInsert(vec_float4 dst, vec_float4 src, int slot) -{ -#ifdef __GNUC__ - if (__builtin_constant_p(slot)) { - dst = vec_sld(dst, dst, slot<<2); - dst = vec_sld(dst, src, 4); - if (slot != 3) dst = vec_sld(dst, dst, (3-slot)<<2); - return dst; - } else -#endif - { - vec_uchar16 shiftpattern = vec_lvsr( 0, (float *)(size_t)(slot<<2) ); - vec_uint4 selectmask = (vec_uint4)vec_perm( (vec_uint4){0,0,0,0}, _VECTORMATH_MASK_0xF000, shiftpattern ); - return vec_sel( dst, src, selectmask ); - } -} - -#define _vmathVfGetElement(vec, slot) ((float *)&(vec))[slot] -#ifdef _VECTORMATH_SET_CONSTS_IN_MEM -#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar -#else -#define _vmathVfSetElement(vec, scalar, slot) \ -{ \ - if (__builtin_constant_p(scalar)) { \ - (vec) = _vmathVfInsert(vec, (vec_float4){scalar, scalar, scalar, scalar}, slot); \ - } else { \ - ((float *)&(vec))[slot] = scalar; \ - } \ -} -#endif - -static inline vec_float4 _vmathVfSplatScalar(float scalar) -{ - vec_float4 result; - if (__builtin_constant_p(scalar)) { - result = (vec_float4){scalar, scalar, scalar, scalar}; - } else { - result = vec_ld(0, &scalar); - result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); - } - return result; -} - -static inline vec_uint4 _vmathVuiSplatScalar(unsigned int scalar) -{ - vec_uint4 result; - if (__builtin_constant_p(scalar)) { - result = (vec_uint4){scalar, scalar, scalar, scalar}; - } else { - result = vec_ld(0, &scalar); - result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); - } - return result; -} - -#endif - -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { - result->vec128 = (vec_float4){_x, _y, _z, 0.0f}; - } else { - float *pf = (float *)&result->vec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - } -} - -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = pnt->vec128; -} - -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) -{ - result->vec128 = _vmathVfSplatScalar(scalar); -} - -static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathV3MakeXAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_1000; -} - -static inline void vmathV3MakeYAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0100; -} - -static inline void vmathV3MakeZAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0010; -} - -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathV3Sub( &tmpV3_0, vec1, vec0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathV3Add( result, vec0, &tmpV3_1 ); -} - -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = _vmathVfSplatScalar(t); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( sines, vec_splat( sines, 0 ) ); - scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); - scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); - result->vec128 = vec_madd( unitVec0->vec128, scale0, vec_madd( unitVec1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ) -{ - return vec->vec128; -} - -static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = _VECTORMATH_MASK_0x000F; - dstVec = vec_sel(vec->vec128, dstVec, mask); - *quad = dstVec; -} - -static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = vec_sld( xyzx, yzxy, 12 ); - xyz2 = vec_sld( yzxy, zxyz, 8 ); - xyz3 = vec_sld( zxyz, zxyz, 4 ); - vec0->vec128 = xyzx; - vec1->vec128 = xyz1; - vec2->vec128 = xyz2; - vec3->vec128 = xyz3; -} - -static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = vec_perm( vec0->vec128, vec1->vec128, _VECTORMATH_PERM_XYZA ); - yzxy = vec_perm( vec1->vec128, vec2->vec128, _VECTORMATH_PERM_YZAB ); - zxyz = vec_perm( vec2->vec128, vec3->vec128, _VECTORMATH_PERM_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathV3StoreXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - vmathV3StoreXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathV3SetX( VmathVector3 *result, float _x ) -{ - _vmathVfSetElement(result->vec128, _x, 0); -} - -static inline float vmathV3GetX( const VmathVector3 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 0); -} - -static inline void vmathV3SetY( VmathVector3 *result, float _y ) -{ - _vmathVfSetElement(result->vec128, _y, 1); -} - -static inline float vmathV3GetY( const VmathVector3 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 1); -} - -static inline void vmathV3SetZ( VmathVector3 *result, float _z ) -{ - _vmathVfSetElement(result->vec128, _z, 2); -} - -static inline float vmathV3GetZ( const VmathVector3 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 2); -} - -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) -{ - _vmathVfSetElement(result->vec128, value, idx); -} - -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) -{ - return _vmathVfGetElement(vec->vec128, idx); -} - -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = vec_add( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = vec_sub( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) -{ - result->vec128 = vec_add( vec->vec128, pnt1->vec128 ); -} - -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->vec128 = vec_madd( vec->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->vec128 = divf4( vec->vec128, _vmathVfSplatScalar(scalar) ); -} - -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = negatef4( vec->vec128 ); -} - -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = vec_madd( vec0->vec128, vec1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = divf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = recipf4( vec->vec128 ); -} - -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = sqrtf4( vec->vec128 ); -} - -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = rsqrtf4( vec->vec128 ); -} - -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = fabsf4( vec->vec128 ); -} - -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV3MaxElem( const VmathVector3 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = fmaxf4( vec_splat( vec->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV3MinElem( const VmathVector3 *vec ) -{ - vec_float4 result; - result = fminf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = fminf4( vec_splat( vec->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV3Sum( const VmathVector3 *vec ) -{ - vec_float4 result; - result = vec_add( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = vec_add( vec_splat( vec->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - vec_float4 result = _vmathVfDot3( vec0->vec128, vec1->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV3LengthSqr( const VmathVector3 *vec ) -{ - vec_float4 result = _vmathVfDot3( vec->vec128, vec->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV3Length( const VmathVector3 *vec ) -{ - return sqrtf( vmathV3LengthSqr( vec ) ); -} - -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) -{ - vec_float4 dot = _vmathVfDot3( vec->vec128, vec->vec128 ); - dot = vec_splat( dot, 0 ); - result->vec128 = vec_madd( vec->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = _vmathVfCross( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) -{ - unsigned int tmp; - tmp = (unsigned int)-(select1 > 0); - result->vec128 = vec_sel( vec0->vec128, vec1->vec128, _vmathVuiSplatScalar(tmp) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print( const VmathVector3 *vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & - __builtin_constant_p(_z) & __builtin_constant_p(_w)) { - result->vec128 = (vec_float4){_x, _y, _z, _w}; - } else { - float *pf = (float *)&result->vec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - pf[3] = _w; - } -} - -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) -{ - result->vec128 = xyz->vec128; - _vmathVfSetElement(result->vec128, _w, 3); -} - -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec->vec128; - result->vec128 = _vmathVfInsert(result->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), 3); -} - -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = pnt->vec128; - result->vec128 = _vmathVfInsert(result->vec128, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), 3); -} - -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) -{ - result->vec128 = _vmathVfSplatScalar(scalar); -} - -static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathV4MakeXAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_1000; -} - -static inline void vmathV4MakeYAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0100; -} - -static inline void vmathV4MakeZAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0010; -} - -static inline void vmathV4MakeWAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0001; -} - -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - VmathVector4 tmpV4_0, tmpV4_1; - vmathV4Sub( &tmpV4_0, vec1, vec0 ); - vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); - vmathV4Add( result, vec0, &tmpV4_1 ); -} - -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot4( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = _vmathVfSplatScalar(t); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( sines, vec_splat( sines, 0 ) ); - scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); - scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); - result->vec128 = vec_madd( unitVec0->vec128, scale0, vec_madd( unitVec1->vec128, scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ) -{ - return vec->vec128; -} - -static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0->vec128, vec1->vec128); - twoQuads[1] = _vmath2VfToHalfFloats(vec2->vec128, vec3->vec128); -} - -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec_sel( vec->vec128, result->vec128, _VECTORMATH_MASK_0x000F ); -} - -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV4SetX( VmathVector4 *result, float _x ) -{ - _vmathVfSetElement(result->vec128, _x, 0); -} - -static inline float vmathV4GetX( const VmathVector4 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 0); -} - -static inline void vmathV4SetY( VmathVector4 *result, float _y ) -{ - _vmathVfSetElement(result->vec128, _y, 1); -} - -static inline float vmathV4GetY( const VmathVector4 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 1); -} - -static inline void vmathV4SetZ( VmathVector4 *result, float _z ) -{ - _vmathVfSetElement(result->vec128, _z, 2); -} - -static inline float vmathV4GetZ( const VmathVector4 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 2); -} - -static inline void vmathV4SetW( VmathVector4 *result, float _w ) -{ - _vmathVfSetElement(result->vec128, _w, 3); -} - -static inline float vmathV4GetW( const VmathVector4 *vec ) -{ - return _vmathVfGetElement(vec->vec128, 3); -} - -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) -{ - _vmathVfSetElement(result->vec128, value, idx); -} - -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) -{ - return _vmathVfGetElement(vec->vec128, idx); -} - -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = vec_add( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = vec_sub( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->vec128 = vec_madd( vec->vec128, _vmathVfSplatScalar(scalar), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->vec128 = divf4( vec->vec128, _vmathVfSplatScalar(scalar) ); -} - -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = negatef4( vec->vec128 ); -} - -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = vec_madd( vec0->vec128, vec1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = divf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = recipf4( vec->vec128 ); -} - -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = sqrtf4( vec->vec128 ); -} - -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = rsqrtf4( vec->vec128 ); -} - -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = fabsf4( vec->vec128 ); -} - -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV4MaxElem( const VmathVector4 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = fmaxf4( vec_splat( vec->vec128, 2 ), result ); - result = fmaxf4( vec_splat( vec->vec128, 3 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV4MinElem( const VmathVector4 *vec ) -{ - vec_float4 result; - result = fminf4( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = fminf4( vec_splat( vec->vec128, 2 ), result ); - result = fminf4( vec_splat( vec->vec128, 3 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV4Sum( const VmathVector4 *vec ) -{ - vec_float4 result; - result = vec_add( vec_splat( vec->vec128, 1 ), vec->vec128 ); - result = vec_add( vec_splat( vec->vec128, 2 ), result ); - result = vec_add( vec_splat( vec->vec128, 3 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - vec_float4 result = _vmathVfDot4( vec0->vec128, vec1->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV4LengthSqr( const VmathVector4 *vec ) -{ - vec_float4 result = _vmathVfDot4( vec->vec128, vec->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathV4Length( const VmathVector4 *vec ) -{ - return sqrtf( vmathV4LengthSqr( vec ) ); -} - -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) -{ - vec_float4 dot = _vmathVfDot4( vec->vec128, vec->vec128 ); - result->vec128 = vec_madd( vec->vec128, rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) -{ - unsigned int tmp; - tmp = (unsigned int)-(select1 > 0); - result->vec128 = vec_sel( vec0->vec128, vec1->vec128, _vmathVuiSplatScalar(tmp) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print( const VmathVector4 *vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = pnt->vec128; -} - -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { - result->vec128 = (vec_float4){_x, _y, _z, 0.0f}; - } else { - float *pf = (float *)&result->vec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - } -} - -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) -{ - result->vec128 = _vmathVfSplatScalar(scalar); -} - -static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathP3AddV3( result, pnt0, &tmpV3_1 ); -} - -static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ) -{ - return pnt->vec128; -} - -static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = _VECTORMATH_MASK_0x000F; - dstVec = vec_sel(pnt->vec128, dstVec, mask); - *quad = dstVec; -} - -static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = vec_sld( xyzx, yzxy, 12 ); - xyz2 = vec_sld( yzxy, zxyz, 8 ); - xyz3 = vec_sld( zxyz, zxyz, 4 ); - pnt0->vec128 = xyzx; - pnt1->vec128 = xyz1; - pnt2->vec128 = xyz2; - pnt3->vec128 = xyz3; -} - -static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = vec_perm( pnt0->vec128, pnt1->vec128, _VECTORMATH_PERM_XYZA ); - yzxy = vec_perm( pnt1->vec128, pnt2->vec128, _VECTORMATH_PERM_YZAB ); - zxyz = vec_perm( pnt2->vec128, pnt3->vec128, _VECTORMATH_PERM_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathP3StoreXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - vmathP3StoreXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathP3SetX( VmathPoint3 *result, float _x ) -{ - _vmathVfSetElement(result->vec128, _x, 0); -} - -static inline float vmathP3GetX( const VmathPoint3 *pnt ) -{ - return _vmathVfGetElement(pnt->vec128, 0); -} - -static inline void vmathP3SetY( VmathPoint3 *result, float _y ) -{ - _vmathVfSetElement(result->vec128, _y, 1); -} - -static inline float vmathP3GetY( const VmathPoint3 *pnt ) -{ - return _vmathVfGetElement(pnt->vec128, 1); -} - -static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) -{ - _vmathVfSetElement(result->vec128, _z, 2); -} - -static inline float vmathP3GetZ( const VmathPoint3 *pnt ) -{ - return _vmathVfGetElement(pnt->vec128, 2); -} - -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) -{ - _vmathVfSetElement(result->vec128, value, idx); -} - -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) -{ - return _vmathVfGetElement(pnt->vec128, idx); -} - -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = vec_sub( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->vec128 = vec_add( pnt->vec128, vec1->vec128 ); -} - -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->vec128 = vec_sub( pnt->vec128, vec1->vec128 ); -} - -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = vec_madd( pnt0->vec128, pnt1->vec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = divf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = recipf4( pnt->vec128 ); -} - -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = sqrtf4( pnt->vec128 ); -} - -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = rsqrtf4( pnt->vec128 ); -} - -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = fabsf4( pnt->vec128 ); -} - -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = copysignf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = fmaxf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); - result = fmaxf4( vec_splat( pnt->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = fminf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline float vmathP3MinElem( const VmathPoint3 *pnt ) -{ - vec_float4 result; - result = fminf4( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); - result = fminf4( vec_splat( pnt->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathP3Sum( const VmathPoint3 *pnt ) -{ - vec_float4 result; - result = vec_add( vec_splat( pnt->vec128, 1 ), pnt->vec128 ); - result = vec_add( vec_splat( pnt->vec128, 2 ), result ); - return _vmathVfGetElement(result, 0); -} - -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromV3( &tmpP3_0, scaleVec ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) -{ - vec_float4 result = _vmathVfDot3( pnt->vec128, unitVec->vec128 ); - return _vmathVfGetElement(result, 0); -} - -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) -{ - unsigned int tmp; - tmp = (unsigned int)-(select1 > 0); - result->vec128 = vec_sel( pnt0->vec128, pnt1->vec128, _vmathVuiSplatScalar(tmp) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print( const VmathPoint3 *pnt ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt->vec128; - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt->vec128; - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h deleted file mode 100644 index 6dcc79c72..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_aos_v.h +++ /dev/null @@ -1,953 +0,0 @@ -/* - 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_VEC_AOS_V_C_H -#define _VECTORMATH_VEC_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for permutes words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } -#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } -#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } -#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } -#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } -#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } -#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } -#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathVector3 result; - vmathV3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector3 result; - vmathV3MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) -{ - VmathVector3 result; - vmathV3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ) -{ - VmathVector3 result; - vmathV3MakeFrom128(&result, vf4); - return result; -} - -static inline VmathVector3 vmathV3MakeXAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeXAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeYAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeYAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeZAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeZAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathVector3 result; - vmathV3Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ) -{ - return vmathV3Get128(&vec); -} - -static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ) -{ - vmathV3StoreXYZ(&vec, quad); -} - -static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) -{ - vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads); -} - -static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ) -{ - vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads); -} - -static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ) -{ - vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads); -} - -static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) -{ - vmathV3SetX(result, _x); -} - -static inline float vmathV3GetX_V( VmathVector3 vec ) -{ - return vmathV3GetX(&vec); -} - -static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) -{ - vmathV3SetY(result, _y); -} - -static inline float vmathV3GetY_V( VmathVector3 vec ) -{ - return vmathV3GetY(&vec); -} - -static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) -{ - vmathV3SetZ(result, _z); -} - -static inline float vmathV3GetZ_V( VmathVector3 vec ) -{ - return vmathV3GetZ(&vec); -} - -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) -{ - vmathV3SetElem(result, idx, value); -} - -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) -{ - return vmathV3GetElem(&vec, idx); -} - -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathV3AddP3(&result, &vec, &pnt1); - return result; -} - -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Neg(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MaxElem_V( VmathVector3 vec ) -{ - return vmathV3MaxElem(&vec); -} - -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MinElem_V( VmathVector3 vec ) -{ - return vmathV3MinElem(&vec); -} - -static inline float vmathV3Sum_V( VmathVector3 vec ) -{ - return vmathV3Sum(&vec); -} - -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - return vmathV3Dot(&vec0, &vec1); -} - -static inline float vmathV3LengthSqr_V( VmathVector3 vec ) -{ - return vmathV3LengthSqr(&vec); -} - -static inline float vmathV3Length_V( VmathVector3 vec ) -{ - return vmathV3Length(&vec); -} - -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Normalize(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Cross(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) -{ - VmathVector3 result; - vmathV3Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print_V( VmathVector3 vec ) -{ - vmathV3Print(&vec); -} - -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) -{ - vmathV3Prints(&vec, name); -} - -#endif - -static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) -{ - VmathVector4 result; - vmathV4MakeFromV3(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathV4MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) -{ - VmathVector4 result; - vmathV4MakeFromQ(&result, &quat); - return result; -} - -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) -{ - VmathVector4 result; - vmathV4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ) -{ - VmathVector4 result; - vmathV4MakeFrom128(&result, vf4); - return result; -} - -static inline VmathVector4 vmathV4MakeXAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeXAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeYAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeYAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeZAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeZAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeWAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeWAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) -{ - VmathVector4 result; - vmathV4Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ) -{ - return vmathV4Get128(&vec); -} - -static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ) -{ - vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads); -} - -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) -{ - vmathV4SetXYZ(result, &vec); -} - -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) -{ - VmathVector3 result; - vmathV4GetXYZ(&result, &vec); - return result; -} - -static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) -{ - vmathV4SetX(result, _x); -} - -static inline float vmathV4GetX_V( VmathVector4 vec ) -{ - return vmathV4GetX(&vec); -} - -static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) -{ - vmathV4SetY(result, _y); -} - -static inline float vmathV4GetY_V( VmathVector4 vec ) -{ - return vmathV4GetY(&vec); -} - -static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) -{ - vmathV4SetZ(result, _z); -} - -static inline float vmathV4GetZ_V( VmathVector4 vec ) -{ - return vmathV4GetZ(&vec); -} - -static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) -{ - vmathV4SetW(result, _w); -} - -static inline float vmathV4GetW_V( VmathVector4 vec ) -{ - return vmathV4GetW(&vec); -} - -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) -{ - vmathV4SetElem(result, idx, value); -} - -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) -{ - return vmathV4GetElem(&vec, idx); -} - -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Neg(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MaxElem_V( VmathVector4 vec ) -{ - return vmathV4MaxElem(&vec); -} - -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MinElem_V( VmathVector4 vec ) -{ - return vmathV4MinElem(&vec); -} - -static inline float vmathV4Sum_V( VmathVector4 vec ) -{ - return vmathV4Sum(&vec); -} - -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - return vmathV4Dot(&vec0, &vec1); -} - -static inline float vmathV4LengthSqr_V( VmathVector4 vec ) -{ - return vmathV4LengthSqr(&vec); -} - -static inline float vmathV4Length_V( VmathVector4 vec ) -{ - return vmathV4Length(&vec); -} - -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Normalize(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) -{ - VmathVector4 result; - vmathV4Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print_V( VmathVector4 vec ) -{ - vmathV4Print(&vec); -} - -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) -{ - vmathV4Prints(&vec, name); -} - -#endif - -static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathPoint3 result; - vmathP3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) -{ - VmathPoint3 result; - vmathP3MakeFromV3(&result, &vec); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) -{ - VmathPoint3 result; - vmathP3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ) -{ - VmathPoint3 result; - vmathP3MakeFrom128(&result, vf4); - return result; -} - -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3Lerp(&result, t, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ) -{ - return vmathP3Get128(&pnt); -} - -static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ) -{ - vmathP3StoreXYZ(&pnt, quad); -} - -static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) -{ - vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads); -} - -static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ) -{ - vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads); -} - -static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ) -{ - vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads); -} - -static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) -{ - vmathP3SetX(result, _x); -} - -static inline float vmathP3GetX_V( VmathPoint3 pnt ) -{ - return vmathP3GetX(&pnt); -} - -static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) -{ - vmathP3SetY(result, _y); -} - -static inline float vmathP3GetY_V( VmathPoint3 pnt ) -{ - return vmathP3GetY(&pnt); -} - -static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) -{ - vmathP3SetZ(result, _z); -} - -static inline float vmathP3GetZ_V( VmathPoint3 pnt ) -{ - return vmathP3GetZ(&pnt); -} - -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) -{ - vmathP3SetElem(result, idx, value); -} - -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) -{ - return vmathP3GetElem(&pnt, idx); -} - -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathVector3 result; - vmathP3Sub(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3AddV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3SubV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MulPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3DivPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RecipPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3SqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RsqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3AbsPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3CopySignPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MaxPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) -{ - return vmathP3MaxElem(&pnt); -} - -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MinPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MinElem_V( VmathPoint3 pnt ) -{ - return vmathP3MinElem(&pnt); -} - -static inline float vmathP3Sum_V( VmathPoint3 pnt ) -{ - return vmathP3Sum(&pnt); -} - -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) -{ - VmathPoint3 result; - vmathP3Scale(&result, &pnt, scaleVal); - return result; -} - -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) -{ - VmathPoint3 result; - vmathP3NonUniformScale(&result, &pnt, &scaleVec); - return result; -} - -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) -{ - return vmathP3Projection(&pnt, &unitVec); -} - -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistSqrFromOrigin(&pnt); -} - -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistFromOrigin(&pnt); -} - -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3DistSqr(&pnt0, &pnt1); -} - -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3Dist(&pnt0, &pnt1); -} - -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) -{ - VmathPoint3 result; - vmathP3Select(&result, &pnt0, &pnt1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print_V( VmathPoint3 pnt ) -{ - vmathP3Print(&pnt); -} - -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) -{ - vmathP3Prints(&pnt, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h deleted file mode 100644 index 1cda25747..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa.h +++ /dev/null @@ -1,1223 +0,0 @@ -/* - 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_VEC_SOA_C_H -#define _VECTORMATH_VEC_SOA_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for permutes, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ) -{ - vec_float4 vec128 = vec->vec128; - result->x = vec_splat( vec128, 0 ); - result->y = vec_splat( vec128, 1 ); - result->z = vec_splat( vec128, 2 ); -} - -static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( vec0->vec128, vec2->vec128 ); - tmp1 = vec_mergeh( vec1->vec128, vec3->vec128 ); - tmp2 = vec_mergel( vec0->vec128, vec2->vec128 ); - tmp3 = vec_mergel( vec1->vec128, vec3->vec128 ); - result->x = vec_mergeh( tmp0, tmp1 ); - result->y = vec_mergel( tmp0, tmp1 ); - result->z = vec_mergeh( tmp2, tmp3 ); -} - -static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vmathSoaV3Sub( &tmpV3_0, vec1, vec0 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathSoaV3Add( result, vec0, &tmpV3_1 ); -} - -static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaV3Dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - vmathSoaV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); - vmathSoaV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); - vmathSoaV3Add( result, &tmpV3_0, &tmpV3_1 ); -} - -static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) -{ - vec_float4 tmp0, tmp1; - tmp0 = vec_mergeh( vec->x, vec->z ); - tmp1 = vec_mergel( vec->x, vec->z ); - vmathV3MakeFrom128( result0, vec_mergeh( tmp0, vec->y ) ); - vmathV3MakeFrom128( result1, vec_perm( tmp0, vec->y, _VECTORMATH_PERM_ZBWX ) ); - vmathV3MakeFrom128( result2, vec_perm( tmp1, vec->y, _VECTORMATH_PERM_XCYX ) ); - vmathV3MakeFrom128( result3, vec_perm( tmp1, vec->y, _VECTORMATH_PERM_ZDWX ) ); -} - -static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = vec_sld( yzxy, xyzx, 8 ); - zxzx = vec_sld( xyzx, zxyz, 8 ); - yzyz = vec_sld( zxyz, yzxy, 8 ); - vmathSoaV3SetX( vec, vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); - vmathSoaV3SetY( vec, vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); - vmathSoaV3SetZ( vec, vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); -} - -static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = vec_perm( vec->x, vec->y, _VECTORMATH_PERM_ZCXA ); - zxzx = vec_perm( vec->z, vec->x, _VECTORMATH_PERM_XBZD ); - yzyz = vec_perm( vec->y, vec->z, _VECTORMATH_PERM_WDYB ); - xyzx = vec_sld( xyxy, zxzx, 8 ); - yzxy = vec_sld( yzyz, xyxy, 8 ); - zxyz = vec_sld( zxzx, yzyz, 8 ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathSoaV3StoreXYZArray( vec0, xyz0 ); - vmathSoaV3StoreXYZArray( vec1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ) -{ - return vec->x; -} - -static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ) -{ - return vec->y; -} - -static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ) -{ - return vec->z; -} - -static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = vec_add( vec0->x, vec1->x ); - result->y = vec_add( vec0->y, vec1->y ); - result->z = vec_add( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = vec_sub( vec0->x, vec1->x ); - result->y = vec_sub( vec0->y, vec1->y ); - result->z = vec_sub( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt1 ) -{ - result->x = vec_add( vec->x, pnt1->x ); - result->y = vec_add( vec->y, pnt1->y ); - result->z = vec_add( vec->z, pnt1->z ); -} - -static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) -{ - result->x = vec_madd( vec->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) -{ - result->x = divf4( vec->x, scalar ); - result->y = divf4( vec->y, scalar ); - result->z = divf4( vec->z, scalar ); -} - -static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = negatef4( vec->x ); - result->y = negatef4( vec->y ); - result->z = negatef4( vec->z ); -} - -static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = divf4( vec0->x, vec1->x ); - result->y = divf4( vec0->y, vec1->y ); - result->z = divf4( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->x ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->y ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->z ); -} - -static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = sqrtf4( vec->x ); - result->y = sqrtf4( vec->y ); - result->z = sqrtf4( vec->z ); -} - -static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->x ) ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->y ) ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->z ) ); -} - -static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = fabsf4( vec->x ); - result->y = fabsf4( vec->y ); - result->z = fabsf4( vec->z ); -} - -static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = copysignf4( vec0->x, vec1->x ); - result->y = copysignf4( vec0->y, vec1->y ); - result->z = copysignf4( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = fmaxf4( vec0->x, vec1->x ); - result->y = fmaxf4( vec0->y, vec1->y ); - result->z = fmaxf4( vec0->z, vec1->z ); -} - -static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec->x, vec->y ); - result = fmaxf4( vec->z, result ); - return result; -} - -static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = fminf4( vec0->x, vec1->x ); - result->y = fminf4( vec0->y, vec1->y ); - result->z = fminf4( vec0->z, vec1->z ); -} - -static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = fminf4( vec->x, vec->y ); - result = fminf4( vec->z, result ); - return result; -} - -static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = vec_add( vec->x, vec->y ); - result = vec_add( result, vec->z ); - return result; -} - -static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = vec_madd( vec->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ) -{ - return sqrtf4( vmathSoaV3LengthSqr( vec ) ); -} - -static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaV3LengthSqr( vec ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - result->x = vec_madd( vec->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = vec_sub( vec_madd( vec0->y, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->z, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_sub( vec_madd( vec0->z, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->x, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_sub( vec_madd( vec0->x, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0->y, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ) -{ - result->x = vec_sel( vec0->x, vec1->x, select1 ); - result->y = vec_sel( vec0->y, vec1->y, select1 ); - result->z = vec_sel( vec0->z, vec1->z, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ) -{ - VmathVector3 vec0, vec1, vec2, vec3; - vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV3Print( &vec0 ); - printf("slot 1:\n"); - vmathV3Print( &vec1 ); - printf("slot 2:\n"); - vmathV3Print( &vec2 ); - printf("slot 3:\n"); - vmathV3Print( &vec3 ); -} - -static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ) -{ - VmathVector3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV3Print( &vec0 ); - printf("slot 1:\n"); - vmathV3Print( &vec1 ); - printf("slot 2:\n"); - vmathV3Print( &vec2 ); - printf("slot 3:\n"); - vmathV3Print( &vec3 ); -} - -#endif - -static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 _w ) -{ - vmathSoaV4SetXYZ( result, xyz ); - vmathSoaV4SetW( result, _w ); -} - -static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); -} - -static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; - result->w = ((vec_float4){1.0f,1.0f,1.0f,1.0f}); -} - -static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ) -{ - vec_float4 vec128 = vec->vec128; - result->x = vec_splat( vec128, 0 ); - result->y = vec_splat( vec128, 1 ); - result->z = vec_splat( vec128, 2 ); - result->w = vec_splat( vec128, 3 ); -} - -static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( vec0->vec128, vec2->vec128 ); - tmp1 = vec_mergeh( vec1->vec128, vec3->vec128 ); - tmp2 = vec_mergel( vec0->vec128, vec2->vec128 ); - tmp3 = vec_mergel( vec1->vec128, vec3->vec128 ); - result->x = vec_mergeh( tmp0, tmp1 ); - result->y = vec_mergel( tmp0, tmp1 ); - result->z = vec_mergeh( tmp2, tmp3 ); - result->w = vec_mergel( tmp2, tmp3 ); -} - -static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - VmathSoaVector4 tmpV4_0, tmpV4_1; - vmathSoaV4Sub( &tmpV4_0, vec1, vec0 ); - vmathSoaV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); - vmathSoaV4Add( result, vec0, &tmpV4_1 ); -} - -static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ) -{ - VmathSoaVector4 tmpV4_0, tmpV4_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaV4Dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - vmathSoaV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); - vmathSoaV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); - vmathSoaV4Add( result, &tmpV4_0, &tmpV4_1 ); -} - -static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( vec->x, vec->z ); - tmp1 = vec_mergeh( vec->y, vec->w ); - tmp2 = vec_mergel( vec->x, vec->z ); - tmp3 = vec_mergel( vec->y, vec->w ); - vmathV4MakeFrom128( result0, vec_mergeh( tmp0, tmp1 ) ); - vmathV4MakeFrom128( result1, vec_mergel( tmp0, tmp1 ) ); - vmathV4MakeFrom128( result2, vec_mergeh( tmp2, tmp3 ) ); - vmathV4MakeFrom128( result3, vec_mergel( tmp2, tmp3 ) ); -} - -static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ) -{ - VmathVector4 v0, v1, v2, v3; - vmathSoaV4Get4Aos( vec, &v0, &v1, &v2, &v3 ); - twoQuads[0] = _vmath2VfToHalfFloats(v0.vec128, v1.vec128); - twoQuads[1] = _vmath2VfToHalfFloats(v2.vec128, v3.vec128); -} - -static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ) -{ - vmathSoaV3MakeFromElems( result, vec->x, vec->y, vec->z ); -} - -static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ) -{ - return vec->x; -} - -static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ) -{ - return vec->y; -} - -static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ) -{ - return vec->z; -} - -static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 _w ) -{ - result->w = _w; -} - -static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ) -{ - return vec->w; -} - -static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = vec_add( vec0->x, vec1->x ); - result->y = vec_add( vec0->y, vec1->y ); - result->z = vec_add( vec0->z, vec1->z ); - result->w = vec_add( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = vec_sub( vec0->x, vec1->x ); - result->y = vec_sub( vec0->y, vec1->y ); - result->z = vec_sub( vec0->z, vec1->z ); - result->w = vec_sub( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) -{ - result->x = vec_madd( vec->x, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec->y, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec->z, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->w = vec_madd( vec->w, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) -{ - result->x = divf4( vec->x, scalar ); - result->y = divf4( vec->y, scalar ); - result->z = divf4( vec->z, scalar ); - result->w = divf4( vec->w, scalar ); -} - -static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = negatef4( vec->x ); - result->y = negatef4( vec->y ); - result->z = negatef4( vec->z ); - result->w = negatef4( vec->w ); -} - -static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->w = vec_madd( vec0->w, vec1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = divf4( vec0->x, vec1->x ); - result->y = divf4( vec0->y, vec1->y ); - result->z = divf4( vec0->z, vec1->z ); - result->w = divf4( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->x ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->y ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->z ); - result->w = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec->w ); -} - -static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = sqrtf4( vec->x ); - result->y = sqrtf4( vec->y ); - result->z = sqrtf4( vec->z ); - result->w = sqrtf4( vec->w ); -} - -static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->x ) ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->y ) ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->z ) ); - result->w = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec->w ) ); -} - -static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = fabsf4( vec->x ); - result->y = fabsf4( vec->y ); - result->z = fabsf4( vec->z ); - result->w = fabsf4( vec->w ); -} - -static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = copysignf4( vec0->x, vec1->x ); - result->y = copysignf4( vec0->y, vec1->y ); - result->z = copysignf4( vec0->z, vec1->z ); - result->w = copysignf4( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = fmaxf4( vec0->x, vec1->x ); - result->y = fmaxf4( vec0->y, vec1->y ); - result->z = fmaxf4( vec0->z, vec1->z ); - result->w = fmaxf4( vec0->w, vec1->w ); -} - -static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec->x, vec->y ); - result = fmaxf4( vec->z, result ); - result = fmaxf4( vec->w, result ); - return result; -} - -static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = fminf4( vec0->x, vec1->x ); - result->y = fminf4( vec0->y, vec1->y ); - result->z = fminf4( vec0->z, vec1->z ); - result->w = fminf4( vec0->w, vec1->w ); -} - -static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = fminf4( vec->x, vec->y ); - result = fminf4( vec->z, result ); - result = fminf4( vec->w, result ); - return result; -} - -static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = vec_add( vec->x, vec->y ); - result = vec_add( result, vec->z ); - result = vec_add( result, vec->w ); - return result; -} - -static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0->x, vec1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec0->y, vec1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0->z, vec1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0->w, vec1->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = vec_madd( vec->x, vec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec->y, vec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec->z, vec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec->w, vec->w, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ) -{ - return sqrtf4( vmathSoaV4LengthSqr( vec ) ); -} - -static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaV4LengthSqr( vec ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - result->x = vec_madd( vec->x, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( vec->y, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( vec->z, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->w = vec_madd( vec->w, lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ) -{ - result->x = vec_sel( vec0->x, vec1->x, select1 ); - result->y = vec_sel( vec0->y, vec1->y, select1 ); - result->z = vec_sel( vec0->z, vec1->z, select1 ); - result->w = vec_sel( vec0->w, vec1->w, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ) -{ - VmathVector4 vec0, vec1, vec2, vec3; - vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV4Print( &vec0 ); - printf("slot 1:\n"); - vmathV4Print( &vec1 ); - printf("slot 2:\n"); - vmathV4Print( &vec2 ); - printf("slot 3:\n"); - vmathV4Print( &vec3 ); -} - -static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ) -{ - VmathVector4 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV4Print( &vec0 ); - printf("slot 1:\n"); - vmathV4Print( &vec1 ); - printf("slot 2:\n"); - vmathV4Print( &vec2 ); - printf("slot 3:\n"); - vmathV4Print( &vec3 ); -} - -#endif - -static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ) -{ - vec_float4 vec128 = pnt->vec128; - result->x = vec_splat( vec128, 0 ); - result->y = vec_splat( vec128, 1 ); - result->z = vec_splat( vec128, 2 ); -} - -static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( pnt0->vec128, pnt2->vec128 ); - tmp1 = vec_mergeh( pnt1->vec128, pnt3->vec128 ); - tmp2 = vec_mergel( pnt0->vec128, pnt2->vec128 ); - tmp3 = vec_mergel( pnt1->vec128, pnt3->vec128 ); - result->x = vec_mergeh( tmp0, tmp1 ); - result->y = vec_mergel( tmp0, tmp1 ); - result->z = vec_mergeh( tmp2, tmp3 ); -} - -static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathSoaP3AddV3( result, pnt0, &tmpV3_1 ); -} - -static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) -{ - vec_float4 tmp0, tmp1; - tmp0 = vec_mergeh( pnt->x, pnt->z ); - tmp1 = vec_mergel( pnt->x, pnt->z ); - vmathP3MakeFrom128( result0, vec_mergeh( tmp0, pnt->y ) ); - vmathP3MakeFrom128( result1, vec_perm( tmp0, pnt->y, _VECTORMATH_PERM_ZBWX ) ); - vmathP3MakeFrom128( result2, vec_perm( tmp1, pnt->y, _VECTORMATH_PERM_XCYX ) ); - vmathP3MakeFrom128( result3, vec_perm( tmp1, pnt->y, _VECTORMATH_PERM_ZDWX ) ); -} - -static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = vec_sld( yzxy, xyzx, 8 ); - zxzx = vec_sld( xyzx, zxyz, 8 ); - yzyz = vec_sld( zxyz, yzxy, 8 ); - vmathSoaP3SetX( vec, vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); - vmathSoaP3SetY( vec, vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); - vmathSoaP3SetZ( vec, vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); -} - -static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *vec, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = vec_perm( vec->x, vec->y, _VECTORMATH_PERM_ZCXA ); - zxzx = vec_perm( vec->z, vec->x, _VECTORMATH_PERM_XBZD ); - yzyz = vec_perm( vec->y, vec->z, _VECTORMATH_PERM_WDYB ); - xyzx = vec_sld( xyxy, zxzx, 8 ); - yzxy = vec_sld( yzyz, xyxy, 8 ); - zxyz = vec_sld( zxzx, yzyz, 8 ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathSoaP3StoreXYZArray( pnt0, xyz0 ); - vmathSoaP3StoreXYZArray( pnt1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ) -{ - return pnt->x; -} - -static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ) -{ - return pnt->y; -} - -static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ) -{ - return pnt->z; -} - -static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ) -{ - return *(&pnt->x + idx); -} - -static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = vec_sub( pnt0->x, pnt1->x ); - result->y = vec_sub( pnt0->y, pnt1->y ); - result->z = vec_sub( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) -{ - result->x = vec_add( pnt->x, vec1->x ); - result->y = vec_add( pnt->y, vec1->y ); - result->z = vec_add( pnt->z, vec1->z ); -} - -static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) -{ - result->x = vec_sub( pnt->x, vec1->x ); - result->y = vec_sub( pnt->y, vec1->y ); - result->z = vec_sub( pnt->z, vec1->z ); -} - -static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = vec_madd( pnt0->x, pnt1->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->y = vec_madd( pnt0->y, pnt1->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result->z = vec_madd( pnt0->z, pnt1->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = divf4( pnt0->x, pnt1->x ); - result->y = divf4( pnt0->y, pnt1->y ); - result->z = divf4( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->x ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->y ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt->z ); -} - -static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = sqrtf4( pnt->x ); - result->y = sqrtf4( pnt->y ); - result->z = sqrtf4( pnt->z ); -} - -static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->x ) ); - result->y = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->y ) ); - result->z = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt->z ) ); -} - -static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = fabsf4( pnt->x ); - result->y = fabsf4( pnt->y ); - result->z = fabsf4( pnt->z ); -} - -static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = copysignf4( pnt0->x, pnt1->x ); - result->y = copysignf4( pnt0->y, pnt1->y ); - result->z = copysignf4( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = fmaxf4( pnt0->x, pnt1->x ); - result->y = fmaxf4( pnt0->y, pnt1->y ); - result->z = fmaxf4( pnt0->z, pnt1->z ); -} - -static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = fmaxf4( pnt->x, pnt->y ); - result = fmaxf4( pnt->z, result ); - return result; -} - -static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = fminf4( pnt0->x, pnt1->x ); - result->y = fminf4( pnt0->y, pnt1->y ); - result->z = fminf4( pnt0->z, pnt1->z ); -} - -static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = fminf4( pnt->x, pnt->y ); - result = fminf4( pnt->z, result ); - return result; -} - -static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = vec_add( pnt->x, pnt->y ); - result = vec_add( result, pnt->z ); - return result; -} - -static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ) -{ - VmathSoaPoint3 tmpP3_0; - vmathSoaP3MakeFromScalar( &tmpP3_0, scaleVal ); - vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ) -{ - VmathSoaPoint3 tmpP3_0; - vmathSoaP3MakeFromV3( &tmpP3_0, scaleVec ); - vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ) -{ - vec_float4 result; - result = vec_madd( pnt->x, unitVec->x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( pnt->y, unitVec->y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( pnt->z, unitVec->z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); - return vmathSoaV3LengthSqr( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); - return vmathSoaV3Length( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathSoaV3LengthSqr( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathSoaV3Length( &tmpV3_0 ); -} - -static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ) -{ - result->x = vec_sel( pnt0->x, pnt1->x, select1 ); - result->y = vec_sel( pnt0->y, pnt1->y, select1 ); - result->z = vec_sel( pnt0->z, pnt1->z, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ) -{ - VmathPoint3 vec0, vec1, vec2, vec3; - vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathP3Print( &vec0 ); - printf("slot 1:\n"); - vmathP3Print( &vec1 ); - printf("slot 2:\n"); - vmathP3Print( &vec2 ); - printf("slot 3:\n"); - vmathP3Print( &vec3 ); -} - -static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ) -{ - VmathPoint3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathP3Print( &vec0 ); - printf("slot 1:\n"); - vmathP3Print( &vec1 ); - printf("slot 2:\n"); - vmathP3Print( &vec2 ); - printf("slot 3:\n"); - vmathP3Print( &vec3 ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h deleted file mode 100644 index 75d7bb6bc..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_soa_v.h +++ /dev/null @@ -1,958 +0,0 @@ -/* - 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_VEC_SOA_V_C_H -#define _VECTORMATH_VEC_SOA_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for permutes, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromAos(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeXAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeYAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeZAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) -{ - vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3); -} - -static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) -{ - vmathSoaV3LoadXYZArray(vec, threeQuads); -} - -static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ) -{ - vmathSoaV3StoreXYZArray(&vec, threeQuads); -} - -static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ) -{ - vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads); -} - -static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x ) -{ - vmathSoaV3SetX(result, _x); -} - -static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetX(&vec); -} - -static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y ) -{ - vmathSoaV3SetY(result, _y); -} - -static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetY(&vec); -} - -static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z ) -{ - vmathSoaV3SetZ(result, _z); -} - -static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetZ(&vec); -} - -static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ) -{ - vmathSoaV3SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ) -{ - return vmathSoaV3GetElem(&vec, idx); -} - -static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaV3AddP3(&result, &vec, &pnt1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3Neg(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3RecipPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3AbsPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3MaxElem(&vec); -} - -static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3MinElem(&vec); -} - -static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3Sum(&vec); -} - -static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - return vmathSoaV3Dot(&vec0, &vec1); -} - -static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3LengthSqr(&vec); -} - -static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3Length(&vec); -} - -static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3Normalize(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Cross(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ) -{ - vmathSoaV3Print(&vec); -} - -static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ) -{ - vmathSoaV3Prints(&vec, name); -} - -#endif - -static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromV3(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromQ(&result, &quat); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromAos(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeXAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeYAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeZAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeWAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) -{ - vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3); -} - -static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ) -{ - vmathSoaV4StoreHalfFloats(&vec, twoQuads); -} - -static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ) -{ - vmathSoaV4SetXYZ(result, &vec); -} - -static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ) -{ - VmathSoaVector3 result; - vmathSoaV4GetXYZ(&result, &vec); - return result; -} - -static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x ) -{ - vmathSoaV4SetX(result, _x); -} - -static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetX(&vec); -} - -static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y ) -{ - vmathSoaV4SetY(result, _y); -} - -static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetY(&vec); -} - -static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z ) -{ - vmathSoaV4SetZ(result, _z); -} - -static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetZ(&vec); -} - -static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w ) -{ - vmathSoaV4SetW(result, _w); -} - -static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetW(&vec); -} - -static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ) -{ - vmathSoaV4SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ) -{ - return vmathSoaV4GetElem(&vec, idx); -} - -static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4Neg(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4RecipPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4AbsPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4MaxElem(&vec); -} - -static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4MinElem(&vec); -} - -static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4Sum(&vec); -} - -static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - return vmathSoaV4Dot(&vec0, &vec1); -} - -static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4LengthSqr(&vec); -} - -static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4Length(&vec); -} - -static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4Normalize(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ) -{ - vmathSoaV4Print(&vec); -} - -static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ) -{ - vmathSoaV4Prints(&vec, name); -} - -#endif - -static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromV3(&result, &vec); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromAos(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3Lerp(&result, t, &pnt0, &pnt1); - return result; -} - -static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) -{ - vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3); -} - -static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) -{ - vmathSoaP3LoadXYZArray(vec, threeQuads); -} - -static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads ) -{ - vmathSoaP3StoreXYZArray(&vec, threeQuads); -} - -static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ) -{ - vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads); -} - -static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x ) -{ - vmathSoaP3SetX(result, _x); -} - -static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetX(&pnt); -} - -static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y ) -{ - vmathSoaP3SetY(result, _y); -} - -static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetY(&pnt); -} - -static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z ) -{ - vmathSoaP3SetZ(result, _z); -} - -static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetZ(&pnt); -} - -static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ) -{ - vmathSoaP3SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ) -{ - return vmathSoaP3GetElem(&pnt, idx); -} - -static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaVector3 result; - vmathSoaP3Sub(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3AddV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3SubV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MulPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3DivPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3RecipPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3SqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3RsqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3AbsPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3MaxElem(&pnt); -} - -static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MinPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3MinElem(&pnt); -} - -static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3Sum(&pnt); -} - -static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ) -{ - VmathSoaPoint3 result; - vmathSoaP3Scale(&result, &pnt, scaleVal); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ) -{ - VmathSoaPoint3 result; - vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec); - return result; -} - -static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ) -{ - return vmathSoaP3Projection(&pnt, &unitVec); -} - -static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3DistSqrFromOrigin(&pnt); -} - -static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3DistFromOrigin(&pnt); -} - -static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - return vmathSoaP3DistSqr(&pnt0, &pnt1); -} - -static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - return vmathSoaP3Dist(&pnt0, &pnt1); -} - -static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3Select(&result, &pnt0, &pnt1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ) -{ - vmathSoaP3Print(&pnt); -} - -static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ) -{ - vmathSoaP3Prints(&pnt, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_types.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_types.h deleted file mode 100644 index 022ce4d90..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vec_types.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - 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. -*/ - -/* Single token vector data types for the PowerPC SIMD/Vector Multi-media - eXtension */ - -#ifndef _VEC_TYPES_H_ -#define _VEC_TYPES_H_ 1 - -#define qword vector unsigned char - -#define vec_uchar16 vector unsigned char -#define vec_char16 vector signed char -#define vec_bchar16 vector bool char - -#define vec_ushort8 vector unsigned short -#define vec_short8 vector signed short -#define vec_bshort8 vector bool short - -#define vec_pixel8 vector pixel - -#define vec_uint4 vector unsigned int -#define vec_int4 vector signed int -#define vec_bint4 vector bool int - -#define vec_float4 vector float - -#define vec_ullong2 vector bool char -#define vec_llong2 vector bool short - -#define vec_double2 vector bool int - -#endif /* _VEC_TYPES_H_ */ diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h deleted file mode 100644 index 6a6ccd285..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos.h +++ /dev/null @@ -1,1960 +0,0 @@ -/* - 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_AOS_C_PPU_H -#define _VECTORMATH_AOS_C_PPU_H - -#include -#include -#include -#include "vec_types.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - vec_float4 vec128; -} VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - vec_float4 vec128; -} VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - vec_float4 vec128; -} VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - vec_float4 vec128; -} VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Copy a 3-D vector - */ -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); - -/* - * Set vector float data in a 3-D vector - */ -static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D vector - */ -static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX( const VmathVector3 *vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY( const VmathVector3 *vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ( const VmathVector3 *vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV3MakeXAxis( VmathVector3 *result ); - -/* - * Construct y axis - */ -static inline void vmathV3MakeYAxis( VmathVector3 *result ); - -/* - * Construct z axis - */ -static inline void vmathV3MakeZAxis( VmathVector3 *result ); - -/* - * Multiply two 3-D vectors per element - */ -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem( const VmathVector3 *vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem( const VmathVector3 *vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum( const VmathVector3 *vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr( const VmathVector3 *vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length( const VmathVector3 *vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - * NOTE: - * Slower than column post-multiply. - */ -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D vectors in three quadwords - */ -static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D vectors as half-floats - */ -static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print( const VmathVector3 *vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); - -#endif - -/* - * Copy a 4-D vector - */ -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); - -/* - * Set vector float data in a 4-D vector - */ -static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 4-D vector - */ -static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX( const VmathVector4 *vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY( const VmathVector4 *vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ( const VmathVector4 *vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW( const VmathVector4 *vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV4MakeXAxis( VmathVector4 *result ); - -/* - * Construct y axis - */ -static inline void vmathV4MakeYAxis( VmathVector4 *result ); - -/* - * Construct z axis - */ -static inline void vmathV4MakeZAxis( VmathVector4 *result ); - -/* - * Construct w axis - */ -static inline void vmathV4MakeWAxis( VmathVector4 *result ); - -/* - * Multiply two 4-D vectors per element - */ -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem( const VmathVector4 *vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem( const VmathVector4 *vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum( const VmathVector4 *vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr( const VmathVector4 *vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length( const VmathVector4 *vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); - -/* - * Store four 4-D vectors as half-floats - */ -static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print( const VmathVector4 *vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); - -#endif - -/* - * Copy a 3-D point - */ -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); - -/* - * Set vector float data in a 3-D point - */ -static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D point - */ -static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX( const VmathPoint3 *pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY( const VmathPoint3 *pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ( const VmathPoint3 *pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Multiply two 3-D points per element - */ -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem( const VmathPoint3 *pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum( const VmathPoint3 *pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D point in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D points in three quadwords - */ -static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D points as half-floats - */ -static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print( const VmathPoint3 *pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); - -#endif - -/* - * Copy a quaternion - */ -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); - -/* - * Set vector float data in a quaternion - */ -static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ); - -/* - * Get vector float data from a quaternion - */ -static inline vec_float4 vmathQGet128( const VmathQuat *quat ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX( const VmathQuat *quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY( const VmathQuat *quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ( const VmathQuat *quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW( const VmathQuat *quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem( const VmathQuat *quat, int idx ); - -/* - * Add two quaternions - */ -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply two quaternions - */ -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct an identity quaternion - */ -static inline void vmathQMakeIdentity( VmathQuat *result ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm( const VmathQuat *quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength( const VmathQuat *quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint( const VmathQuat *quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints( const VmathQuat *quat, const char *name ); - -#endif - -/* - * Copy a 3x3 matrix - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant( const VmathMatrix3 *mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print( const VmathMatrix3 *mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); - -#endif - -/* - * Copy a 4x4 matrix - */ -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant( const VmathMatrix4 *mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print( const VmathMatrix4 *mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); - -#endif - -/* - * Copy a 3x4 transformation matrix - */ -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline void vmathT3MakeIdentity( VmathTransform3 *result ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print( const VmathTransform3 *tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h deleted file mode 100644 index a8599172b..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_aos_v.h +++ /dev/null @@ -1,1925 +0,0 @@ -/* - 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_AOS_C_V_PPU_H -#define _VECTORMATH_AOS_C_V_PPU_H - -#include -#include -#include "vec_types.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - vec_float4 vec128; -} VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - vec_float4 vec128; -} VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - vec_float4 vec128; -} VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - vec_float4 vec128; -} VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 3-D vector - */ -static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D vector - */ -static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX_V( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY_V( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX_V( VmathVector3 vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY_V( VmathVector3 vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ_V( VmathVector3 vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); - -/* - * Construct x axis - */ -static inline VmathVector3 vmathV3MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector3 vmathV3MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector3 vmathV3MakeZAxis_V( ); - -/* - * Multiply two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem_V( VmathVector3 vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem_V( VmathVector3 vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum_V( VmathVector3 vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr_V( VmathVector3 vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length_V( VmathVector3 vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - * NOTE: - * Slower than column post-multiply. - */ -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D vectors in three quadwords - */ -static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D vectors as half-floats - */ -static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print_V( VmathVector3 vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); - -#endif - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 4-D vector - */ -static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 4-D vector - */ -static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX_V( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY_V( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW_V( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX_V( VmathVector4 vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY_V( VmathVector4 vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ_V( VmathVector4 vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW_V( VmathVector4 vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); - -/* - * Construct x axis - */ -static inline VmathVector4 vmathV4MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector4 vmathV4MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector4 vmathV4MakeZAxis_V( ); - -/* - * Construct w axis - */ -static inline VmathVector4 vmathV4MakeWAxis_V( ); - -/* - * Multiply two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem_V( VmathVector4 vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem_V( VmathVector4 vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum_V( VmathVector4 vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr_V( VmathVector4 vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length_V( VmathVector4 vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); - -/* - * Store four 4-D vectors as half-floats - */ -static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print_V( VmathVector4 vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); - -#endif - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 3-D point - */ -static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D point - */ -static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX_V( VmathPoint3 pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY_V( VmathPoint3 pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ_V( VmathPoint3 pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Multiply two 3-D points per element - */ -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem_V( VmathPoint3 pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum_V( VmathPoint3 pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D point in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D points in three quadwords - */ -static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D points as half-floats - */ -static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print_V( VmathPoint3 pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); - -#endif - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a quaternion - */ -static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a quaternion - */ -static inline vec_float4 vmathQGet128_V( VmathQuat quat ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX_V( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY_V( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ_V( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW_V( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX_V( VmathQuat quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY_V( VmathQuat quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ_V( VmathQuat quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW_V( VmathQuat quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem_V( VmathQuat quat, int idx ); - -/* - * Add two quaternions - */ -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply two quaternions - */ -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline VmathQuat vmathQNeg_V( VmathQuat quat ); - -/* - * Construct an identity quaternion - */ -static inline VmathQuat vmathQMakeIdentity_V( ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline VmathQuat vmathQMakeRotationX_V( float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline VmathQuat vmathQMakeRotationY_V( float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline VmathQuat vmathQMakeRotationZ_V( float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline VmathQuat vmathQConj_V( VmathQuat quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm_V( VmathQuat quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength_V( VmathQuat quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint_V( VmathQuat quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints_V( VmathQuat quat, const char *name ); - -#endif - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline VmathMatrix3 vmathM3MakeIdentity_V( ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant_V( VmathMatrix3 mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print_V( VmathMatrix3 mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); - -#endif - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline VmathMatrix4 vmathM4MakeIdentity_V( ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant_V( VmathMatrix4 mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print_V( VmathMatrix4 mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); - -#endif - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline VmathTransform3 vmathT3MakeIdentity_V( ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - * However, the transfer of select1 to a VMX register may use more processing time than a branch. - */ -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print_V( VmathTransform3 tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vectormath_aos.h" -#include "vec_aos_v.h" -#include "quat_aos_v.h" -#include "mat_aos_v.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h deleted file mode 100644 index 0188dcb3a..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa.h +++ /dev/null @@ -1,2013 +0,0 @@ -/* - 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_SOA_C_PPU_H -#define _VECTORMATH_SOA_C_PPU_H - -#include -#include -#include "vectormath_aos.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_SOA_C_TYPES_H -#define _VECTORMATH_SOA_C_TYPES_H - -/* A set of four 3-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaVector3; - -/* A set of four 4-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector4 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaVector4; - -/* A set of four 3-D points in structure-of-arrays format - */ -typedef struct _VmathSoaPoint3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaPoint3; - -/* A set of four quaternions in structure-of-arrays format - */ -typedef struct _VmathSoaQuat -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaQuat; - -/* A set of four 3x3 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; -} VmathSoaMatrix3; - -/* A set of four 4x4 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix4 -{ - VmathSoaVector4 col0; - VmathSoaVector4 col1; - VmathSoaVector4 col2; - VmathSoaVector4 col3; -} VmathSoaMatrix4; - -/* A set of four 3x4 transformation matrices in structure-of-arrays format - */ -typedef struct _VmathSoaTransform3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; - VmathSoaVector3 col3; -} VmathSoaTransform3; - -#endif - -/* - * Copy a 3-D vector - */ -static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3-D vector - */ -static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ); - -/* - * Insert four AoS 3-D vectors - */ -static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ); - -/* - * Extract four AoS 3-D vectors - */ -static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Construct x axis - */ -static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ); - -/* - * Construct y axis - */ -static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ); - -/* - * Construct z axis - */ -static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ); - -/* - * Multiply two 3-D vectors per element - */ -static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D vector in three quadwords - */ -static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D vectors as half-floats - */ -static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ); - -#endif - -/* - * Copy a 4-D vector - */ -static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 4-D vector - */ -static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ); - -/* - * Insert four AoS 4-D vectors - */ -static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ); - -/* - * Extract four AoS 4-D vectors - */ -static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 w ); - -/* - * Get the x element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Construct x axis - */ -static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ); - -/* - * Construct y axis - */ -static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ); - -/* - * Construct z axis - */ -static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ); - -/* - * Construct w axis - */ -static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ); - -/* - * Multiply two 4-D vectors per element - */ -static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ); - -/* - * Store four slots of an SoA 4-D vector as half-floats - */ -static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ); - -#endif - -/* - * Copy a 3-D point - */ -static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3-D point - */ -static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Insert four AoS 3-D points - */ -static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ); - -/* - * Extract four AoS 3-D points - */ -static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); - -/* - * Multiply two 3-D points per element - */ -static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D point in three quadwords - */ -static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *pnt, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D points as half-floats - */ -static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ); - -#endif - -/* - * Copy a quaternion - */ -static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ); - -/* - * Replicate an AoS quaternion - */ -static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ); - -/* - * Insert four AoS quaternions - */ -static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ); - -/* - * Extract four AoS quaternions - */ -static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 w ); - -/* - * Get the x element of a quaternion - */ -static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ); - -/* - * Get the y element of a quaternion - */ -static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ); - -/* - * Get the z element of a quaternion - */ -static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ); - -/* - * Get the w element of a quaternion - */ -static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ); - -/* - * Add two quaternions - */ -static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Multiply two quaternions - */ -static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Construct an identity quaternion - */ -static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ); - -/* - * Compute the length of a quaternion - */ -static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrint( const VmathSoaQuat *quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ); - -#endif - -/* - * Copy a 3x3 matrix - */ -static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3x3 matrix - */ -static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Insert four AoS 3x3 matrices - */ -static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ); - -/* - * Extract four AoS 3x3 matrices - */ -static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ); - -#endif - -/* - * Copy a 4x4 matrix - */ -static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0, const VmathSoaVector4 *col1, const VmathSoaVector4 *col2, const VmathSoaVector4 *col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 4x4 matrix - */ -static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Insert four AoS 4x4 matrices - */ -static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ); - -/* - * Extract four AoS 4x4 matrices - */ -static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ); - -#endif - -/* - * Copy a 3x4 transformation matrix - */ -static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2, const VmathSoaVector3 *col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3x4 transformation matrix - */ -static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Insert four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ); - -/* - * Extract four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set translation component - */ -static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vec_soa.h" -#include "quat_soa.h" -#include "mat_soa.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h b/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h deleted file mode 100644 index 7a93c1757..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/c/vectormath_soa_v.h +++ /dev/null @@ -1,1979 +0,0 @@ -/* - 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_SOA_C_V_PPU_H -#define _VECTORMATH_SOA_C_V_PPU_H - -#include -#include -#include "vectormath_aos_v.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_SOA_C_TYPES_H -#define _VECTORMATH_SOA_C_TYPES_H - -/* A set of four 3-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaVector3; - -/* A set of four 4-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector4 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaVector4; - -/* A set of four 3-D points in structure-of-arrays format - */ -typedef struct _VmathSoaPoint3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaPoint3; - -/* A set of four quaternions in structure-of-arrays format - */ -typedef struct _VmathSoaQuat -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaQuat; - -/* A set of four 3x3 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; -} VmathSoaMatrix3; - -/* A set of four 4x4 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix4 -{ - VmathSoaVector4 col0; - VmathSoaVector4 col1; - VmathSoaVector4 col2; - VmathSoaVector4 col3; -} VmathSoaMatrix4; - -/* A set of four 3x4 transformation matrices in structure-of-arrays format - */ -typedef struct _VmathSoaTransform3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; - VmathSoaVector3 col3; -} VmathSoaTransform3; - -#endif - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ); - -/* - * Insert four AoS 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ); - -/* - * Extract four AoS 3-D vectors - */ -static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ); - -/* - * Construct x axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ); - -/* - * Multiply two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D vector in three quadwords - */ -static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D vectors as half-floats - */ -static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ); - -#endif - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ); - -/* - * Insert four AoS 4-D vectors - */ -static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ); - -/* - * Extract four AoS 4-D vectors - */ -static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 w ); - -/* - * Get the x element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ); - -/* - * Construct x axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ); - -/* - * Construct w axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ); - -/* - * Multiply two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ); - -/* - * Store four slots of an SoA 4-D vector as half-floats - */ -static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ); - -#endif - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ); - -/* - * Insert four AoS 3-D points - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ); - -/* - * Extract four AoS 3-D points - */ -static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); - -/* - * Multiply two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D point in three quadwords - */ -static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 pnt, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D points as half-floats - */ -static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ); - -#endif - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ); - -/* - * Insert four AoS quaternions - */ -static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ); - -/* - * Extract four AoS quaternions - */ -static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 w ); - -/* - * Get the x element of a quaternion - */ -static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ); - -/* - * Get the y element of a quaternion - */ -static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ); - -/* - * Get the z element of a quaternion - */ -static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ); - -/* - * Get the w element of a quaternion - */ -static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ); - -/* - * Add two quaternions - */ -static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Multiply two quaternions - */ -static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ); - -/* - * Construct an identity quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat unitQuat, VmathSoaVector3 vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ); - -/* - * Compute the length of a quaternion - */ -static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrint_V( VmathSoaQuat quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ); - -#endif - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ); - -/* - * Insert four AoS 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ); - -/* - * Extract four AoS 3x3 matrices - */ -static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ); - -#endif - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 col0, VmathSoaVector4 col1, VmathSoaVector4 col2, VmathSoaVector4 col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ); - -/* - * Insert four AoS 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ); - -/* - * Extract four AoS 4x4 matrices - */ -static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ); - -#endif - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2, VmathSoaVector3 col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3x4 transformation matrix - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ); - -/* - * Insert four AoS 3x4 transformation matrices - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ); - -/* - * Extract four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ); - -/* - * Set translation component - */ -static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vectormath_soa.h" -#include "vec_soa_v.h" -#include "quat_soa_v.h" -#include "mat_soa_v.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h deleted file mode 100644 index 351a6f67c..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/boolInVec.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - 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 -#include -#include "../c/vec_types.h" -#undef bool - -namespace Vectormath { - -class floatInVec; - -//-------------------------------------------------------------------------------------------------- -// boolInVec class -// - -class boolInVec -{ - private: - vec_uint4 mData; - - inline boolInVec(vec_uint4 vec); - public: - inline boolInVec() {} - - // matches standard type conversions - // - inline boolInVec(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 vec_uint4 get128() const; - - // operators - // - inline const boolInVec operator ! () const; - inline boolInVec& operator = (boolInVec vec); - inline boolInVec& operator &= (boolInVec vec); - inline boolInVec& operator ^= (boolInVec vec); - inline boolInVec& operator |= (boolInVec vec); - - // friend functions - // - friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); -}; - -//-------------------------------------------------------------------------------------------------- -// boolInVec functions -// - -// operators -// -inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); - -// select between vec0 and vec1 using boolInVec. -// false selects vec0, true selects vec1 -// -inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); - -} // namespace Vectormath - -//-------------------------------------------------------------------------------------------------- -// boolInVec implementation -// - -#include "floatInVec.h" - -namespace Vectormath { - -inline -boolInVec::boolInVec(vec_uint4 vec) -{ - mData = vec; -} - -inline -boolInVec::boolInVec(floatInVec vec) -{ - *this = (vec != floatInVec(0.0f)); -} - -inline -boolInVec::boolInVec(bool scalar) -{ -#ifdef __GNUC__ - if (__builtin_constant_p(scalar)) - { - const unsigned int mask = -(int)scalar; - mData = (vec_uint4){mask, mask, mask, mask}; - } - else -#endif - { - unsigned int mask = -(int)scalar; - vec_uint4 vec = vec_ld(0, &mask); - mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &mask)), 0); - } -} - -#ifdef _VECTORMATH_NO_SCALAR_CAST -inline -bool -boolInVec::getAsBool() const -#else -inline -boolInVec::operator bool() const -#endif -{ - return vec_all_gt(mData, ((vec_uint4){0,0,0,0})); -} - -inline -vec_uint4 -boolInVec::get128() const -{ - return mData; -} - -inline -const boolInVec -boolInVec::operator ! () const -{ - return boolInVec(vec_nor(mData, 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((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator != (boolInVec vec0, boolInVec vec1) -{ - return !(vec0 == vec1); -} - -inline -const boolInVec -operator & (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(vec_and(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator | (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(vec_or(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator ^ (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(vec_xor(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) -{ - return boolInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); -} - -} // namespace Vectormath - -#endif // boolInVec_h diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h deleted file mode 100644 index 957971900..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/floatInVec.h +++ /dev/null @@ -1,361 +0,0 @@ -/* - 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 -#include -#include -#include -#include "../c/vec_types.h" -#undef bool - -namespace Vectormath { - -class boolInVec; - -//-------------------------------------------------------------------------------------------------- -// floatInVec class -// - -class floatInVec -{ - private: - vec_float4 mData; - - inline floatInVec(vec_float4 vec); - public: - inline floatInVec() {} - - // matches standard type conversions - // - inline floatInVec(boolInVec vec); - - // construct from a slot of vec_float4 - // - inline floatInVec(vec_float4 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 vec_float4 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 = (floatInVec vec); - inline floatInVec& operator *= (floatInVec vec); - inline floatInVec& operator /= (floatInVec vec); - inline floatInVec& operator += (floatInVec vec); - inline floatInVec& operator -= (floatInVec vec); - - // friend functions - // - friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); -}; - -//-------------------------------------------------------------------------------------------------- -// floatInVec functions -// - -// operators -// -inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); - -// select between vec0 and vec1 using boolInVec. -// false selects vec0, true selects vec1 -// -inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); - -} // namespace Vectormath - -//-------------------------------------------------------------------------------------------------- -// floatInVec implementation -// - -#include "boolInVec.h" - -namespace Vectormath { - -inline -floatInVec::floatInVec(vec_float4 vec) -{ - mData = vec; -} - -inline -floatInVec::floatInVec(boolInVec vec) -{ - mData = vec_ctf(vec_sub((vec_uint4){0,0,0,0}, vec.get128()), 0); -} - -inline -floatInVec::floatInVec(vec_float4 vec, int slot) -{ -#ifdef __GNUC__ - if (__builtin_constant_p(slot)) - { - mData = vec_splat(vec, slot); - } - else -#endif - { - const vec_uchar16 shiftpattern = vec_lvsl(0, (float *)(size_t)(slot << 2)); - mData = vec_splat(vec_perm(vec, vec, shiftpattern), 0); - } -} - -inline -floatInVec::floatInVec(float scalar) -{ -#ifdef __GNUC__ - if (__builtin_constant_p(scalar)) - { - mData = (vec_float4){scalar, scalar, scalar, scalar}; - } - else -#endif - { - vec_float4 vec = vec_ld(0, &scalar); - mData = vec_splat(vec_perm(vec, vec, vec_lvsl(0, &scalar)), 0); - } -} - -#ifdef _VECTORMATH_NO_SCALAR_CAST -inline -float -floatInVec::getAsFloat() const -#else -inline -floatInVec::operator float() const -#endif -{ - return *((float *)&mData); -} - -inline -vec_float4 -floatInVec::get128() const -{ - return mData; -} - -inline -const floatInVec -floatInVec::operator ++ (int) -{ - vec_float4 olddata = mData; - operator ++(); - return floatInVec(olddata); -} - -inline -const floatInVec -floatInVec::operator -- (int) -{ - vec_float4 olddata = mData; - operator --(); - return floatInVec(olddata); -} - -inline -floatInVec& -floatInVec::operator ++ () -{ - *this += floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f}); - return *this; -} - -inline -floatInVec& -floatInVec::operator -- () -{ - *this -= floatInVec((vec_float4){1.0f,1.0f,1.0f,1.0f}); - return *this; -} - -inline -const floatInVec -floatInVec::operator - () const -{ - return floatInVec((vec_float4)vec_xor((vec_uint4)mData, (vec_uint4){0x80000000,0x80000000,0x80000000,0x80000000})); -} - -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(vec_madd(vec0.get128(), vec1.get128(), (vec_float4){0,0,0,0})); -} - -inline -const floatInVec -operator / (floatInVec num, floatInVec den) -{ - return floatInVec(divf4(num.get128(), den.get128())); -} - -inline -const floatInVec -operator + (floatInVec vec0, floatInVec vec1) -{ - return floatInVec(vec_add(vec0.get128(), vec1.get128())); -} - -inline -const floatInVec -operator - (floatInVec vec0, floatInVec vec1) -{ - return floatInVec(vec_sub(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator < (floatInVec vec0, floatInVec vec1) -{ - return boolInVec((vec_uint4)vec_cmpgt(vec1.get128(), vec0.get128())); -} - -inline -const boolInVec -operator <= (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 > vec1); -} - -inline -const boolInVec -operator > (floatInVec vec0, floatInVec vec1) -{ - return boolInVec((vec_uint4)vec_cmpgt(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator >= (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 < vec1); -} - -inline -const boolInVec -operator == (floatInVec vec0, floatInVec vec1) -{ - return boolInVec((vec_uint4)vec_cmpeq(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator != (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 == vec1); -} - -inline -const floatInVec -select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) -{ - return floatInVec(vec_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); -} - -} // namespace Vectormath - -#endif // floatInVec_h diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h deleted file mode 100644 index 77a184725..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_aos.h +++ /dev/null @@ -1,2188 +0,0 @@ -/* - 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_MAT_AOS_CPP_H -#define _VECTORMATH_MAT_AOS_CPP_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XZBX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_CXXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YAXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W, _VECTORMATH_PERM_Z }) -#define _VECTORMATH_PERM_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y }) -#define _VECTORMATH_PERM_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_ZAYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_BZXX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_ZXXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_YXXC ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X, _VECTORMATH_PERM_X, _VECTORMATH_PERM_C }) -#define _VECTORMATH_PERM_BBYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_B, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( floatInVec scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( Quat unitQuat ) -{ - vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - vec_uint4 select_x = _VECTORMATH_MASK_0xF000; - vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; - xyzw_2 = vec_add( unitQuat.get128(), unitQuat.get128() ); - wwww = vec_splat( unitQuat.get128(), 3 ); - yzxw = vec_perm( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_PERM_YZXW ); - zxyw = vec_perm( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_PERM_ZXYW ); - yzxw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_YZXW ); - zxyw_2 = vec_perm( xyzw_2, xyzw_2, _VECTORMATH_PERM_ZXYW ); - tmp0 = vec_madd( yzxw_2, wwww, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_nmsub( yzxw, yzxw_2, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - tmp2 = vec_madd( yzxw, xyzw_2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp0 = vec_madd( zxyw, xyzw_2, tmp0 ); - tmp1 = vec_nmsub( zxyw, zxyw_2, tmp1 ); - tmp2 = vec_nmsub( zxyw_2, wwww, tmp2 ); - tmp3 = vec_sel( tmp0, tmp1, select_x ); - tmp4 = vec_sel( tmp1, tmp2, select_x ); - tmp5 = vec_sel( tmp2, tmp0, select_x ); - mCol0 = Vector3( vec_sel( tmp3, tmp2, select_z ) ); - mCol1 = Vector3( vec_sel( tmp4, tmp0, select_z ) ); - mCol2 = Vector3( vec_sel( tmp5, tmp1, select_z ) ); -} - -inline Matrix3::Matrix3( Vector3 _col0, Vector3 _col1, Vector3 _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( Vector3 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( Vector3 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( Vector3 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, Vector3 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, Vector3 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, floatInVec val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline const floatInVec Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, res0, res1, res2; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - res0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - res1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - res2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); - tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); - tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); - dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - inv0 = vec_madd( inv0, invdet, zero ); - inv1 = vec_madd( inv1, invdet, zero ); - inv2 = vec_madd( inv2, invdet, zero ); - return Matrix3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ) - ); -} - -inline const floatInVec determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -inline const Matrix3 Matrix3::operator *( floatInVec scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -inline Matrix3 & Matrix3::operator *=( floatInVec scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return floatInVec(scalar) * mat; -} - -inline const Matrix3 operator *( floatInVec scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -inline const Matrix3 Matrix3::rotationX( floatInVec radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -inline const Matrix3 Matrix3::rotationY( floatInVec radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -inline const Matrix3 Matrix3::rotationZ( floatInVec radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - return Matrix3( - Vector3( vec_madd( Z0, Y0, zero ) ), - Vector3( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, Vector3 unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -inline const Matrix3 Matrix3::rotation( floatInVec radians, Vector3 unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - axisS = vec_madd( axis, s, zero ); - negAxisS = negatef4( axisS ); - tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); - tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); - tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); - return Matrix3( - Vector3( vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ) ), - Vector3( vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ) ), - Vector3( vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( Quat unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( Vector3 scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - return Matrix3( - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, boolInVec select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( floatInVec scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( Vector4 _col0, Vector4 _col1, Vector4 _col2, Vector4 _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, Vector3 translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( Quat unitQuat, Vector3 translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( Vector4 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( Vector4 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( Vector4 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( Vector4 _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, Vector4 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, Vector4 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, floatInVec val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline const floatInVec Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergeh( mat.getCol1().get128(), mat.getCol3().get128() ); - tmp2 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp3 = vec_mergel( mat.getCol1().get128(), mat.getCol3().get128() ); - res0 = vec_mergeh( tmp0, tmp1 ); - res1 = vec_mergel( tmp0, tmp1 ); - res2 = vec_mergeh( tmp2, tmp3 ); - res3 = vec_mergel( tmp2, tmp3 ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4( res2 ), - Vector4( res3 ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vector float in0, in1, in2, in3; - vector float tmp0, tmp1, tmp2, tmp3; - vector float cof0, cof1, cof2, cof3; - vector float t0, t1, t2, t3; - vector float t01, t02, t03, t12, t23; - vector float t1r, t2r; - vector float t01r, t02r, t03r, t12r, t23r; - vector float t1r3, t1r3r; - vector float det, det0, det1, det2, det3, invdet; - vector float vzero = (vector float){0.0}; - in0 = mat.getCol0().get128(); - in1 = mat.getCol1().get128(); - in2 = mat.getCol2().get128(); - in3 = mat.getCol3().get128(); - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ - tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ - tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ - tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ - t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ - t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ - t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ - t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ - t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ - cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ - cof1 = vec_nmsub(t0, t23, vzero); /* -(AGP ECL IOH MKD) */ - t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ - cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ - cof1 = vec_madd(t0, t23r, cof1); /* AOH EKD IGP MCL + cof1 */ - cof1 = vec_sld(cof1, cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ - t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ - t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ - cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - cof3 = vec_madd(t0, t12, vzero); /* ANG EJC IFO MBK */ - t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ - cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - cof3 = vec_nmsub(t0, t12r, cof3); /* cof3 - AFO EBK ING MJC */ - cof3 = vec_sld(cof3, cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ - t1r = vec_sld(t1, t1, 8); /* B F J N */ - t2r = vec_sld(t2, t2, 8); /* K O C G */ - t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ - t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ - cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - cof2 = vec_madd(t0, t1r3, vzero); /* AFP EBL INH MJD */ - t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ - cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - cof2 = vec_nmsub(t0, t1r3r, cof2); /* cof2 - ANH EJD IFP MBL */ - cof2 = vec_sld(cof2, cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ - t01 = vec_madd(t0, t1, vzero); /* AJ EN IB MF */ - t01 = vec_perm(t01, t01, _VECTORMATH_PERM_YXWZ); /* EN AJ MF IB */ - cof2 = vec_nmsub(t3, t01, cof2); /* cof2 - LEN PAJ DMF HIB */ - cof3 = vec_madd(t2r, t01, cof3); /* KEN OAJ CMF GIB + cof3 */ - t01r = vec_sld(t01, t01, 8); /* MF IB EN AJ */ - cof2 = vec_madd(t3, t01r, cof2); /* LMF PIB DEN HAJ + cof2 */ - cof3 = vec_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ - t03 = vec_madd(t0, t3, vzero); /* AL EP ID MH */ - t03 = vec_perm(t03, t03, _VECTORMATH_PERM_YXWZ); /* EP AL MH ID */ - cof1 = vec_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ - cof2 = vec_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ - t03r = vec_sld(t03, t03, 8); /* MH ID EP AL */ - cof1 = vec_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ - cof2 = vec_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ - t02 = vec_madd(t0, t2r, vzero); /* AK EO IC MG */ - t02 = vec_perm(t02, t02, _VECTORMATH_PERM_YXWZ); /* E0 AK MG IC */ - cof1 = vec_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ - cof3 = vec_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ - t02r = vec_sld(t02, t02, 8); /* MG IC EO AK */ - cof1 = vec_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ - cof3 = vec_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ - /* Compute the determinant of the matrix - * - * det = sum_across(t0 * cof0); - * - * We perform a sum across the entire vector so that - * we don't have to splat the result when multiplying the - * cofactors by the inverse of the determinant. - */ - det = vec_madd(t0, cof0, vzero); - det0 = vec_splat(det, 0); - det1 = vec_splat(det, 1); - det2 = vec_splat(det, 2); - det3 = vec_splat(det, 3); - det = vec_add(det0, det1); - det2 = vec_add(det2, det3); - det = vec_add(det, det2); - /* Compute the reciprocal of the determinant. - */ - invdet = recipf4(det); - /* Multiply the cofactors by the reciprocal of the determinant. - */ - return Matrix4( - Vector4( vec_madd(cof0, invdet, vzero) ), - Vector4( vec_madd(cof1, invdet, vzero) ), - Vector4( vec_madd(cof2, invdet, vzero) ), - Vector4( vec_madd(cof3, invdet, vzero) ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline const floatInVec determinant( const Matrix4 & mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vector float in0, in1, in2, in3; - vector float tmp0, tmp1, tmp2, tmp3; - vector float cof0; - vector float t0, t1, t2, t3; - vector float t12, t23; - vector float t1r, t2r; - vector float t12r, t23r; - vector float t1r3, t1r3r; - vector float vzero = (vector float){0.0}; - in0 = mat.getCol0().get128(); - in1 = mat.getCol1().get128(); - in2 = mat.getCol2().get128(); - in3 = mat.getCol3().get128(); - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = vec_perm(in0, in1, _VECTORMATH_PERM_XAZC); /* A E C G */ - tmp1 = vec_perm(in2, in3, _VECTORMATH_PERM_XAZC); /* I M K O */ - tmp2 = vec_perm(in0, in1, _VECTORMATH_PERM_YBWD); /* B F D H */ - tmp3 = vec_perm(in2, in3, _VECTORMATH_PERM_YBWD); /* J N L P */ - t0 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_XYAB); /* A E I M */ - t1 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_XYAB); /* J N B F */ - t2 = vec_perm(tmp0, tmp1, _VECTORMATH_PERM_ZWCD); /* C G K O */ - t3 = vec_perm(tmp3, tmp2, _VECTORMATH_PERM_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = vec_madd(t2, t3, vzero); /* CL GP KD OH */ - t23 = vec_perm(t23, t23, _VECTORMATH_PERM_YXWZ); /* GP CL OH KD */ - cof0 = vec_nmsub(t1, t23, vzero); /* -(JGP NCL FOH BKD) */ - t23r = vec_sld(t23, t23, 8); /* OH KD GP CL */ - cof0 = vec_madd(t1, t23r, cof0); /* JOH NKD BGP FCL + cof0 */ - t12 = vec_madd(t1, t2, vzero); /* JC NG BK FO */ - t12 = vec_perm(t12, t12, _VECTORMATH_PERM_YXWZ); /* NG JC FO BK */ - cof0 = vec_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - t12r = vec_sld(t12, t12, 8); /* FO BK NG JC */ - cof0 = vec_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - t1r = vec_sld(t1, t1, 8); /* B F J N */ - t2r = vec_sld(t2, t2, 8); /* K O C G */ - t1r3 = vec_madd(t1r, t3, vzero); /* BL FP JD NH */ - t1r3 = vec_perm(t1r3, t1r3, _VECTORMATH_PERM_YXWZ); /* FP BL NH JD */ - cof0 = vec_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - t1r3r = vec_sld(t1r3, t1r3, 8); /* NH JD FP BL */ - cof0 = vec_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - return floatInVec( _vmathVfDot4(t0,cof0), 0 ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -inline const Matrix4 Matrix4::operator *( floatInVec scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -inline Matrix4 & Matrix4::operator *=( floatInVec scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return floatInVec(scalar) * mat; -} - -inline const Matrix4 operator *( floatInVec scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( Vector4 vec ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz, wwww; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - wwww = vec_splat( vec.get128(), 3 ); - tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); - tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); - tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = vec_madd( mCol3.get128(), wwww, tmp1 ); - res = vec_add( tmp0, tmp1 ); - return Vector4( res ); -} - -inline const Vector4 Matrix4::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector4( res ); -} - -inline const Vector4 Matrix4::operator *( Point3 pnt ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( pnt.get128(), 0 ); - yyyy = vec_splat( pnt.get128(), 1 ); - zzzz = vec_splat( pnt.get128(), 2 ); - tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); - tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); - tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = vec_add( mCol3.get128(), tmp1 ); - res = vec_add( tmp0, tmp1 ); - return Vector4( res ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( Vector3 translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -inline const Matrix4 Matrix4::rotationX( floatInVec radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4::xAxis( ), - Vector4( res1 ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -inline const Matrix4 Matrix4::rotationY( floatInVec radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Matrix4( - Vector4( res0 ), - Vector4::yAxis( ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -inline const Matrix4 Matrix4::rotationZ( floatInVec radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - return Matrix4( - Vector4( vec_madd( Z0, Y0, zero ) ), - Vector4( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), - Vector4( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, Vector3 unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -inline const Matrix4 Matrix4::rotation( floatInVec radians, Vector3 unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - axis = unitVec.get128(); - sincosf4( radians.get128(), &s, &c ); - xxxx = vec_splat( axis, 0 ); - yyyy = vec_splat( axis, 1 ); - zzzz = vec_splat( axis, 2 ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - axisS = vec_madd( axis, s, zero ); - negAxisS = negatef4( axisS ); - tmp0 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_XZBX ); - tmp1 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_CXXX ); - tmp2 = vec_perm( axisS, negAxisS, _VECTORMATH_PERM_YAXX ); - tmp0 = vec_sel( tmp0, c, _VECTORMATH_MASK_0xF000 ); - tmp1 = vec_sel( tmp1, c, _VECTORMATH_MASK_0x0F00 ); - tmp2 = vec_sel( tmp2, c, _VECTORMATH_MASK_0x00F0 ); - zeroW = (vec_float4)_VECTORMATH_MASK_0x000F; - axis = vec_andc( axis, zeroW ); - tmp0 = vec_andc( tmp0, zeroW ); - tmp1 = vec_andc( tmp1, zeroW ); - tmp2 = vec_andc( tmp2, zeroW ); - return Matrix4( - Vector4( vec_madd( vec_madd( axis, xxxx, zero ), oneMinusC, tmp0 ) ), - Vector4( vec_madd( vec_madd( axis, yyyy, zero ), oneMinusC, tmp1 ) ), - Vector4( vec_madd( vec_madd( axis, zzzz, zero ), oneMinusC, tmp2 ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( Quat unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( Vector3 scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - return Matrix4( - Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), - Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), - Vector4( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( Vector3 translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - vec_float4 zero, col0, col1, col2, col3; - union { vec_float4 v; float s[4]; } tmp; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp.v = zero; - tmp.s[0] = f / aspect; - col0 = tmp.v; - tmp.v = zero; - tmp.s[1] = f; - col1 = tmp.v; - tmp.v = zero; - tmp.s[2] = ( zNear + zFar ) * rangeInv; - tmp.s[3] = -1.0f; - col2 = tmp.v; - tmp.v = zero; - tmp.s[2] = zNear * zFar * rangeInv * 2.0f; - col3 = tmp.v; - return Matrix4( - Vector4( col0 ), - Vector4( col1 ), - Vector4( col2 ), - Vector4( col3 ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff; - vec_float4 diagonal, column, near2; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - union { vec_float4 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = vec_splat( n.v, 0 ); - near2 = vec_add( near2, near2 ); - diagonal = vec_madd( near2, inv_diff, zero ); - column = vec_madd( sum, inv_diff, zero ); - return Matrix4( - Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ) ), - Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ) ), - Vector4( vec_sel( column, ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}), _VECTORMATH_MASK_0x000F ) ), - Vector4( vec_sel( zero, vec_madd( diagonal, vec_splat( f.v, 0 ), zero ), _VECTORMATH_MASK_0x00F0 ) ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff, neg_inv_diff; - vec_float4 diagonal, column; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - union { vec_float4 v; float s[4]; } l, f, r, n, b, t; - l.s[0] = left; - f.s[0] = zFar; - r.s[0] = right; - n.s[0] = zNear; - b.s[0] = bottom; - t.s[0] = top; - lbf = vec_mergeh( l.v, f.v ); - rtn = vec_mergeh( r.v, n.v ); - lbf = vec_mergeh( lbf, b.v ); - rtn = vec_mergeh( rtn, t.v ); - diff = vec_sub( rtn, lbf ); - sum = vec_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = vec_add( inv_diff, inv_diff ); - column = vec_madd( sum, vec_sel( neg_inv_diff, inv_diff, _VECTORMATH_MASK_0x00F0 ), zero ); - return Matrix4( - Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0xF000 ) ), - Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x0F00 ) ), - Vector4( vec_sel( zero, diagonal, _VECTORMATH_MASK_0x00F0 ) ), - Vector4( vec_sel( column, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), _VECTORMATH_MASK_0x000F ) ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, boolInVec select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( floatInVec scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( Vector3 _col0, Vector3 _col1, Vector3 _col2, Vector3 _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, Vector3 translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( Quat unitQuat, Vector3 translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( Vector3 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( Vector3 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( Vector3 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( Vector3 _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, Vector3 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, Vector4 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, floatInVec val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline const floatInVec Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); - tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); - tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); - dot = vec_splat( dot, 0 ); - invdet = recipf4( dot ); - tmp3 = vec_mergeh( tmp0, tmp2 ); - tmp4 = vec_mergel( tmp0, tmp2 ); - inv0 = vec_mergeh( tmp3, tmp1 ); - xxxx = vec_splat( inv3, 0 ); - inv1 = vec_perm( tmp3, tmp1, _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp4, tmp1, _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_madd( inv0, xxxx, zero ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - inv0 = vec_madd( inv0, invdet, zero ); - inv1 = vec_madd( inv1, invdet, zero ); - inv2 = vec_madd( inv2, invdet, zero ); - inv3 = vec_madd( inv3, invdet, zero ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1; - vec_float4 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - tmp1 = vec_mergel( tfrm.getCol0().get128(), tfrm.getCol2().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - inv0 = vec_mergeh( tmp0, tfrm.getCol1().get128() ); - xxxx = vec_splat( inv3, 0 ); - inv1 = vec_perm( tmp0, tfrm.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - inv2 = vec_perm( tmp1, tfrm.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( inv3, 1 ); - zzzz = vec_splat( inv3, 2 ); - inv3 = vec_madd( inv0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - inv3 = vec_madd( inv1, yyyy, inv3 ); - inv3 = vec_madd( inv2, zzzz, inv3 ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - xxxx = vec_splat( vec.get128(), 0 ); - yyyy = vec_splat( vec.get128(), 1 ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mCol0.get128(), xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( mCol1.get128(), yyyy, res ); - res = vec_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -inline const Point3 Transform3::operator *( Point3 pnt ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - xxxx = vec_splat( pnt.get128(), 0 ); - yyyy = vec_splat( pnt.get128(), 1 ); - zzzz = vec_splat( pnt.get128(), 2 ); - tmp0 = vec_madd( mCol0.get128(), xxxx, zero ); - tmp1 = vec_madd( mCol1.get128(), yyyy, zero ); - tmp0 = vec_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = vec_add( mCol3.get128(), tmp1 ); - res = vec_add( tmp0, tmp1 ); - return Point3( res ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( Vector3 translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -inline const Transform3 Transform3::rotationX( floatInVec radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = _VECTORMATH_MASK_0x0F00; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res1 = vec_sel( zero, c, select_y ); - res1 = vec_sel( res1, s, select_z ); - res2 = vec_sel( zero, negatef4(s), select_y ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -inline const Transform3 Transform3::rotationY( floatInVec radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_z = _VECTORMATH_MASK_0x00F0; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, negatef4(s), select_z ); - res2 = vec_sel( zero, s, select_x ); - res2 = vec_sel( res2, c, select_z ); - return Transform3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -inline const Transform3 Transform3::rotationZ( floatInVec radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = _VECTORMATH_MASK_0xF000; - select_y = _VECTORMATH_MASK_0x0F00; - zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - sincosf4( radians.get128(), &s, &c ); - res0 = vec_sel( zero, c, select_x ); - res0 = vec_sel( res0, s, select_y ); - res1 = vec_sel( zero, negatef4(s), select_x ); - res1 = vec_sel( res1, c, select_y ); - return Transform3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - angles = Vector4( radiansXYZ, 0.0f ).get128(); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = vec_mergel( c, s ); - Z1 = vec_mergel( negS, c ); - Z1 = vec_andc( Z1, (vec_float4)_VECTORMATH_MASK_0x000F ); - Y0 = vec_perm( negS, c, _VECTORMATH_PERM_BBYX ); - Y1 = vec_perm( c, s, _VECTORMATH_PERM_BBYX ); - X0 = vec_splat( s, 0 ); - X1 = vec_splat( c, 0 ); - tmp = vec_madd( Z0, Y1, zero ); - return Transform3( - Vector3( vec_madd( Z0, Y0, zero ) ), - Vector3( vec_madd( Z1, X1, vec_madd( tmp, X0, zero ) ) ), - Vector3( vec_nmsub( Z1, X0, vec_madd( tmp, X1, zero ) ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, Vector3 unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -inline const Transform3 Transform3::rotation( floatInVec radians, Vector3 unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( Quat unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( Vector3 scaleVec ) -{ - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - return Transform3( - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0xF000 ) ), - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x0F00 ) ), - Vector3( vec_sel( zero, scaleVec.get128(), _VECTORMATH_MASK_0x00F0 ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( Vector3 translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, boolInVec select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - vec_float4 res; - vec_float4 col0, col1, col2; - vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; - vec_float4 radicand, invSqrt, scale; - vec_float4 res0, res1, res2, res3; - vec_float4 xx, yy, zz; - vec_uint4 select_x = _VECTORMATH_MASK_0xF000; - vec_uint4 select_y = _VECTORMATH_MASK_0x0F00; - vec_uint4 select_z = _VECTORMATH_MASK_0x00F0; - vec_uint4 select_w = _VECTORMATH_MASK_0x000F; - vec_float4 zero = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); - - col0 = tfrm.getCol0().get128(); - col1 = tfrm.getCol1().get128(); - col2 = tfrm.getCol2().get128(); - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = vec_sel( col0, col1, select_y ); - xx_yy_zz_xx = vec_perm( xx_yy, col2, _VECTORMATH_PERM_XYCX ); - yy_zz_xx_yy = vec_perm( xx_yy, col2, _VECTORMATH_PERM_YCXY ); - zz_xx_yy_zz = vec_perm( xx_yy, col2, _VECTORMATH_PERM_CXYC ); - - diagSum = vec_add( vec_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = vec_sub( vec_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = vec_add( vec_sel( diagDiff, diagSum, select_w ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - invSqrt = rsqrtf4( radicand ); - - zy_xz_yx = vec_sel( col0, col1, select_z ); - zy_xz_yx = vec_perm( zy_xz_yx, col2, _VECTORMATH_PERM_ZAYX ); - yz_zx_xy = vec_sel( col0, col1, select_x ); - yz_zx_xy = vec_perm( yz_zx_xy, col2, _VECTORMATH_PERM_BZXX ); - - sum = vec_add( zy_xz_yx, yz_zx_xy ); - diff = vec_sub( zy_xz_yx, yz_zx_xy ); - - scale = vec_madd( invSqrt, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), zero ); - res0 = vec_perm( sum, diff, _VECTORMATH_PERM_XZYA ); - res1 = vec_perm( sum, diff, _VECTORMATH_PERM_ZXXB ); - res2 = vec_perm( sum, diff, _VECTORMATH_PERM_YXXC ); - res3 = diff; - res0 = vec_sel( res0, radicand, select_x ); - res1 = vec_sel( res1, radicand, select_y ); - res2 = vec_sel( res2, radicand, select_z ); - res3 = vec_sel( res3, radicand, select_w ); - res0 = vec_madd( res0, vec_splat( scale, 0 ), zero ); - res1 = vec_madd( res1, vec_splat( scale, 1 ), zero ); - res2 = vec_madd( res2, vec_splat( scale, 2 ), zero ); - res3 = vec_madd( res3, vec_splat( scale, 3 ), zero ); - - /* determine case and select answer */ - - xx = vec_splat( col0, 0 ); - yy = vec_splat( col1, 1 ); - zz = vec_splat( col2, 2 ); - res = vec_sel( res0, res1, vec_cmpgt( yy, xx ) ); - res = vec_sel( res, res2, vec_and( vec_cmpgt( zz, xx ), vec_cmpgt( zz, yy ) ) ); - res = vec_sel( res, res3, vec_cmpgt( vec_splat( diagSum, 0 ), zero ) ); - mVec128 = res; -} - -inline const Matrix3 outer( Vector3 tfrm0, Vector3 tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( Vector4 tfrm0, Vector4 tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; - vec_float4 xxxx, yyyy, zzzz; - tmp0 = vec_mergeh( mat.getCol0().get128(), mat.getCol2().get128() ); - tmp1 = vec_mergel( mat.getCol0().get128(), mat.getCol2().get128() ); - xxxx = vec_splat( vec.get128(), 0 ); - mcol0 = vec_mergeh( tmp0, mat.getCol1().get128() ); - mcol1 = vec_perm( tmp0, mat.getCol1().get128(), _VECTORMATH_PERM_ZBWX ); - mcol2 = vec_perm( tmp1, mat.getCol1().get128(), _VECTORMATH_PERM_XCYX ); - yyyy = vec_splat( vec.get128(), 1 ); - res = vec_madd( mcol0, xxxx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zzzz = vec_splat( vec.get128(), 2 ); - res = vec_madd( mcol1, yyyy, res ); - res = vec_madd( mcol2, zzzz, res ); - return Vector3( res ); -} - -inline const Matrix3 crossMatrix( Vector3 vec ) -{ - vec_float4 neg, res0, res1, res2; - neg = negatef4( vec.get128() ); - res0 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_XZBX ); - res1 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_CXXX ); - res2 = vec_perm( vec.get128(), neg, _VECTORMATH_PERM_YAXX ); - res0 = vec_andc( res0, (vec_float4)_VECTORMATH_MASK_0xF000 ); - res1 = vec_andc( res1, (vec_float4)_VECTORMATH_MASK_0x0F00 ); - res2 = vec_andc( res2, (vec_float4)_VECTORMATH_MASK_0x00F0 ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h deleted file mode 100644 index 7868cfd4b..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/mat_soa.h +++ /dev/null @@ -1,1744 +0,0 @@ -/* - 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_MAT_SOA_CPP_H -#define _VECTORMATH_MAT_SOA_CPP_H - -namespace Vectormath { -namespace Soa { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( vec_float4 scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = vec_add( qx, qx ); - qy2 = vec_add( qy, qy ); - qz2 = vec_add( qz, qz ); - qxqx2 = vec_madd( qx, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqy2 = vec_madd( qx, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqz2 = vec_madd( qx, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qxqw2 = vec_madd( qw, qx2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqy2 = vec_madd( qy, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqz2 = vec_madd( qy, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qyqw2 = vec_madd( qw, qy2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qzqz2 = vec_madd( qz, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qzqw2 = vec_madd( qw, qz2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol0 = Vector3( vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qyqy2 ), qzqz2 ), vec_add( qxqy2, qzqw2 ), vec_sub( qxqz2, qyqw2 ) ); - mCol1 = Vector3( vec_sub( qxqy2, qzqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qzqz2 ), vec_add( qyqz2, qxqw2 ) ); - mCol2 = Vector3( vec_add( qxqz2, qyqw2 ), vec_sub( qyqz2, qxqw2 ), vec_sub( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), qxqx2 ), qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3::Matrix3( const Aos::Matrix3 & mat ) -{ - mCol0 = Vector3( mat.getCol0() ); - mCol1 = Vector3( mat.getCol1() ); - mCol2 = Vector3( mat.getCol2() ); -} - -inline Matrix3::Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ) -{ - mCol0 = Vector3( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); - mCol1 = Vector3( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); - mCol2 = Vector3( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); -} - -inline void Matrix3::get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const -{ - Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol0( tmpV3_0 ); - result1.setCol0( tmpV3_1 ); - result2.setCol0( tmpV3_2 ); - result3.setCol0( tmpV3_3 ); - mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol1( tmpV3_0 ); - result1.setCol1( tmpV3_1 ); - result2.setCol1( tmpV3_2 ); - result3.setCol1( tmpV3_3 ); - mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol2( tmpV3_0 ); - result1.setCol2( tmpV3_1 ); - result2.setCol2( tmpV3_2 ); - result3.setCol2( tmpV3_3 ); -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, vec_float4 val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - vec_float4 detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( vec_madd( tmp0.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - Vector3( vec_madd( tmp0.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - Vector3( vec_madd( tmp0.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline vec_float4 determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( vec_float4 scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3::xAxis( ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ), - Vector3::yAxis( ), - Vector3( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - return Matrix3( - Vector3( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ), - Vector3( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - Vector3( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - return Matrix3( - Vector3( vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ), - Vector3( vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ), - Vector3( vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - Aos::Matrix3 mat0, mat1, mat2, mat3; - mat.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( vec_float4 scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol3 = Vector4( mat.getCol3(), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol3 = Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol1 = Vector4( mat.getCol1(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol2 = Vector4( mat.getCol2(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - mCol3 = Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline Matrix4::Matrix4( const Aos::Matrix4 & mat ) -{ - mCol0 = Vector4( mat.getCol0() ); - mCol1 = Vector4( mat.getCol1() ); - mCol2 = Vector4( mat.getCol2() ); - mCol3 = Vector4( mat.getCol3() ); -} - -inline Matrix4::Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ) -{ - mCol0 = Vector4( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); - mCol1 = Vector4( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); - mCol2 = Vector4( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); - mCol3 = Vector4( mat0.getCol3(), mat1.getCol3(), mat2.getCol3(), mat3.getCol3() ); -} - -inline void Matrix4::get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const -{ - Aos::Vector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - mCol0.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol0( tmpV4_0 ); - result1.setCol0( tmpV4_1 ); - result2.setCol0( tmpV4_2 ); - result3.setCol0( tmpV4_3 ); - mCol1.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol1( tmpV4_0 ); - result1.setCol1( tmpV4_1 ); - result2.setCol1( tmpV4_2 ); - result3.setCol1( tmpV4_3 ); - mCol2.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol2( tmpV4_0 ); - result1.setCol2( tmpV4_1 ); - result2.setCol2( tmpV4_2 ); - result3.setCol2( tmpV4_3 ); - mCol3.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol3( tmpV4_0 ); - result1.setCol3( tmpV4_1 ); - result2.setCol3( tmpV4_2 ); - result3.setCol3( tmpV4_3 ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, vec_float4 val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res0.setX( vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - res0.setY( vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - res0.setZ( vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - res0.setW( vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - detInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_add( vec_add( vec_add( vec_madd( mA, res0.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, res0.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, res0.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, res0.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - res1.setX( vec_madd( mI, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res1.setY( vec_madd( mM, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res1.setZ( vec_madd( mA, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res1.setW( vec_madd( mE, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res3.setX( vec_madd( mI, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res3.setY( vec_madd( mM, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res3.setZ( vec_madd( mA, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res3.setW( vec_madd( mE, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res2.setX( vec_madd( mI, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res2.setY( vec_madd( mM, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res2.setZ( vec_madd( mA, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res2.setW( vec_madd( mE, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp0 = vec_sub( vec_madd( mI, mB, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mJ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mM, mF, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mN, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mI, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mM, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mI, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mA, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mM, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - res2.setX( vec_add( vec_sub( vec_madd( mL, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getX() ) ); - res2.setY( vec_add( vec_sub( vec_madd( mP, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getY() ) ); - res2.setZ( vec_sub( vec_sub( vec_madd( mB, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mD, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getZ() ) ); - res2.setW( vec_sub( vec_sub( vec_madd( mF, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mH, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res2.getW() ) ); - res3.setX( vec_add( vec_sub( vec_madd( mJ, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mK, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getX() ) ); - res3.setY( vec_add( vec_sub( vec_madd( mN, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mO, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getY() ) ); - res3.setZ( vec_sub( vec_sub( vec_madd( mC, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getZ() ) ); - res3.setW( vec_sub( vec_sub( vec_madd( mG, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res3.getW() ) ); - res1.setX( vec_sub( vec_sub( vec_madd( mK, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getX() ) ); - res1.setY( vec_sub( vec_sub( vec_madd( mO, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getY() ) ); - res1.setZ( vec_add( vec_sub( vec_madd( mD, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getZ() ) ); - res1.setW( vec_add( vec_sub( vec_madd( mH, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline vec_float4 determinant( const Matrix4 & mat ) -{ - vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = vec_sub( vec_madd( mK, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp1 = vec_sub( vec_madd( mO, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp2 = vec_sub( vec_madd( mB, mK, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mJ, mC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp3 = vec_sub( vec_madd( mF, mO, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mN, mG, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp4 = vec_sub( vec_madd( mJ, mD, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mB, mL, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmp5 = vec_sub( vec_madd( mN, mH, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mF, mP, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dx = vec_sub( vec_sub( vec_madd( mJ, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mL, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mK, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dy = vec_sub( vec_sub( vec_madd( mN, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mP, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mO, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dz = vec_sub( vec_add( vec_madd( mD, tmp3, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mC, tmp5, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mB, tmp1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - dw = vec_sub( vec_add( vec_madd( mH, tmp2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mG, tmp4, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mF, tmp0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return vec_add( vec_add( vec_add( vec_madd( mA, dx, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mE, dy, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mI, dz, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mM, dw, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( vec_float4 scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getX(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getY(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getZ(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol3.getW(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getX() ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getY() ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getZ() ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getW(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getW(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getW(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getW() ) - ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4::xAxis( ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::yAxis( ), - Vector4( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - return Matrix4( - Vector4( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = vec_madd( x, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - yz = vec_madd( y, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - zx = vec_madd( z, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - oneMinusC = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), c ); - return Matrix4( - Vector4( vec_add( vec_madd( vec_madd( x, x, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_sub( vec_madd( xy, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( z, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( y, y, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), vec_add( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_add( vec_madd( zx, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( y, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( yz, oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( x, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( vec_madd( z, z, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), oneMinusC, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 f, rangeInv; - f = tanf4( vec_sub( ((vec_float4){_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2,_VECTORMATH_PI_OVER_2}), vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), fovyRadians, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); - rangeInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - return Matrix4( - Vector4( divf4( f, aspect ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), f, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_add( zNear, zFar ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( vec_madd( zNear, zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), rangeInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Matrix4 Matrix4::frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = vec_add( right, left ); - sum_tb = vec_add( top, bottom ); - sum_nf = vec_add( zNear, zFar ); - inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); - inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); - inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - n2 = vec_add( zNear, zNear ); - return Matrix4( - Vector4( vec_madd( n2, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( n2, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_madd( sum_rl, inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_tb, inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){-1.0f,-1.0f,-1.0f,-1.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_madd( vec_madd( n2, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), zFar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Matrix4 Matrix4::orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = vec_add( right, left ); - sum_tb = vec_add( top, bottom ); - sum_nf = vec_add( zNear, zFar ); - inv_rl = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( right, left ) ); - inv_tb = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( top, bottom ) ); - inv_nf = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec_sub( zNear, zFar ) ); - return Matrix4( - Vector4( vec_add( inv_rl, inv_rl ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_tb, inv_tb ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec_add( inv_nf, inv_nf ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector4( vec_madd( negatef4( sum_rl ), inv_rl, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( negatef4( sum_tb ), inv_tb, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sum_nf, inv_nf, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - Aos::Matrix4 mat0, mat1, mat2, mat3; - mat.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( vec_float4 scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Aos::Transform3 & tfrm ) -{ - mCol0 = Vector3( tfrm.getCol0() ); - mCol1 = Vector3( tfrm.getCol1() ); - mCol2 = Vector3( tfrm.getCol2() ); - mCol3 = Vector3( tfrm.getCol3() ); -} - -inline Transform3::Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ) -{ - mCol0 = Vector3( tfrm0.getCol0(), tfrm1.getCol0(), tfrm2.getCol0(), tfrm3.getCol0() ); - mCol1 = Vector3( tfrm0.getCol1(), tfrm1.getCol1(), tfrm2.getCol1(), tfrm3.getCol1() ); - mCol2 = Vector3( tfrm0.getCol2(), tfrm1.getCol2(), tfrm2.getCol2(), tfrm3.getCol2() ); - mCol3 = Vector3( tfrm0.getCol3(), tfrm1.getCol3(), tfrm2.getCol3(), tfrm3.getCol3() ); -} - -inline void Transform3::get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const -{ - Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol0( tmpV3_0 ); - result1.setCol0( tmpV3_1 ); - result2.setCol0( tmpV3_2 ); - result3.setCol0( tmpV3_3 ); - mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol1( tmpV3_0 ); - result1.setCol1( tmpV3_1 ); - result2.setCol1( tmpV3_2 ); - result3.setCol1( tmpV3_3 ); - mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol2( tmpV3_0 ); - result1.setCol2( tmpV3_1 ); - result2.setCol2( tmpV3_2 ); - result3.setCol2( tmpV3_3 ); - mCol3.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol3( tmpV3_0 ); - result1.setCol3( tmpV3_1 ); - result2.setCol3( tmpV3_2 ); - result3.setCol3( tmpV3_3 ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, vec_float4 val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - vec_float4 detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( vec_madd( tmp0.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getX(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - inv1 = Vector3( vec_madd( tmp0.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getY(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - inv2 = Vector3( vec_madd( tmp0.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp1.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmp2.getZ(), detinv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Vector3 inv0, inv1, inv2; - inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); - inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); - inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - return Vector3( - vec_add( vec_add( vec_madd( mCol0.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( mCol0.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - vec_add( vec_add( vec_add( vec_madd( mCol0.getX(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getX(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getX(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getX() ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getY(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getY(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getY(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getY() ), - vec_add( vec_add( vec_add( vec_madd( mCol0.getZ(), pnt.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mCol1.getZ(), pnt.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mCol2.getZ(), pnt.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3::xAxis( ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c, s ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ), c ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Transform3 Transform3::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3( c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), negatef4( s ) ), - Vector3::yAxis( ), - Vector3( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Transform3 Transform3::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3( c, s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( negatef4( s ), c, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3::zAxis( ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = vec_madd( cZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmp1 = vec_madd( sZ, sY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - return Transform3( - Vector3( vec_madd( cZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), negatef4( sY ) ), - Vector3( vec_sub( vec_madd( tmp0, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_add( vec_madd( tmp1, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - Vector3( vec_add( vec_madd( tmp0, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( sZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_sub( vec_madd( tmp1, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( cZ, sX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( cY, cX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Transform3 Transform3::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), scaleVec.getZ() ), - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - Aos::Transform3 mat0, mat1, mat2, mat3; - tfrm.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - vec_uint4 negTrace, ZgtX, ZgtY, YgtX; - vec_uint4 largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = vec_add( vec_add( xx, yy ), zz ); - - negTrace = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), trace ); - ZgtX = (vec_uint4)vec_cmpgt( zz, xx ); - ZgtY = (vec_uint4)vec_cmpgt( zz, yy ); - YgtX = (vec_uint4)vec_cmpgt( yy, xx ); - largestXorY = vec_andc( negTrace, vec_and( ZgtX, ZgtY ) ); - largestYorZ = vec_and( negTrace, vec_or( YgtX, ZgtX ) ); - largestZorX = vec_andc( negTrace, vec_andc( YgtX, ZgtY ) ); - - zz = vec_sel( zz, negatef4(zz), largestXorY ); - xy = vec_sel( xy, negatef4(xy), largestXorY ); - xx = vec_sel( xx, negatef4(xx), largestYorZ ); - yz = vec_sel( yz, negatef4(yz), largestYorZ ); - yy = vec_sel( yy, negatef4(yy), largestZorX ); - zx = vec_sel( zx, negatef4(zx), largestZorX ); - - radicand = vec_add( vec_add( vec_add( xx, yy ), zz ), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - scale = vec_madd( ((vec_float4){0.5f,0.5f,0.5f,0.5f}), divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( radicand ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - - tmpx = vec_madd( vec_sub( zy, yz ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpy = vec_madd( vec_sub( xz, zx ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpz = vec_madd( vec_sub( yx, xy ), scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - tmpw = vec_madd( radicand, scale, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - qx = vec_sel( qx, tmpw, largestXorY ); - qy = vec_sel( qy, tmpz, largestXorY ); - qz = vec_sel( qz, tmpy, largestXorY ); - qw = vec_sel( qw, tmpx, largestXorY ); - tmpx = qx; - tmpz = qz; - qx = vec_sel( qx, qy, largestYorZ ); - qy = vec_sel( qy, tmpx, largestYorZ ); - qz = vec_sel( qz, qw, largestYorZ ); - qw = vec_sel( qw, tmpz, largestYorZ ); - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - vec_add( vec_add( vec_madd( vec.getX(), mat.getCol0().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol0().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol0().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( vec.getX(), mat.getCol1().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol1().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol1().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_add( vec_madd( vec.getX(), mat.getCol2().getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec.getY(), mat.getCol2().getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( vec.getZ(), mat.getCol2().getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec.getZ(), negatef4( vec.getY() ) ), - Vector3( negatef4( vec.getZ() ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), vec.getX() ), - Vector3( vec.getY(), negatef4( vec.getX() ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h deleted file mode 100644 index 196a48d98..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_aos.h +++ /dev/null @@ -1,536 +0,0 @@ -/* - 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 { - -inline Quat::Quat( float _x, float _y, float _z, float _w ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & - __builtin_constant_p(_z) & __builtin_constant_p(_w)) { - mVec128 = (vec_float4){_x, _y, _z, _w}; - } else { - float *pf = (float *)&mVec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - pf[3] = _w; - } -} - -inline Quat::Quat( floatInVec _x, floatInVec _y, floatInVec _z, floatInVec _w ) -{ - vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); - vec_float4 yw = vec_mergeh( _y.get128(), _w.get128() ); - mVec128 = vec_mergeh( xz, yw ); -} - -inline Quat::Quat( Vector3 xyz, float _w ) -{ - mVec128 = xyz.get128(); - _vmathVfSetElement(mVec128, _w, 3); -} - -inline Quat::Quat( Vector3 xyz, floatInVec _w ) -{ - mVec128 = xyz.get128(); - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); -} - -inline Quat::Quat( Vector4 vec ) -{ - mVec128 = vec.get128(); -} - -inline Quat::Quat( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -inline Quat::Quat( floatInVec scalar ) -{ - mVec128 = scalar.get128(); -} - -inline Quat::Quat( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Quat Quat::identity( ) -{ - return Quat( _VECTORMATH_UNIT_0001 ); -} - -inline const Quat lerp( float t, Quat quat0, Quat quat1 ) -{ - return lerp( floatInVec(t), quat0, quat1 ); -} - -inline const Quat lerp( floatInVec t, Quat quat0, Quat quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ) -{ - return slerp( floatInVec(t), unitQuat0, unitQuat1 ); -} - -inline const Quat slerp( floatInVec t, Quat unitQuat0, Quat unitQuat1 ) -{ - Quat start; - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), cosAngle ); - cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start = Quat( vec_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( 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_madd( unitQuat1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); -} - -inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ) -{ - return squad( floatInVec(t), unitQuat0, unitQuat1, unitQuat2, unitQuat3 ); -} - -inline const Quat squad( floatInVec t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ) -{ - Quat tmp0, tmp1; - tmp0 = slerp( t, unitQuat0, unitQuat3 ); - tmp1 = slerp( t, unitQuat1, unitQuat2 ); - return slerp( ( ( floatInVec(2.0f) * t ) * ( floatInVec(1.0f) - t ) ), tmp0, tmp1 ); -} - -inline vec_float4 Quat::get128( ) const -{ - return mVec128; -} - -inline Quat & Quat::operator =( Quat quat ) -{ - mVec128 = quat.mVec128; - return *this; -} - -inline Quat & Quat::setXYZ( Vector3 vec ) -{ - mVec128 = vec_sel( vec.get128(), mVec128, _VECTORMATH_MASK_0x000F ); - return *this; -} - -inline const Vector3 Quat::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -inline Quat & Quat::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -inline Quat & Quat::setX( floatInVec _x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -inline const floatInVec Quat::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -inline Quat & Quat::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -inline Quat & Quat::setY( floatInVec _y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -inline const floatInVec Quat::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -inline Quat & Quat::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -inline Quat & Quat::setZ( floatInVec _z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -inline const floatInVec Quat::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -inline Quat & Quat::setW( float _w ) -{ - _vmathVfSetElement(mVec128, _w, 3); - return *this; -} - -inline Quat & Quat::setW( floatInVec _w ) -{ - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); - return *this; -} - -inline const floatInVec Quat::getW( ) const -{ - return floatInVec( mVec128, 3 ); -} - -inline Quat & Quat::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -inline Quat & Quat::setElem( int idx, floatInVec value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -inline const floatInVec Quat::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline VecIdx Quat::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline const floatInVec Quat::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline const Quat Quat::operator +( Quat quat ) const -{ - return Quat( vec_add( mVec128, quat.mVec128 ) ); -} - -inline const Quat Quat::operator -( Quat quat ) const -{ - return Quat( vec_sub( mVec128, quat.mVec128 ) ); -} - -inline const Quat Quat::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -inline const Quat Quat::operator *( floatInVec scalar ) const -{ - return Quat( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline Quat & Quat::operator +=( Quat quat ) -{ - *this = *this + quat; - return *this; -} - -inline Quat & Quat::operator -=( Quat quat ) -{ - *this = *this - quat; - return *this; -} - -inline Quat & Quat::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline Quat & Quat::operator *=( floatInVec scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Quat Quat::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -inline const Quat Quat::operator /( floatInVec scalar ) const -{ - return Quat( divf4( mVec128, scalar.get128() ) ); -} - -inline Quat & Quat::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline Quat & Quat::operator /=( floatInVec scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Quat Quat::operator -( ) const -{ - return Quat( negatef4( mVec128 ) ); -} - -inline const Quat operator *( float scalar, Quat quat ) -{ - return floatInVec(scalar) * quat; -} - -inline const Quat operator *( floatInVec scalar, Quat quat ) -{ - return quat * scalar; -} - -inline const floatInVec dot( Quat quat0, Quat quat1 ) -{ - return floatInVec( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); -} - -inline const floatInVec norm( Quat quat ) -{ - return floatInVec( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); -} - -inline const floatInVec length( Quat quat ) -{ - return floatInVec( sqrtf4(_vmathVfDot4( quat.get128(), quat.get128() )), 0 ); -} - -inline const Quat normalize( Quat quat ) -{ - vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() ); - return Quat( vec_madd( quat.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 ) -{ - Vector3 crossVec; - vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - cosAngle = vec_splat( cosAngle, 0 ); - cosAngleX2Plus2 = vec_madd( cosAngle, ((vec_float4){2.0f,2.0f,2.0f,2.0f}), ((vec_float4){2.0f,2.0f,2.0f,2.0f}) ); - recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); - cosHalfAngleX2 = vec_madd( recipCosHalfAngleX2, cosAngleX2Plus2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - crossVec = cross( unitVec0, unitVec1 ); - res = vec_madd( crossVec.get128(), recipCosHalfAngleX2, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_sel( res, vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), _VECTORMATH_MASK_0x000F ); - return Quat( res ); -} - -inline const Quat Quat::rotation( float radians, Vector3 unitVec ) -{ - return rotation( floatInVec(radians), unitVec ); -} - -inline const Quat Quat::rotation( floatInVec radians, Vector3 unitVec ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( vec_madd( unitVec.get128(), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), c, _VECTORMATH_MASK_0x000F ); - return Quat( res ); -} - -inline const Quat Quat::rotationX( float radians ) -{ - return rotationX( floatInVec(radians) ); -} - -inline const Quat Quat::rotationX( floatInVec radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0xF000 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - return Quat( res ); -} - -inline const Quat Quat::rotationY( float radians ) -{ - return rotationY( floatInVec(radians) ); -} - -inline const Quat Quat::rotationY( floatInVec radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x0F00 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - return Quat( res ); -} - -inline const Quat Quat::rotationZ( float radians ) -{ - return rotationZ( floatInVec(radians) ); -} - -inline const Quat Quat::rotationZ( floatInVec radians ) -{ - vec_float4 s, c, angle, res; - angle = vec_madd( radians.get128(), ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - res = vec_sel( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, _VECTORMATH_MASK_0x00F0 ); - res = vec_sel( res, c, _VECTORMATH_MASK_0x000F ); - return Quat( res ); -} - -inline const Quat Quat::operator *( Quat quat ) const -{ - vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; - vec_float4 product, l_wxyz, r_wxyz, xy, qw; - ldata = mVec128; - rdata = quat.mVec128; - tmp0 = vec_perm( ldata, ldata, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( rdata, rdata, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( ldata, ldata, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( rdata, rdata, _VECTORMATH_PERM_YZXW ); - qv = vec_madd( vec_splat( ldata, 3 ), rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qv = vec_madd( vec_splat( rdata, 3 ), ldata, qv ); - qv = vec_madd( tmp0, tmp1, qv ); - qv = vec_nmsub( tmp2, tmp3, qv ); - product = vec_madd( ldata, rdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - 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 ) ); - return Quat( vec_sel( qv, qw, _VECTORMATH_MASK_0x000F ) ); -} - -inline Quat & Quat::operator *=( Quat quat ) -{ - *this = *this * quat; - return *this; -} - -inline const Vector3 rotate( Quat quat, Vector3 vec ) -{ - vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; - qdata = quat.get128(); - vdata = vec.get128(); - tmp0 = vec_perm( qdata, qdata, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( vdata, vdata, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( qdata, qdata, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( vdata, vdata, _VECTORMATH_PERM_YZXW ); - wwww = vec_splat( qdata, 3 ); - qv = vec_madd( wwww, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qv = vec_madd( tmp0, tmp1, qv ); - qv = vec_nmsub( tmp2, tmp3, qv ); - product = vec_madd( qdata, vdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - qw = vec_madd( vec_sld( qdata, qdata, 4 ), vec_sld( vdata, vdata, 4 ), product ); - qw = vec_add( vec_sld( product, product, 8 ), qw ); - tmp1 = vec_perm( qv, qv, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( qv, qv, _VECTORMATH_PERM_YZXW ); - res = vec_madd( vec_splat( qw, 0 ), qdata, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - res = vec_madd( wwww, qv, res ); - res = vec_madd( tmp0, tmp1, res ); - res = vec_nmsub( tmp2, tmp3, res ); - return Vector3( res ); -} - -inline const Quat conj( Quat quat ) -{ - return Quat( vec_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) ); -} - -inline const Quat select( Quat quat0, Quat quat1, bool select1 ) -{ - return select( quat0, quat1, boolInVec(select1) ); -} - -inline const Quat select( Quat quat0, Quat quat1, boolInVec select1 ) -{ - return Quat( vec_sel( quat0.get128(), quat1.get128(), select1.get128() ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Quat quat ) -{ - union { vec_float4 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] ); -} - -inline void print( Quat quat, const char * name ) -{ - union { vec_float4 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 diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h deleted file mode 100644 index fb83e8121..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/quat_soa.h +++ /dev/null @@ -1,479 +0,0 @@ -/* - 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_SOA_CPP_H -#define _VECTORMATH_QUAT_SOA_CPP_H -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Soa { - -inline Quat::Quat( const Quat & quat ) -{ - mX = quat.mX; - mY = quat.mY; - mZ = quat.mZ; - mW = quat.mW; -} - -inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Quat::Quat( const Vector3 & xyz, vec_float4 _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( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline Quat::Quat( Aos::Quat quat ) -{ - vec_float4 vec128 = quat.get128(); - mX = vec_splat( vec128, 0 ); - mY = vec_splat( vec128, 1 ); - mZ = vec_splat( vec128, 2 ); - mW = vec_splat( vec128, 3 ); -} - -inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( quat0.get128(), quat2.get128() ); - tmp1 = vec_mergeh( quat1.get128(), quat3.get128() ); - tmp2 = vec_mergel( quat0.get128(), quat2.get128() ); - tmp3 = vec_mergel( quat1.get128(), quat3.get128() ); - mX = vec_mergeh( tmp0, tmp1 ); - mY = vec_mergel( tmp0, tmp1 ); - mZ = vec_mergeh( tmp2, tmp3 ); - mW = vec_mergel( tmp2, tmp3 ); -} - -inline const Quat Quat::identity( ) -{ - return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ) -{ - Quat start; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitQuat0, unitQuat1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){0.0f,0.0f,0.0f,0.0f}, cosAngle ); - cosAngle = vec_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start.setX( vec_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) ); - start.setY( vec_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) ); - start.setZ( vec_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) ); - start.setW( vec_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); -} - -inline const Quat squad( vec_float4 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( vec_madd( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), t, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), tmp0, tmp1 ); -} - -inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( mX, mZ ); - tmp1 = vec_mergeh( mY, mW ); - tmp2 = vec_mergel( mX, mZ ); - tmp3 = vec_mergel( mY, mW ); - result0 = Aos::Quat( vec_mergeh( tmp0, tmp1 ) ); - result1 = Aos::Quat( vec_mergel( tmp0, tmp1 ) ); - result2 = Aos::Quat( vec_mergeh( tmp2, tmp3 ) ); - result3 = Aos::Quat( vec_mergel( tmp2, tmp3 ) ); -} - -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( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Quat::getX( ) const -{ - return mX; -} - -inline Quat & Quat::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Quat::getY( ) const -{ - return mY; -} - -inline Quat & Quat::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Quat::getZ( ) const -{ - return mZ; -} - -inline Quat & Quat::setW( vec_float4 _w ) -{ - mW = _w; - return *this; -} - -inline vec_float4 Quat::getW( ) const -{ - return mW; -} - -inline Quat & Quat::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Quat::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Quat::vec_float4_t & Quat::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Quat::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Quat Quat::operator +( const Quat & quat ) const -{ - return Quat( - vec_add( mX, quat.mX ), - vec_add( mY, quat.mY ), - vec_add( mZ, quat.mZ ), - vec_add( mW, quat.mW ) - ); -} - -inline const Quat Quat::operator -( const Quat & quat ) const -{ - return Quat( - vec_sub( mX, quat.mX ), - vec_sub( mY, quat.mY ), - vec_sub( mZ, quat.mZ ), - vec_sub( mW, quat.mW ) - ); -} - -inline const Quat Quat::operator *( vec_float4 scalar ) const -{ - return Quat( - vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -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 *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Quat Quat::operator /( vec_float4 scalar ) const -{ - return Quat( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ), - divf4( mW, scalar ) - ); -} - -inline Quat & Quat::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Quat Quat::operator -( ) const -{ - return Quat( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ), - negatef4( mW ) - ); -} - -inline const Quat operator *( vec_float4 scalar, const Quat & quat ) -{ - return quat * scalar; -} - -inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ) -{ - vec_float4 result; - result = vec_madd( quat0.getX(), quat1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( quat0.getY(), quat1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat0.getZ(), quat1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat0.getW(), quat1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 norm( const Quat & quat ) -{ - vec_float4 result; - result = vec_madd( quat.getX(), quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( quat.getY(), quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat.getZ(), quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( quat.getW(), quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 length( const Quat & quat ) -{ - return sqrtf4( norm( quat ) ); -} - -inline const Quat normalize( const Quat & quat ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = norm( quat ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - return Quat( - vec_madd( quat.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( quat.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( quat.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( quat.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf4( vec_madd( ((vec_float4){2.0f,2.0f,2.0f,2.0f}), vec_add( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), dot( unitVec0, unitVec1 ) ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - recipCosHalfAngleX2 = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), cosHalfAngleX2 ); - return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), vec_madd( cosHalfAngleX2, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - return Quat( ( unitVec * s ), c ); -} - -inline const Quat Quat::rotationX( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - return Quat( s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); -} - -inline const Quat Quat::rotationY( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), c ); -} - -inline const Quat Quat::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = vec_madd( radians, ((vec_float4){0.5f,0.5f,0.5f,0.5f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sincosf4( angle, &s, &c ); - return Quat( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), s, c ); -} - -inline const Quat Quat::operator *( const Quat & quat ) const -{ - return Quat( - vec_sub( vec_add( vec_add( vec_madd( mW, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_sub( vec_add( vec_add( vec_madd( mW, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mY, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_sub( vec_add( vec_add( vec_madd( mW, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mZ, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mX, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_sub( vec_sub( vec_sub( vec_madd( mW, quat.mW, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( mX, quat.mX, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mY, quat.mY, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( mZ, quat.mZ, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline Quat & Quat::operator *=( const Quat & quat ) -{ - *this = *this * quat; - return *this; -} - -inline const Vector3 rotate( const Quat & quat, const Vector3 & vec ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = vec_sub( vec_add( vec_madd( quat.getW(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpY = vec_sub( vec_add( vec_madd( quat.getW(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getZ(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getX(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpZ = vec_sub( vec_add( vec_madd( quat.getW(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getX(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getY(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - tmpW = vec_add( vec_add( vec_madd( quat.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( quat.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( quat.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return Vector3( - vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpX, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpY, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpZ, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_add( vec_sub( vec_add( vec_madd( tmpW, quat.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( tmpZ, quat.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpX, quat.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), vec_madd( tmpY, quat.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Quat conj( const Quat & quat ) -{ - return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() ); -} - -inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ) -{ - return Quat( - vec_sel( quat0.getX(), quat1.getX(), select1 ), - vec_sel( quat0.getY(), quat1.getY(), select1 ), - vec_sel( quat0.getZ(), quat1.getZ(), select1 ), - vec_sel( quat0.getW(), quat1.getW(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Quat & quat ) -{ - Aos::Quat vec0, vec1, vec2, vec3; - quat.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Quat & quat, const char * name ) -{ - Aos::Quat vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - quat.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h deleted file mode 100644 index dc1f9849b..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_aos.h +++ /dev/null @@ -1,1492 +0,0 @@ -/* - 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H -//----------------------------------------------------------------------------- -// Constants -// for permutes words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A } -#define _VECTORMATH_PERM_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_X, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Y, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B } -#define _VECTORMATH_PERM_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_A, _VECTORMATH_PERM_B, _VECTORMATH_PERM_C } -#define _VECTORMATH_PERM_XYAW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A, _VECTORMATH_PERM_W } -#define _VECTORMATH_PERM_XAZW (vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_A, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_W } -#define _VECTORMATH_MASK_0xF000 (vec_uint4){ 0xffffffff, 0, 0, 0 } -#define _VECTORMATH_MASK_0x0F00 (vec_uint4){ 0, 0xffffffff, 0, 0 } -#define _VECTORMATH_MASK_0x00F0 (vec_uint4){ 0, 0, 0xffffffff, 0 } -#define _VECTORMATH_MASK_0x000F (vec_uint4){ 0, 0, 0, 0xffffffff } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); - return vec_madd( vec_sld( vec0, vec0, 8 ), vec_sld( vec1, vec1, 8 ), result ); -} - -static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0, vec1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_madd( vec_sld( vec0, vec0, 4 ), vec_sld( vec1, vec1, 4 ), result ); - return vec_add( vec_sld( result, result, 8 ), result ); -} - -static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = vec_perm( vec0, vec0, _VECTORMATH_PERM_YZXW ); - tmp1 = vec_perm( vec1, vec1, _VECTORMATH_PERM_ZXYW ); - tmp2 = vec_perm( vec0, vec0, _VECTORMATH_PERM_ZXYW ); - tmp3 = vec_perm( vec1, vec1, _VECTORMATH_PERM_YZXW ); - result = vec_madd( tmp0, tmp1, (vec_float4){0.0f,0.0f,0.0f,0.0f} ); - result = vec_nmsub( tmp2, tmp3, result ); - return result; -} - -static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) -{ - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = (vec_uint4){0x00007c00u,0x00007c00u,0x00007c00u,0x00007c00u}; - const vec_uint4 mergeMant = (vec_uint4){0x000003ffu,0x000003ffu,0x000003ffu,0x000003ffu}; - const vec_uint4 mergeSign = (vec_uint4){0x00008000u,0x00008000u,0x00008000u,0x00008000u}; - - sign = vec_sr((vec_uint4)v, (vec_uint4){16,16,16,16}); - mant = vec_sr((vec_uint4)v, (vec_uint4){13,13,13,13}); - bexp = vec_and(vec_sr((vec_int4)v, (vec_uint4){23,23,23,23}), (vec_int4){0xff,0xff,0xff,0xff}); - - notZero = (vec_uint4)vec_cmpgt(bexp, (vec_int4){112,112,112,112}); - isInf = (vec_uint4)vec_cmpgt(bexp, (vec_int4){142,142,142,142}); - - bexp = vec_add(bexp, (vec_int4){-112,-112,-112,-112}); - bexp = vec_sl(bexp, (vec_uint4){10,10,10,10}); - - hfloat = vec_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = vec_sel((vec_uint4){0,0,0,0}, hfloat, notZero); - hfloat = vec_sel(hfloat, hfloatInf, isInf); - hfloat = vec_sel(hfloat, sign, mergeSign); - - return hfloat; -} - -static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) -{ - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)vec_perm(hfloat_u, hfloat_v, pack); -} - -#ifndef __GNUC__ -#define __builtin_constant_p(x) 0 -#endif - -static inline vec_float4 _vmathVfInsert(vec_float4 dst, vec_float4 src, int slot) -{ -#ifdef __GNUC__ - if (__builtin_constant_p(slot)) { - dst = vec_sld(dst, dst, slot<<2); - dst = vec_sld(dst, src, 4); - if (slot != 3) dst = vec_sld(dst, dst, (3-slot)<<2); - return dst; - } else -#endif - { - vec_uchar16 shiftpattern = vec_lvsr( 0, (float *)(size_t)(slot<<2) ); - vec_uint4 selectmask = (vec_uint4)vec_perm( (vec_uint4){0,0,0,0}, _VECTORMATH_MASK_0xF000, shiftpattern ); - return vec_sel( dst, src, selectmask ); - } -} - -#define _vmathVfGetElement(vec, slot) ((float *)&(vec))[slot] -#ifdef _VECTORMATH_SET_CONSTS_IN_MEM -#define _vmathVfSetElement(vec, scalar, slot) ((float *)&(vec))[slot] = scalar -#else -#define _vmathVfSetElement(vec, scalar, slot) \ -{ \ - if (__builtin_constant_p(scalar)) { \ - (vec) = _vmathVfInsert(vec, (vec_float4){scalar, scalar, scalar, scalar}, slot); \ - } else { \ - ((float *)&(vec))[slot] = scalar; \ - } \ -} -#endif - -static inline vec_float4 _vmathVfSplatScalar(float scalar) -{ - vec_float4 result; - if (__builtin_constant_p(scalar)) { - result = (vec_float4){scalar, scalar, scalar, scalar}; - } else { - result = vec_ld(0, &scalar); - result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); - } - return result; -} - -static inline vec_uint4 _vmathVuiSplatScalar(unsigned int scalar) -{ - vec_uint4 result; - if (__builtin_constant_p(scalar)) { - result = (vec_uint4){scalar, scalar, scalar, scalar}; - } else { - result = vec_ld(0, &scalar); - result = vec_splat(vec_perm(result, result, vec_lvsl(0, &scalar)), 0); - } - return result; -} - -#endif - -namespace Vectormath { -namespace Aos { - -#ifdef _VECTORMATH_NO_SCALAR_CAST -inline VecIdx::operator floatInVec() const -{ - return floatInVec(ref, i); -} - -inline float VecIdx::getAsFloat() const -#else -inline VecIdx::operator float() const -#endif -{ - return _vmathVfGetElement(ref, i); -} - -inline float VecIdx::operator =( float scalar ) -{ - _vmathVfSetElement(ref, scalar, i); - return scalar; -} - -inline floatInVec VecIdx::operator =( floatInVec scalar ) -{ - ref = _vmathVfInsert(ref, scalar.get128(), i); - return scalar; -} - -inline floatInVec VecIdx::operator =( const VecIdx& scalar ) -{ - return *this = floatInVec(scalar.ref, scalar.i); -} - -inline floatInVec VecIdx::operator *=( float scalar ) -{ - return *this *= floatInVec(scalar); -} - -inline floatInVec VecIdx::operator *=( floatInVec scalar ) -{ - return *this = floatInVec(ref, i) * scalar; -} - -inline floatInVec VecIdx::operator /=( float scalar ) -{ - return *this /= floatInVec(scalar); -} - -inline floatInVec VecIdx::operator /=( floatInVec scalar ) -{ - return *this = floatInVec(ref, i) / scalar; -} - -inline floatInVec VecIdx::operator +=( float scalar ) -{ - return *this += floatInVec(scalar); -} - -inline floatInVec VecIdx::operator +=( floatInVec scalar ) -{ - return *this = floatInVec(ref, i) + scalar; -} - -inline floatInVec VecIdx::operator -=( float scalar ) -{ - return *this -= floatInVec(scalar); -} - -inline floatInVec VecIdx::operator -=( floatInVec scalar ) -{ - return *this = floatInVec(ref, i) - scalar; -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { - mVec128 = (vec_float4){_x, _y, _z, 0.0f}; - } else { - float *pf = (float *)&mVec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - } -} - -inline Vector3::Vector3( floatInVec _x, floatInVec _y, floatInVec _z ) -{ - vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); - mVec128 = vec_mergeh( xz, _y.get128() ); -} - -inline Vector3::Vector3( Point3 pnt ) -{ - mVec128 = pnt.get128(); -} - -inline Vector3::Vector3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -inline Vector3::Vector3( floatInVec scalar ) -{ - mVec128 = scalar.get128(); -} - -inline Vector3::Vector3( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_1000 ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0100 ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0010 ); -} - -inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -inline const Vector3 lerp( floatInVec t, Vector3 vec0, Vector3 vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -inline const Vector3 slerp( floatInVec t, Vector3 unitVec0, Vector3 unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( sines, vec_splat( sines, 0 ) ); - scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); - scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); - return Vector3( vec_madd( unitVec0.get128(), scale0, vec_madd( unitVec1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); -} - -inline vec_float4 Vector3::get128( ) const -{ - return mVec128; -} - -inline void storeXYZ( Vector3 vec, vec_float4 * quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = _VECTORMATH_MASK_0x000F; - dstVec = vec_sel(vec.get128(), dstVec, mask); - *quad = dstVec; -} - -inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = vec_sld( xyzx, yzxy, 12 ); - xyz2 = vec_sld( yzxy, zxyz, 8 ); - xyz3 = vec_sld( zxyz, zxyz, 4 ); - vec0 = Vector3( xyzx ); - vec1 = Vector3( xyz1 ); - vec2 = Vector3( xyz2 ); - vec3 = Vector3( xyz3 ); -} - -inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = vec_perm( vec0.get128(), vec1.get128(), _VECTORMATH_PERM_XYZA ); - yzxy = vec_perm( vec1.get128(), vec2.get128(), _VECTORMATH_PERM_YZAB ); - zxyz = vec_perm( vec2.get128(), vec3.get128(), _VECTORMATH_PERM_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Vector3 & Vector3::operator =( Vector3 vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -inline Vector3 & Vector3::setX( floatInVec _x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -inline const floatInVec Vector3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -inline Vector3 & Vector3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -inline Vector3 & Vector3::setY( floatInVec _y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -inline const floatInVec Vector3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -inline Vector3 & Vector3::setZ( floatInVec _z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -inline const floatInVec Vector3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -inline Vector3 & Vector3::setElem( int idx, floatInVec value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -inline const floatInVec Vector3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline VecIdx Vector3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline const floatInVec Vector3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline const Vector3 Vector3::operator +( Vector3 vec ) const -{ - return Vector3( vec_add( mVec128, vec.mVec128 ) ); -} - -inline const Vector3 Vector3::operator -( Vector3 vec ) const -{ - return Vector3( vec_sub( mVec128, vec.mVec128 ) ); -} - -inline const Point3 Vector3::operator +( Point3 pnt ) const -{ - return Point3( vec_add( mVec128, pnt.get128() ) ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -inline const Vector3 Vector3::operator *( floatInVec scalar ) const -{ - return Vector3( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline Vector3 & Vector3::operator +=( Vector3 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( Vector3 vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline Vector3 & Vector3::operator *=( floatInVec scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -inline const Vector3 Vector3::operator /( floatInVec scalar ) const -{ - return Vector3( divf4( mVec128, scalar.get128() ) ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline Vector3 & Vector3::operator /=( floatInVec scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( negatef4( mVec128 ) ); -} - -inline const Vector3 operator *( float scalar, Vector3 vec ) -{ - return floatInVec(scalar) * vec; -} - -inline const Vector3 operator *( floatInVec scalar, Vector3 vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( vec_madd( vec0.get128(), vec1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( divf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 recipPerElem( Vector3 vec ) -{ - return Vector3( recipf4( vec.get128() ) ); -} - -inline const Vector3 sqrtPerElem( Vector3 vec ) -{ - return Vector3( sqrtf4( vec.get128() ) ); -} - -inline const Vector3 rsqrtPerElem( Vector3 vec ) -{ - return Vector3( rsqrtf4( vec.get128() ) ); -} - -inline const Vector3 absPerElem( Vector3 vec ) -{ - return Vector3( fabsf4( vec.get128() ) ); -} - -inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( copysignf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( fmaxf4( vec0.get128(), vec1.get128() ) ); -} - -inline const floatInVec maxElem( Vector3 vec ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = fmaxf4( vec_splat( vec.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( fminf4( vec0.get128(), vec1.get128() ) ); -} - -inline const floatInVec minElem( Vector3 vec ) -{ - vec_float4 result; - result = fminf4( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = fminf4( vec_splat( vec.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const floatInVec sum( Vector3 vec ) -{ - vec_float4 result; - result = vec_add( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = vec_add( vec_splat( vec.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const floatInVec dot( Vector3 vec0, Vector3 vec1 ) -{ - return floatInVec( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); -} - -inline const floatInVec lengthSqr( Vector3 vec ) -{ - return floatInVec( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); -} - -inline const floatInVec length( Vector3 vec ) -{ - return floatInVec( sqrtf4(_vmathVfDot3( vec.get128(), vec.get128() )), 0 ); -} - -inline const Vector3 normalize( Vector3 vec ) -{ - vec_float4 dot = _vmathVfDot3( vec.get128(), vec.get128() ); - dot = vec_splat( dot, 0 ); - return Vector3( vec_madd( vec.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - -inline const Vector3 select( Vector3 vec0, Vector3 vec1, boolInVec select1 ) -{ - return Vector3( vec_sel( vec0.get128(), vec1.get128(), select1.get128() ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Vector3 vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -inline void print( Vector3 vec, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & - __builtin_constant_p(_z) & __builtin_constant_p(_w)) { - mVec128 = (vec_float4){_x, _y, _z, _w}; - } else { - float *pf = (float *)&mVec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - pf[3] = _w; - } -} - -inline Vector4::Vector4( floatInVec _x, floatInVec _y, floatInVec _z, floatInVec _w ) -{ - vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); - vec_float4 yw = vec_mergeh( _y.get128(), _w.get128() ); - mVec128 = vec_mergeh( xz, yw ); -} - -inline Vector4::Vector4( Vector3 xyz, float _w ) -{ - mVec128 = xyz.get128(); - _vmathVfSetElement(mVec128, _w, 3); -} - -inline Vector4::Vector4( Vector3 xyz, floatInVec _w ) -{ - mVec128 = xyz.get128(); - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); -} - -inline Vector4::Vector4( Vector3 vec ) -{ - mVec128 = vec.get128(); - mVec128 = _vmathVfInsert(mVec128, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), 3); -} - -inline Vector4::Vector4( Point3 pnt ) -{ - mVec128 = pnt.get128(); - mVec128 = _vmathVfInsert(mVec128, ((vec_float4){1.0f,1.0f,1.0f,1.0f}), 3); -} - -inline Vector4::Vector4( Quat quat ) -{ - mVec128 = quat.get128(); -} - -inline Vector4::Vector4( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -inline Vector4::Vector4( floatInVec scalar ) -{ - mVec128 = scalar.get128(); -} - -inline Vector4::Vector4( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_1000 ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0100 ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0010 ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0001 ); -} - -inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ) -{ - return lerp( floatInVec(t), vec0, vec1 ); -} - -inline const Vector4 lerp( floatInVec t, Vector4 vec0, Vector4 vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ) -{ - return slerp( floatInVec(t), unitVec0, unitVec1 ); -} - -inline const Vector4 slerp( floatInVec t, Vector4 unitVec0, Vector4 unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); - cosAngle = vec_splat( cosAngle, 0 ); - selectMask = (vec_uint4)vec_cmpgt( ((vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}), cosAngle ); - angle = acosf4( cosAngle ); - tttt = t.get128(); - oneMinusT = vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), tttt ); - angles = vec_mergeh( angles, oneMinusT ); - angles = vec_madd( angles, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - sines = sinf4( angles ); - scales = divf4( sines, vec_splat( sines, 0 ) ); - scale0 = vec_sel( oneMinusT, vec_splat( scales, 1 ), selectMask ); - scale1 = vec_sel( tttt, vec_splat( scales, 2 ), selectMask ); - return Vector4( vec_madd( unitVec0.get128(), scale0, vec_madd( unitVec1.get128(), scale1, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) ); -} - -inline vec_float4 Vector4::get128( ) const -{ - return mVec128; -} - -inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); -} - -inline Vector4 & Vector4::operator =( Vector4 vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -inline Vector4 & Vector4::setXYZ( Vector3 vec ) -{ - mVec128 = vec_sel( vec.get128(), mVec128, _VECTORMATH_MASK_0x000F ); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -inline Vector4 & Vector4::setX( floatInVec _x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -inline const floatInVec Vector4::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -inline Vector4 & Vector4::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -inline Vector4 & Vector4::setY( floatInVec _y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -inline const floatInVec Vector4::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -inline Vector4 & Vector4::setZ( floatInVec _z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -inline const floatInVec Vector4::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -inline Vector4 & Vector4::setW( float _w ) -{ - _vmathVfSetElement(mVec128, _w, 3); - return *this; -} - -inline Vector4 & Vector4::setW( floatInVec _w ) -{ - mVec128 = _vmathVfInsert(mVec128, _w.get128(), 3); - return *this; -} - -inline const floatInVec Vector4::getW( ) const -{ - return floatInVec( mVec128, 3 ); -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -inline Vector4 & Vector4::setElem( int idx, floatInVec value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -inline const floatInVec Vector4::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline VecIdx Vector4::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline const floatInVec Vector4::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline const Vector4 Vector4::operator +( Vector4 vec ) const -{ - return Vector4( vec_add( mVec128, vec.mVec128 ) ); -} - -inline const Vector4 Vector4::operator -( Vector4 vec ) const -{ - return Vector4( vec_sub( mVec128, vec.mVec128 ) ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return *this * floatInVec(scalar); -} - -inline const Vector4 Vector4::operator *( floatInVec scalar ) const -{ - return Vector4( vec_madd( mVec128, scalar.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline Vector4 & Vector4::operator +=( Vector4 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( Vector4 vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline Vector4 & Vector4::operator *=( floatInVec scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return *this / floatInVec(scalar); -} - -inline const Vector4 Vector4::operator /( floatInVec scalar ) const -{ - return Vector4( divf4( mVec128, scalar.get128() ) ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline Vector4 & Vector4::operator /=( floatInVec scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( negatef4( mVec128 ) ); -} - -inline const Vector4 operator *( float scalar, Vector4 vec ) -{ - return floatInVec(scalar) * vec; -} - -inline const Vector4 operator *( floatInVec scalar, Vector4 vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( vec_madd( vec0.get128(), vec1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( divf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector4 recipPerElem( Vector4 vec ) -{ - return Vector4( recipf4( vec.get128() ) ); -} - -inline const Vector4 sqrtPerElem( Vector4 vec ) -{ - return Vector4( sqrtf4( vec.get128() ) ); -} - -inline const Vector4 rsqrtPerElem( Vector4 vec ) -{ - return Vector4( rsqrtf4( vec.get128() ) ); -} - -inline const Vector4 absPerElem( Vector4 vec ) -{ - return Vector4( fabsf4( vec.get128() ) ); -} - -inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( copysignf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( fmaxf4( vec0.get128(), vec1.get128() ) ); -} - -inline const floatInVec maxElem( Vector4 vec ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = fmaxf4( vec_splat( vec.get128(), 2 ), result ); - result = fmaxf4( vec_splat( vec.get128(), 3 ), result ); - return floatInVec( result, 0 ); -} - -inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( fminf4( vec0.get128(), vec1.get128() ) ); -} - -inline const floatInVec minElem( Vector4 vec ) -{ - vec_float4 result; - result = fminf4( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = fminf4( vec_splat( vec.get128(), 2 ), result ); - result = fminf4( vec_splat( vec.get128(), 3 ), result ); - return floatInVec( result, 0 ); -} - -inline const floatInVec sum( Vector4 vec ) -{ - vec_float4 result; - result = vec_add( vec_splat( vec.get128(), 1 ), vec.get128() ); - result = vec_add( vec_splat( vec.get128(), 2 ), result ); - result = vec_add( vec_splat( vec.get128(), 3 ), result ); - return floatInVec( result, 0 ); -} - -inline const floatInVec dot( Vector4 vec0, Vector4 vec1 ) -{ - return floatInVec( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); -} - -inline const floatInVec lengthSqr( Vector4 vec ) -{ - return floatInVec( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); -} - -inline const floatInVec length( Vector4 vec ) -{ - return floatInVec( sqrtf4(_vmathVfDot4( vec.get128(), vec.get128() )), 0 ); -} - -inline const Vector4 normalize( Vector4 vec ) -{ - vec_float4 dot = _vmathVfDot4( vec.get128(), vec.get128() ); - return Vector4( vec_madd( vec.get128(), rsqrtf4( dot ), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ) -{ - return select( vec0, vec1, boolInVec(select1) ); -} - -inline const Vector4 select( Vector4 vec0, Vector4 vec1, boolInVec select1 ) -{ - return Vector4( vec_sel( vec0.get128(), vec1.get128(), select1.get128() ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Vector4 vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -inline void print( Vector4 vec, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -inline Point3::Point3( float _x, float _y, float _z ) -{ - if (__builtin_constant_p(_x) & __builtin_constant_p(_y) & __builtin_constant_p(_z)) { - mVec128 = (vec_float4){_x, _y, _z, 0.0f}; - } else { - float *pf = (float *)&mVec128; - pf[0] = _x; - pf[1] = _y; - pf[2] = _z; - } -} - -inline Point3::Point3( floatInVec _x, floatInVec _y, floatInVec _z ) -{ - vec_float4 xz = vec_mergeh( _x.get128(), _z.get128() ); - mVec128 = vec_mergeh( xz, _y.get128() ); -} - -inline Point3::Point3( Vector3 vec ) -{ - mVec128 = vec.get128(); -} - -inline Point3::Point3( float scalar ) -{ - mVec128 = floatInVec(scalar).get128(); -} - -inline Point3::Point3( floatInVec scalar ) -{ - mVec128 = scalar.get128(); -} - -inline Point3::Point3( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ) -{ - return lerp( floatInVec(t), pnt0, pnt1 ); -} - -inline const Point3 lerp( floatInVec t, Point3 pnt0, Point3 pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline vec_float4 Point3::get128( ) const -{ - return mVec128; -} - -inline void storeXYZ( Point3 pnt, vec_float4 * quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = _VECTORMATH_MASK_0x000F; - dstVec = vec_sel(pnt.get128(), dstVec, mask); - *quad = dstVec; -} - -inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = vec_sld( xyzx, yzxy, 12 ); - xyz2 = vec_sld( yzxy, zxyz, 8 ); - xyz3 = vec_sld( zxyz, zxyz, 4 ); - pnt0 = Point3( xyzx ); - pnt1 = Point3( xyz1 ); - pnt2 = Point3( xyz2 ); - pnt3 = Point3( xyz3 ); -} - -inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = vec_perm( pnt0.get128(), pnt1.get128(), _VECTORMATH_PERM_XYZA ); - yzxy = vec_perm( pnt1.get128(), pnt2.get128(), _VECTORMATH_PERM_YZAB ); - zxyz = vec_perm( pnt2.get128(), pnt3.get128(), _VECTORMATH_PERM_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Point3 & Point3::operator =( Point3 pnt ) -{ - mVec128 = pnt.mVec128; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - _vmathVfSetElement(mVec128, _x, 0); - return *this; -} - -inline Point3 & Point3::setX( floatInVec _x ) -{ - mVec128 = _vmathVfInsert(mVec128, _x.get128(), 0); - return *this; -} - -inline const floatInVec Point3::getX( ) const -{ - return floatInVec( mVec128, 0 ); -} - -inline Point3 & Point3::setY( float _y ) -{ - _vmathVfSetElement(mVec128, _y, 1); - return *this; -} - -inline Point3 & Point3::setY( floatInVec _y ) -{ - mVec128 = _vmathVfInsert(mVec128, _y.get128(), 1); - return *this; -} - -inline const floatInVec Point3::getY( ) const -{ - return floatInVec( mVec128, 1 ); -} - -inline Point3 & Point3::setZ( float _z ) -{ - _vmathVfSetElement(mVec128, _z, 2); - return *this; -} - -inline Point3 & Point3::setZ( floatInVec _z ) -{ - mVec128 = _vmathVfInsert(mVec128, _z.get128(), 2); - return *this; -} - -inline const floatInVec Point3::getZ( ) const -{ - return floatInVec( mVec128, 2 ); -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - _vmathVfSetElement(mVec128, value, idx); - return *this; -} - -inline Point3 & Point3::setElem( int idx, floatInVec value ) -{ - mVec128 = _vmathVfInsert(mVec128, value.get128(), idx); - return *this; -} - -inline const floatInVec Point3::getElem( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline VecIdx Point3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline const floatInVec Point3::operator []( int idx ) const -{ - return floatInVec( mVec128, idx ); -} - -inline const Vector3 Point3::operator -( Point3 pnt ) const -{ - return Vector3( vec_sub( mVec128, pnt.mVec128 ) ); -} - -inline const Point3 Point3::operator +( Vector3 vec ) const -{ - return Point3( vec_add( mVec128, vec.get128() ) ); -} - -inline const Point3 Point3::operator -( Vector3 vec ) const -{ - return Point3( vec_sub( mVec128, vec.get128() ) ); -} - -inline Point3 & Point3::operator +=( Vector3 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( Vector3 vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( vec_madd( pnt0.get128(), pnt1.get128(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); -} - -inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( divf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const Point3 recipPerElem( Point3 pnt ) -{ - return Point3( recipf4( pnt.get128() ) ); -} - -inline const Point3 sqrtPerElem( Point3 pnt ) -{ - return Point3( sqrtf4( pnt.get128() ) ); -} - -inline const Point3 rsqrtPerElem( Point3 pnt ) -{ - return Point3( rsqrtf4( pnt.get128() ) ); -} - -inline const Point3 absPerElem( Point3 pnt ) -{ - return Point3( fabsf4( pnt.get128() ) ); -} - -inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( copysignf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( fmaxf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const floatInVec maxElem( Point3 pnt ) -{ - vec_float4 result; - result = fmaxf4( vec_splat( pnt.get128(), 1 ), pnt.get128() ); - result = fmaxf4( vec_splat( pnt.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( fminf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const floatInVec minElem( Point3 pnt ) -{ - vec_float4 result; - result = fminf4( vec_splat( pnt.get128(), 1 ), pnt.get128() ); - result = fminf4( vec_splat( pnt.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const floatInVec sum( Point3 pnt ) -{ - vec_float4 result; - result = vec_add( vec_splat( pnt.get128(), 1 ), pnt.get128() ); - result = vec_add( vec_splat( pnt.get128(), 2 ), result ); - return floatInVec( result, 0 ); -} - -inline const Point3 scale( Point3 pnt, float scaleVal ) -{ - return scale( pnt, floatInVec( scaleVal ) ); -} - -inline const Point3 scale( Point3 pnt, floatInVec scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( Point3 pnt, Vector3 scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline const floatInVec projection( Point3 pnt, Vector3 unitVec ) -{ - return floatInVec( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); -} - -inline const floatInVec distSqrFromOrigin( Point3 pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline const floatInVec distFromOrigin( Point3 pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline const floatInVec distSqr( Point3 pnt0, Point3 pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline const floatInVec dist( Point3 pnt0, Point3 pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ) -{ - return select( pnt0, pnt1, boolInVec(select1) ); -} - -inline const Point3 select( Point3 pnt0, Point3 pnt1, boolInVec select1 ) -{ - return Point3( vec_sel( pnt0.get128(), pnt1.get128(), select1.get128() ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Point3 pnt ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -inline void print( Point3 pnt, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h deleted file mode 100644 index 89fdfcf7f..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vec_soa.h +++ /dev/null @@ -1,1425 +0,0 @@ -/* - 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_VEC_SOA_CPP_H -#define _VECTORMATH_VEC_SOA_CPP_H -//----------------------------------------------------------------------------- -// Constants -// for permutes, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_PERM_X 0x00010203 -#define _VECTORMATH_PERM_Y 0x04050607 -#define _VECTORMATH_PERM_Z 0x08090a0b -#define _VECTORMATH_PERM_W 0x0c0d0e0f -#define _VECTORMATH_PERM_A 0x10111213 -#define _VECTORMATH_PERM_B 0x14151617 -#define _VECTORMATH_PERM_C 0x18191a1b -#define _VECTORMATH_PERM_D 0x1c1d1e1f -#define _VECTORMATH_PERM_ZBWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_XCYX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZDWX ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D, _VECTORMATH_PERM_W, _VECTORMATH_PERM_X }) -#define _VECTORMATH_PERM_ZCXA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_C, _VECTORMATH_PERM_X, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XBZD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_B, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WDYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_B }) -#define _VECTORMATH_PERM_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B, _VECTORMATH_PERM_X, _VECTORMATH_PERM_D }) -#define _VECTORMATH_PERM_WCYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_W, _VECTORMATH_PERM_C, _VECTORMATH_PERM_Y, _VECTORMATH_PERM_A }) -#define _VECTORMATH_PERM_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_PERM_X, _VECTORMATH_PERM_D, _VECTORMATH_PERM_Z, _VECTORMATH_PERM_B }) -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Soa { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -} - -inline Vector3::Vector3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -} - -inline Vector3::Vector3( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline Vector3::Vector3( Aos::Vector3 vec ) -{ - vec_float4 vec128 = vec.get128(); - mX = vec_splat( vec128, 0 ); - mY = vec_splat( vec128, 1 ); - mZ = vec_splat( vec128, 2 ); -} - -inline Vector3::Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( vec0.get128(), vec2.get128() ); - tmp1 = vec_mergeh( vec1.get128(), vec3.get128() ); - tmp2 = vec_mergel( vec0.get128(), vec2.get128() ); - tmp3 = vec_mergel( vec1.get128(), vec3.get128() ); - mX = vec_mergeh( tmp0, tmp1 ); - mY = vec_mergel( tmp0, tmp1 ); - mZ = vec_mergeh( tmp2, tmp3 ); -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void Vector3::get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const -{ - vec_float4 tmp0, tmp1; - tmp0 = vec_mergeh( mX, mZ ); - tmp1 = vec_mergel( mX, mZ ); - result0 = Aos::Vector3( vec_mergeh( tmp0, mY ) ); - result1 = Aos::Vector3( vec_perm( tmp0, mY, _VECTORMATH_PERM_ZBWX ) ); - result2 = Aos::Vector3( vec_perm( tmp1, mY, _VECTORMATH_PERM_XCYX ) ); - result3 = Aos::Vector3( vec_perm( tmp1, mY, _VECTORMATH_PERM_ZDWX ) ); -} - -inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = vec_sld( yzxy, xyzx, 8 ); - zxzx = vec_sld( xyzx, zxyz, 8 ); - yzyz = vec_sld( zxyz, yzxy, 8 ); - vec.setX( vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); - vec.setY( vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); - vec.setZ( vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); -} - -inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = vec_perm( vec.getX(), vec.getY(), _VECTORMATH_PERM_ZCXA ); - zxzx = vec_perm( vec.getZ(), vec.getX(), _VECTORMATH_PERM_XBZD ); - yzyz = vec_perm( vec.getY(), vec.getZ(), _VECTORMATH_PERM_WDYB ); - xyzx = vec_sld( xyxy, zxzx, 8 ); - yzxy = vec_sld( yzyz, xyxy, 8 ); - zxyz = vec_sld( zxzx, yzyz, 8 ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( vec0, xyz0 ); - storeXYZArray( vec1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Vector3::vec_float4_t & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - vec_add( mX, vec.mX ), - vec_add( mY, vec.mY ), - vec_add( mZ, vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - vec_sub( mX, vec.mX ), - vec_sub( mY, vec.mY ), - vec_sub( mZ, vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - vec_add( mX, pnt.getX() ), - vec_add( mY, pnt.getY() ), - vec_add( mZ, pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( vec_float4 scalar ) const -{ - return Vector3( - vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( vec_float4 scalar ) const -{ - return Vector3( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ) - ); -} - -inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - divf4( vec0.getX(), vec1.getX() ), - divf4( vec0.getY(), vec1.getY() ), - divf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getX() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getY() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf4( vec.getX() ), - sqrtf4( vec.getY() ), - sqrtf4( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getX() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getY() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getZ() ) ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf4( vec.getX() ), - fabsf4( vec.getY() ), - fabsf4( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - copysignf4( vec0.getX(), vec1.getX() ), - copysignf4( vec0.getY(), vec1.getY() ), - copysignf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - fmaxf4( vec0.getX(), vec1.getX() ), - fmaxf4( vec0.getY(), vec1.getY() ), - fmaxf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline vec_float4 maxElem( const Vector3 & vec ) -{ - vec_float4 result; - result = fmaxf4( vec.getX(), vec.getY() ); - result = fmaxf4( vec.getZ(), result ); - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - fminf4( vec0.getX(), vec1.getX() ), - fminf4( vec0.getY(), vec1.getY() ), - fminf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline vec_float4 minElem( const Vector3 & vec ) -{ - vec_float4 result; - result = fminf4( vec.getX(), vec.getY() ); - result = fminf4( vec.getZ(), result ); - return result; -} - -inline vec_float4 sum( const Vector3 & vec ) -{ - vec_float4 result; - result = vec_add( vec.getX(), vec.getY() ); - result = vec_add( result, vec.getZ() ); - return result; -} - -inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 lengthSqr( const Vector3 & vec ) -{ - vec_float4 result; - result = vec_madd( vec.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 length( const Vector3 & vec ) -{ - return sqrtf4( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( const Vector3 & vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - return Vector3( - vec_madd( vec.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - vec_sub( vec_madd( vec0.getY(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getZ(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_sub( vec_madd( vec0.getZ(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getX(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), - vec_sub( vec_madd( vec0.getX(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), vec_madd( vec0.getY(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ) - ); -} - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ) -{ - return Vector3( - vec_sel( vec0.getX(), vec1.getX(), select1 ), - vec_sel( vec0.getY(), vec1.getY(), select1 ), - vec_sel( vec0.getZ(), vec1.getZ(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - Aos::Vector3 vec0, vec1, vec2, vec3; - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - Aos::Vector3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, vec_float4 _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = ((vec_float4){0.0f,0.0f,0.0f,0.0f}); -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = ((vec_float4){1.0f,1.0f,1.0f,1.0f}); -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline Vector4::Vector4( Aos::Vector4 vec ) -{ - vec_float4 vec128 = vec.get128(); - mX = vec_splat( vec128, 0 ); - mY = vec_splat( vec128, 1 ); - mZ = vec_splat( vec128, 2 ); - mW = vec_splat( vec128, 3 ); -} - -inline Vector4::Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( vec0.get128(), vec2.get128() ); - tmp1 = vec_mergeh( vec1.get128(), vec3.get128() ); - tmp2 = vec_mergel( vec0.get128(), vec2.get128() ); - tmp3 = vec_mergel( vec1.get128(), vec3.get128() ); - mX = vec_mergeh( tmp0, tmp1 ); - mY = vec_mergel( tmp0, tmp1 ); - mZ = vec_mergeh( tmp2, tmp3 ); - mW = vec_mergel( tmp2, tmp3 ); -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); -} - -inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)vec_cmpgt( (vec_float4){_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL,_VECTORMATH_SLERP_TOL}, cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sinf4( angle ) ); - scale0 = vec_sel( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), vec_madd( sinf4( vec_madd( vec_sub( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), t ), angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - scale1 = vec_sel( t, vec_madd( sinf4( vec_madd( t, angle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ), recipSinAngle, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), selectMask ); - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void Vector4::get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( mX, mZ ); - tmp1 = vec_mergeh( mY, mW ); - tmp2 = vec_mergel( mX, mZ ); - tmp3 = vec_mergel( mY, mW ); - result0 = Aos::Vector4( vec_mergeh( tmp0, tmp1 ) ); - result1 = Aos::Vector4( vec_mergel( tmp0, tmp1 ) ); - result2 = Aos::Vector4( vec_mergeh( tmp2, tmp3 ) ); - result3 = Aos::Vector4( vec_mergel( tmp2, tmp3 ) ); -} - -inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ) -{ - Aos::Vector4 v0, v1, v2, v3; - vec.get4Aos( v0, v1, v2, v3 ); - twoQuads[0] = _vmath2VfToHalfFloats(v0.get128(), v1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(v2.get128(), v3.get128()); -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( vec_float4 _w ) -{ - mW = _w; - return *this; -} - -inline vec_float4 Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Vector4::vec_float4_t & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - vec_add( mX, vec.mX ), - vec_add( mY, vec.mY ), - vec_add( mZ, vec.mZ ), - vec_add( mW, vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - vec_sub( mX, vec.mX ), - vec_sub( mY, vec.mY ), - vec_sub( mZ, vec.mZ ), - vec_sub( mW, vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( vec_float4 scalar ) const -{ - return Vector4( - vec_madd( mX, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mY, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mZ, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( mW, scalar, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( vec_float4 scalar ) const -{ - return Vector4( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ), - divf4( mW, scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ), - negatef4( mW ) - ); -} - -inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec0.getW(), vec1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - divf4( vec0.getX(), vec1.getX() ), - divf4( vec0.getY(), vec1.getY() ), - divf4( vec0.getZ(), vec1.getZ() ), - divf4( vec0.getW(), vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getX() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getY() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getZ() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf4( vec.getX() ), - sqrtf4( vec.getY() ), - sqrtf4( vec.getZ() ), - sqrtf4( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getX() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getY() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getZ() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( vec.getW() ) ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf4( vec.getX() ), - fabsf4( vec.getY() ), - fabsf4( vec.getZ() ), - fabsf4( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - copysignf4( vec0.getX(), vec1.getX() ), - copysignf4( vec0.getY(), vec1.getY() ), - copysignf4( vec0.getZ(), vec1.getZ() ), - copysignf4( vec0.getW(), vec1.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - fmaxf4( vec0.getX(), vec1.getX() ), - fmaxf4( vec0.getY(), vec1.getY() ), - fmaxf4( vec0.getZ(), vec1.getZ() ), - fmaxf4( vec0.getW(), vec1.getW() ) - ); -} - -inline vec_float4 maxElem( const Vector4 & vec ) -{ - vec_float4 result; - result = fmaxf4( vec.getX(), vec.getY() ); - result = fmaxf4( vec.getZ(), result ); - result = fmaxf4( vec.getW(), result ); - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - fminf4( vec0.getX(), vec1.getX() ), - fminf4( vec0.getY(), vec1.getY() ), - fminf4( vec0.getZ(), vec1.getZ() ), - fminf4( vec0.getW(), vec1.getW() ) - ); -} - -inline vec_float4 minElem( const Vector4 & vec ) -{ - vec_float4 result; - result = fminf4( vec.getX(), vec.getY() ); - result = fminf4( vec.getZ(), result ); - result = fminf4( vec.getW(), result ); - return result; -} - -inline vec_float4 sum( const Vector4 & vec ) -{ - vec_float4 result; - result = vec_add( vec.getX(), vec.getY() ); - result = vec_add( result, vec.getZ() ); - result = vec_add( result, vec.getW() ); - return result; -} - -inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - vec_float4 result; - result = vec_madd( vec0.getX(), vec1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec0.getY(), vec1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0.getZ(), vec1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec0.getW(), vec1.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 lengthSqr( const Vector4 & vec ) -{ - vec_float4 result; - result = vec_madd( vec.getX(), vec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( vec.getY(), vec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec.getZ(), vec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( vec.getW(), vec.getW(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 length( const Vector4 & vec ) -{ - return sqrtf4( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( lenSqr ) ); - return Vector4( - vec_madd( vec.getX(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec.getY(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec.getZ(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( vec.getW(), lenInv, ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ) -{ - return Vector4( - vec_sel( vec0.getX(), vec1.getX(), select1 ), - vec_sel( vec0.getY(), vec1.getY(), select1 ), - vec_sel( vec0.getZ(), vec1.getZ(), select1 ), - vec_sel( vec0.getW(), vec1.getW(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - Aos::Vector4 vec0, vec1, vec2, vec3; - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - Aos::Vector4 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -} - -inline Point3::Point3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -} - -inline Point3::Point3( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline Point3::Point3( Aos::Point3 pnt ) -{ - vec_float4 vec128 = pnt.get128(); - mX = vec_splat( vec128, 0 ); - mY = vec_splat( vec128, 1 ); - mZ = vec_splat( vec128, 2 ); -} - -inline Point3::Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = vec_mergeh( pnt0.get128(), pnt2.get128() ); - tmp1 = vec_mergeh( pnt1.get128(), pnt3.get128() ); - tmp2 = vec_mergel( pnt0.get128(), pnt2.get128() ); - tmp3 = vec_mergel( pnt1.get128(), pnt3.get128() ); - mX = vec_mergeh( tmp0, tmp1 ); - mY = vec_mergel( tmp0, tmp1 ); - mZ = vec_mergeh( tmp2, tmp3 ); -} - -inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline void Point3::get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const -{ - vec_float4 tmp0, tmp1; - tmp0 = vec_mergeh( mX, mZ ); - tmp1 = vec_mergel( mX, mZ ); - result0 = Aos::Point3( vec_mergeh( tmp0, mY ) ); - result1 = Aos::Point3( vec_perm( tmp0, mY, _VECTORMATH_PERM_ZBWX ) ); - result2 = Aos::Point3( vec_perm( tmp1, mY, _VECTORMATH_PERM_XCYX ) ); - result3 = Aos::Point3( vec_perm( tmp1, mY, _VECTORMATH_PERM_ZDWX ) ); -} - -inline void loadXYZArray( Point3 & vec, const vec_float4 * threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = vec_sld( yzxy, xyzx, 8 ); - zxzx = vec_sld( xyzx, zxyz, 8 ); - yzyz = vec_sld( zxyz, yzxy, 8 ); - vec.setX( vec_perm( xyxy, zxzx, _VECTORMATH_PERM_ZBXD ) ); - vec.setY( vec_perm( xyxy, yzyz, _VECTORMATH_PERM_WCYA ) ); - vec.setZ( vec_perm( zxzx, yzyz, _VECTORMATH_PERM_XDZB ) ); -} - -inline void storeXYZArray( const Point3 & vec, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = vec_perm( vec.getX(), vec.getY(), _VECTORMATH_PERM_ZCXA ); - zxzx = vec_perm( vec.getZ(), vec.getX(), _VECTORMATH_PERM_XBZD ); - yzyz = vec_perm( vec.getY(), vec.getZ(), _VECTORMATH_PERM_WDYB ); - xyzx = vec_sld( xyxy, zxzx, 8 ); - yzxy = vec_sld( yzyz, xyxy, 8 ); - zxyz = vec_sld( zxzx, yzyz, 8 ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( pnt0, xyz0 ); - storeXYZArray( pnt1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Point3::vec_float4_t & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - vec_sub( mX, pnt.mX ), - vec_sub( mY, pnt.mY ), - vec_sub( mZ, pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - vec_add( mX, vec.getX() ), - vec_add( mY, vec.getY() ), - vec_add( mZ, vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - vec_sub( mX, vec.getX() ), - vec_sub( mY, vec.getY() ), - vec_sub( mZ, vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - vec_madd( pnt0.getX(), pnt1.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( pnt0.getY(), pnt1.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ), - vec_madd( pnt0.getZ(), pnt1.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - divf4( pnt0.getX(), pnt1.getX() ), - divf4( pnt0.getY(), pnt1.getY() ), - divf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getX() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getY() ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf4( pnt.getX() ), - sqrtf4( pnt.getY() ), - sqrtf4( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getX() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getY() ) ), - divf4( ((vec_float4){1.0f,1.0f,1.0f,1.0f}), sqrtf4( pnt.getZ() ) ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf4( pnt.getX() ), - fabsf4( pnt.getY() ), - fabsf4( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - copysignf4( pnt0.getX(), pnt1.getX() ), - copysignf4( pnt0.getY(), pnt1.getY() ), - copysignf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - fmaxf4( pnt0.getX(), pnt1.getX() ), - fmaxf4( pnt0.getY(), pnt1.getY() ), - fmaxf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline vec_float4 maxElem( const Point3 & pnt ) -{ - vec_float4 result; - result = fmaxf4( pnt.getX(), pnt.getY() ); - result = fmaxf4( pnt.getZ(), result ); - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - fminf4( pnt0.getX(), pnt1.getX() ), - fminf4( pnt0.getY(), pnt1.getY() ), - fminf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline vec_float4 minElem( const Point3 & pnt ) -{ - vec_float4 result; - result = fminf4( pnt.getX(), pnt.getY() ); - result = fminf4( pnt.getZ(), result ); - return result; -} - -inline vec_float4 sum( const Point3 & pnt ) -{ - vec_float4 result; - result = vec_add( pnt.getX(), pnt.getY() ); - result = vec_add( result, pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - vec_float4 result; - result = vec_madd( pnt.getX(), unitVec.getX(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ); - result = vec_add( result, vec_madd( pnt.getY(), unitVec.getY(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - result = vec_add( result, vec_madd( pnt.getZ(), unitVec.getZ(), ((vec_float4){0.0f,0.0f,0.0f,0.0f}) ) ); - return result; -} - -inline vec_float4 distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline vec_float4 distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ) -{ - return Point3( - vec_sel( pnt0.getX(), pnt1.getX(), select1 ), - vec_sel( pnt0.getY(), pnt1.getY(), select1 ), - vec_sel( pnt0.getZ(), pnt1.getZ(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - Aos::Point3 vec0, vec1, vec2, vec3; - pnt.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - Aos::Point3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - pnt.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h deleted file mode 100644 index df3357570..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vecidx_aos.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - 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. -// - -class VecIdx -{ -private: - typedef vec_float4 vec_float4_t; - vec_float4_t &ref __attribute__ ((aligned(16))); - int i __attribute__ ((aligned(16))); -public: - inline VecIdx( vec_float4_t& 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 =( floatInVec scalar ); - inline floatInVec operator =( const VecIdx& scalar ); - inline floatInVec operator *=( float scalar ); - inline floatInVec operator *=( floatInVec scalar ); - inline floatInVec operator /=( float scalar ); - inline floatInVec operator /=( floatInVec scalar ); - inline floatInVec operator +=( float scalar ); - inline floatInVec operator +=( floatInVec scalar ); - inline floatInVec operator -=( float scalar ); - inline floatInVec operator -=( floatInVec scalar ); -}; - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h deleted file mode 100644 index 0a7fa1738..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_aos.h +++ /dev/null @@ -1,2244 +0,0 @@ -/* - 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_AOS_CPP_PPU_H -#define _VECTORMATH_AOS_CPP_PPU_H - -#include -#include -#include "vecidx_aos.h" -#include "floatInVec.h" -#include "boolInVec.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Construct a 3-D vector from x, y, and z elements (scalar data contained in vector data type) - // - inline Vector3( floatInVec x, floatInVec y, floatInVec z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( Point3 pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Set all elements of a 3-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit inline Vector3( floatInVec scalar ); - - // Set vector float data in a 3-D vector - // - explicit inline Vector3( vec_float4 vf4 ); - - // Get vector float data from a 3-D vector - // - inline vec_float4 get128( ) const; - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( Vector3 vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Set the x element of a 3-D vector (scalar data contained in vector data type) - // - inline Vector3 & setX( floatInVec x ); - - // Set the y element of a 3-D vector (scalar data contained in vector data type) - // - inline Vector3 & setY( floatInVec y ); - - // Set the z element of a 3-D vector (scalar data contained in vector data type) - // - inline Vector3 & setZ( floatInVec z ); - - // Get the x element of a 3-D vector - // - inline const floatInVec getX( ) const; - - // Get the y element of a 3-D vector - // - inline const floatInVec getY( ) const; - - // Get the z element of a 3-D vector - // - inline const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D vector by index (scalar data contained in vector data type) - // - inline Vector3 & setElem( int idx, floatInVec value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline const floatInVec operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( Vector3 vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( Vector3 vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( Point3 pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Multiply a 3-D vector by a scalar (scalar data contained in vector data type) - // - inline const Vector3 operator *( floatInVec scalar ) const; - - // Divide a 3-D vector by a scalar (scalar data contained in vector data type) - // - inline const Vector3 operator /( floatInVec scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( Vector3 vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( Vector3 vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - inline Vector3 & operator *=( floatInVec scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - inline Vector3 & operator /=( floatInVec scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, Vector3 vec ); - -// Multiply a 3-D vector by a scalar (scalar data contained in vector data type) -// -inline const Vector3 operator *( floatInVec scalar, Vector3 vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( Vector3 vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( Vector3 vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( Vector3 vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( Vector3 vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ); - -// Maximum element of a 3-D vector -// -inline const floatInVec maxElem( Vector3 vec ); - -// Minimum element of a 3-D vector -// -inline const floatInVec minElem( Vector3 vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline const floatInVec sum( Vector3 vec ); - -// Compute the dot product of two 3-D vectors -// -inline const floatInVec dot( Vector3 vec0, Vector3 vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline const floatInVec lengthSqr( Vector3 vec ); - -// Compute the length of a 3-D vector -// -inline const floatInVec length( Vector3 vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( Vector3 vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( Vector3 vec0, Vector3 vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// NOTE: -// Slower than column post-multiply. -// -inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( Vector3 vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ); - -// Linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( floatInVec t, Vector3 vec0, Vector3 vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ); - -// Spherical linear interpolation between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( floatInVec t, Vector3 unitVec0, Vector3 unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ); - -// Conditionally select between two 3-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector3 select( Vector3 vec0, Vector3 vec1, boolInVec select1 ); - -// Store x, y, and z elements of a 3-D vector in the first three words of a quadword. -// The value of the fourth word (the word with the highest address) remains unchanged -// -inline void storeXYZ( Vector3 vec, vec_float4 * quad ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ); - -// Store four 3-D vectors in three quadwords -// -inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ); - -// Store eight 3-D vectors as half-floats -// -inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector3 vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector3 vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from x, y, z, and w elements (scalar data contained in vector data type) - // - inline Vector4( floatInVec x, floatInVec y, floatInVec z, floatInVec w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( Vector3 xyz, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar (scalar data contained in vector data type) - // - inline Vector4( Vector3 xyz, floatInVec w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( Vector3 vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( Point3 pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( Quat quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Set all elements of a 4-D vector to the same scalar value (scalar data contained in vector data type) - // - explicit inline Vector4( floatInVec scalar ); - - // Set vector float data in a 4-D vector - // - explicit inline Vector4( vec_float4 vf4 ); - - // Get vector float data from a 4-D vector - // - inline vec_float4 get128( ) const; - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( Vector4 vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( Vector3 vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Set the x element of a 4-D vector (scalar data contained in vector data type) - // - inline Vector4 & setX( floatInVec x ); - - // Set the y element of a 4-D vector (scalar data contained in vector data type) - // - inline Vector4 & setY( floatInVec y ); - - // Set the z element of a 4-D vector (scalar data contained in vector data type) - // - inline Vector4 & setZ( floatInVec z ); - - // Set the w element of a 4-D vector (scalar data contained in vector data type) - // - inline Vector4 & setW( floatInVec w ); - - // Get the x element of a 4-D vector - // - inline const floatInVec getX( ) const; - - // Get the y element of a 4-D vector - // - inline const floatInVec getY( ) const; - - // Get the z element of a 4-D vector - // - inline const floatInVec getZ( ) const; - - // Get the w element of a 4-D vector - // - inline const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a 4-D vector by index (scalar data contained in vector data type) - // - inline Vector4 & setElem( int idx, floatInVec value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline const floatInVec operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( Vector4 vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( Vector4 vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Multiply a 4-D vector by a scalar (scalar data contained in vector data type) - // - inline const Vector4 operator *( floatInVec scalar ) const; - - // Divide a 4-D vector by a scalar (scalar data contained in vector data type) - // - inline const Vector4 operator /( floatInVec scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( Vector4 vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( Vector4 vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - inline Vector4 & operator *=( floatInVec scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - inline Vector4 & operator /=( floatInVec scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, Vector4 vec ); - -// Multiply a 4-D vector by a scalar (scalar data contained in vector data type) -// -inline const Vector4 operator *( floatInVec scalar, Vector4 vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( Vector4 vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( Vector4 vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( Vector4 vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( Vector4 vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ); - -// Maximum element of a 4-D vector -// -inline const floatInVec maxElem( Vector4 vec ); - -// Minimum element of a 4-D vector -// -inline const floatInVec minElem( Vector4 vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline const floatInVec sum( Vector4 vec ); - -// Compute the dot product of two 4-D vectors -// -inline const floatInVec dot( Vector4 vec0, Vector4 vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline const floatInVec lengthSqr( Vector4 vec ); - -// Compute the length of a 4-D vector -// -inline const floatInVec length( Vector4 vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( Vector4 vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( Vector4 vec0, Vector4 vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ); - -// Linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( floatInVec t, Vector4 vec0, Vector4 vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ); - -// Spherical linear interpolation between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( floatInVec t, Vector4 unitVec0, Vector4 unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ); - -// Conditionally select between two 4-D vectors (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector4 select( Vector4 vec0, Vector4 vec1, boolInVec select1 ); - -// Store four 4-D vectors as half-floats -// -inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector4 vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector4 vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Construct a 3-D point from x, y, and z elements (scalar data contained in vector data type) - // - inline Point3( floatInVec x, floatInVec y, floatInVec z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( Vector3 vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Set all elements of a 3-D point to the same scalar value (scalar data contained in vector data type) - // - explicit inline Point3( floatInVec scalar ); - - // Set vector float data in a 3-D point - // - explicit inline Point3( vec_float4 vf4 ); - - // Get vector float data from a 3-D point - // - inline vec_float4 get128( ) const; - - // Assign one 3-D point to another - // - inline Point3 & operator =( Point3 pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Set the x element of a 3-D point (scalar data contained in vector data type) - // - inline Point3 & setX( floatInVec x ); - - // Set the y element of a 3-D point (scalar data contained in vector data type) - // - inline Point3 & setY( floatInVec y ); - - // Set the z element of a 3-D point (scalar data contained in vector data type) - // - inline Point3 & setZ( floatInVec z ); - - // Get the x element of a 3-D point - // - inline const floatInVec getX( ) const; - - // Get the y element of a 3-D point - // - inline const floatInVec getY( ) const; - - // Get the z element of a 3-D point - // - inline const floatInVec getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Set an x, y, or z element of a 3-D point by index (scalar data contained in vector data type) - // - inline Point3 & setElem( int idx, floatInVec value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline const floatInVec operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( Point3 pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( Vector3 vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( Vector3 vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( Vector3 vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( Vector3 vec ); - -}; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( Point3 pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( Point3 pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( Point3 pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( Point3 pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ); - -// Maximum element of a 3-D point -// -inline const floatInVec maxElem( Point3 pnt ); - -// Minimum element of a 3-D point -// -inline const floatInVec minElem( Point3 pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline const floatInVec sum( Point3 pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( Point3 pnt, float scaleVal ); - -// Apply uniform scale to a 3-D point (scalar data contained in vector data type) -// -inline const Point3 scale( Point3 pnt, floatInVec scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( Point3 pnt, Vector3 scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline const floatInVec projection( Point3 pnt, Vector3 unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline const floatInVec distSqrFromOrigin( Point3 pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline const floatInVec distFromOrigin( Point3 pnt ); - -// Compute the square of the distance between two 3-D points -// -inline const floatInVec distSqr( Point3 pnt0, Point3 pnt1 ); - -// Compute the distance between two 3-D points -// -inline const floatInVec dist( Point3 pnt0, Point3 pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ); - -// Linear interpolation between two 3-D points (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( floatInVec t, Point3 pnt0, Point3 pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ); - -// Conditionally select between two 3-D points (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Point3 select( Point3 pnt0, Point3 pnt1, boolInVec select1 ); - -// Store x, y, and z elements of a 3-D point in the first three words of a quadword. -// The value of the fourth word (the word with the highest address) remains unchanged -// -inline void storeXYZ( Point3 pnt, vec_float4 * quad ); - -// Load four three-float 3-D points, stored in three quadwords -// -inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ); - -// Store four 3-D points in three quadwords -// -inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ); - -// Store eight 3-D points as half-floats -// -inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Point3 pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Point3 pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from x, y, z, and w elements (scalar data contained in vector data type) - // - inline Quat( floatInVec x, floatInVec y, floatInVec z, floatInVec w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( Vector3 xyz, float w ); - - // Construct a quaternion from a 3-D vector and a scalar (scalar data contained in vector data type) - // - inline Quat( Vector3 xyz, floatInVec w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( Vector4 vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Set all elements of a quaternion to the same scalar value (scalar data contained in vector data type) - // - explicit inline Quat( floatInVec scalar ); - - // Set vector float data in a quaternion - // - explicit inline Quat( vec_float4 vf4 ); - - // Get vector float data from a quaternion - // - inline vec_float4 get128( ) const; - - // Assign one quaternion to another - // - inline Quat & operator =( Quat quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( Vector3 vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Set the x element of a quaternion (scalar data contained in vector data type) - // - inline Quat & setX( floatInVec x ); - - // Set the y element of a quaternion (scalar data contained in vector data type) - // - inline Quat & setY( floatInVec y ); - - // Set the z element of a quaternion (scalar data contained in vector data type) - // - inline Quat & setZ( floatInVec z ); - - // Set the w element of a quaternion (scalar data contained in vector data type) - // - inline Quat & setW( floatInVec w ); - - // Get the x element of a quaternion - // - inline const floatInVec getX( ) const; - - // Get the y element of a quaternion - // - inline const floatInVec getY( ) const; - - // Get the z element of a quaternion - // - inline const floatInVec getZ( ) const; - - // Get the w element of a quaternion - // - inline const floatInVec getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Set an x, y, z, or w element of a quaternion by index (scalar data contained in vector data type) - // - inline Quat & setElem( int idx, floatInVec value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline const floatInVec getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline const floatInVec operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( Quat quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( Quat quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( Quat quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Multiply a quaternion by a scalar (scalar data contained in vector data type) - // - inline const Quat operator *( floatInVec scalar ) const; - - // Divide a quaternion by a scalar (scalar data contained in vector data type) - // - inline const Quat operator /( floatInVec scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( Quat quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( Quat quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( Quat quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - inline Quat & operator *=( floatInVec scalar ); - - // Perform compound assignment and division by a scalar (scalar data contained in vector data type) - // - inline Quat & operator /=( floatInVec scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( Vector3 unitVec0, Vector3 unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, Vector3 unitVec ); - - // Construct a quaternion to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static inline const Quat rotation( floatInVec radians, Vector3 unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - - // Construct a quaternion to rotate around the x axis (scalar data contained in vector data type) - // - static inline const Quat rotationX( floatInVec radians ); - - // Construct a quaternion to rotate around the y axis (scalar data contained in vector data type) - // - static inline const Quat rotationY( floatInVec radians ); - - // Construct a quaternion to rotate around the z axis (scalar data contained in vector data type) - // - static inline const Quat rotationZ( floatInVec radians ); - -}; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, Quat quat ); - -// Multiply a quaternion by a scalar (scalar data contained in vector data type) -// -inline const Quat operator *( floatInVec scalar, Quat quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( Quat quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( Quat unitQuat, Vector3 vec ); - -// Compute the dot product of two quaternions -// -inline const floatInVec dot( Quat quat0, Quat quat1 ); - -// Compute the norm of a quaternion -// -inline const floatInVec norm( Quat quat ); - -// Compute the length of a quaternion -// -inline const floatInVec length( Quat quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( Quat quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, Quat quat0, Quat quat1 ); - -// Linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( floatInVec t, Quat quat0, Quat quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ); - -// Spherical linear interpolation between two quaternions (scalar data contained in vector data type) -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( floatInVec t, Quat unitQuat0, Quat unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); - -// Spherical quadrangle interpolation (scalar data contained in vector data type) -// -inline const Quat squad( floatInVec t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Quat select( Quat quat0, Quat quat1, bool select1 ); - -// Conditionally select between two quaternions (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Quat select( Quat quat0, Quat quat1, boolInVec select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Quat quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Quat quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( Vector3 col0, Vector3 col1, Vector3 col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( Quat unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Set all elements of a 3x3 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit inline Matrix3( floatInVec scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( Vector3 col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( Vector3 col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( Vector3 col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, Vector3 vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, Vector3 vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Set the element of a 3x3 matrix referred to by column and row indices (scalar data contained in vector data type) - // - inline Matrix3 & setElem( int col, int row, floatInVec val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline const floatInVec getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) - // - inline const Matrix3 operator *( floatInVec scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( Vector3 vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - inline Matrix3 & operator *=( floatInVec scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static inline const Matrix3 rotationX( floatInVec radians ); - - // Construct a 3x3 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static inline const Matrix3 rotationY( floatInVec radians ); - - // Construct a 3x3 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static inline const Matrix3 rotationZ( floatInVec radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, Vector3 unitVec ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static inline const Matrix3 rotation( floatInVec radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( Quat unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( Vector3 scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Multiply a 3x3 matrix by a scalar (scalar data contained in vector data type) -// -inline const Matrix3 operator *( floatInVec scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline const floatInVec determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -// Conditionally select between two 3x3 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, boolInVec select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( Vector4 col0, Vector4 col1, Vector4 col2, Vector4 col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, Vector3 translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( Quat unitQuat, Vector3 translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Set all elements of a 4x4 matrix to the same scalar value (scalar data contained in vector data type) - // - explicit inline Matrix4( floatInVec scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( Vector3 translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( Vector4 col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( Vector4 col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( Vector4 col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( Vector4 col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, Vector4 vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, Vector4 vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Set the element of a 4x4 matrix referred to by column and row indices (scalar data contained in vector data type) - // - inline Matrix4 & setElem( int col, int row, floatInVec val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline const floatInVec getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) - // - inline const Matrix4 operator *( floatInVec scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( Vector4 vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( Vector3 vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( Point3 pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a scalar (scalar data contained in vector data type) - // - inline Matrix4 & operator *=( floatInVec scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x axis (scalar data contained in vector data type) - // - static inline const Matrix4 rotationX( floatInVec radians ); - - // Construct a 4x4 matrix to rotate around the y axis (scalar data contained in vector data type) - // - static inline const Matrix4 rotationY( floatInVec radians ); - - // Construct a 4x4 matrix to rotate around the z axis (scalar data contained in vector data type) - // - static inline const Matrix4 rotationZ( floatInVec radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, Vector3 unitVec ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static inline const Matrix4 rotation( floatInVec radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( Quat unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( Vector3 scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( Vector3 translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Multiply a 4x4 matrix by a scalar (scalar data contained in vector data type) -// -inline const Matrix4 operator *( floatInVec scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline const floatInVec determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -// Conditionally select between two 4x4 matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, boolInVec select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( Vector3 col0, Vector3 col1, Vector3 col2, Vector3 col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, Vector3 translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( Quat unitQuat, Vector3 translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value (scalar data contained in vector data type) - // - explicit inline Transform3( floatInVec scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( Vector3 translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( Vector3 col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( Vector3 col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( Vector3 col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( Vector3 col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, Vector3 vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, Vector4 vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Set the element of a 3x4 transformation matrix referred to by column and row indices (scalar data contained in vector data type) - // - inline Transform3 & setElem( int col, int row, floatInVec val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline const floatInVec getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( Vector3 vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( Point3 pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x axis (scalar data contained in vector data type) - // - static inline const Transform3 rotationX( floatInVec radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis (scalar data contained in vector data type) - // - static inline const Transform3 rotationY( floatInVec radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis (scalar data contained in vector data type) - // - static inline const Transform3 rotationZ( floatInVec radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, Vector3 unitVec ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector (scalar data contained in vector data type) - // - static inline const Transform3 rotation( floatInVec radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( Quat unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( Vector3 scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( Vector3 translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// However, the transfer of select1 to a VMX register may use more processing time than a branch. -// Use the boolInVec version for better performance. -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -// Conditionally select between two 3x4 transformation matrices (scalar data contained in vector data type) -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, boolInVec select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h deleted file mode 100644 index 65932d803..000000000 --- a/Extras/vectormathlibrary/include/vectormath/ppu/cpp/vectormath_soa.h +++ /dev/null @@ -1,1919 +0,0 @@ -/* - 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_SOA_CPP_PPU_H -#define _VECTORMATH_SOA_CPP_PPU_H - -#include -#include -#include "vectormath_aos.h" - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Soa { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A set of four 3-D vectors in structure-of-arrays format -// -class Vector3 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( vec_float4 x, vec_float4 y, vec_float4 z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( vec_float4 scalar ); - - // Replicate an AoS 3-D vector - // - inline Vector3( Aos::Vector3 vec ); - - // Insert four AoS 3-D vectors - // - inline Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ); - - // Extract four AoS 3-D vectors - // - inline void get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const; - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( vec_float4 x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( vec_float4 y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( vec_float4 z ); - - // Get the x element of a 3-D vector - // - inline vec_float4 getX( ) const; - - // Get the y element of a 3-D vector - // - inline vec_float4 getY( ) const; - - // Get the z element of a 3-D vector - // - inline vec_float4 getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, vec_float4 value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( vec_float4 scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( vec_float4 scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline vec_float4 maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline vec_float4 minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline vec_float4 sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline vec_float4 lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline vec_float4 length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ); - -// Store four slots of an SoA 3-D vector in three quadwords -// -inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ); - -// Store eight slots of two SoA 3-D vectors as half-floats -// -inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A set of four 4-D vectors in structure-of-arrays format -// -class Vector4 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - vec_float4 mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, vec_float4 w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( vec_float4 scalar ); - - // Replicate an AoS 4-D vector - // - inline Vector4( Aos::Vector4 vec ); - - // Insert four AoS 4-D vectors - // - inline Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ); - - // Extract four AoS 4-D vectors - // - inline void get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const; - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( vec_float4 x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( vec_float4 y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( vec_float4 z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( vec_float4 w ); - - // Get the x element of a 4-D vector - // - inline vec_float4 getX( ) const; - - // Get the y element of a 4-D vector - // - inline vec_float4 getY( ) const; - - // Get the z element of a 4-D vector - // - inline vec_float4 getZ( ) const; - - // Get the w element of a 4-D vector - // - inline vec_float4 getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, vec_float4 value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( vec_float4 scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( vec_float4 scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline vec_float4 maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline vec_float4 minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline vec_float4 sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline vec_float4 lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline vec_float4 length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ); - -// Store four slots of an SoA 4-D vector as half-floats -// -inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A set of four 3-D points in structure-of-arrays format -// -class Point3 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( vec_float4 x, vec_float4 y, vec_float4 z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( vec_float4 scalar ); - - // Replicate an AoS 3-D point - // - inline Point3( Aos::Point3 pnt ); - - // Insert four AoS 3-D points - // - inline Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ); - - // Extract four AoS 3-D points - // - inline void get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const; - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( vec_float4 x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( vec_float4 y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( vec_float4 z ); - - // Get the x element of a 3-D point - // - inline vec_float4 getX( ) const; - - // Get the y element of a 3-D point - // - inline vec_float4 getY( ) const; - - // Get the z element of a 3-D point - // - inline vec_float4 getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, vec_float4 value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -}; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline vec_float4 maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline vec_float4 minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline vec_float4 sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline vec_float4 distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline vec_float4 distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ); - -// Load four three-float 3-D points, stored in three quadwords -// -inline void loadXYZArray( Point3 & pnt, const vec_float4 * threeQuads ); - -// Store four slots of an SoA 3-D point in three quadwords -// -inline void storeXYZArray( const Point3 & pnt, vec_float4 * threeQuads ); - -// Store eight slots of two SoA 3-D points as half-floats -// -inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A set of four quaternions in structure-of-arrays format -// -class Quat -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - vec_float4 mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, vec_float4 w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( vec_float4 scalar ); - - // Replicate an AoS quaternion - // - inline Quat( Aos::Quat quat ); - - // Insert four AoS quaternions - // - inline Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ); - - // Extract four AoS quaternions - // - inline void get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const; - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( vec_float4 x ); - - // Set the y element of a quaternion - // - inline Quat & setY( vec_float4 y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( vec_float4 z ); - - // Set the w element of a quaternion - // - inline Quat & setW( vec_float4 w ); - - // Get the x element of a quaternion - // - inline vec_float4 getX( ) const; - - // Get the y element of a quaternion - // - inline vec_float4 getY( ) const; - - // Get the z element of a quaternion - // - inline vec_float4 getZ( ) const; - - // Get the w element of a quaternion - // - inline vec_float4 getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, vec_float4 value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( vec_float4 scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( vec_float4 scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( vec_float4 radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( vec_float4 radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( vec_float4 radians ); - -}; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( vec_float4 scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline vec_float4 norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline vec_float4 length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A set of four 3x3 matrices in structure-of-arrays format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( vec_float4 scalar ); - - // Replicate an AoS 3x3 matrix - // - inline Matrix3( const Aos::Matrix3 & mat ); - - // Insert four AoS 3x3 matrices - // - inline Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ); - - // Extract four AoS 3x3 matrices - // - inline void get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const; - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( vec_float4 scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline vec_float4 determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A set of four 4x4 matrices in structure-of-arrays format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( vec_float4 scalar ); - - // Replicate an AoS 4x4 matrix - // - inline Matrix4( const Aos::Matrix4 & mat ); - - // Insert four AoS 4x4 matrices - // - inline Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ); - - // Extract four AoS 4x4 matrices - // - inline void get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const; - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( vec_float4 scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline vec_float4 determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A set of four 3x4 transformation matrices in structure-of-arrays format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( vec_float4 scalar ); - - // Replicate an AoS 3x4 transformation matrix - // - inline Transform3( const Aos::Transform3 & tfrm ); - - // Insert four AoS 3x4 transformation matrices - // - inline Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ); - - // Extract four AoS 3x4 transformation matrices - // - inline void get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const; - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Soa -} // namespace Vectormath - -#include "vec_soa.h" -#include "quat_soa.h" -#include "mat_soa.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h deleted file mode 100644 index 4e0d6ee5c..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos.h +++ /dev/null @@ -1,1452 +0,0 @@ -/* - 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_MAT_AOS_C_H -#define _VECTORMATH_MAT_AOS_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( &result->col0, &mat->col0 ); - vmathV3Copy( &result->col1, &mat->col1 ); - vmathV3Copy( &result->col2, &mat->col2 ); -} - -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); -} - -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat->x; - qy = unitQuat->y; - qz = unitQuat->z; - qw = unitQuat->w; - qx2 = ( qx + qx ); - qy2 = ( qy + qy ); - qz2 = ( qz + qz ); - qxqx2 = ( qx * qx2 ); - qxqy2 = ( qx * qy2 ); - qxqz2 = ( qx * qz2 ); - qxqw2 = ( qw * qx2 ); - qyqy2 = ( qy * qy2 ); - qyqz2 = ( qy * qz2 ); - qyqw2 = ( qw * qy2 ); - qzqz2 = ( qz * qz2 ); - qzqw2 = ( qw * qz2 ); - vmathV3MakeFromElems( &result->col0, ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); - vmathV3MakeFromElems( &result->col1, ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); - vmathV3MakeFromElems( &result->col2, ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); -} - -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); -} - -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathM3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, mat, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col0 ); -} - -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col1 ); -} - -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col2 ); -} - -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) -{ - vmathV3Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) -{ - vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); -} - -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - VmathMatrix3 tmpResult; - vmathV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); - vmathV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); - vmathV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); - vmathM3Copy( result, &tmpResult ); -} - -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - VmathVector3 tmp0, tmp1, tmp2; - float detinv; - vmathV3Cross( &tmp0, &mat->col1, &mat->col2 ); - vmathV3Cross( &tmp1, &mat->col2, &mat->col0 ); - vmathV3Cross( &tmp2, &mat->col0, &mat->col1 ); - detinv = ( 1.0f / vmathV3Dot( &mat->col2, &tmp2 ) ); - vmathV3MakeFromElems( &result->col0, ( tmp0.x * detinv ), ( tmp1.x * detinv ), ( tmp2.x * detinv ) ); - vmathV3MakeFromElems( &result->col1, ( tmp0.y * detinv ), ( tmp1.y * detinv ), ( tmp2.y * detinv ) ); - vmathV3MakeFromElems( &result->col2, ( tmp0.z * detinv ), ( tmp1.z * detinv ), ( tmp2.z * detinv ) ); -} - -static inline float vmathM3Determinant( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0; - vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); - return vmathV3Dot( &mat->col2, &tmpV3_0 ); -} - -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Neg( &result->col0, &mat->col0 ); - vmathV3Neg( &result->col1, &mat->col1 ); - vmathV3Neg( &result->col2, &mat->col2 ); -} - -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3AbsPerElem( &result->col0, &mat->col0 ); - vmathV3AbsPerElem( &result->col1, &mat->col1 ); - vmathV3AbsPerElem( &result->col2, &mat->col2 ); -} - -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); -} - -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) -{ - float tmpX, tmpY, tmpZ; - tmpX = ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ); - tmpY = ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ); - tmpZ = ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ); - vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - VmathMatrix3 tmpResult; - vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM3Copy( result, &tmpResult ); -} - -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeFromElems( &result->col1, 0.0f, c, s ); - vmathV3MakeFromElems( &result->col2, 0.0f, -s, c ); -} - -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeFromElems( &result->col0, c, 0.0f, -s ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeFromElems( &result->col2, s, 0.0f, c ); -} - -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeFromElems( &result->col0, c, s, 0.0f ); - vmathV3MakeFromElems( &result->col1, -s, c, 0.0f ); - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ->x ); - cX = cosf( radiansXYZ->x ); - sY = sinf( radiansXYZ->y ); - cY = cosf( radiansXYZ->y ); - sZ = sinf( radiansXYZ->z ); - cZ = cosf( radiansXYZ->z ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - vmathV3MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY ); - vmathV3MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ); - vmathV3MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ); -} - -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - vmathV3MakeFromElems( &result->col0, ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ); - vmathV3MakeFromElems( &result->col1, ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ); - vmathV3MakeFromElems( &result->col2, ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ); -} - -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - vmathM3MakeFromQ( result, unitQuat ); -} - -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) -{ - vmathV3MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f ); - vmathV3MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f ); - vmathV3MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z ); -} - -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); -} - -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) -{ - vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); -} - -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathM3GetRow( &tmpV3_0, mat, 0 ); - vmathV3Print( &tmpV3_0 ); - vmathM3GetRow( &tmpV3_1, mat, 1 ); - vmathV3Print( &tmpV3_1 ); - vmathM3GetRow( &tmpV3_2, mat, 2 ); - vmathV3Print( &tmpV3_2 ); -} - -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM3Print( mat ); -} - -#endif - -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( &result->col0, &mat->col0 ); - vmathV4Copy( &result->col1, &mat->col1 ); - vmathV4Copy( &result->col2, &mat->col2 ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) -{ - vmathV4MakeFromScalar( &result->col0, scalar ); - vmathV4MakeFromScalar( &result->col1, scalar ); - vmathV4MakeFromScalar( &result->col2, scalar ); - vmathV4MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); -} - -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col0, _col0 ); - vmathV4Copy( &result->col1, _col1 ); - vmathV4Copy( &result->col2, _col2 ); - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 mat; - vmathM3MakeFromQ( &mat, unitQuat ); - vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) -{ - vmathV4Copy( &result->col0, _col0 ); -} - -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) -{ - vmathV4Copy( &result->col1, _col1 ); -} - -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) -{ - vmathV4Copy( &result->col2, _col2 ); -} - -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) -{ - vmathV4Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) -{ - vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) -{ - VmathVector4 tmpV3_0; - vmathM4GetCol( &tmpV3_0, result, col ); - vmathV4SetElem( &tmpV3_0, row, val ); - vmathM4SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) -{ - VmathVector4 tmpV4_0; - vmathM4GetCol( &tmpV4_0, mat, col ); - return vmathV4GetElem( &tmpV4_0, row ); -} - -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col0 ); -} - -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col1 ); -} - -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col2 ); -} - -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col3 ); -} - -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) -{ - vmathV4Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) -{ - vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); -} - -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathMatrix4 tmpResult; - vmathV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); - vmathV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); - vmathV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); - vmathV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathVector4 res0, res1, res2, res3; - float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - vmathV4SetX( &res0, ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); - vmathV4SetY( &res0, ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); - vmathV4SetZ( &res0, ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); - vmathV4SetW( &res0, ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); - detInv = ( 1.0f / ( ( ( ( mA * res0.x ) + ( mE * res0.y ) ) + ( mI * res0.z ) ) + ( mM * res0.w ) ) ); - vmathV4SetX( &res1, ( mI * tmp1 ) ); - vmathV4SetY( &res1, ( mM * tmp0 ) ); - vmathV4SetZ( &res1, ( mA * tmp1 ) ); - vmathV4SetW( &res1, ( mE * tmp0 ) ); - vmathV4SetX( &res3, ( mI * tmp3 ) ); - vmathV4SetY( &res3, ( mM * tmp2 ) ); - vmathV4SetZ( &res3, ( mA * tmp3 ) ); - vmathV4SetW( &res3, ( mE * tmp2 ) ); - vmathV4SetX( &res2, ( mI * tmp5 ) ); - vmathV4SetY( &res2, ( mM * tmp4 ) ); - vmathV4SetZ( &res2, ( mA * tmp5 ) ); - vmathV4SetW( &res2, ( mE * tmp4 ) ); - tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); - tmp1 = ( ( mM * mF ) - ( mE * mN ) ); - tmp2 = ( ( mI * mD ) - ( mA * mL ) ); - tmp3 = ( ( mM * mH ) - ( mE * mP ) ); - tmp4 = ( ( mI * mC ) - ( mA * mK ) ); - tmp5 = ( ( mM * mG ) - ( mE * mO ) ); - vmathV4SetX( &res2, ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.x ) ); - vmathV4SetY( &res2, ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.y ) ); - vmathV4SetZ( &res2, ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.z ) ); - vmathV4SetW( &res2, ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.w ) ); - vmathV4SetX( &res3, ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.x ) ); - vmathV4SetY( &res3, ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.y ) ); - vmathV4SetZ( &res3, ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.z ) ); - vmathV4SetW( &res3, ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.w ) ); - vmathV4SetX( &res1, ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.x ) ); - vmathV4SetY( &res1, ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.y ) ); - vmathV4SetZ( &res1, ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.z ) ); - vmathV4SetW( &res1, ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.w ) ); - vmathV4ScalarMul( &result->col0, &res0, detInv ); - vmathV4ScalarMul( &result->col1, &res1, detInv ); - vmathV4ScalarMul( &result->col2, &res2, detInv ); - vmathV4ScalarMul( &result->col3, &res3, detInv ); -} - -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3Inverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3OrthoInverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline float vmathM4Determinant( const VmathMatrix4 *mat ) -{ - float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); - dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); - dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); - dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); - return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); -} - -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Neg( &result->col0, &mat->col0 ); - vmathV4Neg( &result->col1, &mat->col1 ); - vmathV4Neg( &result->col2, &mat->col2 ); - vmathV4Neg( &result->col3, &mat->col3 ); -} - -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4AbsPerElem( &result->col0, &mat->col0 ); - vmathV4AbsPerElem( &result->col1, &mat->col1 ); - vmathV4AbsPerElem( &result->col2, &mat->col2 ); - vmathV4AbsPerElem( &result->col3, &mat->col3 ); -} - -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); - vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); -} - -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) -{ - float tmpX, tmpY, tmpZ, tmpW; - tmpX = ( ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ) + ( mat->col3.x * vec->w ) ); - tmpY = ( ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ) + ( mat->col3.y * vec->w ) ); - tmpZ = ( ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ) + ( mat->col3.z * vec->w ) ); - tmpW = ( ( ( ( mat->col0.w * vec->x ) + ( mat->col1.w * vec->y ) ) + ( mat->col2.w * vec->z ) ) + ( mat->col3.w * vec->w ) ); - vmathV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) -{ - result->x = ( ( ( mat->col0.x * vec->x ) + ( mat->col1.x * vec->y ) ) + ( mat->col2.x * vec->z ) ); - result->y = ( ( ( mat->col0.y * vec->x ) + ( mat->col1.y * vec->y ) ) + ( mat->col2.y * vec->z ) ); - result->z = ( ( ( mat->col0.z * vec->x ) + ( mat->col1.z * vec->y ) ) + ( mat->col2.z * vec->z ) ); - result->w = ( ( ( mat->col0.w * vec->x ) + ( mat->col1.w * vec->y ) ) + ( mat->col2.w * vec->z ) ); -} - -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) -{ - result->x = ( ( ( ( mat->col0.x * pnt->x ) + ( mat->col1.x * pnt->y ) ) + ( mat->col2.x * pnt->z ) ) + mat->col3.x ); - result->y = ( ( ( ( mat->col0.y * pnt->x ) + ( mat->col1.y * pnt->y ) ) + ( mat->col2.y * pnt->z ) ) + mat->col3.y ); - result->z = ( ( ( ( mat->col0.z * pnt->x ) + ( mat->col1.z * pnt->y ) ) + ( mat->col2.z * pnt->z ) ) + mat->col3.z ); - result->w = ( ( ( ( mat->col0.w * pnt->x ) + ( mat->col1.w * pnt->y ) ) + ( mat->col2.w * pnt->z ) ) + mat->col3.w ); -} - -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - VmathMatrix4 tmpResult; - vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) -{ - VmathMatrix4 tmpResult; - VmathPoint3 tmpP3_0; - vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); - vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); - vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) -{ - vmathV4SetXYZ( &result->col0, &mat3->col0 ); - vmathV4SetXYZ( &result->col1, &mat3->col1 ); - vmathV4SetXYZ( &result->col2, &mat3->col2 ); -} - -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( &result->col0, &mat->col0 ); - vmathV4GetXYZ( &result->col1, &mat->col1 ); - vmathV4GetXYZ( &result->col2, &mat->col2 ); -} - -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4SetXYZ( &result->col3, translateVec ); -} - -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( result, &mat->col3 ); -} - -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeFromElems( &result->col1, 0.0f, c, s, 0.0f ); - vmathV4MakeFromElems( &result->col2, 0.0f, -s, c, 0.0f ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV4MakeFromElems( &result->col0, c, 0.0f, -s, 0.0f ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeFromElems( &result->col2, s, 0.0f, c, 0.0f ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV4MakeFromElems( &result->col0, c, s, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col1, -s, c, 0.0f, 0.0f ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ->x ); - cX = cosf( radiansXYZ->x ); - sY = sinf( radiansXYZ->y ); - cY = cosf( radiansXYZ->y ); - sZ = sinf( radiansXYZ->z ); - cZ = cosf( radiansXYZ->z ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - vmathV4MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ); - vmathV4MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ); - vmathV4MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - vmathV4MakeFromElems( &result->col0, ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ); - vmathV4MakeFromElems( &result->col1, ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ); - vmathV4MakeFromElems( &result->col2, ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) -{ - VmathTransform3 tmpT3_0; - vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) -{ - vmathV4MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z, 0.0f ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) -{ - VmathVector4 scale4; - vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); - vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); - vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); - vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); - vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); -} - -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) -{ - VmathMatrix4 m4EyeFrame; - VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathV3Normalize( &v3Y, upVec ); - vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); - vmathV3Normalize( &v3Z, &tmpV3_0 ); - vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); - vmathV3Normalize( &v3X, &tmpV3_1 ); - vmathV3Cross( &v3Y, &v3Z, &v3X ); - vmathV4MakeFromV3( &tmpV4_0, &v3X ); - vmathV4MakeFromV3( &tmpV4_1, &v3Y ); - vmathV4MakeFromV3( &tmpV4_2, &v3Z ); - vmathV4MakeFromP3( &tmpV4_3, eyePos ); - vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); - vmathM4OrthoInverse( result, &m4EyeFrame ); -} - -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); - rangeInv = ( 1.0f / ( zNear - zFar ) ); - vmathV4MakeFromElems( &result->col0, ( f / aspect ), 0.0f, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col1, 0.0f, f, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ); - vmathV4MakeFromElems( &result->col3, 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ); -} - -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - n2 = ( zNear + zNear ); - vmathV4MakeFromElems( &result->col0, ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col1, 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col2, ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ); - vmathV4MakeFromElems( &result->col3, 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ); -} - -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - vmathV4MakeFromElems( &result->col0, ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col1, 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ); - vmathV4MakeFromElems( &result->col2, 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ); - vmathV4MakeFromElems( &result->col3, ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ); -} - -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) -{ - vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); - vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print( const VmathMatrix4 *mat ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathM4GetRow( &tmpV4_0, mat, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathM4GetRow( &tmpV4_1, mat, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathM4GetRow( &tmpV4_2, mat, 2 ); - vmathV4Print( &tmpV4_2 ); - vmathM4GetRow( &tmpV4_3, mat, 3 ); - vmathV4Print( &tmpV4_3 ); -} - -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM4Print( mat ); -} - -#endif - -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); - vmathV3MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) -{ - vmathT3SetUpper3x3( result, tfrm ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 tmpM3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathT3SetUpper3x3( result, &tmpM3_0 ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathT3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, tfrm, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col0 ); -} - -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col1 ); -} - -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col2 ); -} - -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) -{ - vmathV3Copy( result, (&tfrm->col0 + col) ); -} - -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) -{ - vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); -} - -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - VmathVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - float detinv; - vmathV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); - vmathV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); - vmathV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); - detinv = ( 1.0f / vmathV3Dot( &tfrm->col2, &tmp2 ) ); - vmathV3MakeFromElems( &inv0, ( tmp0.x * detinv ), ( tmp1.x * detinv ), ( tmp2.x * detinv ) ); - vmathV3MakeFromElems( &inv1, ( tmp0.y * detinv ), ( tmp1.y * detinv ), ( tmp2.y * detinv ) ); - vmathV3MakeFromElems( &inv2, ( tmp0.z * detinv ), ( tmp1.z * detinv ), ( tmp2.z * detinv ) ); - vmathV3Copy( &result->col0, &inv0 ); - vmathV3Copy( &result->col1, &inv1 ); - vmathV3Copy( &result->col2, &inv2 ); - vmathV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - VmathVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - vmathV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); - vmathV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); - vmathV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); - vmathV3Copy( &result->col0, &inv0 ); - vmathV3Copy( &result->col1, &inv1 ); - vmathV3Copy( &result->col2, &inv2 ); - vmathV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); - vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); - vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); - vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) -{ - float tmpX, tmpY, tmpZ; - tmpX = ( ( ( tfrm->col0.x * vec->x ) + ( tfrm->col1.x * vec->y ) ) + ( tfrm->col2.x * vec->z ) ); - tmpY = ( ( ( tfrm->col0.y * vec->x ) + ( tfrm->col1.y * vec->y ) ) + ( tfrm->col2.y * vec->z ) ); - tmpZ = ( ( ( tfrm->col0.z * vec->x ) + ( tfrm->col1.z * vec->y ) ) + ( tfrm->col2.z * vec->z ) ); - vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) -{ - float tmpX, tmpY, tmpZ; - tmpX = ( ( ( ( tfrm->col0.x * pnt->x ) + ( tfrm->col1.x * pnt->y ) ) + ( tfrm->col2.x * pnt->z ) ) + tfrm->col3.x ); - tmpY = ( ( ( ( tfrm->col0.y * pnt->x ) + ( tfrm->col1.y * pnt->y ) ) + ( tfrm->col2.y * pnt->z ) ) + tfrm->col3.y ); - tmpZ = ( ( ( ( tfrm->col0.z * pnt->x ) + ( tfrm->col1.z * pnt->y ) ) + ( tfrm->col2.z * pnt->z ) ) + tfrm->col3.z ); - vmathP3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - VmathTransform3 tmpResult; - VmathPoint3 tmpP3_0, tmpP3_1; - vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); - vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); - vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); - vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); - vmathT3Copy( result, &tmpResult ); -} - -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); - vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); - vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); - vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); -} - -static inline void vmathT3MakeIdentity( VmathTransform3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); -} - -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) -{ - vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); -} - -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeFromElems( &result->col1, 0.0f, c, s ); - vmathV3MakeFromElems( &result->col2, 0.0f, -s, c ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeFromElems( &result->col0, c, 0.0f, -s ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeFromElems( &result->col2, s, 0.0f, c ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - vmathV3MakeFromElems( &result->col0, c, s, 0.0f ); - vmathV3MakeFromElems( &result->col1, -s, c, 0.0f ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ->x ); - cX = cosf( radiansXYZ->x ); - sY = sinf( radiansXYZ->y ); - cY = cosf( radiansXYZ->y ); - sZ = sinf( radiansXYZ->z ); - cZ = cosf( radiansXYZ->z ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - vmathV3MakeFromElems( &result->col0, ( cZ * cY ), ( sZ * cY ), -sY ); - vmathV3MakeFromElems( &result->col1, ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ); - vmathV3MakeFromElems( &result->col2, ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) -{ - vmathV3MakeFromElems( &result->col0, scaleVec->x, 0.0f, 0.0f ); - vmathV3MakeFromElems( &result->col1, 0.0f, scaleVec->y, 0.0f ); - vmathV3MakeFromElems( &result->col2, 0.0f, 0.0f, scaleVec->z ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) -{ - vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); - vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); -} - -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); - vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); - vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); - vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print( const VmathTransform3 *tfrm ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; - vmathT3GetRow( &tmpV4_0, tfrm, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathT3GetRow( &tmpV4_1, tfrm, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathT3GetRow( &tmpV4_2, tfrm, 2 ); - vmathV4Print( &tmpV4_2 ); -} - -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) -{ - printf("%s:\n", name); - vmathT3Print( tfrm ); -} - -#endif - -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) -{ - float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - int negTrace, ZgtX, ZgtY, YgtX; - int largestXorY, largestYorZ, largestZorX; - - xx = tfrm->col0.x; - yx = tfrm->col0.y; - zx = tfrm->col0.z; - xy = tfrm->col1.x; - yy = tfrm->col1.y; - zy = tfrm->col1.z; - xz = tfrm->col2.x; - yz = tfrm->col2.y; - zz = tfrm->col2.z; - - trace = ( ( xx + yy ) + zz ); - - negTrace = ( trace < 0.0f ); - ZgtX = zz > xx; - ZgtY = zz > yy; - YgtX = yy > xx; - largestXorY = ( !ZgtX || !ZgtY ) && negTrace; - largestYorZ = ( YgtX || ZgtX ) && negTrace; - largestZorX = ( ZgtY || !YgtX ) && negTrace; - - if ( largestXorY ) - { - zz = -zz; - xy = -xy; - } - if ( largestYorZ ) - { - xx = -xx; - yz = -yz; - } - if ( largestZorX ) - { - yy = -yy; - zx = -zx; - } - - radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); - scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); - - tmpx = ( ( zy - yz ) * scale ); - tmpy = ( ( xz - zx ) * scale ); - tmpz = ( ( yx - xy ) * scale ); - tmpw = ( radicand * scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - if ( largestXorY ) - { - qx = tmpw; - qy = tmpz; - qz = tmpy; - qw = tmpx; - } - if ( largestYorZ ) - { - tmpx = qx; - tmpz = qz; - qx = qy; - qy = tmpx; - qz = qw; - qw = tmpz; - } - - result->x = qx; - result->y = qy; - result->z = qz; - result->w = qw; -} - -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) -{ - vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); - vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); - vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); -} - -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) -{ - vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); - vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); - vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); - vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); -} - -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - float tmpX, tmpY, tmpZ; - tmpX = ( ( ( vec->x * mat->col0.x ) + ( vec->y * mat->col0.y ) ) + ( vec->z * mat->col0.z ) ); - tmpY = ( ( ( vec->x * mat->col1.x ) + ( vec->y * mat->col1.y ) ) + ( vec->z * mat->col1.z ) ); - tmpZ = ( ( ( vec->x * mat->col2.x ) + ( vec->y * mat->col2.y ) ) + ( vec->z * mat->col2.z ) ); - vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) -{ - vmathV3MakeFromElems( &result->col0, 0.0f, vec->z, -vec->y ); - vmathV3MakeFromElems( &result->col1, -vec->z, 0.0f, vec->x ); - vmathV3MakeFromElems( &result->col2, vec->y, -vec->x, 0.0f ); -} - -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); - vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); - vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); - vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h deleted file mode 100644 index 270ffcb50..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/mat_aos_v.h +++ /dev/null @@ -1,1006 +0,0 @@ -/* - 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_MAT_AOS_V_C_H -#define _VECTORMATH_MAT_AOS_V_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) -{ - VmathMatrix3 result; - vmathM3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeFromQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) -{ - VmathMatrix3 result; - vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); - return result; -} - -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) -{ - vmathM3SetCol0(result, &_col0); -} - -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) -{ - vmathM3SetCol1(result, &_col1); -} - -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) -{ - vmathM3SetCol2(result, &_col2); -} - -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) -{ - vmathM3SetCol(result, col, &vec); -} - -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) -{ - vmathM3SetRow(result, row, &vec); -} - -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) -{ - vmathM3SetElem(result, col, row, val); -} - -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) -{ - return vmathM3GetElem(&mat, col, row); -} - -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol0(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol1(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol2(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) -{ - VmathVector3 result; - vmathM3GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) -{ - VmathVector3 result; - vmathM3GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Inverse(&result, &mat); - return result; -} - -static inline float vmathM3Determinant_V( VmathMatrix3 mat ) -{ - return vmathM3Determinant(&mat); -} - -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Neg(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) -{ - VmathMatrix3 result; - vmathM3ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathM3MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MakeIdentity_V( ) -{ - VmathMatrix3 result; - vmathM3MakeIdentity(&result); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix3 result; - vmathM3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) -{ - VmathMatrix3 result; - vmathM3Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print_V( VmathMatrix3 mat ) -{ - vmathM3Print(&mat); -} - -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) -{ - vmathM3Prints(&mat, name); -} - -#endif - -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) -{ - VmathMatrix4 result; - vmathM4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) -{ - VmathMatrix4 result; - vmathM4MakeFromT3(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) -{ - VmathMatrix4 result; - vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromM3V3(&result, &mat, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) -{ - vmathM4SetCol0(result, &_col0); -} - -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) -{ - vmathM4SetCol1(result, &_col1); -} - -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) -{ - vmathM4SetCol2(result, &_col2); -} - -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) -{ - vmathM4SetCol3(result, &_col3); -} - -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) -{ - vmathM4SetCol(result, col, &vec); -} - -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) -{ - vmathM4SetRow(result, row, &vec); -} - -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) -{ - vmathM4SetElem(result, col, row, val); -} - -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) -{ - return vmathM4GetElem(&mat, col, row); -} - -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol0(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol1(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol2(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol3(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) -{ - VmathVector4 result; - vmathM4GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) -{ - VmathVector4 result; - vmathM4GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Inverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AffineInverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4OrthoInverse(&result, &mat); - return result; -} - -static inline float vmathM4Determinant_V( VmathMatrix4 mat ) -{ - return vmathM4Determinant(&mat); -} - -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Neg(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) -{ - VmathMatrix4 result; - vmathM4ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) -{ - VmathVector4 result; - vmathM4MulV4(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) -{ - VmathVector4 result; - vmathM4MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathM4MulP3(&result, &mat, &pnt); - return result; -} - -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) -{ - VmathMatrix4 result; - vmathM4MulT3(&result, &mat, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MakeIdentity_V( ) -{ - VmathMatrix4 result; - vmathM4MakeIdentity(&result); - return result; -} - -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) -{ - vmathM4SetUpper3x3(result, &mat3); -} - -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) -{ - VmathMatrix3 result; - vmathM4GetUpper3x3(&result, &mat); - return result; -} - -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) -{ - vmathM4SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) -{ - VmathVector3 result; - vmathM4GetTranslation(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix4 result; - vmathM4MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix4 result; - vmathM4MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) -{ - VmathMatrix4 result; - vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) -{ - VmathMatrix4 result; - vmathM4Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print_V( VmathMatrix4 mat ) -{ - vmathM4Print(&mat); -} - -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) -{ - vmathM4Prints(&mat, name); -} - -#endif - -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) -{ - VmathTransform3 result; - vmathT3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) -{ - VmathTransform3 result; - vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) -{ - vmathT3SetCol0(result, &_col0); -} - -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) -{ - vmathT3SetCol1(result, &_col1); -} - -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) -{ - vmathT3SetCol2(result, &_col2); -} - -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) -{ - vmathT3SetCol3(result, &_col3); -} - -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) -{ - vmathT3SetCol(result, col, &vec); -} - -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) -{ - vmathT3SetRow(result, row, &vec); -} - -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) -{ - vmathT3SetElem(result, col, row, val); -} - -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) -{ - return vmathT3GetElem(&tfrm, col, row); -} - -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol0(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol1(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol2(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol3(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) -{ - VmathVector3 result; - vmathT3GetCol(&result, &tfrm, col); - return result; -} - -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) -{ - VmathVector4 result; - vmathT3GetRow(&result, &tfrm, row); - return result; -} - -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3Inverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3OrthoInverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3AbsPerElem(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) -{ - VmathVector3 result; - vmathT3MulV3(&result, &tfrm, &vec); - return result; -} - -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathT3MulP3(&result, &tfrm, &pnt); - return result; -} - -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3Mul(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3MulPerElem(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MakeIdentity_V( ) -{ - VmathTransform3 result; - vmathT3MakeIdentity(&result); - return result; -} - -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) -{ - vmathT3SetUpper3x3(result, &tfrm); -} - -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) -{ - VmathMatrix3 result; - vmathT3GetUpper3x3(&result, &tfrm); - return result; -} - -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) -{ - vmathT3SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetTranslation(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationX(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationY(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathTransform3 result; - vmathT3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathTransform3 result; - vmathT3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathTransform3 result; - vmathT3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3AppendScale(&result, &tfrm, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3PrependScale(&result, &scaleVec, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) -{ - VmathTransform3 result; - vmathT3Select(&result, &tfrm0, &tfrm1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print_V( VmathTransform3 tfrm ) -{ - vmathT3Print(&tfrm); -} - -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) -{ - vmathT3Prints(&tfrm, name); -} - -#endif - -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) -{ - VmathQuat result; - vmathQMakeFromM3(&result, &tfrm); - return result; -} - -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) -{ - VmathMatrix3 result; - vmathV3Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) -{ - VmathMatrix4 result; - vmathV4Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathV3RowMul(&result, &vec, &mat); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) -{ - VmathMatrix3 result; - vmathV3CrossMatrix(&result, &vec); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathV3CrossMatrixMul(&result, &vec, &mat); - return result; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h deleted file mode 100644 index c886ab669..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - 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_C_H -#define _VECTORMATH_QUAT_AOS_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) -{ - vmathQSetXYZ( result, xyz ); - vmathQSetW( result, _w ); -} - -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathQMakeIdentity( VmathQuat *result ) -{ - vmathQMakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f ); -} - -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - VmathQuat tmpQ_0, tmpQ_1; - vmathQSub( &tmpQ_0, quat1, quat0 ); - vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); - vmathQAdd( result, quat0, &tmpQ_1 ); -} - -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) -{ - VmathQuat start, tmpQ_0, tmpQ_1; - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = vmathQDot( unitQuat0, unitQuat1 ); - if ( cosAngle < 0.0f ) { - cosAngle = -cosAngle; - vmathQNeg( &start, unitQuat0 ); - } else { - vmathQCopy( &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; - } - vmathQScalarMul( &tmpQ_0, &start, scale0 ); - vmathQScalarMul( &tmpQ_1, unitQuat1, scale1 ); - vmathQAdd( result, &tmpQ_0, &tmpQ_1 ); -} - -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) -{ - VmathQuat tmp0, tmp1; - vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); - vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); - vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); -} - -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) -{ - vmathV3MakeFromElems( result, quat->x, quat->y, quat->z ); -} - -static inline void vmathQSetX( VmathQuat *result, float _x ) -{ - result->x = _x; -} - -static inline float vmathQGetX( const VmathQuat *quat ) -{ - return quat->x; -} - -static inline void vmathQSetY( VmathQuat *result, float _y ) -{ - result->y = _y; -} - -static inline float vmathQGetY( const VmathQuat *quat ) -{ - return quat->y; -} - -static inline void vmathQSetZ( VmathQuat *result, float _z ) -{ - result->z = _z; -} - -static inline float vmathQGetZ( const VmathQuat *quat ) -{ - return quat->z; -} - -static inline void vmathQSetW( VmathQuat *result, float _w ) -{ - result->w = _w; -} - -static inline float vmathQGetW( const VmathQuat *quat ) -{ - return quat->w; -} - -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) -{ - *(&result->x + idx) = value; -} - -static inline float vmathQGetElem( const VmathQuat *quat, int idx ) -{ - return *(&quat->x + idx); -} - -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->x = ( quat0->x + quat1->x ); - result->y = ( quat0->y + quat1->y ); - result->z = ( quat0->z + quat1->z ); - result->w = ( quat0->w + quat1->w ); -} - -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->x = ( quat0->x - quat1->x ); - result->y = ( quat0->y - quat1->y ); - result->z = ( quat0->z - quat1->z ); - result->w = ( quat0->w - quat1->w ); -} - -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->x = ( quat->x * scalar ); - result->y = ( quat->y * scalar ); - result->z = ( quat->z * scalar ); - result->w = ( quat->w * scalar ); -} - -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->x = ( quat->x / scalar ); - result->y = ( quat->y / scalar ); - result->z = ( quat->z / scalar ); - result->w = ( quat->w / scalar ); -} - -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) -{ - result->x = -quat->x; - result->y = -quat->y; - result->z = -quat->z; - result->w = -quat->w; -} - -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - float result; - result = ( quat0->x * quat1->x ); - result = ( result + ( quat0->y * quat1->y ) ); - result = ( result + ( quat0->z * quat1->z ) ); - result = ( result + ( quat0->w * quat1->w ) ); - return result; -} - -static inline float vmathQNorm( const VmathQuat *quat ) -{ - float result; - result = ( quat->x * quat->x ); - result = ( result + ( quat->y * quat->y ) ); - result = ( result + ( quat->z * quat->z ) ); - result = ( result + ( quat->w * quat->w ) ); - return result; -} - -static inline float vmathQLength( const VmathQuat *quat ) -{ - return sqrtf( vmathQNorm( quat ) ); -} - -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) -{ - float lenSqr, lenInv; - lenSqr = vmathQNorm( quat ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - result->x = ( quat->x * lenInv ); - result->y = ( quat->y * lenInv ); - result->z = ( quat->z * lenInv ); - result->w = ( quat->w * lenInv ); -} - -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - float cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf( ( 2.0f * ( 1.0f + vmathV3Dot( unitVec0, unitVec1 ) ) ) ); - recipCosHalfAngleX2 = ( 1.0f / cosHalfAngleX2 ); - vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); - vmathQMakeFromV3Scalar( result, &tmpV3_1, ( cosHalfAngleX2 * 0.5f ) ); -} - -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) -{ - VmathVector3 tmpV3_0; - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - vmathV3ScalarMul( &tmpV3_0, unitVec, s ); - vmathQMakeFromV3Scalar( result, &tmpV3_0, c ); -} - -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - vmathQMakeFromElems( result, s, 0.0f, 0.0f, c ); -} - -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - vmathQMakeFromElems( result, 0.0f, s, 0.0f, c ); -} - -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) -{ - float s, c, angle; - angle = ( radians * 0.5f ); - s = sinf( angle ); - c = cosf( angle ); - vmathQMakeFromElems( result, 0.0f, 0.0f, s, c ); -} - -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - float tmpX, tmpY, tmpZ, tmpW; - tmpX = ( ( ( ( quat0->w * quat1->x ) + ( quat0->x * quat1->w ) ) + ( quat0->y * quat1->z ) ) - ( quat0->z * quat1->y ) ); - tmpY = ( ( ( ( quat0->w * quat1->y ) + ( quat0->y * quat1->w ) ) + ( quat0->z * quat1->x ) ) - ( quat0->x * quat1->z ) ); - tmpZ = ( ( ( ( quat0->w * quat1->z ) + ( quat0->z * quat1->w ) ) + ( quat0->x * quat1->y ) ) - ( quat0->y * quat1->x ) ); - tmpW = ( ( ( ( quat0->w * quat1->w ) - ( quat0->x * quat1->x ) ) - ( quat0->y * quat1->y ) ) - ( quat0->z * quat1->z ) ); - vmathQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) -{ - float tmpX, tmpY, tmpZ, tmpW; - tmpX = ( ( ( quat->w * vec->x ) + ( quat->y * vec->z ) ) - ( quat->z * vec->y ) ); - tmpY = ( ( ( quat->w * vec->y ) + ( quat->z * vec->x ) ) - ( quat->x * vec->z ) ); - tmpZ = ( ( ( quat->w * vec->z ) + ( quat->x * vec->y ) ) - ( quat->y * vec->x ) ); - tmpW = ( ( ( quat->x * vec->x ) + ( quat->y * vec->y ) ) + ( quat->z * vec->z ) ); - result->x = ( ( ( ( tmpW * quat->x ) + ( tmpX * quat->w ) ) - ( tmpY * quat->z ) ) + ( tmpZ * quat->y ) ); - result->y = ( ( ( ( tmpW * quat->y ) + ( tmpY * quat->w ) ) - ( tmpZ * quat->x ) ) + ( tmpX * quat->z ) ); - result->z = ( ( ( ( tmpW * quat->z ) + ( tmpZ * quat->w ) ) - ( tmpX * quat->y ) ) + ( tmpY * quat->x ) ); -} - -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) -{ - vmathQMakeFromElems( result, -quat->x, -quat->y, -quat->z, quat->w ); -} - -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) -{ - result->x = ( select1 )? quat1->x : quat0->x; - result->y = ( select1 )? quat1->y : quat0->y; - result->z = ( select1 )? quat1->z : quat0->z; - result->w = ( select1 )? quat1->w : quat0->w; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint( const VmathQuat *quat ) -{ - printf( "( %f %f %f %f )\n", quat->x, quat->y, quat->z, quat->w ); -} - -static inline void vmathQPrints( const VmathQuat *quat, const char *name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, quat->x, quat->y, quat->z, quat->w ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h deleted file mode 100644 index b5a9e248d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/quat_aos_v.h +++ /dev/null @@ -1,300 +0,0 @@ -/* - 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_V_C_H -#define _VECTORMATH_QUAT_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathQuat result; - vmathQMakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathQuat result; - vmathQMakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) -{ - VmathQuat result; - vmathQMakeFromV4(&result, &vec); - return result; -} - -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) -{ - VmathQuat result; - vmathQMakeFromScalar(&result, scalar); - return result; -} - -static inline VmathQuat vmathQMakeIdentity_V( ) -{ - VmathQuat result; - vmathQMakeIdentity(&result); - return result; -} - -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQLerp(&result, t, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) -{ - VmathQuat result; - vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); - return result; -} - -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) -{ - VmathQuat result; - vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); - return result; -} - -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) -{ - vmathQSetXYZ(result, &vec); -} - -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) -{ - VmathVector3 result; - vmathQGetXYZ(&result, &quat); - return result; -} - -static inline void vmathQSetX_V( VmathQuat *result, float _x ) -{ - vmathQSetX(result, _x); -} - -static inline float vmathQGetX_V( VmathQuat quat ) -{ - return vmathQGetX(&quat); -} - -static inline void vmathQSetY_V( VmathQuat *result, float _y ) -{ - vmathQSetY(result, _y); -} - -static inline float vmathQGetY_V( VmathQuat quat ) -{ - return vmathQGetY(&quat); -} - -static inline void vmathQSetZ_V( VmathQuat *result, float _z ) -{ - vmathQSetZ(result, _z); -} - -static inline float vmathQGetZ_V( VmathQuat quat ) -{ - return vmathQGetZ(&quat); -} - -static inline void vmathQSetW_V( VmathQuat *result, float _w ) -{ - vmathQSetW(result, _w); -} - -static inline float vmathQGetW_V( VmathQuat quat ) -{ - return vmathQGetW(&quat); -} - -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) -{ - vmathQSetElem(result, idx, value); -} - -static inline float vmathQGetElem_V( VmathQuat quat, int idx ) -{ - return vmathQGetElem(&quat, idx); -} - -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQAdd(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQSub(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarMul(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarDiv(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQNeg_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNeg(&result, &quat); - return result; -} - -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) -{ - return vmathQDot(&quat0, &quat1); -} - -static inline float vmathQNorm_V( VmathQuat quat ) -{ - return vmathQNorm(&quat); -} - -static inline float vmathQLength_V( VmathQuat quat ) -{ - return vmathQLength(&quat); -} - -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNormalize(&result, &quat); - return result; -} - -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathQuat result; - vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); - return result; -} - -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathQuat result; - vmathQMakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathQuat vmathQMakeRotationX_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationX(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationY_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationY(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationZ_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationZ(&result, radians); - return result; -} - -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQMul(&result, &quat0, &quat1); - return result; -} - -static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathQRotate(&result, &quat, &vec); - return result; -} - -static inline VmathQuat vmathQConj_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQConj(&result, &quat); - return result; -} - -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) -{ - VmathQuat result; - vmathQSelect(&result, &quat0, &quat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint_V( VmathQuat quat ) -{ - vmathQPrint(&quat); -} - -static inline void vmathQPrints_V( VmathQuat quat, const char *name ) -{ - vmathQPrints(&quat, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h deleted file mode 100644 index f0b0f437d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos.h +++ /dev/null @@ -1,971 +0,0 @@ -/* - 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_VEC_AOS_C_H -#define _VECTORMATH_VEC_AOS_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathV3MakeXAxis( VmathVector3 *result ) -{ - vmathV3MakeFromElems( result, 1.0f, 0.0f, 0.0f ); -} - -static inline void vmathV3MakeYAxis( VmathVector3 *result ) -{ - vmathV3MakeFromElems( result, 0.0f, 1.0f, 0.0f ); -} - -static inline void vmathV3MakeZAxis( VmathVector3 *result ) -{ - vmathV3MakeFromElems( result, 0.0f, 0.0f, 1.0f ); -} - -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathV3Sub( &tmpV3_0, vec1, vec0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathV3Add( result, vec0, &tmpV3_1 ); -} - -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = vmathV3Dot( unitVec0, unitVec1 ); - 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; - } - vmathV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); - vmathV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); - vmathV3Add( result, &tmpV3_0, &tmpV3_1 ); -} - -static inline void vmathV3SetX( VmathVector3 *result, float _x ) -{ - result->x = _x; -} - -static inline float vmathV3GetX( const VmathVector3 *vec ) -{ - return vec->x; -} - -static inline void vmathV3SetY( VmathVector3 *result, float _y ) -{ - result->y = _y; -} - -static inline float vmathV3GetY( const VmathVector3 *vec ) -{ - return vec->y; -} - -static inline void vmathV3SetZ( VmathVector3 *result, float _z ) -{ - result->z = _z; -} - -static inline float vmathV3GetZ( const VmathVector3 *vec ) -{ - return vec->z; -} - -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) -{ - *(&result->x + idx) = value; -} - -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = ( vec0->x + vec1->x ); - result->y = ( vec0->y + vec1->y ); - result->z = ( vec0->z + vec1->z ); -} - -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = ( vec0->x - vec1->x ); - result->y = ( vec0->y - vec1->y ); - result->z = ( vec0->z - vec1->z ); -} - -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) -{ - result->x = ( vec->x + pnt1->x ); - result->y = ( vec->y + pnt1->y ); - result->z = ( vec->z + pnt1->z ); -} - -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->x = ( vec->x * scalar ); - result->y = ( vec->y * scalar ); - result->z = ( vec->z * scalar ); -} - -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->x = ( vec->x / scalar ); - result->y = ( vec->y / scalar ); - result->z = ( vec->z / scalar ); -} - -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = -vec->x; - result->y = -vec->y; - result->z = -vec->z; -} - -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = ( vec0->x * vec1->x ); - result->y = ( vec0->y * vec1->y ); - result->z = ( vec0->z * vec1->z ); -} - -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = ( vec0->x / vec1->x ); - result->y = ( vec0->y / vec1->y ); - result->z = ( vec0->z / vec1->z ); -} - -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = ( 1.0f / vec->x ); - result->y = ( 1.0f / vec->y ); - result->z = ( 1.0f / vec->z ); -} - -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = sqrtf( vec->x ); - result->y = sqrtf( vec->y ); - result->z = sqrtf( vec->z ); -} - -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = ( 1.0f / sqrtf( vec->x ) ); - result->y = ( 1.0f / sqrtf( vec->y ) ); - result->z = ( 1.0f / sqrtf( vec->z ) ); -} - -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->x = fabsf( vec->x ); - result->y = fabsf( vec->y ); - result->z = fabsf( vec->z ); -} - -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x ); - result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y ); - result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z ); -} - -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = (vec0->x > vec1->x)? vec0->x : vec1->x; - result->y = (vec0->y > vec1->y)? vec0->y : vec1->y; - result->z = (vec0->z > vec1->z)? vec0->z : vec1->z; -} - -static inline float vmathV3MaxElem( const VmathVector3 *vec ) -{ - float result; - result = (vec->x > vec->y)? vec->x : vec->y; - result = (vec->z > result)? vec->z : result; - return result; -} - -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->x = (vec0->x < vec1->x)? vec0->x : vec1->x; - result->y = (vec0->y < vec1->y)? vec0->y : vec1->y; - result->z = (vec0->z < vec1->z)? vec0->z : vec1->z; -} - -static inline float vmathV3MinElem( const VmathVector3 *vec ) -{ - float result; - result = (vec->x < vec->y)? vec->x : vec->y; - result = (vec->z < result)? vec->z : result; - return result; -} - -static inline float vmathV3Sum( const VmathVector3 *vec ) -{ - float result; - result = ( vec->x + vec->y ); - result = ( result + vec->z ); - return result; -} - -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - float result; - result = ( vec0->x * vec1->x ); - result = ( result + ( vec0->y * vec1->y ) ); - result = ( result + ( vec0->z * vec1->z ) ); - return result; -} - -static inline float vmathV3LengthSqr( const VmathVector3 *vec ) -{ - float result; - result = ( vec->x * vec->x ); - result = ( result + ( vec->y * vec->y ) ); - result = ( result + ( vec->z * vec->z ) ); - return result; -} - -static inline float vmathV3Length( const VmathVector3 *vec ) -{ - return sqrtf( vmathV3LengthSqr( vec ) ); -} - -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) -{ - float lenSqr, lenInv; - lenSqr = vmathV3LengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - result->x = ( vec->x * lenInv ); - result->y = ( vec->y * lenInv ); - result->z = ( vec->z * lenInv ); -} - -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - float tmpX, tmpY, tmpZ; - tmpX = ( ( vec0->y * vec1->z ) - ( vec0->z * vec1->y ) ); - tmpY = ( ( vec0->z * vec1->x ) - ( vec0->x * vec1->z ) ); - tmpZ = ( ( vec0->x * vec1->y ) - ( vec0->y * vec1->x ) ); - vmathV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) -{ - result->x = ( select1 )? vec1->x : vec0->x; - result->y = ( select1 )? vec1->y : vec0->y; - result->z = ( select1 )? vec1->z : vec0->z; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print( const VmathVector3 *vec ) -{ - printf( "( %f %f %f )\n", vec->x, vec->y, vec->z ); -} - -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) -{ - printf( "%s: ( %f %f %f )\n", name, vec->x, vec->y, vec->z ); -} - -#endif - -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) -{ - vmathV4SetXYZ( result, xyz ); - vmathV4SetW( result, _w ); -} - -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = 0.0f; -} - -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; - result->w = 1.0f; -} - -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathV4MakeXAxis( VmathVector4 *result ) -{ - vmathV4MakeFromElems( result, 1.0f, 0.0f, 0.0f, 0.0f ); -} - -static inline void vmathV4MakeYAxis( VmathVector4 *result ) -{ - vmathV4MakeFromElems( result, 0.0f, 1.0f, 0.0f, 0.0f ); -} - -static inline void vmathV4MakeZAxis( VmathVector4 *result ) -{ - vmathV4MakeFromElems( result, 0.0f, 0.0f, 1.0f, 0.0f ); -} - -static inline void vmathV4MakeWAxis( VmathVector4 *result ) -{ - vmathV4MakeFromElems( result, 0.0f, 0.0f, 0.0f, 1.0f ); -} - -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - VmathVector4 tmpV4_0, tmpV4_1; - vmathV4Sub( &tmpV4_0, vec1, vec0 ); - vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); - vmathV4Add( result, vec0, &tmpV4_1 ); -} - -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) -{ - VmathVector4 tmpV4_0, tmpV4_1; - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = vmathV4Dot( unitVec0, unitVec1 ); - 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; - } - vmathV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); - vmathV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); - vmathV4Add( result, &tmpV4_0, &tmpV4_1 ); -} - -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) -{ - vmathV3MakeFromElems( result, vec->x, vec->y, vec->z ); -} - -static inline void vmathV4SetX( VmathVector4 *result, float _x ) -{ - result->x = _x; -} - -static inline float vmathV4GetX( const VmathVector4 *vec ) -{ - return vec->x; -} - -static inline void vmathV4SetY( VmathVector4 *result, float _y ) -{ - result->y = _y; -} - -static inline float vmathV4GetY( const VmathVector4 *vec ) -{ - return vec->y; -} - -static inline void vmathV4SetZ( VmathVector4 *result, float _z ) -{ - result->z = _z; -} - -static inline float vmathV4GetZ( const VmathVector4 *vec ) -{ - return vec->z; -} - -static inline void vmathV4SetW( VmathVector4 *result, float _w ) -{ - result->w = _w; -} - -static inline float vmathV4GetW( const VmathVector4 *vec ) -{ - return vec->w; -} - -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) -{ - *(&result->x + idx) = value; -} - -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = ( vec0->x + vec1->x ); - result->y = ( vec0->y + vec1->y ); - result->z = ( vec0->z + vec1->z ); - result->w = ( vec0->w + vec1->w ); -} - -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = ( vec0->x - vec1->x ); - result->y = ( vec0->y - vec1->y ); - result->z = ( vec0->z - vec1->z ); - result->w = ( vec0->w - vec1->w ); -} - -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->x = ( vec->x * scalar ); - result->y = ( vec->y * scalar ); - result->z = ( vec->z * scalar ); - result->w = ( vec->w * scalar ); -} - -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->x = ( vec->x / scalar ); - result->y = ( vec->y / scalar ); - result->z = ( vec->z / scalar ); - result->w = ( vec->w / scalar ); -} - -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = -vec->x; - result->y = -vec->y; - result->z = -vec->z; - result->w = -vec->w; -} - -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = ( vec0->x * vec1->x ); - result->y = ( vec0->y * vec1->y ); - result->z = ( vec0->z * vec1->z ); - result->w = ( vec0->w * vec1->w ); -} - -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = ( vec0->x / vec1->x ); - result->y = ( vec0->y / vec1->y ); - result->z = ( vec0->z / vec1->z ); - result->w = ( vec0->w / vec1->w ); -} - -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = ( 1.0f / vec->x ); - result->y = ( 1.0f / vec->y ); - result->z = ( 1.0f / vec->z ); - result->w = ( 1.0f / vec->w ); -} - -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = sqrtf( vec->x ); - result->y = sqrtf( vec->y ); - result->z = sqrtf( vec->z ); - result->w = sqrtf( vec->w ); -} - -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = ( 1.0f / sqrtf( vec->x ) ); - result->y = ( 1.0f / sqrtf( vec->y ) ); - result->z = ( 1.0f / sqrtf( vec->z ) ); - result->w = ( 1.0f / sqrtf( vec->w ) ); -} - -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->x = fabsf( vec->x ); - result->y = fabsf( vec->y ); - result->z = fabsf( vec->z ); - result->w = fabsf( vec->w ); -} - -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = ( vec1->x < 0.0f )? -fabsf( vec0->x ) : fabsf( vec0->x ); - result->y = ( vec1->y < 0.0f )? -fabsf( vec0->y ) : fabsf( vec0->y ); - result->z = ( vec1->z < 0.0f )? -fabsf( vec0->z ) : fabsf( vec0->z ); - result->w = ( vec1->w < 0.0f )? -fabsf( vec0->w ) : fabsf( vec0->w ); -} - -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = (vec0->x > vec1->x)? vec0->x : vec1->x; - result->y = (vec0->y > vec1->y)? vec0->y : vec1->y; - result->z = (vec0->z > vec1->z)? vec0->z : vec1->z; - result->w = (vec0->w > vec1->w)? vec0->w : vec1->w; -} - -static inline float vmathV4MaxElem( const VmathVector4 *vec ) -{ - float result; - result = (vec->x > vec->y)? vec->x : vec->y; - result = (vec->z > result)? vec->z : result; - result = (vec->w > result)? vec->w : result; - return result; -} - -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->x = (vec0->x < vec1->x)? vec0->x : vec1->x; - result->y = (vec0->y < vec1->y)? vec0->y : vec1->y; - result->z = (vec0->z < vec1->z)? vec0->z : vec1->z; - result->w = (vec0->w < vec1->w)? vec0->w : vec1->w; -} - -static inline float vmathV4MinElem( const VmathVector4 *vec ) -{ - float result; - result = (vec->x < vec->y)? vec->x : vec->y; - result = (vec->z < result)? vec->z : result; - result = (vec->w < result)? vec->w : result; - return result; -} - -static inline float vmathV4Sum( const VmathVector4 *vec ) -{ - float result; - result = ( vec->x + vec->y ); - result = ( result + vec->z ); - result = ( result + vec->w ); - return result; -} - -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - float result; - result = ( vec0->x * vec1->x ); - result = ( result + ( vec0->y * vec1->y ) ); - result = ( result + ( vec0->z * vec1->z ) ); - result = ( result + ( vec0->w * vec1->w ) ); - return result; -} - -static inline float vmathV4LengthSqr( const VmathVector4 *vec ) -{ - float result; - result = ( vec->x * vec->x ); - result = ( result + ( vec->y * vec->y ) ); - result = ( result + ( vec->z * vec->z ) ); - result = ( result + ( vec->w * vec->w ) ); - return result; -} - -static inline float vmathV4Length( const VmathVector4 *vec ) -{ - return sqrtf( vmathV4LengthSqr( vec ) ); -} - -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) -{ - float lenSqr, lenInv; - lenSqr = vmathV4LengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - result->x = ( vec->x * lenInv ); - result->y = ( vec->y * lenInv ); - result->z = ( vec->z * lenInv ); - result->w = ( vec->w * lenInv ); -} - -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) -{ - result->x = ( select1 )? vec1->x : vec0->x; - result->y = ( select1 )? vec1->y : vec0->y; - result->z = ( select1 )? vec1->z : vec0->z; - result->w = ( select1 )? vec1->w : vec0->w; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print( const VmathVector4 *vec ) -{ - printf( "( %f %f %f %f )\n", vec->x, vec->y, vec->z, vec->w ); -} - -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, vec->x, vec->y, vec->z, vec->w ); -} - -#endif - -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathP3AddV3( result, pnt0, &tmpV3_1 ); -} - -static inline void vmathP3SetX( VmathPoint3 *result, float _x ) -{ - result->x = _x; -} - -static inline float vmathP3GetX( const VmathPoint3 *pnt ) -{ - return pnt->x; -} - -static inline void vmathP3SetY( VmathPoint3 *result, float _y ) -{ - result->y = _y; -} - -static inline float vmathP3GetY( const VmathPoint3 *pnt ) -{ - return pnt->y; -} - -static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) -{ - result->z = _z; -} - -static inline float vmathP3GetZ( const VmathPoint3 *pnt ) -{ - return pnt->z; -} - -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) -{ - *(&result->x + idx) = value; -} - -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) -{ - return *(&pnt->x + idx); -} - -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = ( pnt0->x - pnt1->x ); - result->y = ( pnt0->y - pnt1->y ); - result->z = ( pnt0->z - pnt1->z ); -} - -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->x = ( pnt->x + vec1->x ); - result->y = ( pnt->y + vec1->y ); - result->z = ( pnt->z + vec1->z ); -} - -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->x = ( pnt->x - vec1->x ); - result->y = ( pnt->y - vec1->y ); - result->z = ( pnt->z - vec1->z ); -} - -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = ( pnt0->x * pnt1->x ); - result->y = ( pnt0->y * pnt1->y ); - result->z = ( pnt0->z * pnt1->z ); -} - -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = ( pnt0->x / pnt1->x ); - result->y = ( pnt0->y / pnt1->y ); - result->z = ( pnt0->z / pnt1->z ); -} - -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->x = ( 1.0f / pnt->x ); - result->y = ( 1.0f / pnt->y ); - result->z = ( 1.0f / pnt->z ); -} - -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->x = sqrtf( pnt->x ); - result->y = sqrtf( pnt->y ); - result->z = sqrtf( pnt->z ); -} - -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->x = ( 1.0f / sqrtf( pnt->x ) ); - result->y = ( 1.0f / sqrtf( pnt->y ) ); - result->z = ( 1.0f / sqrtf( pnt->z ) ); -} - -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->x = fabsf( pnt->x ); - result->y = fabsf( pnt->y ); - result->z = fabsf( pnt->z ); -} - -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = ( pnt1->x < 0.0f )? -fabsf( pnt0->x ) : fabsf( pnt0->x ); - result->y = ( pnt1->y < 0.0f )? -fabsf( pnt0->y ) : fabsf( pnt0->y ); - result->z = ( pnt1->z < 0.0f )? -fabsf( pnt0->z ) : fabsf( pnt0->z ); -} - -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = (pnt0->x > pnt1->x)? pnt0->x : pnt1->x; - result->y = (pnt0->y > pnt1->y)? pnt0->y : pnt1->y; - result->z = (pnt0->z > pnt1->z)? pnt0->z : pnt1->z; -} - -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) -{ - float result; - result = (pnt->x > pnt->y)? pnt->x : pnt->y; - result = (pnt->z > result)? pnt->z : result; - return result; -} - -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->x = (pnt0->x < pnt1->x)? pnt0->x : pnt1->x; - result->y = (pnt0->y < pnt1->y)? pnt0->y : pnt1->y; - result->z = (pnt0->z < pnt1->z)? pnt0->z : pnt1->z; -} - -static inline float vmathP3MinElem( const VmathPoint3 *pnt ) -{ - float result; - result = (pnt->x < pnt->y)? pnt->x : pnt->y; - result = (pnt->z < result)? pnt->z : result; - return result; -} - -static inline float vmathP3Sum( const VmathPoint3 *pnt ) -{ - float result; - result = ( pnt->x + pnt->y ); - result = ( result + pnt->z ); - return result; -} - -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromV3( &tmpP3_0, scaleVec ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) -{ - float result; - result = ( pnt->x * unitVec->x ); - result = ( result + ( pnt->y * unitVec->y ) ); - result = ( result + ( pnt->z * unitVec->z ) ); - return result; -} - -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) -{ - result->x = ( select1 )? pnt1->x : pnt0->x; - result->y = ( select1 )? pnt1->y : pnt0->y; - result->z = ( select1 )? pnt1->z : pnt0->z; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print( const VmathPoint3 *pnt ) -{ - printf( "( %f %f %f )\n", pnt->x, pnt->y, pnt->z ); -} - -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) -{ - printf( "%s: ( %f %f %f )\n", name, pnt->x, pnt->y, pnt->z ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h deleted file mode 100644 index 75c49370d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/vec_aos_v.h +++ /dev/null @@ -1,848 +0,0 @@ -/* - 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_VEC_AOS_V_C_H -#define _VECTORMATH_VEC_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathVector3 result; - vmathV3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector3 result; - vmathV3MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) -{ - VmathVector3 result; - vmathV3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector3 vmathV3MakeXAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeXAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeYAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeYAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeZAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeZAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathVector3 result; - vmathV3Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) -{ - vmathV3SetX(result, _x); -} - -static inline float vmathV3GetX_V( VmathVector3 vec ) -{ - return vmathV3GetX(&vec); -} - -static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) -{ - vmathV3SetY(result, _y); -} - -static inline float vmathV3GetY_V( VmathVector3 vec ) -{ - return vmathV3GetY(&vec); -} - -static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) -{ - vmathV3SetZ(result, _z); -} - -static inline float vmathV3GetZ_V( VmathVector3 vec ) -{ - return vmathV3GetZ(&vec); -} - -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) -{ - vmathV3SetElem(result, idx, value); -} - -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) -{ - return vmathV3GetElem(&vec, idx); -} - -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathV3AddP3(&result, &vec, &pnt1); - return result; -} - -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Neg(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MaxElem_V( VmathVector3 vec ) -{ - return vmathV3MaxElem(&vec); -} - -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MinElem_V( VmathVector3 vec ) -{ - return vmathV3MinElem(&vec); -} - -static inline float vmathV3Sum_V( VmathVector3 vec ) -{ - return vmathV3Sum(&vec); -} - -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - return vmathV3Dot(&vec0, &vec1); -} - -static inline float vmathV3LengthSqr_V( VmathVector3 vec ) -{ - return vmathV3LengthSqr(&vec); -} - -static inline float vmathV3Length_V( VmathVector3 vec ) -{ - return vmathV3Length(&vec); -} - -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Normalize(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Cross(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) -{ - VmathVector3 result; - vmathV3Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print_V( VmathVector3 vec ) -{ - vmathV3Print(&vec); -} - -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) -{ - vmathV3Prints(&vec, name); -} - -#endif - -static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) -{ - VmathVector4 result; - vmathV4MakeFromV3(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathV4MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) -{ - VmathVector4 result; - vmathV4MakeFromQ(&result, &quat); - return result; -} - -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) -{ - VmathVector4 result; - vmathV4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector4 vmathV4MakeXAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeXAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeYAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeYAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeZAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeZAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeWAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeWAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) -{ - VmathVector4 result; - vmathV4Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) -{ - vmathV4SetXYZ(result, &vec); -} - -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) -{ - VmathVector3 result; - vmathV4GetXYZ(&result, &vec); - return result; -} - -static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) -{ - vmathV4SetX(result, _x); -} - -static inline float vmathV4GetX_V( VmathVector4 vec ) -{ - return vmathV4GetX(&vec); -} - -static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) -{ - vmathV4SetY(result, _y); -} - -static inline float vmathV4GetY_V( VmathVector4 vec ) -{ - return vmathV4GetY(&vec); -} - -static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) -{ - vmathV4SetZ(result, _z); -} - -static inline float vmathV4GetZ_V( VmathVector4 vec ) -{ - return vmathV4GetZ(&vec); -} - -static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) -{ - vmathV4SetW(result, _w); -} - -static inline float vmathV4GetW_V( VmathVector4 vec ) -{ - return vmathV4GetW(&vec); -} - -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) -{ - vmathV4SetElem(result, idx, value); -} - -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) -{ - return vmathV4GetElem(&vec, idx); -} - -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Neg(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MaxElem_V( VmathVector4 vec ) -{ - return vmathV4MaxElem(&vec); -} - -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MinElem_V( VmathVector4 vec ) -{ - return vmathV4MinElem(&vec); -} - -static inline float vmathV4Sum_V( VmathVector4 vec ) -{ - return vmathV4Sum(&vec); -} - -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - return vmathV4Dot(&vec0, &vec1); -} - -static inline float vmathV4LengthSqr_V( VmathVector4 vec ) -{ - return vmathV4LengthSqr(&vec); -} - -static inline float vmathV4Length_V( VmathVector4 vec ) -{ - return vmathV4Length(&vec); -} - -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Normalize(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) -{ - VmathVector4 result; - vmathV4Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print_V( VmathVector4 vec ) -{ - vmathV4Print(&vec); -} - -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) -{ - vmathV4Prints(&vec, name); -} - -#endif - -static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathPoint3 result; - vmathP3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) -{ - VmathPoint3 result; - vmathP3MakeFromV3(&result, &vec); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) -{ - VmathPoint3 result; - vmathP3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3Lerp(&result, t, &pnt0, &pnt1); - return result; -} - -static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) -{ - vmathP3SetX(result, _x); -} - -static inline float vmathP3GetX_V( VmathPoint3 pnt ) -{ - return vmathP3GetX(&pnt); -} - -static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) -{ - vmathP3SetY(result, _y); -} - -static inline float vmathP3GetY_V( VmathPoint3 pnt ) -{ - return vmathP3GetY(&pnt); -} - -static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) -{ - vmathP3SetZ(result, _z); -} - -static inline float vmathP3GetZ_V( VmathPoint3 pnt ) -{ - return vmathP3GetZ(&pnt); -} - -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) -{ - vmathP3SetElem(result, idx, value); -} - -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) -{ - return vmathP3GetElem(&pnt, idx); -} - -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathVector3 result; - vmathP3Sub(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3AddV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3SubV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MulPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3DivPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RecipPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3SqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RsqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3AbsPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3CopySignPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MaxPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) -{ - return vmathP3MaxElem(&pnt); -} - -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MinPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MinElem_V( VmathPoint3 pnt ) -{ - return vmathP3MinElem(&pnt); -} - -static inline float vmathP3Sum_V( VmathPoint3 pnt ) -{ - return vmathP3Sum(&pnt); -} - -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) -{ - VmathPoint3 result; - vmathP3Scale(&result, &pnt, scaleVal); - return result; -} - -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) -{ - VmathPoint3 result; - vmathP3NonUniformScale(&result, &pnt, &scaleVec); - return result; -} - -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) -{ - return vmathP3Projection(&pnt, &unitVec); -} - -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistSqrFromOrigin(&pnt); -} - -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistFromOrigin(&pnt); -} - -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3DistSqr(&pnt0, &pnt1); -} - -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3Dist(&pnt0, &pnt1); -} - -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) -{ - VmathPoint3 result; - vmathP3Select(&result, &pnt0, &pnt1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print_V( VmathPoint3 pnt ) -{ - vmathP3Print(&pnt); -} - -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) -{ - vmathP3Prints(&pnt, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h deleted file mode 100644 index 26bee0b81..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos.h +++ /dev/null @@ -1,1879 +0,0 @@ -/* - 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_AOS_C_SCALAR_H -#define _VECTORMATH_AOS_C_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - float x; - float y; - float z; -#ifndef __GNUC__ - float d; -#endif -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - float x; - float y; - float z; - float w; -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - float x; - float y; - float z; -#ifndef __GNUC__ - float d; -#endif -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - float x; - float y; - float z; - float w; -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Copy a 3-D vector - */ -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX( const VmathVector3 *vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY( const VmathVector3 *vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ( const VmathVector3 *vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV3MakeXAxis( VmathVector3 *result ); - -/* - * Construct y axis - */ -static inline void vmathV3MakeYAxis( VmathVector3 *result ); - -/* - * Construct z axis - */ -static inline void vmathV3MakeZAxis( VmathVector3 *result ); - -/* - * Multiply two 3-D vectors per element - */ -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem( const VmathVector3 *vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem( const VmathVector3 *vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum( const VmathVector3 *vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr( const VmathVector3 *vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length( const VmathVector3 *vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - */ -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print( const VmathVector3 *vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); - -#endif - -/* - * Copy a 4-D vector - */ -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX( const VmathVector4 *vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY( const VmathVector4 *vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ( const VmathVector4 *vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW( const VmathVector4 *vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV4MakeXAxis( VmathVector4 *result ); - -/* - * Construct y axis - */ -static inline void vmathV4MakeYAxis( VmathVector4 *result ); - -/* - * Construct z axis - */ -static inline void vmathV4MakeZAxis( VmathVector4 *result ); - -/* - * Construct w axis - */ -static inline void vmathV4MakeWAxis( VmathVector4 *result ); - -/* - * Multiply two 4-D vectors per element - */ -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem( const VmathVector4 *vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem( const VmathVector4 *vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum( const VmathVector4 *vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr( const VmathVector4 *vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length( const VmathVector4 *vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - */ -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print( const VmathVector4 *vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); - -#endif - -/* - * Copy a 3-D point - */ -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX( const VmathPoint3 *pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY( const VmathPoint3 *pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ( const VmathPoint3 *pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Multiply two 3-D points per element - */ -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem( const VmathPoint3 *pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum( const VmathPoint3 *pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Conditionally select between two 3-D points - */ -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print( const VmathPoint3 *pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); - -#endif - -/* - * Copy a quaternion - */ -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX( const VmathQuat *quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY( const VmathQuat *quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ( const VmathQuat *quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW( const VmathQuat *quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem( const VmathQuat *quat, int idx ); - -/* - * Add two quaternions - */ -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply two quaternions - */ -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct an identity quaternion - */ -static inline void vmathQMakeIdentity( VmathQuat *result ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm( const VmathQuat *quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength( const VmathQuat *quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); - -/* - * Conditionally select between two quaternions - */ -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint( const VmathQuat *quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints( const VmathQuat *quat, const char *name ); - -#endif - -/* - * Copy a 3x3 matrix - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant( const VmathMatrix3 *mat ); - -/* - * Conditionally select between two 3x3 matrices - */ -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print( const VmathMatrix3 *mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); - -#endif - -/* - * Copy a 4x4 matrix - */ -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant( const VmathMatrix4 *mat ); - -/* - * Conditionally select between two 4x4 matrices - */ -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print( const VmathMatrix4 *mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); - -#endif - -/* - * Copy a 3x4 transformation matrix - */ -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline void vmathT3MakeIdentity( VmathTransform3 *result ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - */ -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print( const VmathTransform3 *tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h b/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h deleted file mode 100644 index f766bb148..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/c/vectormath_aos_v.h +++ /dev/null @@ -1,1845 +0,0 @@ -/* - 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_AOS_C_V_SCALAR_H -#define _VECTORMATH_AOS_C_V_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - float x; - float y; - float z; -#ifndef __GNUC__ - float d; -#endif -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - float x; - float y; - float z; - float w; -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - float x; - float y; - float z; -#ifndef __GNUC__ - float d; -#endif -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - float x; - float y; - float z; - float w; -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX_V( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY_V( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX_V( VmathVector3 vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY_V( VmathVector3 vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ_V( VmathVector3 vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); - -/* - * Construct x axis - */ -static inline VmathVector3 vmathV3MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector3 vmathV3MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector3 vmathV3MakeZAxis_V( ); - -/* - * Multiply two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem_V( VmathVector3 vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem_V( VmathVector3 vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum_V( VmathVector3 vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr_V( VmathVector3 vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length_V( VmathVector3 vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - */ -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print_V( VmathVector3 vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); - -#endif - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX_V( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY_V( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW_V( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX_V( VmathVector4 vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY_V( VmathVector4 vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ_V( VmathVector4 vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW_V( VmathVector4 vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); - -/* - * Construct x axis - */ -static inline VmathVector4 vmathV4MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector4 vmathV4MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector4 vmathV4MakeZAxis_V( ); - -/* - * Construct w axis - */ -static inline VmathVector4 vmathV4MakeWAxis_V( ); - -/* - * Multiply two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem_V( VmathVector4 vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem_V( VmathVector4 vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum_V( VmathVector4 vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr_V( VmathVector4 vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length_V( VmathVector4 vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - */ -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print_V( VmathVector4 vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); - -#endif - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX_V( VmathPoint3 pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY_V( VmathPoint3 pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ_V( VmathPoint3 pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Multiply two 3-D points per element - */ -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem_V( VmathPoint3 pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum_V( VmathPoint3 pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Conditionally select between two 3-D points - */ -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print_V( VmathPoint3 pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); - -#endif - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX_V( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY_V( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ_V( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW_V( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX_V( VmathQuat quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY_V( VmathQuat quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ_V( VmathQuat quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW_V( VmathQuat quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem_V( VmathQuat quat, int idx ); - -/* - * Add two quaternions - */ -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply two quaternions - */ -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline VmathQuat vmathQNeg_V( VmathQuat quat ); - -/* - * Construct an identity quaternion - */ -static inline VmathQuat vmathQMakeIdentity_V( ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline VmathQuat vmathQMakeRotationX_V( float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline VmathQuat vmathQMakeRotationY_V( float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline VmathQuat vmathQMakeRotationZ_V( float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline VmathQuat vmathQConj_V( VmathQuat quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm_V( VmathQuat quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength_V( VmathQuat quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); - -/* - * Conditionally select between two quaternions - */ -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint_V( VmathQuat quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints_V( VmathQuat quat, const char *name ); - -#endif - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline VmathMatrix3 vmathM3MakeIdentity_V( ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant_V( VmathMatrix3 mat ); - -/* - * Conditionally select between two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print_V( VmathMatrix3 mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); - -#endif - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline VmathMatrix4 vmathM4MakeIdentity_V( ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant_V( VmathMatrix4 mat ); - -/* - * Conditionally select between two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print_V( VmathMatrix4 mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); - -#endif - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline VmathTransform3 vmathT3MakeIdentity_V( ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - */ -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print_V( VmathTransform3 tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vectormath_aos.h" -#include "vec_aos_v.h" -#include "quat_aos_v.h" -#include "mat_aos_v.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/boolInVec.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/boolInVec.h deleted file mode 100644 index 7ea380f91..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/boolInVec.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - Copyright (C) 2006-2010 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_SCALAR_H -#define _BOOLINVEC_SCALAR_H - -#include -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 diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/floatInVec.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/floatInVec.h deleted file mode 100644 index 1aa2ee1cc..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/floatInVec.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - Copyright (C) 2006-2010 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__SCALAR_H -#define _FLOATINVEC__SCALAR_H - -#include -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 diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h deleted file mode 100644 index 1ea2c77b9..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/mat_aos.h +++ /dev/null @@ -1,1643 +0,0 @@ -/* - Copyright (C) 2006-2010 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_MAT_AOS_CPP__SCALAR_H -#define _VECTORMATH_MAT_AOS_CPP__SCALAR_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - float qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = ( qx + qx ); - qy2 = ( qy + qy ); - qz2 = ( qz + qz ); - qxqx2 = ( qx * qx2 ); - qxqy2 = ( qx * qy2 ); - qxqz2 = ( qx * qz2 ); - qxqw2 = ( qw * qx2 ); - qyqy2 = ( qy * qy2 ); - qyqz2 = ( qy * qz2 ); - qyqw2 = ( qw * qy2 ); - qzqz2 = ( qz * qz2 ); - qzqw2 = ( qw * qz2 ); - mCol0 = Vector3( ( ( 1.0f - qyqy2 ) - qzqz2 ), ( qxqy2 + qzqw2 ), ( qxqz2 - qyqw2 ) ); - mCol1 = Vector3( ( qxqy2 - qzqw2 ), ( ( 1.0f - qxqx2 ) - qzqz2 ), ( qyqz2 + qxqw2 ) ); - mCol2 = Vector3( ( qxqz2 + qyqw2 ), ( qyqz2 - qxqw2 ), ( ( 1.0f - qxqx2 ) - qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - float detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = ( 1.0f / dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ), - Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ), - Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ) - ); -} - -inline float determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix3( - Vector3( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ) ), - Vector3( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ) ), - Vector3( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - float mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - res0.setX( ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ) ); - res0.setY( ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ) ); - res0.setZ( ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ) ); - res0.setW( ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ) ); - detInv = ( 1.0f / ( ( ( ( mA * res0.getX() ) + ( mE * res0.getY() ) ) + ( mI * res0.getZ() ) ) + ( mM * res0.getW() ) ) ); - res1.setX( ( mI * tmp1 ) ); - res1.setY( ( mM * tmp0 ) ); - res1.setZ( ( mA * tmp1 ) ); - res1.setW( ( mE * tmp0 ) ); - res3.setX( ( mI * tmp3 ) ); - res3.setY( ( mM * tmp2 ) ); - res3.setZ( ( mA * tmp3 ) ); - res3.setW( ( mE * tmp2 ) ); - res2.setX( ( mI * tmp5 ) ); - res2.setY( ( mM * tmp4 ) ); - res2.setZ( ( mA * tmp5 ) ); - res2.setW( ( mE * tmp4 ) ); - tmp0 = ( ( mI * mB ) - ( mA * mJ ) ); - tmp1 = ( ( mM * mF ) - ( mE * mN ) ); - tmp2 = ( ( mI * mD ) - ( mA * mL ) ); - tmp3 = ( ( mM * mH ) - ( mE * mP ) ); - tmp4 = ( ( mI * mC ) - ( mA * mK ) ); - tmp5 = ( ( mM * mG ) - ( mE * mO ) ); - res2.setX( ( ( ( mL * tmp1 ) - ( mJ * tmp3 ) ) + res2.getX() ) ); - res2.setY( ( ( ( mP * tmp0 ) - ( mN * tmp2 ) ) + res2.getY() ) ); - res2.setZ( ( ( ( mB * tmp3 ) - ( mD * tmp1 ) ) - res2.getZ() ) ); - res2.setW( ( ( ( mF * tmp2 ) - ( mH * tmp0 ) ) - res2.getW() ) ); - res3.setX( ( ( ( mJ * tmp5 ) - ( mK * tmp1 ) ) + res3.getX() ) ); - res3.setY( ( ( ( mN * tmp4 ) - ( mO * tmp0 ) ) + res3.getY() ) ); - res3.setZ( ( ( ( mC * tmp1 ) - ( mB * tmp5 ) ) - res3.getZ() ) ); - res3.setW( ( ( ( mG * tmp0 ) - ( mF * tmp4 ) ) - res3.getW() ) ); - res1.setX( ( ( ( mK * tmp3 ) - ( mL * tmp5 ) ) - res1.getX() ) ); - res1.setY( ( ( ( mO * tmp2 ) - ( mP * tmp4 ) ) - res1.getY() ) ); - res1.setZ( ( ( ( mD * tmp5 ) - ( mC * tmp3 ) ) + res1.getZ() ) ); - res1.setW( ( ( ( mH * tmp4 ) - ( mG * tmp2 ) ) + res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline float determinant( const Matrix4 & mat ) -{ - float dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = ( ( mK * mD ) - ( mC * mL ) ); - tmp1 = ( ( mO * mH ) - ( mG * mP ) ); - tmp2 = ( ( mB * mK ) - ( mJ * mC ) ); - tmp3 = ( ( mF * mO ) - ( mN * mG ) ); - tmp4 = ( ( mJ * mD ) - ( mB * mL ) ); - tmp5 = ( ( mN * mH ) - ( mF * mP ) ); - dx = ( ( ( mJ * tmp1 ) - ( mL * tmp3 ) ) - ( mK * tmp5 ) ); - dy = ( ( ( mN * tmp0 ) - ( mP * tmp2 ) ) - ( mO * tmp4 ) ); - dz = ( ( ( mD * tmp3 ) + ( mC * tmp5 ) ) - ( mB * tmp1 ) ); - dw = ( ( ( mH * tmp2 ) + ( mG * tmp4 ) ) - ( mF * tmp0 ) ); - return ( ( ( ( mA * dx ) + ( mE * dy ) ) + ( mI * dz ) ) + ( mM * dw ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ) + ( mCol3.getX() * vec.getW() ) ), - ( ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ) + ( mCol3.getY() * vec.getW() ) ), - ( ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) + ( mCol3.getZ() * vec.getW() ) ), - ( ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) + ( mCol3.getW() * vec.getW() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ), - ( ( ( mCol0.getW() * vec.getX() ) + ( mCol1.getW() * vec.getY() ) ) + ( mCol2.getW() * vec.getZ() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ), - ( ( ( ( mCol0.getW() * pnt.getX() ) + ( mCol1.getW() * pnt.getY() ) ) + ( mCol2.getW() * pnt.getZ() ) ) + mCol3.getW() ) - ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4::xAxis( ), - Vector4( 0.0f, c, s, 0.0f ), - Vector4( 0.0f, -s, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, 0.0f, -s, 0.0f ), - Vector4::yAxis( ), - Vector4( s, 0.0f, c, 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Matrix4( - Vector4( c, s, 0.0f, 0.0f ), - Vector4( -s, c, 0.0f, 0.0f ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Matrix4( - Vector4( ( cZ * cY ), ( sZ * cY ), -sY, 0.0f ), - Vector4( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ), 0.0f ), - Vector4( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, const Vector3 & unitVec ) -{ - float x, y, z, s, c, oneMinusC, xy, yz, zx; - s = sinf( radians ); - c = cosf( radians ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = ( x * y ); - yz = ( y * z ); - zx = ( z * x ); - oneMinusC = ( 1.0f - c ); - return Matrix4( - Vector4( ( ( ( x * x ) * oneMinusC ) + c ), ( ( xy * oneMinusC ) + ( z * s ) ), ( ( zx * oneMinusC ) - ( y * s ) ), 0.0f ), - Vector4( ( ( xy * oneMinusC ) - ( z * s ) ), ( ( ( y * y ) * oneMinusC ) + c ), ( ( yz * oneMinusC ) + ( x * s ) ), 0.0f ), - Vector4( ( ( zx * oneMinusC ) + ( y * s ) ), ( ( yz * oneMinusC ) - ( x * s ) ), ( ( ( z * z ) * oneMinusC ) + c ), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, scaleVec.getY(), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, scaleVec.getZ(), 0.0f ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - f = tanf( ( (float)( _VECTORMATH_PI_OVER_2 ) - ( 0.5f * fovyRadians ) ) ); - rangeInv = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( f / aspect ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, f, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( ( zNear + zFar ) * rangeInv ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( ( zNear * zFar ) * rangeInv ) * 2.0f ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - n2 = ( zNear + zNear ); - return Matrix4( - Vector4( ( n2 * inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( n2 * inv_tb ), 0.0f, 0.0f ), - Vector4( ( sum_rl * inv_rl ), ( sum_tb * inv_tb ), ( sum_nf * inv_nf ), -1.0f ), - Vector4( 0.0f, 0.0f, ( ( n2 * inv_nf ) * zFar ), 0.0f ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - float sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = ( right + left ); - sum_tb = ( top + bottom ); - sum_nf = ( zNear + zFar ); - inv_rl = ( 1.0f / ( right - left ) ); - inv_tb = ( 1.0f / ( top - bottom ) ); - inv_nf = ( 1.0f / ( zNear - zFar ) ); - return Matrix4( - Vector4( ( inv_rl + inv_rl ), 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, ( inv_tb + inv_tb ), 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, ( inv_nf + inv_nf ), 0.0f ), - Vector4( ( -sum_rl * inv_rl ), ( -sum_tb * inv_tb ), ( sum_nf * inv_nf ), 1.0f ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline float Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - float detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = ( 1.0f / dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( ( tmp0.getX() * detinv ), ( tmp1.getX() * detinv ), ( tmp2.getX() * detinv ) ); - inv1 = Vector3( ( tmp0.getY() * detinv ), ( tmp1.getY() * detinv ), ( tmp2.getY() * detinv ) ); - inv2 = Vector3( ( tmp0.getZ() * detinv ), ( tmp1.getZ() * detinv ), ( tmp2.getZ() * detinv ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Vector3 inv0, inv1, inv2; - inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); - inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); - inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - return Vector3( - ( ( ( mCol0.getX() * vec.getX() ) + ( mCol1.getX() * vec.getY() ) ) + ( mCol2.getX() * vec.getZ() ) ), - ( ( ( mCol0.getY() * vec.getX() ) + ( mCol1.getY() * vec.getY() ) ) + ( mCol2.getY() * vec.getZ() ) ), - ( ( ( mCol0.getZ() * vec.getX() ) + ( mCol1.getZ() * vec.getY() ) ) + ( mCol2.getZ() * vec.getZ() ) ) - ); -} - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - ( ( ( ( mCol0.getX() * pnt.getX() ) + ( mCol1.getX() * pnt.getY() ) ) + ( mCol2.getX() * pnt.getZ() ) ) + mCol3.getX() ), - ( ( ( ( mCol0.getY() * pnt.getX() ) + ( mCol1.getY() * pnt.getY() ) ) + ( mCol2.getY() * pnt.getZ() ) ) + mCol3.getY() ), - ( ( ( ( mCol0.getZ() * pnt.getX() ) + ( mCol1.getZ() * pnt.getY() ) ) + ( mCol2.getZ() * pnt.getZ() ) ) + mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3::xAxis( ), - Vector3( 0.0f, c, s ), - Vector3( 0.0f, -s, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, 0.0f, -s ), - Vector3::yAxis( ), - Vector3( s, 0.0f, c ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - float s, c; - s = sinf( radians ); - c = cosf( radians ); - return Transform3( - Vector3( c, s, 0.0f ), - Vector3( -s, c, 0.0f ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - float sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sX = sinf( radiansXYZ.getX() ); - cX = cosf( radiansXYZ.getX() ); - sY = sinf( radiansXYZ.getY() ); - cY = cosf( radiansXYZ.getY() ); - sZ = sinf( radiansXYZ.getZ() ); - cZ = cosf( radiansXYZ.getZ() ); - tmp0 = ( cZ * sY ); - tmp1 = ( sZ * sY ); - return Transform3( - Vector3( ( cZ * cY ), ( sZ * cY ), -sY ), - Vector3( ( ( tmp0 * sX ) - ( sZ * cX ) ), ( ( tmp1 * sX ) + ( cZ * cX ) ), ( cY * sX ) ), - Vector3( ( ( tmp0 * cX ) + ( sZ * sX ) ), ( ( tmp1 * cX ) - ( cZ * sX ) ), ( cY * cX ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), 0.0f, 0.0f ), - Vector3( 0.0f, scaleVec.getY(), 0.0f ), - Vector3( 0.0f, 0.0f, scaleVec.getZ() ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - float trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - int negTrace, ZgtX, ZgtY, YgtX; - int largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = ( ( xx + yy ) + zz ); - - negTrace = ( trace < 0.0f ); - ZgtX = zz > xx; - ZgtY = zz > yy; - YgtX = yy > xx; - largestXorY = ( !ZgtX || !ZgtY ) && negTrace; - largestYorZ = ( YgtX || ZgtX ) && negTrace; - largestZorX = ( ZgtY || !YgtX ) && negTrace; - - if ( largestXorY ) - { - zz = -zz; - xy = -xy; - } - if ( largestYorZ ) - { - xx = -xx; - yz = -yz; - } - if ( largestZorX ) - { - yy = -yy; - zx = -zx; - } - - radicand = ( ( ( xx + yy ) + zz ) + 1.0f ); - scale = ( 0.5f * ( 1.0f / sqrtf( radicand ) ) ); - - tmpx = ( ( zy - yz ) * scale ); - tmpy = ( ( xz - zx ) * scale ); - tmpz = ( ( yx - xy ) * scale ); - tmpw = ( radicand * scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - if ( largestXorY ) - { - qx = tmpw; - qy = tmpz; - qz = tmpy; - qw = tmpx; - } - if ( largestYorZ ) - { - tmpx = qx; - tmpz = qz; - qx = qy; - qy = tmpx; - qz = qw; - qw = tmpz; - } - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - ( ( ( vec.getX() * mat.getCol0().getX() ) + ( vec.getY() * mat.getCol0().getY() ) ) + ( vec.getZ() * mat.getCol0().getZ() ) ), - ( ( ( vec.getX() * mat.getCol1().getX() ) + ( vec.getY() * mat.getCol1().getY() ) ) + ( vec.getZ() * mat.getCol1().getZ() ) ), - ( ( ( vec.getX() * mat.getCol2().getX() ) + ( vec.getY() * mat.getCol2().getY() ) ) + ( vec.getZ() * mat.getCol2().getZ() ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( 0.0f, vec.getZ(), -vec.getY() ), - Vector3( -vec.getZ(), 0.0f, vec.getX() ), - Vector3( vec.getY(), -vec.getX(), 0.0f ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h deleted file mode 100644 index 205c724f0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/quat_aos.h +++ /dev/null @@ -1,446 +0,0 @@ -/* - Copyright (C) 2006-2010 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 { - -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 diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h deleted file mode 100644 index 9f1af36e9..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vec_aos.h +++ /dev/null @@ -1,1439 +0,0 @@ -/* - Copyright (C) 2006-2010 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Aos { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -} - -inline Vector3::Vector3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( 1.0f, 0.0f, 0.0f ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( 0.0f, 1.0f, 0.0f ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( 0.0f, 0.0f, 1.0f ); -} - -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZ( Vector3 & vec, const float * fptr ) -{ - vec = Vector3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Vector3 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); -} - -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - ( mX + pnt.getX() ), - ( mY + pnt.getY() ), - ( mZ + pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return Vector3( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return Vector3( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - -mX, - -mY, - -mZ - ); -} - -inline const Vector3 operator *( float scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float maxElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ() - ); -} - -inline float minElem( const Vector3 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - return result; -} - -inline float sum( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - return result; -} - -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - return result; -} - -inline float lengthSqr( const Vector3 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - return result; -} - -inline float length( const Vector3 & vec ) -{ - return ::sqrtf( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( const Vector3 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector3( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ) - ); -} - -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - ( ( vec0.getY() * vec1.getZ() ) - ( vec0.getZ() * vec1.getY() ) ), - ( ( vec0.getZ() * vec1.getX() ) - ( vec0.getX() * vec1.getZ() ) ), - ( ( vec0.getX() * vec1.getY() ) - ( vec0.getY() * vec1.getX() ) ) - ); -} - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ) -{ - return Vector3( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, float _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = 0.0f; -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = 1.0f; -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( 1.0f, 0.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( 0.0f, 1.0f, 0.0f, 0.0f ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( 0.0f, 0.0f, 1.0f, 0.0f ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); -} - -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - float recipSinAngle, scale0, scale1, cosAngle, angle; - cosAngle = dot( unitVec0, unitVec1 ); - 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 ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void loadXYZW( Vector4 & vec, const float * fptr ) -{ - vec = Vector4( fptr[0], fptr[1], fptr[2], fptr[3] ); -} - -inline void storeXYZW( const Vector4 & vec, float * fptr ) -{ - fptr[0] = vec.getX(); - fptr[1] = vec.getY(); - fptr[2] = vec.getZ(); - fptr[3] = vec.getW(); -} - -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 4; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( float _w ) -{ - mW = _w; - return *this; -} - -inline float Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - ( mX + vec.mX ), - ( mY + vec.mY ), - ( mZ + vec.mZ ), - ( mW + vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - ( mX - vec.mX ), - ( mY - vec.mY ), - ( mZ - vec.mZ ), - ( mW - vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return Vector4( - ( mX * scalar ), - ( mY * scalar ), - ( mZ * scalar ), - ( mW * scalar ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return Vector4( - ( mX / scalar ), - ( mY / scalar ), - ( mZ / scalar ), - ( mW / scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - -mX, - -mY, - -mZ, - -mW - ); -} - -inline const Vector4 operator *( float scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() * vec1.getX() ), - ( vec0.getY() * vec1.getY() ), - ( vec0.getZ() * vec1.getZ() ), - ( vec0.getW() * vec1.getW() ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec0.getX() / vec1.getX() ), - ( vec0.getY() / vec1.getY() ), - ( vec0.getZ() / vec1.getZ() ), - ( vec0.getW() / vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / vec.getX() ), - ( 1.0f / vec.getY() ), - ( 1.0f / vec.getZ() ), - ( 1.0f / vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf( vec.getX() ), - sqrtf( vec.getY() ), - sqrtf( vec.getZ() ), - sqrtf( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - ( 1.0f / sqrtf( vec.getX() ) ), - ( 1.0f / sqrtf( vec.getY() ) ), - ( 1.0f / sqrtf( vec.getZ() ) ), - ( 1.0f / sqrtf( vec.getW() ) ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf( vec.getX() ), - fabsf( vec.getY() ), - fabsf( vec.getZ() ), - fabsf( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ), - ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ), - ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ), - ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float maxElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() > vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() > result)? vec.getZ() : result; - result = (vec.getW() > result)? vec.getW() : result; - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(), - (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(), - (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(), - (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW() - ); -} - -inline float minElem( const Vector4 & vec ) -{ - float result; - result = (vec.getX() < vec.getY())? vec.getX() : vec.getY(); - result = (vec.getZ() < result)? vec.getZ() : result; - result = (vec.getW() < result)? vec.getW() : result; - return result; -} - -inline float sum( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() + vec.getY() ); - result = ( result + vec.getZ() ); - result = ( result + vec.getW() ); - return result; -} - -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - float result; - result = ( vec0.getX() * vec1.getX() ); - result = ( result + ( vec0.getY() * vec1.getY() ) ); - result = ( result + ( vec0.getZ() * vec1.getZ() ) ); - result = ( result + ( vec0.getW() * vec1.getW() ) ); - return result; -} - -inline float lengthSqr( const Vector4 & vec ) -{ - float result; - result = ( vec.getX() * vec.getX() ); - result = ( result + ( vec.getY() * vec.getY() ) ); - result = ( result + ( vec.getZ() * vec.getZ() ) ); - result = ( result + ( vec.getW() * vec.getW() ) ); - return result; -} - -inline float length( const Vector4 & vec ) -{ - return ::sqrtf( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - float lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = ( 1.0f / sqrtf( lenSqr ) ); - return Vector4( - ( vec.getX() * lenInv ), - ( vec.getY() * lenInv ), - ( vec.getZ() * lenInv ), - ( vec.getW() * lenInv ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ) -{ - return Vector4( - ( select1 )? vec1.getX() : vec0.getX(), - ( select1 )? vec1.getY() : vec0.getY(), - ( select1 )? vec1.getZ() : vec0.getZ(), - ( select1 )? vec1.getW() : vec0.getW() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -} - -inline Point3::Point3( float _x, float _y, float _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -} - -inline Point3::Point3( float scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline void loadXYZ( Point3 & pnt, const float * fptr ) -{ - pnt = Point3( fptr[0], fptr[1], fptr[2] ); -} - -inline void storeXYZ( const Point3 & pnt, float * fptr ) -{ - fptr[0] = pnt.getX(); - fptr[1] = pnt.getY(); - fptr[2] = pnt.getZ(); -} - -inline void loadHalfFloats( Point3 & vec, const unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - unsigned short fp16 = hfptr[i]; - unsigned int sign = fp16 >> 15; - unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1); - unsigned int mantissa = fp16 & ((1 << 10) - 1); - - if (exponent == 0) { - // zero - mantissa = 0; - - } else if (exponent == 31) { - // infinity or nan -> infinity - exponent = 255; - mantissa = 0; - - } else { - exponent += 127 - 15; - mantissa <<= 13; - } - - Data32 d; - d.u32 = (sign << 31) | (exponent << 23) | mantissa; - vec[i] = d.f32; - } -} - -inline void storeHalfFloats( const Point3 & vec, unsigned short * hfptr ) -{ - union Data32 { - unsigned int u32; - float f32; - }; - - for (int i = 0; i < 3; i++) { - Data32 d; - d.f32 = vec[i]; - - unsigned int sign = d.u32 >> 31; - unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1); - unsigned int mantissa = d.u32 & ((1 << 23) - 1);; - - if (exponent == 0) { - // zero or denorm -> zero - mantissa = 0; - - } else if (exponent == 255 && mantissa != 0) { - // nan -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent >= 127 - 15 + 31) { - // overflow or infinity -> infinity - exponent = 31; - mantissa = 0; - - } else if (exponent <= 127 - 15) { - // underflow -> zero - exponent = 0; - mantissa = 0; - - } else { - exponent -= 127 - 15; - mantissa >>= 13; - } - - hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa); - } -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - mX = _x; - return *this; -} - -inline float Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( float _y ) -{ - mY = _y; - return *this; -} - -inline float Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( float _z ) -{ - mZ = _z; - return *this; -} - -inline float Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline float Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline float & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline float Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - ( mX - pnt.mX ), - ( mY - pnt.mY ), - ( mZ - pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - ( mX + vec.getX() ), - ( mY + vec.getY() ), - ( mZ + vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - ( mX - vec.getX() ), - ( mY - vec.getY() ), - ( mZ - vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() * pnt1.getX() ), - ( pnt0.getY() * pnt1.getY() ), - ( pnt0.getZ() * pnt1.getZ() ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt0.getX() / pnt1.getX() ), - ( pnt0.getY() / pnt1.getY() ), - ( pnt0.getZ() / pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / pnt.getX() ), - ( 1.0f / pnt.getY() ), - ( 1.0f / pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf( pnt.getX() ), - sqrtf( pnt.getY() ), - sqrtf( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - ( 1.0f / sqrtf( pnt.getX() ) ), - ( 1.0f / sqrtf( pnt.getY() ) ), - ( 1.0f / sqrtf( pnt.getZ() ) ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf( pnt.getX() ), - fabsf( pnt.getY() ), - fabsf( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ), - ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ), - ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float maxElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() > result)? pnt.getZ() : result; - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(), - (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(), - (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ() - ); -} - -inline float minElem( const Point3 & pnt ) -{ - float result; - result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY(); - result = (pnt.getZ() < result)? pnt.getZ() : result; - return result; -} - -inline float sum( const Point3 & pnt ) -{ - float result; - result = ( pnt.getX() + pnt.getY() ); - result = ( result + pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, float scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline float projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - float result; - result = ( pnt.getX() * unitVec.getX() ); - result = ( result + ( pnt.getY() * unitVec.getY() ) ); - result = ( result + ( pnt.getZ() * unitVec.getZ() ) ); - return result; -} - -inline float distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline float distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ) -{ - return Point3( - ( select1 )? pnt1.getX() : pnt0.getX(), - ( select1 )? pnt1.getY() : pnt0.getY(), - ( select1 )? pnt1.getZ() : pnt0.getZ() - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h deleted file mode 100644 index e1c04beaf..000000000 --- a/Extras/vectormathlibrary/include/vectormath/scalar/cpp/vectormath_aos.h +++ /dev/null @@ -1,1885 +0,0 @@ -/* - 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_AOS_CPP_SCALAR_H -#define _VECTORMATH_AOS_CPP_SCALAR_H - -#include - -#ifdef _VECTORMATH_DEBUG -#include -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Get the x element of a 3-D vector - // - inline float getX( ) const; - - // Get the y element of a 3-D vector - // - inline float getY( ) const; - - // Get the z element of a 3-D vector - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline float maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline float minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline float sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline float dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline float lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline float length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Vector3 & vec, const float * fptr ); - -// Store x, y, and z elements of a 3-D vector in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Vector3 & vec, float * fptr ); - -// Load three-half-floats as a 3-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr ); - -// Store a 3-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, float w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Get the x element of a 4-D vector - // - inline float getX( ) const; - - // Get the y element of a 4-D vector - // - inline float getY( ) const; - - // Get the z element of a 4-D vector - // - inline float getZ( ) const; - - // Get the w element of a 4-D vector - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline float maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline float minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline float sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline float dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline float lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline float length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Vector4 & vec, const float * fptr ); - -// Store x, y, z, and w elements of a 4-D vector in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Vector4 & vec, float * fptr ); - -// Load four-half-floats as a 4-D vector -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr ); - -// Store a 4-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - float mX; - float mY; - float mZ; -#ifndef __GNUC__ - float d; -#endif - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Get the x element of a 3-D point - // - inline float getX( ) const; - - // Get the y element of a 3-D point - // - inline float getY( ) const; - - // Get the z element of a 3-D point - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline float maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline float minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline float sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, float scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline float projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline float distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline float distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline float dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 ); - -// Load x, y, and z elements from the first three words of a float array. -// -// -inline void loadXYZ( Point3 & pnt, const float * fptr ); - -// Store x, y, and z elements of a 3-D point in the first three words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZ( const Point3 & pnt, float * fptr ); - -// Load three-half-floats as a 3-D point -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. -// -inline void loadHalfFloats( Point3 & pnt, const unsigned short * hfptr ); - -// Store a 3-D point as half-floats. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// NOTE: -// This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed. -// -inline void storeHalfFloats( const Point3 & pnt, unsigned short * hfptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - float mX; - float mY; - float mZ; - float mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, float w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Get the x element of a quaternion - // - inline float getX( ) const; - - // Get the y element of a quaternion - // - inline float getY( ) const; - - // Get the z element of a quaternion - // - inline float getZ( ) const; - - // Get the w element of a quaternion - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline float & operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - -} -#ifdef __GNUC__ -__attribute__ ((aligned(16))) -#endif -; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline float dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline float norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline float length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// -inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 ); - -// Load x, y, z, and w elements from the first four words of a float array. -// -// -inline void loadXYZW( Quat & quat, const float * fptr ); - -// Store x, y, z, and w elements of a quaternion in the first four words of a float array. -// Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed -// -inline void storeXYZW( const Quat & quat, float * fptr ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline float determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline float determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos.h deleted file mode 100644 index d6b4cb0ba..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos.h +++ /dev/null @@ -1,1833 +0,0 @@ -/* - 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_MAT_AOS_C_H -#define _VECTORMATH_MAT_AOS_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) -#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) -#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) -#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( &result->col0, &mat->col0 ); - vmathV3Copy( &result->col1, &mat->col1 ); - vmathV3Copy( &result->col2, &mat->col2 ); -} - -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); -} - -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_uint4 select_x = (vec_uint4)spu_maskb(0xf000); - vec_uint4 select_z = (vec_uint4)spu_maskb(0x00f0); - xyzw_2 = spu_add( unitQuat->vec128, unitQuat->vec128 ); - wwww = spu_shuffle( unitQuat->vec128, unitQuat->vec128, shuffle_wwww ); - yzxw = spu_shuffle( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_SHUF_YZXW ); - zxyw = spu_shuffle( unitQuat->vec128, unitQuat->vec128, _VECTORMATH_SHUF_ZXYW ); - yzxw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_YZXW ); - zxyw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_ZXYW ); - tmp0 = spu_mul( yzxw_2, wwww ); - tmp1 = spu_nmsub( yzxw, yzxw_2, spu_splats(1.0f) ); - tmp2 = spu_mul( yzxw, xyzw_2 ); - tmp0 = spu_madd( zxyw, xyzw_2, tmp0 ); - tmp1 = spu_nmsub( zxyw, zxyw_2, tmp1 ); - tmp2 = spu_nmsub( zxyw_2, wwww, tmp2 ); - tmp3 = spu_sel( tmp0, tmp1, select_x ); - tmp4 = spu_sel( tmp1, tmp2, select_x ); - tmp5 = spu_sel( tmp2, tmp0, select_x ); - result->col0.vec128 = spu_sel( tmp3, tmp2, select_z ); - result->col1.vec128 = spu_sel( tmp4, tmp0, select_z ); - result->col2.vec128 = spu_sel( tmp5, tmp1, select_z ); -} - -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV3GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV3GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV3GetElem( vec, 2 ) ); -} - -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathM3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathM3GetCol( &tmpV3_0, mat, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col0 ); -} - -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col1 ); -} - -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Copy( result, &mat->col2 ); -} - -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ) -{ - vmathV3Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ) -{ - vmathV3MakeFromElems( result, vmathV3GetElem( &mat->col0, row ), vmathV3GetElem( &mat->col1, row ), vmathV3GetElem( &mat->col2, row ) ); -} - -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, res0, res1, res2; - tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); - res0 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_XAYB ); - res1 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); - res2 = spu_shuffle( tmp1, mat->col1.vec128, _VECTORMATH_SHUF_XCY0 ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - tmp2 = _vmathVfCross( mat->col0.vec128, mat->col1.vec128 ); - tmp0 = _vmathVfCross( mat->col1.vec128, mat->col2.vec128 ); - tmp1 = _vmathVfCross( mat->col2.vec128, mat->col0.vec128 ); - dot = _vmathVfDot3( tmp2, mat->col2.vec128 ); - dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); - invdet = recipf4( dot ); - tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); - tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); - inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); - inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); - inv0 = spu_mul( inv0, invdet ); - inv1 = spu_mul( inv1, invdet ); - inv2 = spu_mul( inv2, invdet ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; -} - -static inline float vmathM3Determinant( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0; - vmathV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); - return vmathV3Dot( &mat->col2, &tmpV3_0 ); -} - -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Add( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3Neg( &result->col0, &mat->col0 ); - vmathV3Neg( &result->col1, &mat->col1 ); - vmathV3Neg( &result->col2, &mat->col2 ); -} - -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathV3AbsPerElem( &result->col0, &mat->col0 ); - vmathV3AbsPerElem( &result->col1, &mat->col1 ); - vmathV3AbsPerElem( &result->col2, &mat->col2 ); -} - -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV3ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV3ScalarMul( &result->col2, &mat->col2, scalar ); -} - -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); - res = spu_mul( mat->col0.vec128, xxxx ); - res = spu_madd( mat->col1.vec128, yyyy, res ); - res = spu_madd( mat->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - VmathMatrix3 tmpResult; - vmathM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM3Copy( result, &tmpResult ); -} - -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ) -{ - vmathV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - vmathV3MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV3MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; -} - -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV3MakeZAxis( &result->col2 ); -} - -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ->vec128; - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - result->col0.vec128 = spu_mul( Z0, Y0 ); - result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); - result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); -} - -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - axis = unitVec->vec128; - sincosf4( spu_splats( radians ), &s, &c ); - xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); - yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); - zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - axisS = spu_mul( axis, s ); - negAxisS = negatef4( axisS ); - tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); - tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); - tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); - tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); - tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); - tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); - result->col0.vec128 = spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ); - result->col1.vec128 = spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ); - result->col2.vec128 = spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ); -} - -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ) -{ - vmathM3MakeFromQ( result, unitQuat ); -} - -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); - result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); - result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); -} - -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); -} - -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ) -{ - vmathV3MulPerElem( &result->col0, &mat->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &mat->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &mat->col2, scaleVec ); -} - -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print( const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathM3GetRow( &tmpV3_0, mat, 0 ); - vmathV3Print( &tmpV3_0 ); - vmathM3GetRow( &tmpV3_1, mat, 1 ); - vmathV3Print( &tmpV3_1 ); - vmathM3GetRow( &tmpV3_2, mat, 2 ); - vmathV3Print( &tmpV3_2 ); -} - -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM3Print( mat ); -} - -#endif - -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( &result->col0, &mat->col0 ); - vmathV4Copy( &result->col1, &mat->col1 ); - vmathV4Copy( &result->col2, &mat->col2 ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ) -{ - vmathV4MakeFromScalar( &result->col0, scalar ); - vmathV4MakeFromScalar( &result->col1, scalar ); - vmathV4MakeFromScalar( &result->col2, scalar ); - vmathV4MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, &mat->col3, 1.0f ); -} - -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *_col0, const VmathVector4 *_col1, const VmathVector4 *_col2, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col0, _col0 ); - vmathV4Copy( &result->col1, _col1 ); - vmathV4Copy( &result->col2, _col2 ); - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ) -{ - vmathV4MakeFromV3Scalar( &result->col0, &mat->col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat->col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat->col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 mat; - vmathM3MakeFromQ( &mat, unitQuat ); - vmathV4MakeFromV3Scalar( &result->col0, &mat.col0, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col1, &mat.col1, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col2, &mat.col2, 0.0f ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *_col0 ) -{ - vmathV4Copy( &result->col0, _col0 ); -} - -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *_col1 ) -{ - vmathV4Copy( &result->col1, _col1 ); -} - -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *_col2 ) -{ - vmathV4Copy( &result->col2, _col2 ); -} - -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *_col3 ) -{ - vmathV4Copy( &result->col3, _col3 ); -} - -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ) -{ - vmathV4Copy( (&result->col0 + col), vec ); -} - -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ) -{ - vmathV4SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV4SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV4SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV4SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ) -{ - VmathVector4 tmpV3_0; - vmathM4GetCol( &tmpV3_0, result, col ); - vmathV4SetElem( &tmpV3_0, row, val ); - vmathM4SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ) -{ - VmathVector4 tmpV4_0; - vmathM4GetCol( &tmpV4_0, mat, col ); - return vmathV4GetElem( &tmpV4_0, row ); -} - -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col0 ); -} - -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col1 ); -} - -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col2 ); -} - -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Copy( result, &mat->col3 ); -} - -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ) -{ - vmathV4Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ) -{ - vmathV4MakeFromElems( result, vmathV4GetElem( &mat->col0, row ), vmathV4GetElem( &mat->col1, row ), vmathV4GetElem( &mat->col2, row ), vmathV4GetElem( &mat->col3, row ) ); -} - -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat->col1.vec128, mat->col3.vec128, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( mat->col1.vec128, mat->col3.vec128, _VECTORMATH_SHUF_ZCWD ); - res0 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - res1 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - res2 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - res3 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; - result->col3.vec128 = res3; -} - -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 in0, in1, in2, in3; - vec_float4 tmp0, tmp1, tmp2, tmp3; - vec_float4 cof0, cof1, cof2, cof3; - vec_float4 t0, t1, t2, t3; - vec_float4 t01, t02, t03, t12, t23; - vec_float4 t1r, t2r; - vec_float4 t01r, t02r, t03r, t12r, t23r; - vec_float4 t1r3, t1r3r; - vec_float4 det, det1, det2, det3, invdet; - in0 = mat->col0.vec128; - in1 = mat->col1.vec128; - in2 = mat->col2.vec128; - in3 = mat->col3.vec128; - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ - tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ - tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ - tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ - t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ - t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ - t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ - t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = spu_mul(t2, t3); /* CL GP KD OH */ - t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ - cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ - cof1 = spu_mul(t0, t23); /* AGP ECL IOH MKD */ - t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ - cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ - cof1 = spu_msub(t0, t23r, cof1); /* AOH EKD IGP MCL - cof1 */ - cof1 = spu_rlqwbyte(cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ - - t12 = spu_mul(t1, t2); /* JC NG BK FO */ - t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ - cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - cof3 = spu_mul(t0, t12); /* ANG EJC IFO MBK */ - t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ - cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - cof3 = spu_msub(t0, t12r, cof3); /* AFO EBK ING MJC - cof3 */ - cof3 = spu_rlqwbyte(cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ - t1r = spu_rlqwbyte(t1, 8); /* B F J N */ - t2r = spu_rlqwbyte(t2, 8); /* K O C G */ - t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ - t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ - cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - cof2 = spu_mul(t0, t1r3); /* AFP EBL INH MJD */ - t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ - cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - cof2 = spu_msub(t0, t1r3r, cof2); /* ANH EJD IFP MBL - cof2 */ - cof2 = spu_rlqwbyte(cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ - t01 = spu_mul(t0, t1); /* AJ EN IB MF */ - t01 = spu_shuffle(t01, t01, _VECTORMATH_SHUF_YXWZ); /* EN AJ MF IB */ - cof2 = spu_madd(t3, t01, cof2); /* LEN PAJ DMF HIB + cof2 */ - cof3 = spu_msub(t2r, t01, cof3); /* KEN OAJ CMF GIB - cof3 */ - t01r = spu_rlqwbyte(t01, 8); /* MF IB EN AJ */ - cof2 = spu_msub(t3, t01r, cof2); /* LMF PIB DEN HAJ - cof2 */ - cof3 = spu_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ - t03 = spu_mul(t0, t3); /* AL EP ID MH */ - t03 = spu_shuffle(t03, t03, _VECTORMATH_SHUF_YXWZ); /* EP AL MH ID */ - cof1 = spu_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ - cof2 = spu_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ - t03r = spu_rlqwbyte(t03, 8); /* MH ID EP AL */ - cof1 = spu_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ - cof2 = spu_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ - t02 = spu_mul(t0, t2r); /* AK EO IC MG */ - t02 = spu_shuffle(t02, t02, _VECTORMATH_SHUF_YXWZ); /* E0 AK MG IC */ - cof1 = spu_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ - cof3 = spu_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ - t02r = spu_rlqwbyte(t02, 8); /* MG IC EO AK */ - cof1 = spu_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ - cof3 = spu_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ - /* Compute the determinant of the matrix - * - * det = sum_across(t0 * cof0); - * - * We perform a sum across the entire vector so that - * we don't have to splat the result when multiplying the - * cofactors by the inverse of the determinant. - */ - det = spu_mul(t0, cof0); - det1 = spu_rlqwbyte(det, 4); - det2 = spu_rlqwbyte(det, 8); - det3 = spu_rlqwbyte(det, 12); - det = spu_add(det, det1); - det2 = spu_add(det2, det3); - det = spu_add(det, det2); - /* Compute the reciprocal of the determinant. - */ - invdet = recipf4(det); - /* Multiply the cofactors by the reciprocal of the determinant. - */ - result->col0.vec128 = spu_mul(cof0, invdet); - result->col1.vec128 = spu_mul(cof1, invdet); - result->col2.vec128 = spu_mul(cof2, invdet); - result->col3.vec128 = spu_mul(cof3, invdet); -} - -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3Inverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - VmathTransform3 affineMat, tmpT3_0; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathT3SetCol0( &affineMat, &tmpV3_0 ); - vmathV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathT3SetCol1( &affineMat, &tmpV3_1 ); - vmathV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathT3SetCol2( &affineMat, &tmpV3_2 ); - vmathV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathT3SetCol3( &affineMat, &tmpV3_3 ); - vmathT3OrthoInverse( &tmpT3_0, &affineMat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline float vmathM4Determinant( const VmathMatrix4 *mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 in0, in1, in2, in3; - vec_float4 tmp0, tmp1, tmp2, tmp3; - vec_float4 cof0; - vec_float4 t0, t1, t2, t3; - vec_float4 t12, t23; - vec_float4 t1r, t2r; - vec_float4 t12r, t23r; - vec_float4 t1r3, t1r3r; - in0 = mat->col0.vec128; - in1 = mat->col1.vec128; - in2 = mat->col2.vec128; - in3 = mat->col3.vec128; - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ - tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ - tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ - tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ - t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ - t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ - t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ - t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = spu_mul(t2, t3); /* CL GP KD OH */ - t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ - cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ - t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ - cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ - - t12 = spu_mul(t1, t2); /* JC NG BK FO */ - t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ - cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ - cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - t1r = spu_rlqwbyte(t1, 8); /* B F J N */ - t2r = spu_rlqwbyte(t2, 8); /* K O C G */ - t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ - t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ - cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ - cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - return spu_extract( _vmathVfDot4(t0,cof0), 0 ); -} - -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Add( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Add( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4Neg( &result->col0, &mat->col0 ); - vmathV4Neg( &result->col1, &mat->col1 ); - vmathV4Neg( &result->col2, &mat->col2 ); - vmathV4Neg( &result->col3, &mat->col3 ); -} - -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathV4AbsPerElem( &result->col0, &mat->col0 ); - vmathV4AbsPerElem( &result->col1, &mat->col1 ); - vmathV4AbsPerElem( &result->col2, &mat->col2 ); - vmathV4AbsPerElem( &result->col3, &mat->col3 ); -} - -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, scalar ); - vmathV4ScalarMul( &result->col1, &mat->col1, scalar ); - vmathV4ScalarMul( &result->col2, &mat->col2, scalar ); - vmathV4ScalarMul( &result->col3, &mat->col3, scalar ); -} - -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz, wwww; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); - wwww = spu_shuffle( vec->vec128, vec->vec128, shuffle_wwww ); - tmp0 = spu_mul( mat->col0.vec128, xxxx ); - tmp1 = spu_mul( mat->col1.vec128, yyyy ); - tmp0 = spu_madd( mat->col2.vec128, zzzz, tmp0 ); - tmp1 = spu_madd( mat->col3.vec128, wwww, tmp1 ); - res = spu_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); - res = spu_mul( mat->col0.vec128, xxxx ); - res = spu_madd( mat->col1.vec128, yyyy, res ); - res = spu_madd( mat->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_zzzz ); - tmp0 = spu_mul( mat->col0.vec128, xxxx ); - tmp1 = spu_mul( mat->col1.vec128, yyyy ); - tmp0 = spu_madd( mat->col2.vec128, zzzz, tmp0 ); - tmp1 = spu_add( mat->col3.vec128, tmp1 ); - res = spu_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - VmathMatrix4 tmpResult; - vmathM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); - vmathM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); - vmathM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); - vmathM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm1 ) -{ - VmathMatrix4 tmpResult; - VmathPoint3 tmpP3_0; - vmathM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); - vmathM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); - vmathM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); - vmathM4Copy( result, &tmpResult ); -} - -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ) -{ - vmathV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); - vmathV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ) -{ - vmathV4SetXYZ( &result->col0, &mat3->col0 ); - vmathV4SetXYZ( &result->col1, &mat3->col1 ); - vmathV4SetXYZ( &result->col2, &mat3->col2 ); -} - -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( &result->col0, &mat->col0 ); - vmathV4GetXYZ( &result->col1, &mat->col1 ); - vmathV4GetXYZ( &result->col2, &mat->col2 ); -} - -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4SetXYZ( &result->col3, translateVec ); -} - -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ) -{ - vmathV4GetXYZ( result, &mat->col3 ); -} - -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - vmathV4MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV4MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ->vec128; - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - result->col0.vec128 = spu_mul( Z0, Y0 ); - result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); - result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - axis = unitVec->vec128; - sincosf4( spu_splats( radians ), &s, &c ); - xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); - yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); - zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - axisS = spu_mul( axis, s ); - negAxisS = negatef4( axisS ); - tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); - tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); - tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); - tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); - tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); - tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); - zeroW = (vec_float4)spu_maskb(0x000f); - axis = spu_andc( axis, zeroW ); - result->col0.vec128 = spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ); - result->col1.vec128 = spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ); - result->col2.vec128 = spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ) -{ - VmathTransform3 tmpT3_0; - vmathT3MakeRotationQ( &tmpT3_0, unitQuat ); - vmathM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); - result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); - result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); - vmathV4MakeWAxis( &result->col3 ); -} - -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ) -{ - vmathV4ScalarMul( &result->col0, &mat->col0, vmathV3GetX( scaleVec ) ); - vmathV4ScalarMul( &result->col1, &mat->col1, vmathV3GetY( scaleVec ) ); - vmathV4ScalarMul( &result->col2, &mat->col2, vmathV3GetZ( scaleVec ) ); - vmathV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ) -{ - VmathVector4 scale4; - vmathV4MakeFromV3Scalar( &scale4, scaleVec, 1.0f ); - vmathV4MulPerElem( &result->col0, &mat->col0, &scale4 ); - vmathV4MulPerElem( &result->col1, &mat->col1, &scale4 ); - vmathV4MulPerElem( &result->col2, &mat->col2, &scale4 ); - vmathV4MulPerElem( &result->col3, &mat->col3, &scale4 ); -} - -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ) -{ - vmathV4MakeXAxis( &result->col0 ); - vmathV4MakeYAxis( &result->col1 ); - vmathV4MakeZAxis( &result->col2 ); - vmathV4MakeFromV3Scalar( &result->col3, translateVec, 1.0f ); -} - -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ) -{ - VmathMatrix4 m4EyeFrame; - VmathVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathV3Normalize( &v3Y, upVec ); - vmathP3Sub( &tmpV3_0, eyePos, lookAtPos ); - vmathV3Normalize( &v3Z, &tmpV3_0 ); - vmathV3Cross( &tmpV3_1, &v3Y, &v3Z ); - vmathV3Normalize( &v3X, &tmpV3_1 ); - vmathV3Cross( &v3Y, &v3Z, &v3X ); - vmathV4MakeFromV3( &tmpV4_0, &v3X ); - vmathV4MakeFromV3( &tmpV4_1, &v3Y ); - vmathV4MakeFromV3( &tmpV4_2, &v3Z ); - vmathV4MakeFromP3( &tmpV4_3, eyePos ); - vmathM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); - vmathM4OrthoInverse( result, &m4EyeFrame ); -} - -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - vec_float4 zero, col0, col1, col2, col3; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = spu_splats(0.0f); - col0 = zero; - col1 = zero; - col2 = zero; - col3 = zero; - col0 = spu_insert( f / aspect, col0, 0 ); - col1 = spu_insert( f, col1, 1 ); - col2 = spu_insert( ( zNear + zFar ) * rangeInv, col2, 2 ); - col2 = spu_insert( -1.0f, col2, 3 ); - col3 = spu_insert( zNear * zFar * rangeInv * 2.0f, col3, 2 ); - result->col0.vec128 = col0; - result->col1.vec128 = col1; - result->col2.vec128 = col2; - result->col3.vec128 = col3; -} - -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff; - vec_float4 diagonal, column, near2; - vec_float4 zero = spu_splats(0.0f); - lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); - lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); - diff = spu_sub( rtn, lbf ); - sum = spu_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = spu_splats( zNear ); - near2 = spu_add( near2, near2 ); - diagonal = spu_mul( near2, inv_diff ); - column = spu_mul( sum, inv_diff ); - result->col0.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ); - result->col1.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ); - result->col2.vec128 = spu_sel( column, spu_splats(-1.0f), (vec_uint4)spu_maskb(0x000f) ); - result->col3.vec128 = spu_sel( zero, spu_mul( diagonal, spu_splats(zFar) ), (vec_uint4)spu_maskb(0x00f0) ); -} - -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff, neg_inv_diff; - vec_float4 diagonal, column; - vec_float4 zero = spu_splats(0.0f); - lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); - lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); - diff = spu_sub( rtn, lbf ); - sum = spu_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = spu_add( inv_diff, inv_diff ); - column = spu_mul( sum, spu_sel( neg_inv_diff, inv_diff, (vec_uint4)spu_maskb(0x00f0) ) ); - result->col0.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ); - result->col1.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ); - result->col2.vec128 = spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x00f0) ); - result->col3.vec128 = spu_sel( column, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); -} - -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ) -{ - vmathV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); - vmathV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print( const VmathMatrix4 *mat ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathM4GetRow( &tmpV4_0, mat, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathM4GetRow( &tmpV4_1, mat, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathM4GetRow( &tmpV4_2, mat, 2 ); - vmathV4Print( &tmpV4_2 ); - vmathM4GetRow( &tmpV4_3, mat, 3 ); - vmathV4Print( &tmpV4_3 ); -} - -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathM4Print( mat ); -} - -#endif - -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ) -{ - vmathV3MakeFromScalar( &result->col0, scalar ); - vmathV3MakeFromScalar( &result->col1, scalar ); - vmathV3MakeFromScalar( &result->col2, scalar ); - vmathV3MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *_col0, const VmathVector3 *_col1, const VmathVector3 *_col2, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col0, _col0 ); - vmathV3Copy( &result->col1, _col1 ); - vmathV3Copy( &result->col2, _col2 ); - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ) -{ - vmathT3SetUpper3x3( result, tfrm ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ) -{ - VmathMatrix3 tmpM3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathT3SetUpper3x3( result, &tmpM3_0 ); - vmathT3SetTranslation( result, translateVec ); -} - -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *_col0 ) -{ - vmathV3Copy( &result->col0, _col0 ); -} - -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *_col1 ) -{ - vmathV3Copy( &result->col1, _col1 ); -} - -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *_col2 ) -{ - vmathV3Copy( &result->col2, _col2 ); -} - -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *_col3 ) -{ - vmathV3Copy( &result->col3, _col3 ); -} - -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ) -{ - vmathV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ) -{ - vmathV3SetElem( &result->col0, row, vmathV4GetElem( vec, 0 ) ); - vmathV3SetElem( &result->col1, row, vmathV4GetElem( vec, 1 ) ); - vmathV3SetElem( &result->col2, row, vmathV4GetElem( vec, 2 ) ); - vmathV3SetElem( &result->col3, row, vmathV4GetElem( vec, 3 ) ); -} - -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, result, col ); - vmathV3SetElem( &tmpV3_0, row, val ); - vmathT3SetCol( result, col, &tmpV3_0 ); -} - -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ) -{ - VmathVector3 tmpV3_0; - vmathT3GetCol( &tmpV3_0, tfrm, col ); - return vmathV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col0 ); -} - -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col1 ); -} - -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col2 ); -} - -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ) -{ - vmathV3Copy( result, (&tfrm->col0 + col) ); -} - -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ) -{ - vmathV4MakeFromElems( result, vmathV3GetElem( &tfrm->col0, row ), vmathV3GetElem( &tfrm->col1, row ), vmathV3GetElem( &tfrm->col2, row ), vmathV3GetElem( &tfrm->col3, row ) ); -} - -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp2 = _vmathVfCross( tfrm->col0.vec128, tfrm->col1.vec128 ); - tmp0 = _vmathVfCross( tfrm->col1.vec128, tfrm->col2.vec128 ); - tmp1 = _vmathVfCross( tfrm->col2.vec128, tfrm->col0.vec128 ); - inv3 = negatef4( tfrm->col3.vec128 ); - dot = _vmathVfDot3( tmp2, tfrm->col2.vec128 ); - dot = spu_shuffle( dot, dot, shuffle_xxxx ); - invdet = recipf4( dot ); - tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); - tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); - inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); - xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); - inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); - zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); - inv3 = spu_mul( inv0, xxxx ); - inv3 = spu_madd( inv1, yyyy, inv3 ); - inv3 = spu_madd( inv2, zzzz, inv3 ); - inv0 = spu_mul( inv0, invdet ); - inv1 = spu_mul( inv1, invdet ); - inv2 = spu_mul( inv2, invdet ); - inv3 = spu_mul( inv3, invdet ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; - result->col3.vec128 = inv3; -} - -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp0 = spu_shuffle( tfrm->col0.vec128, tfrm->col2.vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( tfrm->col0.vec128, tfrm->col2.vec128, _VECTORMATH_SHUF_ZCWD ); - inv3 = negatef4( tfrm->col3.vec128 ); - inv0 = spu_shuffle( tmp0, tfrm->col1.vec128, _VECTORMATH_SHUF_XAYB ); - xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); - inv1 = spu_shuffle( tmp0, tfrm->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp1, tfrm->col1.vec128, _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); - zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); - inv3 = spu_mul( inv0, xxxx ); - inv3 = spu_madd( inv1, yyyy, inv3 ); - inv3 = spu_madd( inv2, zzzz, inv3 ); - result->col0.vec128 = inv0; - result->col1.vec128 = inv1; - result->col2.vec128 = inv2; - result->col3.vec128 = inv3; -} - -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3AbsPerElem( &result->col0, &tfrm->col0 ); - vmathV3AbsPerElem( &result->col1, &tfrm->col1 ); - vmathV3AbsPerElem( &result->col2, &tfrm->col2 ); - vmathV3AbsPerElem( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ) -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); - res = spu_mul( tfrm->col0.vec128, xxxx ); - res = spu_madd( tfrm->col1.vec128, yyyy, res ); - res = spu_madd( tfrm->col2.vec128, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ) -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_xxxx ); - yyyy = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_yyyy ); - zzzz = spu_shuffle( pnt->vec128, pnt->vec128, shuffle_zzzz ); - tmp0 = spu_mul( tfrm->col0.vec128, xxxx ); - tmp1 = spu_mul( tfrm->col1.vec128, yyyy ); - tmp0 = spu_madd( tfrm->col2.vec128, zzzz, tmp0 ); - tmp1 = spu_add( tfrm->col3.vec128, tmp1 ); - res = spu_add( tmp0, tmp1 ); - result->vec128 = res; -} - -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - VmathTransform3 tmpResult; - VmathPoint3 tmpP3_0, tmpP3_1; - vmathT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); - vmathT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); - vmathT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); - vmathP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); - vmathV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); - vmathT3Copy( result, &tmpResult ); -} - -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ) -{ - vmathV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); - vmathV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); - vmathV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); - vmathV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); -} - -static inline void vmathT3MakeIdentity( VmathTransform3 *result ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *tfrm ) -{ - vmathV3Copy( &result->col0, &tfrm->col0 ); - vmathV3Copy( &result->col1, &tfrm->col1 ); - vmathV3Copy( &result->col2, &tfrm->col2 ); -} - -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ) -{ - vmathM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); -} - -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ) -{ - vmathV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - vmathV3MakeXAxis( &result->col0 ); - result->col1.vec128 = res1; - result->col2.vec128 = res2; - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - result->col0.vec128 = res0; - vmathV3MakeYAxis( &result->col1 ); - result->col2.vec128 = res2; - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - vmathV3MakeZAxis( &result->col2 ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ->vec128; - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - result->col0.vec128 = spu_mul( Z0, Y0 ); - result->col1.vec128 = spu_madd( Z1, X1, spu_mul( tmp, X0 ) ); - result->col2.vec128 = spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ) -{ - VmathMatrix3 tmpM3_0; - VmathVector3 tmpV3_0; - vmathM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathV3MakeFromScalar( &tmpV3_0, 0.0f ); - vmathT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - result->col0.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0xf000) ); - result->col1.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x0f00) ); - result->col2.vec128 = spu_sel( zero, scaleVec->vec128, (vec_uint4)spu_maskb(0x00f0) ); - vmathV3MakeFromScalar( &result->col3, 0.0f ); -} - -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ) -{ - vmathV3ScalarMul( &result->col0, &tfrm->col0, vmathV3GetX( scaleVec ) ); - vmathV3ScalarMul( &result->col1, &tfrm->col1, vmathV3GetY( scaleVec ) ); - vmathV3ScalarMul( &result->col2, &tfrm->col2, vmathV3GetZ( scaleVec ) ); - vmathV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ) -{ - vmathV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); - vmathV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); - vmathV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); - vmathV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); -} - -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ) -{ - vmathV3MakeXAxis( &result->col0 ); - vmathV3MakeYAxis( &result->col1 ); - vmathV3MakeZAxis( &result->col2 ); - vmathV3Copy( &result->col3, translateVec ); -} - -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ) -{ - vmathV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); - vmathV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); - vmathV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); - vmathV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print( const VmathTransform3 *tfrm ) -{ - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; - vmathT3GetRow( &tmpV4_0, tfrm, 0 ); - vmathV4Print( &tmpV4_0 ); - vmathT3GetRow( &tmpV4_1, tfrm, 1 ); - vmathV4Print( &tmpV4_1 ); - vmathT3GetRow( &tmpV4_2, tfrm, 2 ); - vmathV4Print( &tmpV4_2 ); -} - -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ) -{ - printf("%s:\n", name); - vmathT3Print( tfrm ); -} - -#endif - -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *tfrm ) -{ - vec_float4 res; - vec_float4 col0, col1, col2; - vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; - vec_float4 radicand, invSqrt, scale; - vec_float4 res0, res1, res2, res3; - vec_float4 xx, yy, zz; - vec_uint4 select_x = (vec_uint4)spu_maskb( 0xf000 ); - vec_uint4 select_y = (vec_uint4)spu_maskb( 0x0f00 ); - vec_uint4 select_z = (vec_uint4)spu_maskb( 0x00f0 ); - vec_uint4 select_w = (vec_uint4)spu_maskb( 0x000f ); - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((unsigned int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((unsigned int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((unsigned int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((unsigned int)0x0c0d0e0f); - - col0 = tfrm->col0.vec128; - col1 = tfrm->col1.vec128; - col2 = tfrm->col2.vec128; - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = spu_sel( col0, col1, select_y ); - xx_yy_zz_xx = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_XYCX ); - yy_zz_xx_yy = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_YCXY ); - zz_xx_yy_zz = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_CXYC ); - - diagSum = spu_add( spu_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = spu_sub( spu_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = spu_add( spu_sel( diagDiff, diagSum, select_w ), spu_splats(1.0f) ); - invSqrt = rsqrtf4( radicand ); - - zy_xz_yx = spu_sel( col0, col1, select_z ); - zy_xz_yx = spu_shuffle( zy_xz_yx, col2, _VECTORMATH_SHUF_ZAY0 ); - yz_zx_xy = spu_sel( col0, col1, select_x ); - yz_zx_xy = spu_shuffle( yz_zx_xy, col2, _VECTORMATH_SHUF_BZX0 ); - - sum = spu_add( zy_xz_yx, yz_zx_xy ); - diff = spu_sub( zy_xz_yx, yz_zx_xy ); - - scale = spu_mul( invSqrt, spu_splats(0.5f) ); - res0 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_0ZYA ); - res1 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_Z0XB ); - res2 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_YX0C ); - res3 = diff; - res0 = spu_sel( res0, radicand, select_x ); - res1 = spu_sel( res1, radicand, select_y ); - res2 = spu_sel( res2, radicand, select_z ); - res3 = spu_sel( res3, radicand, select_w ); - res0 = spu_mul( res0, spu_shuffle( scale, scale, shuffle_xxxx ) ); - res1 = spu_mul( res1, spu_shuffle( scale, scale, shuffle_yyyy ) ); - res2 = spu_mul( res2, spu_shuffle( scale, scale, shuffle_zzzz ) ); - res3 = spu_mul( res3, spu_shuffle( scale, scale, shuffle_wwww ) ); - - /* determine case and select answer */ - - xx = spu_shuffle( col0, col0, shuffle_xxxx ); - yy = spu_shuffle( col1, col1, shuffle_yyyy ); - zz = spu_shuffle( col2, col2, shuffle_zzzz ); - res = spu_sel( res0, res1, spu_cmpgt( yy, xx ) ); - res = spu_sel( res, res2, spu_and( spu_cmpgt( zz, xx ), spu_cmpgt( zz, yy ) ) ); - res = spu_sel( res, res3, spu_cmpgt( spu_shuffle( diagSum, diagSum, shuffle_xxxx ), spu_splats(0.0f) ) ); - result->vec128 = res; -} - -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *tfrm0, const VmathVector3 *tfrm1 ) -{ - vmathV3ScalarMul( &result->col0, tfrm0, vmathV3GetX( tfrm1 ) ); - vmathV3ScalarMul( &result->col1, tfrm0, vmathV3GetY( tfrm1 ) ); - vmathV3ScalarMul( &result->col2, tfrm0, vmathV3GetZ( tfrm1 ) ); -} - -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *tfrm0, const VmathVector4 *tfrm1 ) -{ - vmathV4ScalarMul( &result->col0, tfrm0, vmathV4GetX( tfrm1 ) ); - vmathV4ScalarMul( &result->col1, tfrm0, vmathV4GetY( tfrm1 ) ); - vmathV4ScalarMul( &result->col2, tfrm0, vmathV4GetZ( tfrm1 ) ); - vmathV4ScalarMul( &result->col3, tfrm0, vmathV4GetW( tfrm1 ) ); -} - -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp0 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat->col0.vec128, mat->col2.vec128, _VECTORMATH_SHUF_ZCWD ); - xxxx = spu_shuffle( vec->vec128, vec->vec128, shuffle_xxxx ); - mcol0 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_XAYB ); - mcol1 = spu_shuffle( tmp0, mat->col1.vec128, _VECTORMATH_SHUF_ZBW0 ); - mcol2 = spu_shuffle( tmp1, mat->col1.vec128, _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( vec->vec128, vec->vec128, shuffle_yyyy ); - res = spu_mul( mcol0, xxxx ); - zzzz = spu_shuffle( vec->vec128, vec->vec128, shuffle_zzzz ); - res = spu_madd( mcol1, yyyy, res ); - res = spu_madd( mcol2, zzzz, res ); - result->vec128 = res; -} - -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ) -{ - vec_float4 neg, res0, res1, res2; - neg = negatef4( vec->vec128 ); - res0 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_0ZB0 ); - res1 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_C0X0 ); - res2 = spu_shuffle( vec->vec128, neg, _VECTORMATH_SHUF_YA00 ); - result->col0.vec128 = res0; - result->col1.vec128 = res1; - result->col2.vec128 = res2; -} - -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ) -{ - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathV3Cross( &tmpV3_0, vec, &mat->col0 ); - vmathV3Cross( &tmpV3_1, vec, &mat->col1 ); - vmathV3Cross( &tmpV3_2, vec, &mat->col2 ); - vmathM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h deleted file mode 100644 index 986612ebe..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_aos_v.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* - 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_MAT_AOS_V_C_H -#define _VECTORMATH_MAT_AOS_V_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) -#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) -#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) -#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ) -{ - VmathMatrix3 result; - vmathM3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeFromQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2 ) -{ - VmathMatrix3 result; - vmathM3MakeFromCols(&result, &_col0, &_col1, &_col2); - return result; -} - -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 _col0 ) -{ - vmathM3SetCol0(result, &_col0); -} - -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 _col1 ) -{ - vmathM3SetCol1(result, &_col1); -} - -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 _col2 ) -{ - vmathM3SetCol2(result, &_col2); -} - -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ) -{ - vmathM3SetCol(result, col, &vec); -} - -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ) -{ - vmathM3SetRow(result, row, &vec); -} - -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ) -{ - vmathM3SetElem(result, col, row, val); -} - -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ) -{ - return vmathM3GetElem(&mat, col, row); -} - -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol0(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol1(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathM3GetCol2(&result, &mat); - return result; -} - -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ) -{ - VmathVector3 result; - vmathM3GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ) -{ - VmathVector3 result; - vmathM3GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Inverse(&result, &mat); - return result; -} - -static inline float vmathM3Determinant_V( VmathMatrix3 mat ) -{ - return vmathM3Determinant(&mat); -} - -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3Neg(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ) -{ - VmathMatrix3 result; - vmathM3ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathM3MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ) -{ - VmathMatrix3 result; - vmathM3MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix3 vmathM3MakeIdentity_V( ) -{ - VmathMatrix3 result; - vmathM3MakeIdentity(&result); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix3 result; - vmathM3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix3 result; - vmathM3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix3 result; - vmathM3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ) -{ - VmathMatrix3 result; - vmathM3AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathM3PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ) -{ - VmathMatrix3 result; - vmathM3Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM3Print_V( VmathMatrix3 mat ) -{ - vmathM3Print(&mat); -} - -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ) -{ - vmathM3Prints(&mat, name); -} - -#endif - -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ) -{ - VmathMatrix4 result; - vmathM4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ) -{ - VmathMatrix4 result; - vmathM4MakeFromT3(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 _col0, VmathVector4 _col1, VmathVector4 _col2, VmathVector4 _col3 ) -{ - VmathMatrix4 result; - vmathM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromM3V3(&result, &mat, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 _col0 ) -{ - vmathM4SetCol0(result, &_col0); -} - -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 _col1 ) -{ - vmathM4SetCol1(result, &_col1); -} - -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 _col2 ) -{ - vmathM4SetCol2(result, &_col2); -} - -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 _col3 ) -{ - vmathM4SetCol3(result, &_col3); -} - -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ) -{ - vmathM4SetCol(result, col, &vec); -} - -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ) -{ - vmathM4SetRow(result, row, &vec); -} - -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ) -{ - vmathM4SetElem(result, col, row, val); -} - -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ) -{ - return vmathM4GetElem(&mat, col, row); -} - -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol0(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol1(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol2(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ) -{ - VmathVector4 result; - vmathM4GetCol3(&result, &mat); - return result; -} - -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ) -{ - VmathVector4 result; - vmathM4GetCol(&result, &mat, col); - return result; -} - -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ) -{ - VmathVector4 result; - vmathM4GetRow(&result, &mat, row); - return result; -} - -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Transpose(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Inverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AffineInverse(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4OrthoInverse(&result, &mat); - return result; -} - -static inline float vmathM4Determinant_V( VmathMatrix4 mat ) -{ - return vmathM4Determinant(&mat); -} - -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4Neg(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4AbsPerElem(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ) -{ - VmathMatrix4 result; - vmathM4ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ) -{ - VmathVector4 result; - vmathM4MulV4(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ) -{ - VmathVector4 result; - vmathM4MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathM4MulP3(&result, &mat, &pnt); - return result; -} - -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm1 ) -{ - VmathMatrix4 result; - vmathM4MulT3(&result, &mat, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ) -{ - VmathMatrix4 result; - vmathM4MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathMatrix4 vmathM4MakeIdentity_V( ) -{ - VmathMatrix4 result; - vmathM4MakeIdentity(&result); - return result; -} - -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ) -{ - vmathM4SetUpper3x3(result, &mat3); -} - -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ) -{ - VmathMatrix3 result; - vmathM4GetUpper3x3(&result, &mat); - return result; -} - -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ) -{ - vmathM4SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ) -{ - VmathVector3 result; - vmathM4GetTranslation(&result, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationX(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationY(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZ(&result, radians); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathMatrix4 result; - vmathM4MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathMatrix4 result; - vmathM4MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathMatrix4 result; - vmathM4MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ) -{ - VmathMatrix4 result; - vmathM4AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ) -{ - VmathMatrix4 result; - vmathM4PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathMatrix4 result; - vmathM4MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ) -{ - VmathMatrix4 result; - vmathM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); - return result; -} - -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - VmathMatrix4 result; - vmathM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ) -{ - VmathMatrix4 result; - vmathM4Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathM4Print_V( VmathMatrix4 mat ) -{ - vmathM4Print(&mat); -} - -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ) -{ - vmathM4Prints(&mat, name); -} - -#endif - -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ) -{ - VmathTransform3 result; - vmathT3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 _col0, VmathVector3 _col1, VmathVector3 _col2, VmathVector3 _col3 ) -{ - VmathTransform3 result; - vmathT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromM3V3(&result, &tfrm, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 _col0 ) -{ - vmathT3SetCol0(result, &_col0); -} - -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 _col1 ) -{ - vmathT3SetCol1(result, &_col1); -} - -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 _col2 ) -{ - vmathT3SetCol2(result, &_col2); -} - -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 _col3 ) -{ - vmathT3SetCol3(result, &_col3); -} - -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ) -{ - vmathT3SetCol(result, col, &vec); -} - -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ) -{ - vmathT3SetRow(result, row, &vec); -} - -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ) -{ - vmathT3SetElem(result, col, row, val); -} - -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ) -{ - return vmathT3GetElem(&tfrm, col, row); -} - -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol0(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol1(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol2(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetCol3(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ) -{ - VmathVector3 result; - vmathT3GetCol(&result, &tfrm, col); - return result; -} - -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ) -{ - VmathVector4 result; - vmathT3GetRow(&result, &tfrm, row); - return result; -} - -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3Inverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3OrthoInverse(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3AbsPerElem(&result, &tfrm); - return result; -} - -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ) -{ - VmathVector3 result; - vmathT3MulV3(&result, &tfrm, &vec); - return result; -} - -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathT3MulP3(&result, &tfrm, &pnt); - return result; -} - -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3Mul(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ) -{ - VmathTransform3 result; - vmathT3MulPerElem(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathTransform3 vmathT3MakeIdentity_V( ) -{ - VmathTransform3 result; - vmathT3MakeIdentity(&result); - return result; -} - -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 tfrm ) -{ - vmathT3SetUpper3x3(result, &tfrm); -} - -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ) -{ - VmathMatrix3 result; - vmathT3GetUpper3x3(&result, &tfrm); - return result; -} - -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ) -{ - vmathT3SetTranslation(result, &translateVec); -} - -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ) -{ - VmathVector3 result; - vmathT3GetTranslation(&result, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationX(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationY(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ) -{ - VmathTransform3 result; - vmathT3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ) -{ - VmathTransform3 result; - vmathT3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathTransform3 result; - vmathT3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ) -{ - VmathTransform3 result; - vmathT3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ) -{ - VmathTransform3 result; - vmathT3AppendScale(&result, &tfrm, &scaleVec); - return result; -} - -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ) -{ - VmathTransform3 result; - vmathT3PrependScale(&result, &scaleVec, &tfrm); - return result; -} - -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ) -{ - VmathTransform3 result; - vmathT3MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ) -{ - VmathTransform3 result; - vmathT3Select(&result, &tfrm0, &tfrm1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathT3Print_V( VmathTransform3 tfrm ) -{ - vmathT3Print(&tfrm); -} - -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ) -{ - vmathT3Prints(&tfrm, name); -} - -#endif - -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 tfrm ) -{ - VmathQuat result; - vmathQMakeFromM3(&result, &tfrm); - return result; -} - -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 tfrm0, VmathVector3 tfrm1 ) -{ - VmathMatrix3 result; - vmathV3Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 tfrm0, VmathVector4 tfrm1 ) -{ - VmathMatrix4 result; - vmathV4Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathVector3 result; - vmathV3RowMul(&result, &vec, &mat); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ) -{ - VmathMatrix3 result; - vmathV3CrossMatrix(&result, &vec); - return result; -} - -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ) -{ - VmathMatrix3 result; - vmathV3CrossMatrixMul(&result, &vec, &mat); - return result; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa.h deleted file mode 100644 index c2c3734e0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa.h +++ /dev/null @@ -1,1493 +0,0 @@ -/* - 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_MAT_SOA_C_H -#define _VECTORMATH_MAT_SOA_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( &result->col0, &mat->col0 ); - vmathSoaV3Copy( &result->col1, &mat->col1 ); - vmathSoaV3Copy( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ) -{ - vmathSoaV3MakeFromScalar( &result->col0, scalar ); - vmathSoaV3MakeFromScalar( &result->col1, scalar ); - vmathSoaV3MakeFromScalar( &result->col2, scalar ); -} - -static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) -{ - vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat->x; - qy = unitQuat->y; - qz = unitQuat->z; - qw = unitQuat->w; - qx2 = spu_add( qx, qx ); - qy2 = spu_add( qy, qy ); - qz2 = spu_add( qz, qz ); - qxqx2 = spu_mul( qx, qx2 ); - qxqy2 = spu_mul( qx, qy2 ); - qxqz2 = spu_mul( qx, qz2 ); - qxqw2 = spu_mul( qw, qx2 ); - qyqy2 = spu_mul( qy, qy2 ); - qyqz2 = spu_mul( qy, qz2 ); - qyqw2 = spu_mul( qw, qy2 ); - qzqz2 = spu_mul( qz, qz2 ); - qzqw2 = spu_mul( qw, qz2 ); - vmathSoaV3MakeFromElems( &result->col0, spu_sub( spu_sub( spu_splats(1.0f), qyqy2 ), qzqz2 ), spu_add( qxqy2, qzqw2 ), spu_sub( qxqz2, qyqw2 ) ); - vmathSoaV3MakeFromElems( &result->col1, spu_sub( qxqy2, qzqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qzqz2 ), spu_add( qyqz2, qxqw2 ) ); - vmathSoaV3MakeFromElems( &result->col2, spu_add( qxqz2, qyqw2 ), spu_sub( qyqz2, qxqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qyqy2 ) ); -} - -static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); - vmathSoaV3Copy( &result->col1, _col1 ); - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ) -{ - vmathSoaV3MakeFromAos( &result->col0, &mat->col0 ); - vmathSoaV3MakeFromAos( &result->col1, &mat->col1 ); - vmathSoaV3MakeFromAos( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ) -{ - vmathSoaV3MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); - vmathSoaV3MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); - vmathSoaV3MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); -} - -static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) -{ - vmathSoaV3Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV3Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV3Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); -} - -static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col0 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col1 ) -{ - vmathSoaV3Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ) -{ - vmathSoaV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ) -{ - vmathSoaV3SetElem( &result->col0, row, vmathSoaV3GetElem( vec, 0 ) ); - vmathSoaV3SetElem( &result->col1, row, vmathSoaV3GetElem( vec, 1 ) ); - vmathSoaV3SetElem( &result->col2, row, vmathSoaV3GetElem( vec, 2 ) ); -} - -static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaM3GetCol( &tmpV3_0, result, col ); - vmathSoaV3SetElem( &tmpV3_0, row, val ); - vmathSoaM3SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaM3GetCol( &tmpV3_0, mat, col ); - return vmathSoaV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col0 ); -} - -static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col1 ); -} - -static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Copy( result, &mat->col2 ); -} - -static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ) -{ - vmathSoaV3Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ) -{ - vmathSoaV3MakeFromElems( result, vmathSoaV3GetElem( &mat->col0, row ), vmathSoaV3GetElem( &mat->col1, row ), vmathSoaV3GetElem( &mat->col2, row ) ); -} - -static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - VmathSoaMatrix3 tmpResult; - vmathSoaV3MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x ); - vmathSoaV3MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y ); - vmathSoaV3MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z ); - vmathSoaM3Copy( result, &tmpResult ); -} - -static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmp0, tmp1, tmp2; - vec_float4 detinv; - vmathSoaV3Cross( &tmp0, &mat->col1, &mat->col2 ); - vmathSoaV3Cross( &tmp1, &mat->col2, &mat->col0 ); - vmathSoaV3Cross( &tmp2, &mat->col0, &mat->col1 ); - detinv = recipf4( vmathSoaV3Dot( &mat->col2, &tmp2 ) ); - vmathSoaV3MakeFromElems( &result->col0, spu_mul( tmp0.x, detinv ), spu_mul( tmp1.x, detinv ), spu_mul( tmp2.x, detinv ) ); - vmathSoaV3MakeFromElems( &result->col1, spu_mul( tmp0.y, detinv ), spu_mul( tmp1.y, detinv ), spu_mul( tmp2.y, detinv ) ); - vmathSoaV3MakeFromElems( &result->col2, spu_mul( tmp0.z, detinv ), spu_mul( tmp1.z, detinv ), spu_mul( tmp2.z, detinv ) ); -} - -static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3Cross( &tmpV3_0, &mat->col0, &mat->col1 ); - return vmathSoaV3Dot( &mat->col2, &tmpV3_0 ); -} - -static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3Add( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3Sub( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3Neg( &result->col0, &mat->col0 ); - vmathSoaV3Neg( &result->col1, &mat->col1 ); - vmathSoaV3Neg( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3AbsPerElem( &result->col0, &mat->col0 ); - vmathSoaV3AbsPerElem( &result->col1, &mat->col1 ); - vmathSoaV3AbsPerElem( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ) -{ - vmathSoaV3ScalarMul( &result->col0, &mat->col0, scalar ); - vmathSoaV3ScalarMul( &result->col1, &mat->col1, scalar ); - vmathSoaV3ScalarMul( &result->col2, &mat->col2, scalar ); -} - -static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ); - tmpY = spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ); - tmpZ = spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - VmathSoaMatrix3 tmpResult; - vmathSoaM3MulV3( &tmpResult.col0, mat0, &mat1->col0 ); - vmathSoaM3MulV3( &tmpResult.col1, mat0, &mat1->col1 ); - vmathSoaM3MulV3( &tmpResult.col2, mat0, &mat1->col2 ); - vmathSoaM3Copy( result, &tmpResult ); -} - -static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ) -{ - vmathSoaV3MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV3MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV3MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); -} - -static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); -} - -static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), c, s ); - vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c ); -} - -static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ) ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeFromElems( &result->col2, s, spu_splats(0.0f), c ); -} - -static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, s, spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f) ); - vmathSoaV3MakeZAxis( &result->col2 ); -} - -static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - vmathSoaV3MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ); - vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ); - vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ); -} - -static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = spu_mul( x, y ); - yz = spu_mul( y, z ); - zx = spu_mul( z, x ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - vmathSoaV3MakeFromElems( &result->col0, spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ) ); - vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ) ); - vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ) ); -} - -static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ) -{ - vmathSoaM3MakeFromQ( result, unitQuat ); -} - -static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z ); -} - -static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); -} - -static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ) -{ - vmathSoaV3MulPerElem( &result->col0, &mat->col0, scaleVec ); - vmathSoaV3MulPerElem( &result->col1, &mat->col1, scaleVec ); - vmathSoaV3MulPerElem( &result->col2, &mat->col2, scaleVec ); -} - -static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ) -{ - vmathSoaV3Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathSoaV3Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathSoaV3Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ) -{ - VmathMatrix3 mat0, mat1, mat2, mat3; - vmathSoaM3Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathM3Print( &mat0 ); - printf("slot 1:\n"); - vmathM3Print( &mat1 ); - printf("slot 2:\n"); - vmathM3Print( &mat2 ); - printf("slot 3:\n"); - vmathM3Print( &mat3 ); -} - -static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathSoaM3Print( mat ); -} - -#endif - -static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( &result->col0, &mat->col0 ); - vmathSoaV4Copy( &result->col1, &mat->col1 ); - vmathSoaV4Copy( &result->col2, &mat->col2 ); - vmathSoaV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ) -{ - vmathSoaV4MakeFromScalar( &result->col0, scalar ); - vmathSoaV4MakeFromScalar( &result->col1, scalar ); - vmathSoaV4MakeFromScalar( &result->col2, scalar ); - vmathSoaV4MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ) -{ - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, &mat->col3, spu_splats(1.0f) ); -} - -static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0, const VmathSoaVector4 *_col1, const VmathSoaVector4 *_col2, const VmathSoaVector4 *_col3 ) -{ - vmathSoaV4Copy( &result->col0, _col0 ); - vmathSoaV4Copy( &result->col1, _col1 ); - vmathSoaV4Copy( &result->col2, _col2 ); - vmathSoaV4Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat->col0, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat->col1, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat->col2, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); -} - -static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) -{ - VmathSoaMatrix3 mat; - vmathSoaM3MakeFromQ( &mat, unitQuat ); - vmathSoaV4MakeFromV3Scalar( &result->col0, &mat.col0, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col1, &mat.col1, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col2, &mat.col2, spu_splats(0.0f) ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); -} - -static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ) -{ - vmathSoaV4MakeFromAos( &result->col0, &mat->col0 ); - vmathSoaV4MakeFromAos( &result->col1, &mat->col1 ); - vmathSoaV4MakeFromAos( &result->col2, &mat->col2 ); - vmathSoaV4MakeFromAos( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ) -{ - vmathSoaV4MakeFrom4Aos( &result->col0, &mat0->col0, &mat1->col0, &mat2->col0, &mat3->col0 ); - vmathSoaV4MakeFrom4Aos( &result->col1, &mat0->col1, &mat1->col1, &mat2->col1, &mat3->col1 ); - vmathSoaV4MakeFrom4Aos( &result->col2, &mat0->col2, &mat1->col2, &mat2->col2, &mat3->col2 ); - vmathSoaV4MakeFrom4Aos( &result->col3, &mat0->col3, &mat1->col3, &mat2->col3, &mat3->col3 ); -} - -static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) -{ - vmathSoaV4Get4Aos( &mat->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV4Get4Aos( &mat->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV4Get4Aos( &mat->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); - vmathSoaV4Get4Aos( &mat->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); -} - -static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col0 ) -{ - vmathSoaV4Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col1 ) -{ - vmathSoaV4Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col2 ) -{ - vmathSoaV4Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *_col3 ) -{ - vmathSoaV4Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ) -{ - vmathSoaV4Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ) -{ - vmathSoaV4SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); - vmathSoaV4SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); - vmathSoaV4SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); - vmathSoaV4SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); -} - -static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector4 tmpV3_0; - vmathSoaM4GetCol( &tmpV3_0, result, col ); - vmathSoaV4SetElem( &tmpV3_0, row, val ); - vmathSoaM4SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ) -{ - VmathSoaVector4 tmpV4_0; - vmathSoaM4GetCol( &tmpV4_0, mat, col ); - return vmathSoaV4GetElem( &tmpV4_0, row ); -} - -static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col0 ); -} - -static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col1 ); -} - -static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col2 ); -} - -static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Copy( result, &mat->col3 ); -} - -static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ) -{ - vmathSoaV4Copy( result, (&mat->col0 + col) ); -} - -static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ) -{ - vmathSoaV4MakeFromElems( result, vmathSoaV4GetElem( &mat->col0, row ), vmathSoaV4GetElem( &mat->col1, row ), vmathSoaV4GetElem( &mat->col2, row ), vmathSoaV4GetElem( &mat->col3, row ) ); -} - -static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaMatrix4 tmpResult; - vmathSoaV4MakeFromElems( &tmpResult.col0, mat->col0.x, mat->col1.x, mat->col2.x, mat->col3.x ); - vmathSoaV4MakeFromElems( &tmpResult.col1, mat->col0.y, mat->col1.y, mat->col2.y, mat->col3.y ); - vmathSoaV4MakeFromElems( &tmpResult.col2, mat->col0.z, mat->col1.z, mat->col2.z, mat->col3.z ); - vmathSoaV4MakeFromElems( &tmpResult.col3, mat->col0.w, mat->col1.w, mat->col2.w, mat->col3.w ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaVector4 res0, res1, res2, res3; - vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); - tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); - tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); - tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); - tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); - tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); - vmathSoaV4SetX( &res0, spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ) ); - vmathSoaV4SetY( &res0, spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ) ); - vmathSoaV4SetZ( &res0, spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ) ); - vmathSoaV4SetW( &res0, spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ) ); - detInv = recipf4( spu_add( spu_add( spu_add( spu_mul( mA, res0.x ), spu_mul( mE, res0.y ) ), spu_mul( mI, res0.z ) ), spu_mul( mM, res0.w ) ) ); - vmathSoaV4SetX( &res1, spu_mul( mI, tmp1 ) ); - vmathSoaV4SetY( &res1, spu_mul( mM, tmp0 ) ); - vmathSoaV4SetZ( &res1, spu_mul( mA, tmp1 ) ); - vmathSoaV4SetW( &res1, spu_mul( mE, tmp0 ) ); - vmathSoaV4SetX( &res3, spu_mul( mI, tmp3 ) ); - vmathSoaV4SetY( &res3, spu_mul( mM, tmp2 ) ); - vmathSoaV4SetZ( &res3, spu_mul( mA, tmp3 ) ); - vmathSoaV4SetW( &res3, spu_mul( mE, tmp2 ) ); - vmathSoaV4SetX( &res2, spu_mul( mI, tmp5 ) ); - vmathSoaV4SetY( &res2, spu_mul( mM, tmp4 ) ); - vmathSoaV4SetZ( &res2, spu_mul( mA, tmp5 ) ); - vmathSoaV4SetW( &res2, spu_mul( mE, tmp4 ) ); - tmp0 = spu_sub( spu_mul( mI, mB ), spu_mul( mA, mJ ) ); - tmp1 = spu_sub( spu_mul( mM, mF ), spu_mul( mE, mN ) ); - tmp2 = spu_sub( spu_mul( mI, mD ), spu_mul( mA, mL ) ); - tmp3 = spu_sub( spu_mul( mM, mH ), spu_mul( mE, mP ) ); - tmp4 = spu_sub( spu_mul( mI, mC ), spu_mul( mA, mK ) ); - tmp5 = spu_sub( spu_mul( mM, mG ), spu_mul( mE, mO ) ); - vmathSoaV4SetX( &res2, spu_add( spu_sub( spu_mul( mL, tmp1 ), spu_mul( mJ, tmp3 ) ), res2.x ) ); - vmathSoaV4SetY( &res2, spu_add( spu_sub( spu_mul( mP, tmp0 ), spu_mul( mN, tmp2 ) ), res2.y ) ); - vmathSoaV4SetZ( &res2, spu_sub( spu_sub( spu_mul( mB, tmp3 ), spu_mul( mD, tmp1 ) ), res2.z ) ); - vmathSoaV4SetW( &res2, spu_sub( spu_sub( spu_mul( mF, tmp2 ), spu_mul( mH, tmp0 ) ), res2.w ) ); - vmathSoaV4SetX( &res3, spu_add( spu_sub( spu_mul( mJ, tmp5 ), spu_mul( mK, tmp1 ) ), res3.x ) ); - vmathSoaV4SetY( &res3, spu_add( spu_sub( spu_mul( mN, tmp4 ), spu_mul( mO, tmp0 ) ), res3.y ) ); - vmathSoaV4SetZ( &res3, spu_sub( spu_sub( spu_mul( mC, tmp1 ), spu_mul( mB, tmp5 ) ), res3.z ) ); - vmathSoaV4SetW( &res3, spu_sub( spu_sub( spu_mul( mG, tmp0 ), spu_mul( mF, tmp4 ) ), res3.w ) ); - vmathSoaV4SetX( &res1, spu_sub( spu_sub( spu_mul( mK, tmp3 ), spu_mul( mL, tmp5 ) ), res1.x ) ); - vmathSoaV4SetY( &res1, spu_sub( spu_sub( spu_mul( mO, tmp2 ), spu_mul( mP, tmp4 ) ), res1.y ) ); - vmathSoaV4SetZ( &res1, spu_add( spu_sub( spu_mul( mD, tmp5 ), spu_mul( mC, tmp3 ) ), res1.z ) ); - vmathSoaV4SetW( &res1, spu_add( spu_sub( spu_mul( mH, tmp4 ), spu_mul( mG, tmp2 ) ), res1.w ) ); - vmathSoaV4ScalarMul( &result->col0, &res0, detInv ); - vmathSoaV4ScalarMul( &result->col1, &res1, detInv ); - vmathSoaV4ScalarMul( &result->col2, &res2, detInv ); - vmathSoaV4ScalarMul( &result->col3, &res3, detInv ); -} - -static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaTransform3 affineMat, tmpT3_0; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); - vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); - vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); - vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); - vmathSoaT3Inverse( &tmpT3_0, &affineMat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - VmathSoaTransform3 affineMat, tmpT3_0; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - vmathSoaV4GetXYZ( &tmpV3_0, &mat->col0 ); - vmathSoaT3SetCol0( &affineMat, &tmpV3_0 ); - vmathSoaV4GetXYZ( &tmpV3_1, &mat->col1 ); - vmathSoaT3SetCol1( &affineMat, &tmpV3_1 ); - vmathSoaV4GetXYZ( &tmpV3_2, &mat->col2 ); - vmathSoaT3SetCol2( &affineMat, &tmpV3_2 ); - vmathSoaV4GetXYZ( &tmpV3_3, &mat->col3 ); - vmathSoaT3SetCol3( &affineMat, &tmpV3_3 ); - vmathSoaT3OrthoInverse( &tmpT3_0, &affineMat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ) -{ - vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat->col0.x; - mB = mat->col0.y; - mC = mat->col0.z; - mD = mat->col0.w; - mE = mat->col1.x; - mF = mat->col1.y; - mG = mat->col1.z; - mH = mat->col1.w; - mI = mat->col2.x; - mJ = mat->col2.y; - mK = mat->col2.z; - mL = mat->col2.w; - mM = mat->col3.x; - mN = mat->col3.y; - mO = mat->col3.z; - mP = mat->col3.w; - tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); - tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); - tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); - tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); - tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); - tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); - dx = spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ); - dy = spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ); - dz = spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ); - dw = spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ); - return spu_add( spu_add( spu_add( spu_mul( mA, dx ), spu_mul( mE, dy ) ), spu_mul( mI, dz ) ), spu_mul( mM, dw ) ); -} - -static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4Add( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4Add( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4Add( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4Add( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4Sub( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4Sub( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4Sub( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4Sub( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4Neg( &result->col0, &mat->col0 ); - vmathSoaV4Neg( &result->col1, &mat->col1 ); - vmathSoaV4Neg( &result->col2, &mat->col2 ); - vmathSoaV4Neg( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4AbsPerElem( &result->col0, &mat->col0 ); - vmathSoaV4AbsPerElem( &result->col1, &mat->col1 ); - vmathSoaV4AbsPerElem( &result->col2, &mat->col2 ); - vmathSoaV4AbsPerElem( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ) -{ - vmathSoaV4ScalarMul( &result->col0, &mat->col0, scalar ); - vmathSoaV4ScalarMul( &result->col1, &mat->col1, scalar ); - vmathSoaV4ScalarMul( &result->col2, &mat->col2, scalar ); - vmathSoaV4ScalarMul( &result->col3, &mat->col3, scalar ); -} - -static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = spu_add( spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ), spu_mul( mat->col3.x, vec->w ) ); - tmpY = spu_add( spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ), spu_mul( mat->col3.y, vec->w ) ); - tmpZ = spu_add( spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ), spu_mul( mat->col3.z, vec->w ) ); - tmpW = spu_add( spu_add( spu_add( spu_mul( mat->col0.w, vec->x ), spu_mul( mat->col1.w, vec->y ) ), spu_mul( mat->col2.w, vec->z ) ), spu_mul( mat->col3.w, vec->w ) ); - vmathSoaV4MakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ) -{ - result->x = spu_add( spu_add( spu_mul( mat->col0.x, vec->x ), spu_mul( mat->col1.x, vec->y ) ), spu_mul( mat->col2.x, vec->z ) ); - result->y = spu_add( spu_add( spu_mul( mat->col0.y, vec->x ), spu_mul( mat->col1.y, vec->y ) ), spu_mul( mat->col2.y, vec->z ) ); - result->z = spu_add( spu_add( spu_mul( mat->col0.z, vec->x ), spu_mul( mat->col1.z, vec->y ) ), spu_mul( mat->col2.z, vec->z ) ); - result->w = spu_add( spu_add( spu_mul( mat->col0.w, vec->x ), spu_mul( mat->col1.w, vec->y ) ), spu_mul( mat->col2.w, vec->z ) ); -} - -static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ) -{ - result->x = spu_add( spu_add( spu_add( spu_mul( mat->col0.x, pnt->x ), spu_mul( mat->col1.x, pnt->y ) ), spu_mul( mat->col2.x, pnt->z ) ), mat->col3.x ); - result->y = spu_add( spu_add( spu_add( spu_mul( mat->col0.y, pnt->x ), spu_mul( mat->col1.y, pnt->y ) ), spu_mul( mat->col2.y, pnt->z ) ), mat->col3.y ); - result->z = spu_add( spu_add( spu_add( spu_mul( mat->col0.z, pnt->x ), spu_mul( mat->col1.z, pnt->y ) ), spu_mul( mat->col2.z, pnt->z ) ), mat->col3.z ); - result->w = spu_add( spu_add( spu_add( spu_mul( mat->col0.w, pnt->x ), spu_mul( mat->col1.w, pnt->y ) ), spu_mul( mat->col2.w, pnt->z ) ), mat->col3.w ); -} - -static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - VmathSoaMatrix4 tmpResult; - vmathSoaM4MulV4( &tmpResult.col0, mat0, &mat1->col0 ); - vmathSoaM4MulV4( &tmpResult.col1, mat0, &mat1->col1 ); - vmathSoaM4MulV4( &tmpResult.col2, mat0, &mat1->col2 ); - vmathSoaM4MulV4( &tmpResult.col3, mat0, &mat1->col3 ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm1 ) -{ - VmathSoaMatrix4 tmpResult; - VmathSoaPoint3 tmpP3_0; - vmathSoaM4MulV3( &tmpResult.col0, mat, &tfrm1->col0 ); - vmathSoaM4MulV3( &tmpResult.col1, mat, &tfrm1->col1 ); - vmathSoaM4MulV3( &tmpResult.col2, mat, &tfrm1->col2 ); - vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathSoaM4MulP3( &tmpResult.col3, mat, &tmpP3_0 ); - vmathSoaM4Copy( result, &tmpResult ); -} - -static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ) -{ - vmathSoaV4MulPerElem( &result->col0, &mat0->col0, &mat1->col0 ); - vmathSoaV4MulPerElem( &result->col1, &mat0->col1, &mat1->col1 ); - vmathSoaV4MulPerElem( &result->col2, &mat0->col2, &mat1->col2 ); - vmathSoaV4MulPerElem( &result->col3, &mat0->col3, &mat1->col3 ); -} - -static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ) -{ - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ) -{ - vmathSoaV4SetXYZ( &result->col0, &mat3->col0 ); - vmathSoaV4SetXYZ( &result->col1, &mat3->col1 ); - vmathSoaV4SetXYZ( &result->col2, &mat3->col2 ); -} - -static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4GetXYZ( &result->col0, &mat->col0 ); - vmathSoaV4GetXYZ( &result->col1, &mat->col1 ); - vmathSoaV4GetXYZ( &result->col2, &mat->col2 ); -} - -static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4SetXYZ( &result->col3, translateVec ); -} - -static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ) -{ - vmathSoaV4GetXYZ( result, &mat->col3 ); -} - -static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), c, s, spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c, spu_splats(0.0f) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ), spu_splats(0.0f) ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeFromElems( &result->col2, s, spu_splats(0.0f), c, spu_splats(0.0f) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV4MakeFromElems( &result->col0, c, s, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - vmathSoaV4MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ), spu_splats(0.0f) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec->x; - y = unitVec->y; - z = unitVec->z; - xy = spu_mul( x, y ); - yz = spu_mul( y, z ); - zx = spu_mul( z, x ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - vmathSoaV4MakeFromElems( &result->col0, spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ), spu_splats(0.0f) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ) -{ - VmathSoaTransform3 tmpT3_0; - vmathSoaT3MakeRotationQ( &tmpT3_0, unitQuat ); - vmathSoaM4MakeFromT3( result, &tmpT3_0 ); -} - -static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV4MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z, spu_splats(0.0f) ); - vmathSoaV4MakeWAxis( &result->col3 ); -} - -static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV4ScalarMul( &result->col0, &mat->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV4ScalarMul( &result->col1, &mat->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV4ScalarMul( &result->col2, &mat->col2, vmathSoaV3GetZ( scaleVec ) ); - vmathSoaV4Copy( &result->col3, &mat->col3 ); -} - -static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ) -{ - VmathSoaVector4 scale4; - vmathSoaV4MakeFromV3Scalar( &scale4, scaleVec, spu_splats(1.0f) ); - vmathSoaV4MulPerElem( &result->col0, &mat->col0, &scale4 ); - vmathSoaV4MulPerElem( &result->col1, &mat->col1, &scale4 ); - vmathSoaV4MulPerElem( &result->col2, &mat->col2, &scale4 ); - vmathSoaV4MulPerElem( &result->col3, &mat->col3, &scale4 ); -} - -static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV4MakeXAxis( &result->col0 ); - vmathSoaV4MakeYAxis( &result->col1 ); - vmathSoaV4MakeZAxis( &result->col2 ); - vmathSoaV4MakeFromV3Scalar( &result->col3, translateVec, spu_splats(1.0f) ); -} - -static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ) -{ - VmathSoaMatrix4 m4EyeFrame; - VmathSoaVector3 v3X, v3Y, v3Z, tmpV3_0, tmpV3_1; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - vmathSoaV3Normalize( &v3Y, upVec ); - vmathSoaP3Sub( &tmpV3_0, eyePos, lookAtPos ); - vmathSoaV3Normalize( &v3Z, &tmpV3_0 ); - vmathSoaV3Cross( &tmpV3_1, &v3Y, &v3Z ); - vmathSoaV3Normalize( &v3X, &tmpV3_1 ); - vmathSoaV3Cross( &v3Y, &v3Z, &v3X ); - vmathSoaV4MakeFromV3( &tmpV4_0, &v3X ); - vmathSoaV4MakeFromV3( &tmpV4_1, &v3Y ); - vmathSoaV4MakeFromV3( &tmpV4_2, &v3Z ); - vmathSoaV4MakeFromP3( &tmpV4_3, eyePos ); - vmathSoaM4MakeFromCols( &m4EyeFrame, &tmpV4_0, &tmpV4_1, &tmpV4_2, &tmpV4_3 ); - vmathSoaM4OrthoInverse( result, &m4EyeFrame ); -} - -static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 f, rangeInv; - f = tanf4( spu_sub( spu_splats( _VECTORMATH_PI_OVER_2 ), spu_mul( spu_splats(0.5f), fovyRadians ) ) ); - rangeInv = recipf4( spu_sub( zNear, zFar ) ); - vmathSoaV4MakeFromElems( &result->col0, divf4( f, aspect ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), f, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_add( zNear, zFar ), rangeInv ), spu_splats(-1.0f) ); - vmathSoaV4MakeFromElems( &result->col3, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( spu_mul( zNear, zFar ), rangeInv ), spu_splats(2.0f) ), spu_splats(0.0f) ); -} - -static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = spu_add( right, left ); - sum_tb = spu_add( top, bottom ); - sum_nf = spu_add( zNear, zFar ); - inv_rl = recipf4( spu_sub( right, left ) ); - inv_tb = recipf4( spu_sub( top, bottom ) ); - inv_nf = recipf4( spu_sub( zNear, zFar ) ); - n2 = spu_add( zNear, zNear ); - vmathSoaV4MakeFromElems( &result->col0, spu_mul( n2, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), spu_mul( n2, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_mul( sum_rl, inv_rl ), spu_mul( sum_tb, inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(-1.0f) ); - vmathSoaV4MakeFromElems( &result->col3, spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( n2, inv_nf ), zFar ), spu_splats(0.0f) ); -} - -static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = spu_add( right, left ); - sum_tb = spu_add( top, bottom ); - sum_nf = spu_add( zNear, zFar ); - inv_rl = recipf4( spu_sub( right, left ) ); - inv_tb = recipf4( spu_sub( top, bottom ) ); - inv_nf = recipf4( spu_sub( zNear, zFar ) ); - vmathSoaV4MakeFromElems( &result->col0, spu_add( inv_rl, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col1, spu_splats(0.0f), spu_add( inv_tb, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), spu_add( inv_nf, inv_nf ), spu_splats(0.0f) ); - vmathSoaV4MakeFromElems( &result->col3, spu_mul( negatef4( sum_rl ), inv_rl ), spu_mul( negatef4( sum_tb ), inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(1.0f) ); -} - -static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ) -{ - vmathSoaV4Select( &result->col0, &mat0->col0, &mat1->col0, select1 ); - vmathSoaV4Select( &result->col1, &mat0->col1, &mat1->col1, select1 ); - vmathSoaV4Select( &result->col2, &mat0->col2, &mat1->col2, select1 ); - vmathSoaV4Select( &result->col3, &mat0->col3, &mat1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ) -{ - VmathMatrix4 mat0, mat1, mat2, mat3; - vmathSoaM4Get4Aos( mat, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathM4Print( &mat0 ); - printf("slot 1:\n"); - vmathM4Print( &mat1 ); - printf("slot 2:\n"); - vmathM4Print( &mat2 ); - printf("slot 3:\n"); - vmathM4Print( &mat3 ); -} - -static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ) -{ - printf("%s:\n", name); - vmathSoaM4Print( mat ); -} - -#endif - -static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( &result->col0, &tfrm->col0 ); - vmathSoaV3Copy( &result->col1, &tfrm->col1 ); - vmathSoaV3Copy( &result->col2, &tfrm->col2 ); - vmathSoaV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ) -{ - vmathSoaV3MakeFromScalar( &result->col0, scalar ); - vmathSoaV3MakeFromScalar( &result->col1, scalar ); - vmathSoaV3MakeFromScalar( &result->col2, scalar ); - vmathSoaV3MakeFromScalar( &result->col3, scalar ); -} - -static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0, const VmathSoaVector3 *_col1, const VmathSoaVector3 *_col2, const VmathSoaVector3 *_col3 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); - vmathSoaV3Copy( &result->col1, _col1 ); - vmathSoaV3Copy( &result->col2, _col2 ); - vmathSoaV3Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ) -{ - vmathSoaT3SetUpper3x3( result, tfrm ); - vmathSoaT3SetTranslation( result, translateVec ); -} - -static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ) -{ - VmathSoaMatrix3 tmpM3_0; - vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathSoaT3SetUpper3x3( result, &tmpM3_0 ); - vmathSoaT3SetTranslation( result, translateVec ); -} - -static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ) -{ - vmathSoaV3MakeFromAos( &result->col0, &tfrm->col0 ); - vmathSoaV3MakeFromAos( &result->col1, &tfrm->col1 ); - vmathSoaV3MakeFromAos( &result->col2, &tfrm->col2 ); - vmathSoaV3MakeFromAos( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ) -{ - vmathSoaV3MakeFrom4Aos( &result->col0, &tfrm0->col0, &tfrm1->col0, &tfrm2->col0, &tfrm3->col0 ); - vmathSoaV3MakeFrom4Aos( &result->col1, &tfrm0->col1, &tfrm1->col1, &tfrm2->col1, &tfrm3->col1 ); - vmathSoaV3MakeFrom4Aos( &result->col2, &tfrm0->col2, &tfrm1->col2, &tfrm2->col2, &tfrm3->col2 ); - vmathSoaV3MakeFrom4Aos( &result->col3, &tfrm0->col3, &tfrm1->col3, &tfrm2->col3, &tfrm3->col3 ); -} - -static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) -{ - vmathSoaV3Get4Aos( &tfrm->col0, &result0->col0, &result1->col0, &result2->col0, &result3->col0 ); - vmathSoaV3Get4Aos( &tfrm->col1, &result0->col1, &result1->col1, &result2->col1, &result3->col1 ); - vmathSoaV3Get4Aos( &tfrm->col2, &result0->col2, &result1->col2, &result2->col2, &result3->col2 ); - vmathSoaV3Get4Aos( &tfrm->col3, &result0->col3, &result1->col3, &result2->col3, &result3->col3 ); -} - -static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *_col0 ) -{ - vmathSoaV3Copy( &result->col0, _col0 ); -} - -static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *_col1 ) -{ - vmathSoaV3Copy( &result->col1, _col1 ); -} - -static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *_col2 ) -{ - vmathSoaV3Copy( &result->col2, _col2 ); -} - -static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *_col3 ) -{ - vmathSoaV3Copy( &result->col3, _col3 ); -} - -static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ) -{ - vmathSoaV3Copy( (&result->col0 + col), vec ); -} - -static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ) -{ - vmathSoaV3SetElem( &result->col0, row, vmathSoaV4GetElem( vec, 0 ) ); - vmathSoaV3SetElem( &result->col1, row, vmathSoaV4GetElem( vec, 1 ) ); - vmathSoaV3SetElem( &result->col2, row, vmathSoaV4GetElem( vec, 2 ) ); - vmathSoaV3SetElem( &result->col3, row, vmathSoaV4GetElem( vec, 3 ) ); -} - -static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaT3GetCol( &tmpV3_0, result, col ); - vmathSoaV3SetElem( &tmpV3_0, row, val ); - vmathSoaT3SetCol( result, col, &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaT3GetCol( &tmpV3_0, tfrm, col ); - return vmathSoaV3GetElem( &tmpV3_0, row ); -} - -static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col0 ); -} - -static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col1 ); -} - -static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col2 ); -} - -static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ) -{ - vmathSoaV3Copy( result, (&tfrm->col0 + col) ); -} - -static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ) -{ - vmathSoaV4MakeFromElems( result, vmathSoaV3GetElem( &tfrm->col0, row ), vmathSoaV3GetElem( &tfrm->col1, row ), vmathSoaV3GetElem( &tfrm->col2, row ), vmathSoaV3GetElem( &tfrm->col3, row ) ); -} - -static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - VmathSoaVector3 tmp0, tmp1, tmp2, inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - vec_float4 detinv; - vmathSoaV3Cross( &tmp0, &tfrm->col1, &tfrm->col2 ); - vmathSoaV3Cross( &tmp1, &tfrm->col2, &tfrm->col0 ); - vmathSoaV3Cross( &tmp2, &tfrm->col0, &tfrm->col1 ); - detinv = recipf4( vmathSoaV3Dot( &tfrm->col2, &tmp2 ) ); - vmathSoaV3MakeFromElems( &inv0, spu_mul( tmp0.x, detinv ), spu_mul( tmp1.x, detinv ), spu_mul( tmp2.x, detinv ) ); - vmathSoaV3MakeFromElems( &inv1, spu_mul( tmp0.y, detinv ), spu_mul( tmp1.y, detinv ), spu_mul( tmp2.y, detinv ) ); - vmathSoaV3MakeFromElems( &inv2, spu_mul( tmp0.z, detinv ), spu_mul( tmp1.z, detinv ), spu_mul( tmp2.z, detinv ) ); - vmathSoaV3Copy( &result->col0, &inv0 ); - vmathSoaV3Copy( &result->col1, &inv1 ); - vmathSoaV3Copy( &result->col2, &inv2 ); - vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathSoaV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - VmathSoaVector3 inv0, inv1, inv2, tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5; - vmathSoaV3MakeFromElems( &inv0, tfrm->col0.x, tfrm->col1.x, tfrm->col2.x ); - vmathSoaV3MakeFromElems( &inv1, tfrm->col0.y, tfrm->col1.y, tfrm->col2.y ); - vmathSoaV3MakeFromElems( &inv2, tfrm->col0.z, tfrm->col1.z, tfrm->col2.z ); - vmathSoaV3Copy( &result->col0, &inv0 ); - vmathSoaV3Copy( &result->col1, &inv1 ); - vmathSoaV3Copy( &result->col2, &inv2 ); - vmathSoaV3ScalarMul( &tmpV3_0, &inv0, tfrm->col3.x ); - vmathSoaV3ScalarMul( &tmpV3_1, &inv1, tfrm->col3.y ); - vmathSoaV3ScalarMul( &tmpV3_2, &inv2, tfrm->col3.z ); - vmathSoaV3Add( &tmpV3_3, &tmpV3_1, &tmpV3_2 ); - vmathSoaV3Add( &tmpV3_4, &tmpV3_0, &tmpV3_3 ); - vmathSoaV3Neg( &tmpV3_5, &tmpV3_4 ); - vmathSoaV3Copy( &result->col3, &tmpV3_5 ); -} - -static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3AbsPerElem( &result->col0, &tfrm->col0 ); - vmathSoaV3AbsPerElem( &result->col1, &tfrm->col1 ); - vmathSoaV3AbsPerElem( &result->col2, &tfrm->col2 ); - vmathSoaV3AbsPerElem( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = spu_add( spu_add( spu_mul( tfrm->col0.x, vec->x ), spu_mul( tfrm->col1.x, vec->y ) ), spu_mul( tfrm->col2.x, vec->z ) ); - tmpY = spu_add( spu_add( spu_mul( tfrm->col0.y, vec->x ), spu_mul( tfrm->col1.y, vec->y ) ), spu_mul( tfrm->col2.y, vec->z ) ); - tmpZ = spu_add( spu_add( spu_mul( tfrm->col0.z, vec->x ), spu_mul( tfrm->col1.z, vec->y ) ), spu_mul( tfrm->col2.z, vec->z ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.x, pnt->x ), spu_mul( tfrm->col1.x, pnt->y ) ), spu_mul( tfrm->col2.x, pnt->z ) ), tfrm->col3.x ); - tmpY = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.y, pnt->x ), spu_mul( tfrm->col1.y, pnt->y ) ), spu_mul( tfrm->col2.y, pnt->z ) ), tfrm->col3.y ); - tmpZ = spu_add( spu_add( spu_add( spu_mul( tfrm->col0.z, pnt->x ), spu_mul( tfrm->col1.z, pnt->y ) ), spu_mul( tfrm->col2.z, pnt->z ) ), tfrm->col3.z ); - vmathSoaP3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) -{ - VmathSoaTransform3 tmpResult; - VmathSoaPoint3 tmpP3_0, tmpP3_1; - vmathSoaT3MulV3( &tmpResult.col0, tfrm0, &tfrm1->col0 ); - vmathSoaT3MulV3( &tmpResult.col1, tfrm0, &tfrm1->col1 ); - vmathSoaT3MulV3( &tmpResult.col2, tfrm0, &tfrm1->col2 ); - vmathSoaP3MakeFromV3( &tmpP3_0, &tfrm1->col3 ); - vmathSoaT3MulP3( &tmpP3_1, tfrm0, &tmpP3_0 ); - vmathSoaV3MakeFromP3( &tmpResult.col3, &tmpP3_1 ); - vmathSoaT3Copy( result, &tmpResult ); -} - -static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ) -{ - vmathSoaV3MulPerElem( &result->col0, &tfrm0->col0, &tfrm1->col0 ); - vmathSoaV3MulPerElem( &result->col1, &tfrm0->col1, &tfrm1->col1 ); - vmathSoaV3MulPerElem( &result->col2, &tfrm0->col2, &tfrm1->col2 ); - vmathSoaV3MulPerElem( &result->col3, &tfrm0->col3, &tfrm1->col3 ); -} - -static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm ) -{ - vmathSoaV3Copy( &result->col0, &tfrm->col0 ); - vmathSoaV3Copy( &result->col1, &tfrm->col1 ); - vmathSoaV3Copy( &result->col2, &tfrm->col2 ); -} - -static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaM3MakeFromCols( result, &tfrm->col0, &tfrm->col1, &tfrm->col2 ); -} - -static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV3Copy( &result->col3, translateVec ); -} - -static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3Copy( result, &tfrm->col3 ); -} - -static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), c, s ); - vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), negatef4( s ), c ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, spu_splats(0.0f), negatef4( s ) ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeFromElems( &result->col2, s, spu_splats(0.0f), c ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - vmathSoaV3MakeFromElems( &result->col0, c, s, spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( s ), c, spu_splats(0.0f) ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ->x, &sX, &cX ); - sincosf4( radiansXYZ->y, &sY, &cY ); - sincosf4( radiansXYZ->z, &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - vmathSoaV3MakeFromElems( &result->col0, spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ); - vmathSoaV3MakeFromElems( &result->col1, spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ); - vmathSoaV3MakeFromElems( &result->col2, spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - VmathSoaMatrix3 tmpM3_0; - VmathSoaVector3 tmpV3_0; - vmathSoaM3MakeRotationAxis( &tmpM3_0, radians, unitVec ); - vmathSoaV3MakeFromScalar( &tmpV3_0, spu_splats(0.0f) ); - vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ) -{ - VmathSoaMatrix3 tmpM3_0; - VmathSoaVector3 tmpV3_0; - vmathSoaM3MakeFromQ( &tmpM3_0, unitQuat ); - vmathSoaV3MakeFromScalar( &tmpV3_0, spu_splats(0.0f) ); - vmathSoaT3MakeFromM3V3( result, &tmpM3_0, &tmpV3_0 ); -} - -static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3MakeFromElems( &result->col0, scaleVec->x, spu_splats(0.0f), spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col1, spu_splats(0.0f), scaleVec->y, spu_splats(0.0f) ); - vmathSoaV3MakeFromElems( &result->col2, spu_splats(0.0f), spu_splats(0.0f), scaleVec->z ); - vmathSoaV3MakeFromScalar( &result->col3, spu_splats(0.0f) ); -} - -static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ) -{ - vmathSoaV3ScalarMul( &result->col0, &tfrm->col0, vmathSoaV3GetX( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col1, &tfrm->col1, vmathSoaV3GetY( scaleVec ) ); - vmathSoaV3ScalarMul( &result->col2, &tfrm->col2, vmathSoaV3GetZ( scaleVec ) ); - vmathSoaV3Copy( &result->col3, &tfrm->col3 ); -} - -static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ) -{ - vmathSoaV3MulPerElem( &result->col0, &tfrm->col0, scaleVec ); - vmathSoaV3MulPerElem( &result->col1, &tfrm->col1, scaleVec ); - vmathSoaV3MulPerElem( &result->col2, &tfrm->col2, scaleVec ); - vmathSoaV3MulPerElem( &result->col3, &tfrm->col3, scaleVec ); -} - -static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ) -{ - vmathSoaV3MakeXAxis( &result->col0 ); - vmathSoaV3MakeYAxis( &result->col1 ); - vmathSoaV3MakeZAxis( &result->col2 ); - vmathSoaV3Copy( &result->col3, translateVec ); -} - -static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ) -{ - vmathSoaV3Select( &result->col0, &tfrm0->col0, &tfrm1->col0, select1 ); - vmathSoaV3Select( &result->col1, &tfrm0->col1, &tfrm1->col1, select1 ); - vmathSoaV3Select( &result->col2, &tfrm0->col2, &tfrm1->col2, select1 ); - vmathSoaV3Select( &result->col3, &tfrm0->col3, &tfrm1->col3, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ) -{ - VmathTransform3 mat0, mat1, mat2, mat3; - vmathSoaT3Get4Aos( tfrm, &mat0, &mat1, &mat2, &mat3 ); - printf("slot 0:\n"); - vmathT3Print( &mat0 ); - printf("slot 1:\n"); - vmathT3Print( &mat1 ); - printf("slot 2:\n"); - vmathT3Print( &mat2 ); - printf("slot 3:\n"); - vmathT3Print( &mat3 ); -} - -static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ) -{ - printf("%s:\n", name); - vmathSoaT3Print( tfrm ); -} - -#endif - -static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *tfrm ) -{ - vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - vec_uint4 negTrace, ZgtX, ZgtY, YgtX; - vec_uint4 largestXorY, largestYorZ, largestZorX; - - xx = tfrm->col0.x; - yx = tfrm->col0.y; - zx = tfrm->col0.z; - xy = tfrm->col1.x; - yy = tfrm->col1.y; - zy = tfrm->col1.z; - xz = tfrm->col2.x; - yz = tfrm->col2.y; - zz = tfrm->col2.z; - - trace = spu_add( spu_add( xx, yy ), zz ); - - negTrace = spu_cmpgt( spu_splats(0.0f), trace ); - ZgtX = spu_cmpgt( zz, xx ); - ZgtY = spu_cmpgt( zz, yy ); - YgtX = spu_cmpgt( yy, xx ); - largestXorY = spu_and( negTrace, spu_nand( ZgtX, ZgtY ) ); - largestYorZ = spu_and( negTrace, spu_or( YgtX, ZgtX ) ); - largestZorX = spu_and( negTrace, spu_orc( ZgtY, YgtX ) ); - - zz = spu_sel( zz, negatef4(zz), largestXorY ); - xy = spu_sel( xy, negatef4(xy), largestXorY ); - xx = spu_sel( xx, negatef4(xx), largestYorZ ); - yz = spu_sel( yz, negatef4(yz), largestYorZ ); - yy = spu_sel( yy, negatef4(yy), largestZorX ); - zx = spu_sel( zx, negatef4(zx), largestZorX ); - - radicand = spu_add( spu_add( spu_add( xx, yy ), zz ), spu_splats(1.0f) ); - scale = spu_mul( spu_splats(0.5f), rsqrtf4( radicand ) ); - - tmpx = spu_mul( spu_sub( zy, yz ), scale ); - tmpy = spu_mul( spu_sub( xz, zx ), scale ); - tmpz = spu_mul( spu_sub( yx, xy ), scale ); - tmpw = spu_mul( radicand, scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - qx = spu_sel( qx, tmpw, largestXorY ); - qy = spu_sel( qy, tmpz, largestXorY ); - qz = spu_sel( qz, tmpy, largestXorY ); - qw = spu_sel( qw, tmpx, largestXorY ); - tmpx = qx; - tmpz = qz; - qx = spu_sel( qx, qy, largestYorZ ); - qy = spu_sel( qy, tmpx, largestYorZ ); - qz = spu_sel( qz, qw, largestYorZ ); - qw = spu_sel( qw, tmpz, largestYorZ ); - - result->x = qx; - result->y = qy; - result->z = qz; - result->w = qw; -} - -static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *tfrm0, const VmathSoaVector3 *tfrm1 ) -{ - vmathSoaV3ScalarMul( &result->col0, tfrm0, vmathSoaV3GetX( tfrm1 ) ); - vmathSoaV3ScalarMul( &result->col1, tfrm0, vmathSoaV3GetY( tfrm1 ) ); - vmathSoaV3ScalarMul( &result->col2, tfrm0, vmathSoaV3GetZ( tfrm1 ) ); -} - -static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *tfrm0, const VmathSoaVector4 *tfrm1 ) -{ - vmathSoaV4ScalarMul( &result->col0, tfrm0, vmathSoaV4GetX( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col1, tfrm0, vmathSoaV4GetY( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col2, tfrm0, vmathSoaV4GetZ( tfrm1 ) ); - vmathSoaV4ScalarMul( &result->col3, tfrm0, vmathSoaV4GetW( tfrm1 ) ); -} - -static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = spu_add( spu_add( spu_mul( vec->x, mat->col0.x ), spu_mul( vec->y, mat->col0.y ) ), spu_mul( vec->z, mat->col0.z ) ); - tmpY = spu_add( spu_add( spu_mul( vec->x, mat->col1.x ), spu_mul( vec->y, mat->col1.y ) ), spu_mul( vec->z, mat->col1.z ) ); - tmpZ = spu_add( spu_add( spu_mul( vec->x, mat->col2.x ), spu_mul( vec->y, mat->col2.y ) ), spu_mul( vec->z, mat->col2.z ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ) -{ - vmathSoaV3MakeFromElems( &result->col0, spu_splats(0.0f), vec->z, negatef4( vec->y ) ); - vmathSoaV3MakeFromElems( &result->col1, negatef4( vec->z ), spu_splats(0.0f), vec->x ); - vmathSoaV3MakeFromElems( &result->col2, vec->y, negatef4( vec->x ), spu_splats(0.0f) ); -} - -static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; - vmathSoaV3Cross( &tmpV3_0, vec, &mat->col0 ); - vmathSoaV3Cross( &tmpV3_1, vec, &mat->col1 ); - vmathSoaV3Cross( &tmpV3_2, vec, &mat->col2 ); - vmathSoaM3MakeFromCols( result, &tmpV3_0, &tmpV3_1, &tmpV3_2 ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h deleted file mode 100644 index c8401e3d0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/mat_soa_v.h +++ /dev/null @@ -1,1063 +0,0 @@ -/* - 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_MAT_SOA_V_C_H -#define _VECTORMATH_MAT_SOA_V_C_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - */ -#define _VECTORMATH_PI_OVER_2 1.570796327f - -/*----------------------------------------------------------------------------- - * Definitions - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromCols(&result, &_col0, &_col1, &_col2); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFromAos(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); - return result; -} - -static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ) -{ - vmathSoaM3Get4Aos(&mat, result0, result1, result2, result3); -} - -static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col0 ) -{ - vmathSoaM3SetCol0(result, &_col0); -} - -static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col1 ) -{ - vmathSoaM3SetCol1(result, &_col1); -} - -static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 _col2 ) -{ - vmathSoaM3SetCol2(result, &_col2); -} - -static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ) -{ - vmathSoaM3SetCol(result, col, &vec); -} - -static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ) -{ - vmathSoaM3SetRow(result, row, &vec); -} - -static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ) -{ - vmathSoaM3SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ) -{ - return vmathSoaM3GetElem(&mat, col, row); -} - -static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol0(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol1(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol2(&result, &mat); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ) -{ - VmathSoaVector3 result; - vmathSoaM3GetCol(&result, &mat, col); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ) -{ - VmathSoaVector3 result; - vmathSoaM3GetRow(&result, &mat, row); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Transpose(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Inverse(&result, &mat); - return result; -} - -static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ) -{ - return vmathSoaM3Determinant(&mat); -} - -static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Neg(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3AbsPerElem(&result, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ) -{ - VmathSoaMatrix3 result; - vmathSoaM3ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaM3MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeIdentity(&result); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix3 result; - vmathSoaM3AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM3PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ) -{ - VmathSoaMatrix3 result; - vmathSoaM3Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ) -{ - vmathSoaM3Print(&mat); -} - -static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ) -{ - vmathSoaM3Prints(&mat, name); -} - -#endif - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromT3(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 _col0, VmathSoaVector4 _col1, VmathSoaVector4 _col2, VmathSoaVector4 _col3 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromM3V3(&result, &mat, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFromAos(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFrom4Aos(&result, &mat0, &mat1, &mat2, &mat3); - return result; -} - -static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ) -{ - vmathSoaM4Get4Aos(&mat, result0, result1, result2, result3); -} - -static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col0 ) -{ - vmathSoaM4SetCol0(result, &_col0); -} - -static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col1 ) -{ - vmathSoaM4SetCol1(result, &_col1); -} - -static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col2 ) -{ - vmathSoaM4SetCol2(result, &_col2); -} - -static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 _col3 ) -{ - vmathSoaM4SetCol3(result, &_col3); -} - -static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ) -{ - vmathSoaM4SetCol(result, col, &vec); -} - -static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ) -{ - vmathSoaM4SetRow(result, row, &vec); -} - -static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ) -{ - vmathSoaM4SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ) -{ - return vmathSoaM4GetElem(&mat, col, row); -} - -static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol0(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol1(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol2(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol3(&result, &mat); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ) -{ - VmathSoaVector4 result; - vmathSoaM4GetCol(&result, &mat, col); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ) -{ - VmathSoaVector4 result; - vmathSoaM4GetRow(&result, &mat, row); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Transpose(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Inverse(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AffineInverse(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4OrthoInverse(&result, &mat); - return result; -} - -static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ) -{ - return vmathSoaM4Determinant(&mat); -} - -static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Add(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Sub(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Neg(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AbsPerElem(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4ScalarMul(&result, &mat, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaM4MulV4(&result, &mat, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ) -{ - VmathSoaVector4 result; - vmathSoaM4MulV3(&result, &mat, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ) -{ - VmathSoaVector4 result; - vmathSoaM4MulP3(&result, &mat, &pnt); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Mul(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MulT3(&result, &mat, &tfrm1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MulPerElem(&result, &mat0, &mat1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeIdentity(&result); - return result; -} - -static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ) -{ - vmathSoaM4SetUpper3x3(result, &mat3); -} - -static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaM4GetUpper3x3(&result, &mat); - return result; -} - -static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ) -{ - vmathSoaM4SetTranslation(result, &translateVec); -} - -static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ) -{ - VmathSoaVector3 result; - vmathSoaM4GetTranslation(&result, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4AppendScale(&result, &mat, &scaleVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ) -{ - VmathSoaMatrix4 result; - vmathSoaM4PrependScale(&result, &scaleVec, &mat); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeLookAt(&result, &eyePos, &lookAtPos, &upVec); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakePerspective(&result, fovyRadians, aspect, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeFrustum(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - VmathSoaMatrix4 result; - vmathSoaM4MakeOrthographic(&result, left, right, bottom, top, zNear, zFar); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ) -{ - VmathSoaMatrix4 result; - vmathSoaM4Select(&result, &mat0, &mat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ) -{ - vmathSoaM4Print(&mat); -} - -static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ) -{ - vmathSoaM4Prints(&mat, name); -} - -#endif - -static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 _col0, VmathSoaVector3 _col1, VmathSoaVector3 _col2, VmathSoaVector3 _col3 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromCols(&result, &_col0, &_col1, &_col2, &_col3); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromM3V3(&result, &tfrm, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromQV3(&result, &unitQuat, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFromAos(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeFrom4Aos(&result, &tfrm0, &tfrm1, &tfrm2, &tfrm3); - return result; -} - -static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ) -{ - vmathSoaT3Get4Aos(&tfrm, result0, result1, result2, result3); -} - -static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 _col0 ) -{ - vmathSoaT3SetCol0(result, &_col0); -} - -static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 _col1 ) -{ - vmathSoaT3SetCol1(result, &_col1); -} - -static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 _col2 ) -{ - vmathSoaT3SetCol2(result, &_col2); -} - -static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 _col3 ) -{ - vmathSoaT3SetCol3(result, &_col3); -} - -static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ) -{ - vmathSoaT3SetCol(result, col, &vec); -} - -static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ) -{ - vmathSoaT3SetRow(result, row, &vec); -} - -static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ) -{ - vmathSoaT3SetElem(result, col, row, val); -} - -static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ) -{ - return vmathSoaT3GetElem(&tfrm, col, row); -} - -static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol0(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol1(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol2(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol3(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ) -{ - VmathSoaVector3 result; - vmathSoaT3GetCol(&result, &tfrm, col); - return result; -} - -static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ) -{ - VmathSoaVector4 result; - vmathSoaT3GetRow(&result, &tfrm, row); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3Inverse(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3OrthoInverse(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3AbsPerElem(&result, &tfrm); - return result; -} - -static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaT3MulV3(&result, &tfrm, &vec); - return result; -} - -static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaT3MulP3(&result, &tfrm, &pnt); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3Mul(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3MulPerElem(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeIdentity(&result); - return result; -} - -static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 tfrm ) -{ - vmathSoaT3SetUpper3x3(result, &tfrm); -} - -static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaMatrix3 result; - vmathSoaT3GetUpper3x3(&result, &tfrm); - return result; -} - -static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ) -{ - vmathSoaT3SetTranslation(result, &translateVec); -} - -static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ) -{ - VmathSoaVector3 result; - vmathSoaT3GetTranslation(&result, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationZYX(&result, &radiansXYZ); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeRotationQ(&result, &unitQuat); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeScale(&result, &scaleVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3AppendScale(&result, &tfrm, &scaleVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ) -{ - VmathSoaTransform3 result; - vmathSoaT3PrependScale(&result, &scaleVec, &tfrm); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ) -{ - VmathSoaTransform3 result; - vmathSoaT3MakeTranslation(&result, &translateVec); - return result; -} - -static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ) -{ - VmathSoaTransform3 result; - vmathSoaT3Select(&result, &tfrm0, &tfrm1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ) -{ - vmathSoaT3Print(&tfrm); -} - -static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ) -{ - vmathSoaT3Prints(&tfrm, name); -} - -#endif - -static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 tfrm ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromM3(&result, &tfrm); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 tfrm0, VmathSoaVector3 tfrm1 ) -{ - VmathSoaMatrix3 result; - vmathSoaV3Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 tfrm0, VmathSoaVector4 tfrm1 ) -{ - VmathSoaMatrix4 result; - vmathSoaV4Outer(&result, &tfrm0, &tfrm1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) -{ - VmathSoaVector3 result; - vmathSoaV3RowMul(&result, &vec, &mat); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ) -{ - VmathSoaMatrix3 result; - vmathSoaV3CrossMatrix(&result, &vec); - return result; -} - -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ) -{ - VmathSoaMatrix3 result; - vmathSoaV3CrossMatrixMul(&result, &vec, &mat); - return result; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos.h deleted file mode 100644 index 0f25d654b..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos.h +++ /dev/null @@ -1,371 +0,0 @@ -/* - 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_C_H -#define _VECTORMATH_QUAT_AOS_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathQMakeFromElems( VmathQuat *result, float _x, float _y, float _z, float _w ) -{ - result->vec128 = (vec_float4){ _x, _y, _z, _w }; -} - -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float _w ) -{ - result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); -} - -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ) -{ - result->vec128 = spu_splats( scalar ); -} - -static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathQMakeIdentity( VmathQuat *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0001; -} - -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - VmathQuat tmpQ_0, tmpQ_1; - vmathQSub( &tmpQ_0, quat1, quat0 ); - vmathQScalarMul( &tmpQ_1, &tmpQ_0, t ); - vmathQAdd( result, quat0, &tmpQ_1 ); -} - -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ) -{ - VmathQuat start; - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot4( unitQuat0->vec128, unitQuat1->vec128 ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); - cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start.vec128 = spu_sel( unitQuat0->vec128, negatef4( unitQuat0->vec128 ), selectMask ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - result->vec128 = spu_madd( start.vec128, scale0, spu_mul( unitQuat1->vec128, scale1 ) ); -} - -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ) -{ - VmathQuat tmp0, tmp1; - vmathQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); - vmathQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); - vmathQSlerp( result, ( ( 2.0f * t ) * ( 1.0f - t ) ), &tmp0, &tmp1 ); -} - -static inline vec_float4 vmathQGet128( const VmathQuat *quat ) -{ - return quat->vec128; -} - -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ) -{ - result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) ); -} - -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathQSetX( VmathQuat *result, float _x ) -{ - result->vec128 = spu_insert( _x, result->vec128, 0 ); -} - -static inline float vmathQGetX( const VmathQuat *quat ) -{ - return spu_extract( quat->vec128, 0 ); -} - -static inline void vmathQSetY( VmathQuat *result, float _y ) -{ - result->vec128 = spu_insert( _y, result->vec128, 1 ); -} - -static inline float vmathQGetY( const VmathQuat *quat ) -{ - return spu_extract( quat->vec128, 1 ); -} - -static inline void vmathQSetZ( VmathQuat *result, float _z ) -{ - result->vec128 = spu_insert( _z, result->vec128, 2 ); -} - -static inline float vmathQGetZ( const VmathQuat *quat ) -{ - return spu_extract( quat->vec128, 2 ); -} - -static inline void vmathQSetW( VmathQuat *result, float _w ) -{ - result->vec128 = spu_insert( _w, result->vec128, 3 ); -} - -static inline float vmathQGetW( const VmathQuat *quat ) -{ - return spu_extract( quat->vec128, 3 ); -} - -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ) -{ - result->vec128 = spu_insert( value, result->vec128, idx ); -} - -static inline float vmathQGetElem( const VmathQuat *quat, int idx ) -{ - return spu_extract( quat->vec128, idx ); -} - -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->vec128 = spu_add( quat0->vec128, quat1->vec128 ); -} - -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - result->vec128 = spu_sub( quat0->vec128, quat1->vec128 ); -} - -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->vec128 = spu_mul( quat->vec128, spu_splats(scalar) ); -} - -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ) -{ - result->vec128 = divf4( quat->vec128, spu_splats(scalar) ); -} - -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = negatef4( quat->vec128 ); -} - -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - return spu_extract( _vmathVfDot4( quat0->vec128, quat1->vec128 ), 0 ); -} - -static inline float vmathQNorm( const VmathQuat *quat ) -{ - return spu_extract( _vmathVfDot4( quat->vec128, quat->vec128 ), 0 ); -} - -static inline float vmathQLength( const VmathQuat *quat ) -{ - return sqrtf( vmathQNorm( quat ) ); -} - -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ) -{ - vec_float4 dot = _vmathVfDot4( quat->vec128, quat->vec128 ); - result->vec128 = spu_mul( quat->vec128, rsqrtf4( dot ) ); -} - -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - VmathVector3 crossVec, tmpV3_0; - vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; - cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) ); - cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) ); - recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); - cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 ); - vmathV3Cross( &tmpV3_0, unitVec0, unitVec1 ); - crossVec = tmpV3_0; - res = spu_mul( crossVec.vec128, recipCosHalfAngleX2 ); - res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_mul( unitVec->vec128, s ), c, (vec_uint4)spu_maskb(0x000f) ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - result->vec128 = res; -} - -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - result->vec128 = res; -} - -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ) -{ - vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; - vec_float4 product, l_wxyz, r_wxyz, xy, qw; - ldata = quat0->vec128; - rdata = quat1->vec128; - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW ); - qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata ); - qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv ); - qv = spu_madd( tmp0, tmp1, qv ); - qv = spu_nmsub( tmp2, tmp3, qv ); - product = spu_mul( ldata, rdata ); - l_wxyz = spu_rlqwbyte( ldata, 12 ); - r_wxyz = spu_rlqwbyte( rdata, 12 ); - qw = spu_nmsub( l_wxyz, r_wxyz, product ); - xy = spu_madd( l_wxyz, r_wxyz, product ); - qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) ); - result->vec128 = spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ); -} - -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *quat, const VmathVector3 *vec ) -{ - vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; - qdata = quat->vec128; - vdata = vec->vec128; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW ); - wwww = spu_shuffle( qdata, qdata, shuffle_wwww ); - qv = spu_mul( wwww, vdata ); - qv = spu_madd( tmp0, tmp1, qv ); - qv = spu_nmsub( tmp2, tmp3, qv ); - product = spu_mul( qdata, vdata ); - qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product ); - qw = spu_add( spu_rlqwbyte( product, 8 ), qw ); - tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW ); - res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata ); - res = spu_madd( wwww, qv, res ); - res = spu_madd( tmp0, tmp1, res ); - res = spu_nmsub( tmp2, tmp3, res ); - result->vec128 = res; -} - -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ) -{ - result->vec128 = spu_xor( quat->vec128, ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ); -} - -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ) -{ - result->vec128 = spu_sel( quat0->vec128, quat1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint( const VmathQuat *quat ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = quat->vec128; - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -static inline void vmathQPrints( const VmathQuat *quat, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = quat->vec128; - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h deleted file mode 100644 index 04cf6ccf9..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_aos_v.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - 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_V_C_H -#define _VECTORMATH_QUAT_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathQuat vmathQMakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathQuat result; - vmathQMakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathQuat result; - vmathQMakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ) -{ - VmathQuat result; - vmathQMakeFromV4(&result, &vec); - return result; -} - -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ) -{ - VmathQuat result; - vmathQMakeFromScalar(&result, scalar); - return result; -} - -static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ) -{ - VmathQuat result; - vmathQMakeFrom128(&result, vf4); - return result; -} - -static inline VmathQuat vmathQMakeIdentity_V( ) -{ - VmathQuat result; - vmathQMakeIdentity(&result); - return result; -} - -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQLerp(&result, t, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ) -{ - VmathQuat result; - vmathQSlerp(&result, t, &unitQuat0, &unitQuat1); - return result; -} - -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ) -{ - VmathQuat result; - vmathQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); - return result; -} - -static inline vec_float4 vmathQGet128_V( VmathQuat quat ) -{ - return vmathQGet128(&quat); -} - -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ) -{ - vmathQSetXYZ(result, &vec); -} - -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ) -{ - VmathVector3 result; - vmathQGetXYZ(&result, &quat); - return result; -} - -static inline void vmathQSetX_V( VmathQuat *result, float _x ) -{ - vmathQSetX(result, _x); -} - -static inline float vmathQGetX_V( VmathQuat quat ) -{ - return vmathQGetX(&quat); -} - -static inline void vmathQSetY_V( VmathQuat *result, float _y ) -{ - vmathQSetY(result, _y); -} - -static inline float vmathQGetY_V( VmathQuat quat ) -{ - return vmathQGetY(&quat); -} - -static inline void vmathQSetZ_V( VmathQuat *result, float _z ) -{ - vmathQSetZ(result, _z); -} - -static inline float vmathQGetZ_V( VmathQuat quat ) -{ - return vmathQGetZ(&quat); -} - -static inline void vmathQSetW_V( VmathQuat *result, float _w ) -{ - vmathQSetW(result, _w); -} - -static inline float vmathQGetW_V( VmathQuat quat ) -{ - return vmathQGetW(&quat); -} - -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ) -{ - vmathQSetElem(result, idx, value); -} - -static inline float vmathQGetElem_V( VmathQuat quat, int idx ) -{ - return vmathQGetElem(&quat, idx); -} - -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQAdd(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQSub(&result, &quat0, &quat1); - return result; -} - -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarMul(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ) -{ - VmathQuat result; - vmathQScalarDiv(&result, &quat, scalar); - return result; -} - -static inline VmathQuat vmathQNeg_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNeg(&result, &quat); - return result; -} - -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ) -{ - return vmathQDot(&quat0, &quat1); -} - -static inline float vmathQNorm_V( VmathQuat quat ) -{ - return vmathQNorm(&quat); -} - -static inline float vmathQLength_V( VmathQuat quat ) -{ - return vmathQLength(&quat); -} - -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQNormalize(&result, &quat); - return result; -} - -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathQuat result; - vmathQMakeRotationArc(&result, &unitVec0, &unitVec1); - return result; -} - -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ) -{ - VmathQuat result; - vmathQMakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathQuat vmathQMakeRotationX_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationX(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationY_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationY(&result, radians); - return result; -} - -static inline VmathQuat vmathQMakeRotationZ_V( float radians ) -{ - VmathQuat result; - vmathQMakeRotationZ(&result, radians); - return result; -} - -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ) -{ - VmathQuat result; - vmathQMul(&result, &quat0, &quat1); - return result; -} - -static inline VmathVector3 vmathQRotate_V( VmathQuat quat, VmathVector3 vec ) -{ - VmathVector3 result; - vmathQRotate(&result, &quat, &vec); - return result; -} - -static inline VmathQuat vmathQConj_V( VmathQuat quat ) -{ - VmathQuat result; - vmathQConj(&result, &quat); - return result; -} - -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ) -{ - VmathQuat result; - vmathQSelect(&result, &quat0, &quat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathQPrint_V( VmathQuat quat ) -{ - vmathQPrint(&quat); -} - -static inline void vmathQPrints_V( VmathQuat quat, const char *name ) -{ - vmathQPrints(&quat, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa.h deleted file mode 100644 index cd79e9d8d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa.h +++ /dev/null @@ -1,419 +0,0 @@ -/* - 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_SOA_C_H -#define _VECTORMATH_QUAT_SOA_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 _w ) -{ - vmathSoaQSetXYZ( result, xyz ); - vmathSoaQSetW( result, _w ); -} - -static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_float4 vec128 = quat->vec128; - result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); - result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); - result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); - result->w = spu_shuffle( vec128, vec128, shuffle_wwww ); -} - -static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( quat0->vec128, quat2->vec128, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( quat1->vec128, quat3->vec128, _VECTORMATH_SHUF_ZCWD ); - result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); -} - -static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ) -{ - vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - VmathSoaQuat tmpQ_0, tmpQ_1; - vmathSoaQSub( &tmpQ_0, quat1, quat0 ); - vmathSoaQScalarMul( &tmpQ_1, &tmpQ_0, t ); - vmathSoaQAdd( result, quat0, &tmpQ_1 ); -} - -static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ) -{ - VmathSoaQuat start, tmpQ_0, tmpQ_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaQDot( unitQuat0, unitQuat1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); - cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); - vmathSoaQSetX( &start, spu_sel( unitQuat0->x, negatef4( unitQuat0->x ), selectMask ) ); - vmathSoaQSetY( &start, spu_sel( unitQuat0->y, negatef4( unitQuat0->y ), selectMask ) ); - vmathSoaQSetZ( &start, spu_sel( unitQuat0->z, negatef4( unitQuat0->z ), selectMask ) ); - vmathSoaQSetW( &start, spu_sel( unitQuat0->w, negatef4( unitQuat0->w ), selectMask ) ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - vmathSoaQScalarMul( &tmpQ_0, &start, scale0 ); - vmathSoaQScalarMul( &tmpQ_1, unitQuat1, scale1 ); - vmathSoaQAdd( result, &tmpQ_0, &tmpQ_1 ); -} - -static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ) -{ - VmathSoaQuat tmp0, tmp1; - vmathSoaQSlerp( &tmp0, t, unitQuat0, unitQuat3 ); - vmathSoaQSlerp( &tmp1, t, unitQuat1, unitQuat2 ); - vmathSoaQSlerp( result, spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), &tmp0, &tmp1 ); -} - -static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( quat->x, quat->z, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( quat->y, quat->w, _VECTORMATH_SHUF_ZCWD ); - vmathQMakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); - vmathQMakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); - vmathQMakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); - vmathQMakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); -} - -static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ) -{ - vmathSoaV3MakeFromElems( result, quat->x, quat->y, quat->z ); -} - -static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ) -{ - return quat->x; -} - -static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ) -{ - return quat->y; -} - -static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ) -{ - return quat->z; -} - -static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 _w ) -{ - result->w = _w; -} - -static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ) -{ - return quat->w; -} - -static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ) -{ - return *(&quat->x + idx); -} - -static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - result->x = spu_add( quat0->x, quat1->x ); - result->y = spu_add( quat0->y, quat1->y ); - result->z = spu_add( quat0->z, quat1->z ); - result->w = spu_add( quat0->w, quat1->w ); -} - -static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - result->x = spu_sub( quat0->x, quat1->x ); - result->y = spu_sub( quat0->y, quat1->y ); - result->z = spu_sub( quat0->z, quat1->z ); - result->w = spu_sub( quat0->w, quat1->w ); -} - -static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) -{ - result->x = spu_mul( quat->x, scalar ); - result->y = spu_mul( quat->y, scalar ); - result->z = spu_mul( quat->z, scalar ); - result->w = spu_mul( quat->w, scalar ); -} - -static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ) -{ - result->x = divf4( quat->x, scalar ); - result->y = divf4( quat->y, scalar ); - result->z = divf4( quat->z, scalar ); - result->w = divf4( quat->w, scalar ); -} - -static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - result->x = negatef4( quat->x ); - result->y = negatef4( quat->y ); - result->z = negatef4( quat->z ); - result->w = negatef4( quat->w ); -} - -static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - vec_float4 result; - result = spu_mul( quat0->x, quat1->x ); - result = spu_add( result, spu_mul( quat0->y, quat1->y ) ); - result = spu_add( result, spu_mul( quat0->z, quat1->z ) ); - result = spu_add( result, spu_mul( quat0->w, quat1->w ) ); - return result; -} - -static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ) -{ - vec_float4 result; - result = spu_mul( quat->x, quat->x ); - result = spu_add( result, spu_mul( quat->y, quat->y ) ); - result = spu_add( result, spu_mul( quat->z, quat->z ) ); - result = spu_add( result, spu_mul( quat->w, quat->w ) ); - return result; -} - -static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ) -{ - return sqrtf4( vmathSoaQNorm( quat ) ); -} - -static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaQNorm( quat ); - lenInv = rsqrtf4( lenSqr ); - result->x = spu_mul( quat->x, lenInv ); - result->y = spu_mul( quat->y, lenInv ); - result->z = spu_mul( quat->z, lenInv ); - result->w = spu_mul( quat->w, lenInv ); -} - -static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), vmathSoaV3Dot( unitVec0, unitVec1 ) ) ) ); - recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 ); - vmathSoaV3Cross( &tmpV3_0, unitVec0, unitVec1 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, recipCosHalfAngleX2 ); - vmathSoaQMakeFromV3Scalar( result, &tmpV3_1, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) ); -} - -static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ) -{ - VmathSoaVector3 tmpV3_0; - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - vmathSoaV3ScalarMul( &tmpV3_0, unitVec, s ); - vmathSoaQMakeFromV3Scalar( result, &tmpV3_0, c ); -} - -static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, s, spu_splats(0.0f), spu_splats(0.0f), c ); -} - -static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, spu_splats(0.0f), s, spu_splats(0.0f), c ); -} - -static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - vmathSoaQMakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), s, c ); -} - -static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->x ), spu_mul( quat0->x, quat1->w ) ), spu_mul( quat0->y, quat1->z ) ), spu_mul( quat0->z, quat1->y ) ); - tmpY = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->y ), spu_mul( quat0->y, quat1->w ) ), spu_mul( quat0->z, quat1->x ) ), spu_mul( quat0->x, quat1->z ) ); - tmpZ = spu_sub( spu_add( spu_add( spu_mul( quat0->w, quat1->z ), spu_mul( quat0->z, quat1->w ) ), spu_mul( quat0->x, quat1->y ) ), spu_mul( quat0->y, quat1->x ) ); - tmpW = spu_sub( spu_sub( spu_sub( spu_mul( quat0->w, quat1->w ), spu_mul( quat0->x, quat1->x ) ), spu_mul( quat0->y, quat1->y ) ), spu_mul( quat0->z, quat1->z ) ); - vmathSoaQMakeFromElems( result, tmpX, tmpY, tmpZ, tmpW ); -} - -static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *quat, const VmathSoaVector3 *vec ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = spu_sub( spu_add( spu_mul( quat->w, vec->x ), spu_mul( quat->y, vec->z ) ), spu_mul( quat->z, vec->y ) ); - tmpY = spu_sub( spu_add( spu_mul( quat->w, vec->y ), spu_mul( quat->z, vec->x ) ), spu_mul( quat->x, vec->z ) ); - tmpZ = spu_sub( spu_add( spu_mul( quat->w, vec->z ), spu_mul( quat->x, vec->y ) ), spu_mul( quat->y, vec->x ) ); - tmpW = spu_add( spu_add( spu_mul( quat->x, vec->x ), spu_mul( quat->y, vec->y ) ), spu_mul( quat->z, vec->z ) ); - result->x = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->x ), spu_mul( tmpX, quat->w ) ), spu_mul( tmpY, quat->z ) ), spu_mul( tmpZ, quat->y ) ); - result->y = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->y ), spu_mul( tmpY, quat->w ) ), spu_mul( tmpZ, quat->x ) ), spu_mul( tmpX, quat->z ) ); - result->z = spu_add( spu_sub( spu_add( spu_mul( tmpW, quat->z ), spu_mul( tmpZ, quat->w ) ), spu_mul( tmpX, quat->y ) ), spu_mul( tmpY, quat->x ) ); -} - -static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ) -{ - vmathSoaQMakeFromElems( result, negatef4( quat->x ), negatef4( quat->y ), negatef4( quat->z ), quat->w ); -} - -static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ) -{ - result->x = spu_sel( quat0->x, quat1->x, select1 ); - result->y = spu_sel( quat0->y, quat1->y, select1 ); - result->z = spu_sel( quat0->z, quat1->z, select1 ); - result->w = spu_sel( quat0->w, quat1->w, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaQPrint( const VmathSoaQuat *quat ) -{ - VmathQuat vec0, vec1, vec2, vec3; - vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathQPrint( &vec0 ); - printf("slot 1:\n"); - vmathQPrint( &vec1 ); - printf("slot 2:\n"); - vmathQPrint( &vec2 ); - printf("slot 3:\n"); - vmathQPrint( &vec3 ); -} - -static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ) -{ - VmathQuat vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaQGet4Aos( quat, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathQPrint( &vec0 ); - printf("slot 1:\n"); - vmathQPrint( &vec1 ); - printf("slot 2:\n"); - vmathQPrint( &vec2 ); - printf("slot 3:\n"); - vmathQPrint( &vec3 ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h deleted file mode 100644 index 601d9da92..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/quat_soa_v.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - 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_SOA_V_C_H -#define _VECTORMATH_QUAT_SOA_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromV4(&result, &vec); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQMakeFromAos(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ) -{ - VmathSoaQuat result; - vmathSoaQMakeFrom4Aos(&result, &quat0, &quat1, &quat2, &quat3); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ) -{ - VmathSoaQuat result; - vmathSoaQMakeIdentity(&result); - return result; -} - -static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQLerp(&result, t, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ) -{ - VmathSoaQuat result; - vmathSoaQSlerp(&result, t, &unitQuat0, &unitQuat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ) -{ - VmathSoaQuat result; - vmathSoaQSquad(&result, t, &unitQuat0, &unitQuat1, &unitQuat2, &unitQuat3); - return result; -} - -static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ) -{ - vmathSoaQGet4Aos(&quat, result0, result1, result2, result3); -} - -static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ) -{ - vmathSoaQSetXYZ(result, &vec); -} - -static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ) -{ - VmathSoaVector3 result; - vmathSoaQGetXYZ(&result, &quat); - return result; -} - -static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 _x ) -{ - vmathSoaQSetX(result, _x); -} - -static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetX(&quat); -} - -static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 _y ) -{ - vmathSoaQSetY(result, _y); -} - -static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetY(&quat); -} - -static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 _z ) -{ - vmathSoaQSetZ(result, _z); -} - -static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetZ(&quat); -} - -static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 _w ) -{ - vmathSoaQSetW(result, _w); -} - -static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ) -{ - return vmathSoaQGetW(&quat); -} - -static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ) -{ - vmathSoaQSetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ) -{ - return vmathSoaQGetElem(&quat, idx); -} - -static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQAdd(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQSub(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQScalarMul(&result, &quat, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ) -{ - VmathSoaQuat result; - vmathSoaQScalarDiv(&result, &quat, scalar); - return result; -} - -static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQNeg(&result, &quat); - return result; -} - -static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - return vmathSoaQDot(&quat0, &quat1); -} - -static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ) -{ - return vmathSoaQNorm(&quat); -} - -static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ) -{ - return vmathSoaQLength(&quat); -} - -static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQNormalize(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationArc(&result, &unitVec0, &unitVec1); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationAxis(&result, radians, &unitVec); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationX(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationY(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ) -{ - VmathSoaQuat result; - vmathSoaQMakeRotationZ(&result, radians); - return result; -} - -static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ) -{ - VmathSoaQuat result; - vmathSoaQMul(&result, &quat0, &quat1); - return result; -} - -static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat quat, VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaQRotate(&result, &quat, &vec); - return result; -} - -static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ) -{ - VmathSoaQuat result; - vmathSoaQConj(&result, &quat); - return result; -} - -static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ) -{ - VmathSoaQuat result; - vmathSoaQSelect(&result, &quat0, &quat1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaQPrint_V( VmathSoaQuat quat ) -{ - vmathSoaQPrint(&quat); -} - -static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ) -{ - vmathSoaQPrints(&quat, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos.h deleted file mode 100644 index 715f27df7..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* - 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_VEC_AOS_C_H -#define _VECTORMATH_VEC_AOS_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); -} - -static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_add( spu_rlqwbyte( result, 8 ), result ); -} - -static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_YZXW ); - result = spu_mul( tmp0, tmp1 ); - result = spu_nmsub( tmp2, tmp3, result ); - return result; -} - -static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) -{ - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = spu_splats(0x00007c00u); - const vec_uint4 mergeMant = spu_splats(0x000003ffu); - const vec_uint4 mergeSign = spu_splats(0x00008000u); - - sign = spu_rlmask((vec_uint4)v, -16); - mant = spu_rlmask((vec_uint4)v, -13); - bexp = spu_and(spu_rlmask((vec_int4)v, -23), 0xff); - - notZero = spu_cmpgt(bexp, 112); - isInf = spu_cmpgt(bexp, 142); - - bexp = spu_add(bexp, -112); - bexp = spu_sl(bexp, 10); - - hfloat = spu_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = spu_sel(spu_splats(0u), hfloat, notZero); - hfloat = spu_sel(hfloat, hfloatInf, isInf); - hfloat = spu_sel(hfloat, sign, mergeSign); - - return hfloat; -} - -static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) -{ - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)spu_shuffle(hfloat_u, hfloat_v, pack); -} - -#endif - -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV3MakeFromElems( VmathVector3 *result, float _x, float _y, float _z ) -{ - result->vec128 = (vec_float4){ _x, _y, _z, 0.0f }; -} - -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = pnt->vec128; -} - -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ) -{ - result->vec128 = spu_splats( scalar ); -} - -static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathV3MakeXAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_1000; -} - -static inline void vmathV3MakeYAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0100; -} - -static inline void vmathV3MakeZAxis( VmathVector3 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0010; -} - -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathV3Sub( &tmpV3_0, vec1, vec0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathV3Add( result, vec0, &tmpV3_1 ); -} - -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot3( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - result->vec128 = spu_madd( unitVec0->vec128, scale0, spu_mul( unitVec1->vec128, scale1 ) ); -} - -static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ) -{ - return vec->vec128; -} - -static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); - dstVec = spu_sel(vec->vec128, dstVec, mask); - *quad = dstVec; -} - -static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); - xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); - xyz3 = spu_rlqwbyte( zxyz, 4 ); - vec0->vec128 = xyzx; - vec1->vec128 = xyz1; - vec2->vec128 = xyz2; - vec3->vec128 = xyz3; -} - -static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = spu_shuffle( vec0->vec128, vec1->vec128, _VECTORMATH_SHUF_XYZA ); - yzxy = spu_shuffle( vec1->vec128, vec2->vec128, _VECTORMATH_SHUF_YZAB ); - zxyz = spu_shuffle( vec2->vec128, vec3->vec128, _VECTORMATH_SHUF_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathV3StoreXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - vmathV3StoreXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathV3SetX( VmathVector3 *result, float _x ) -{ - result->vec128 = spu_insert( _x, result->vec128, 0 ); -} - -static inline float vmathV3GetX( const VmathVector3 *vec ) -{ - return spu_extract( vec->vec128, 0 ); -} - -static inline void vmathV3SetY( VmathVector3 *result, float _y ) -{ - result->vec128 = spu_insert( _y, result->vec128, 1 ); -} - -static inline float vmathV3GetY( const VmathVector3 *vec ) -{ - return spu_extract( vec->vec128, 1 ); -} - -static inline void vmathV3SetZ( VmathVector3 *result, float _z ) -{ - result->vec128 = spu_insert( _z, result->vec128, 2 ); -} - -static inline float vmathV3GetZ( const VmathVector3 *vec ) -{ - return spu_extract( vec->vec128, 2 ); -} - -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ) -{ - result->vec128 = spu_insert( value, result->vec128, idx ); -} - -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ) -{ - return spu_extract( vec->vec128, idx ); -} - -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = spu_add( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = spu_sub( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt1 ) -{ - result->vec128 = spu_add( vec->vec128, pnt1->vec128 ); -} - -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->vec128 = spu_mul( vec->vec128, spu_splats(scalar) ); -} - -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ) -{ - result->vec128 = divf4( vec->vec128, spu_splats(scalar) ); -} - -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = negatef4( vec->vec128 ); -} - -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = spu_mul( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = divf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = recipf4( vec->vec128 ); -} - -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = sqrtf4( vec->vec128 ); -} - -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = rsqrtf4( vec->vec128 ); -} - -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ) -{ - result->vec128 = fabsf4( vec->vec128 ); -} - -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV3MaxElem( const VmathVector3 *vec ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); - result = fmaxf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV3MinElem( const VmathVector3 *vec ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); - result = fminf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline float vmathV3Sum( const VmathVector3 *vec ) -{ - return - spu_extract( vec->vec128, 0 ) + - spu_extract( vec->vec128, 1 ) + - spu_extract( vec->vec128, 2 ); -} - -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - return spu_extract( _vmathVfDot3( vec0->vec128, vec1->vec128 ), 0 ); -} - -static inline float vmathV3LengthSqr( const VmathVector3 *vec ) -{ - return spu_extract( _vmathVfDot3( vec->vec128, vec->vec128 ), 0 ); -} - -static inline float vmathV3Length( const VmathVector3 *vec ) -{ - return sqrtf( vmathV3LengthSqr( vec ) ); -} - -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ) -{ - vec_float4 dot = _vmathVfDot3( vec->vec128, vec->vec128 ); - dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); - result->vec128 = spu_mul( vec->vec128, rsqrtf4( dot ) ); -} - -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ) -{ - result->vec128 = _vmathVfCross( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ) -{ - result->vec128 = spu_sel( vec0->vec128, vec1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print( const VmathVector3 *vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV4MakeFromElems( VmathVector4 *result, float _x, float _y, float _z, float _w ) -{ - result->vec128 = (vec_float4){ _x, _y, _z, _w }; -} - -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float _w ) -{ - result->vec128 = spu_shuffle( xyz->vec128, spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); -} - -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->vec128 = spu_sel( vec->vec128, spu_splats(0.0f), (vec_uint4)spu_maskb(0x000f) ); -} - -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = spu_sel( pnt->vec128, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); -} - -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ) -{ - result->vec128 = quat->vec128; -} - -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ) -{ - result->vec128 = spu_splats( scalar ); -} - -static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathV4MakeXAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_1000; -} - -static inline void vmathV4MakeYAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0100; -} - -static inline void vmathV4MakeZAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0010; -} - -static inline void vmathV4MakeWAxis( VmathVector4 *result ) -{ - result->vec128 = _VECTORMATH_UNIT_0001; -} - -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - VmathVector4 tmpV4_0, tmpV4_1; - vmathV4Sub( &tmpV4_0, vec1, vec0 ); - vmathV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); - vmathV4Add( result, vec0, &tmpV4_1 ); -} - -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot4( unitVec0->vec128, unitVec1->vec128 ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - result->vec128 = spu_madd( unitVec0->vec128, scale0, spu_mul( unitVec1->vec128, scale1 ) ); -} - -static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ) -{ - return vec->vec128; -} - -static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0->vec128, vec1->vec128); - twoQuads[1] = _vmath2VfToHalfFloats(vec2->vec128, vec3->vec128); -} - -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ) -{ - result->vec128 = spu_sel( vec->vec128, result->vec128, (vec_uint4)spu_maskb(0x000f) ); -} - -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathV4SetX( VmathVector4 *result, float _x ) -{ - result->vec128 = spu_insert( _x, result->vec128, 0 ); -} - -static inline float vmathV4GetX( const VmathVector4 *vec ) -{ - return spu_extract( vec->vec128, 0 ); -} - -static inline void vmathV4SetY( VmathVector4 *result, float _y ) -{ - result->vec128 = spu_insert( _y, result->vec128, 1 ); -} - -static inline float vmathV4GetY( const VmathVector4 *vec ) -{ - return spu_extract( vec->vec128, 1 ); -} - -static inline void vmathV4SetZ( VmathVector4 *result, float _z ) -{ - result->vec128 = spu_insert( _z, result->vec128, 2 ); -} - -static inline float vmathV4GetZ( const VmathVector4 *vec ) -{ - return spu_extract( vec->vec128, 2 ); -} - -static inline void vmathV4SetW( VmathVector4 *result, float _w ) -{ - result->vec128 = spu_insert( _w, result->vec128, 3 ); -} - -static inline float vmathV4GetW( const VmathVector4 *vec ) -{ - return spu_extract( vec->vec128, 3 ); -} - -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ) -{ - result->vec128 = spu_insert( value, result->vec128, idx ); -} - -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ) -{ - return spu_extract( vec->vec128, idx ); -} - -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = spu_add( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = spu_sub( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->vec128 = spu_mul( vec->vec128, spu_splats(scalar) ); -} - -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ) -{ - result->vec128 = divf4( vec->vec128, spu_splats(scalar) ); -} - -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = negatef4( vec->vec128 ); -} - -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = spu_mul( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = divf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = recipf4( vec->vec128 ); -} - -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = sqrtf4( vec->vec128 ); -} - -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = rsqrtf4( vec->vec128 ); -} - -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ) -{ - result->vec128 = fabsf4( vec->vec128 ); -} - -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = copysignf4( vec0->vec128, vec1->vec128 ); -} - -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = fmaxf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV4MaxElem( const VmathVector4 *vec ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); - result = fmaxf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); - result = fmaxf4( spu_promote( spu_extract( vec->vec128, 3 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - result->vec128 = fminf4( vec0->vec128, vec1->vec128 ); -} - -static inline float vmathV4MinElem( const VmathVector4 *vec ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( vec->vec128, 1 ), 0 ), vec->vec128 ); - result = fminf4( spu_promote( spu_extract( vec->vec128, 2 ), 0 ), result ); - result = fminf4( spu_promote( spu_extract( vec->vec128, 3 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline float vmathV4Sum( const VmathVector4 *vec ) -{ - return - spu_extract( vec->vec128, 0 ) + - spu_extract( vec->vec128, 1 ) + - spu_extract( vec->vec128, 2 ) + - spu_extract( vec->vec128, 3 ); -} - -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ) -{ - return spu_extract( _vmathVfDot4( vec0->vec128, vec1->vec128 ), 0 ); -} - -static inline float vmathV4LengthSqr( const VmathVector4 *vec ) -{ - return spu_extract( _vmathVfDot4( vec->vec128, vec->vec128 ), 0 ); -} - -static inline float vmathV4Length( const VmathVector4 *vec ) -{ - return sqrtf( vmathV4LengthSqr( vec ) ); -} - -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ) -{ - vec_float4 dot = _vmathVfDot4( vec->vec128, vec->vec128 ); - result->vec128 = spu_mul( vec->vec128, rsqrtf4( dot ) ); -} - -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ) -{ - result->vec128 = spu_sel( vec0->vec128, vec1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print( const VmathVector4 *vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec->vec128; - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = pnt->vec128; -} - -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float _x, float _y, float _z ) -{ - result->vec128 = (vec_float4){ _x, _y, _z, 0.0f }; -} - -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ) -{ - result->vec128 = vec->vec128; -} - -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ) -{ - result->vec128 = spu_splats( scalar ); -} - -static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ) -{ - result->vec128 = vf4; -} - -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0, tmpV3_1; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - vmathV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathP3AddV3( result, pnt0, &tmpV3_1 ); -} - -static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ) -{ - return pnt->vec128; -} - -static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); - dstVec = spu_sel(pnt->vec128, dstVec, mask); - *quad = dstVec; -} - -static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); - xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); - xyz3 = spu_rlqwbyte( zxyz, 4 ); - pnt0->vec128 = xyzx; - pnt1->vec128 = xyz1; - pnt2->vec128 = xyz2; - pnt3->vec128 = xyz3; -} - -static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = spu_shuffle( pnt0->vec128, pnt1->vec128, _VECTORMATH_SHUF_XYZA ); - yzxy = spu_shuffle( pnt1->vec128, pnt2->vec128, _VECTORMATH_SHUF_YZAB ); - zxyz = spu_shuffle( pnt2->vec128, pnt3->vec128, _VECTORMATH_SHUF_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathP3StoreXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - vmathP3StoreXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathP3SetX( VmathPoint3 *result, float _x ) -{ - result->vec128 = spu_insert( _x, result->vec128, 0 ); -} - -static inline float vmathP3GetX( const VmathPoint3 *pnt ) -{ - return spu_extract( pnt->vec128, 0 ); -} - -static inline void vmathP3SetY( VmathPoint3 *result, float _y ) -{ - result->vec128 = spu_insert( _y, result->vec128, 1 ); -} - -static inline float vmathP3GetY( const VmathPoint3 *pnt ) -{ - return spu_extract( pnt->vec128, 1 ); -} - -static inline void vmathP3SetZ( VmathPoint3 *result, float _z ) -{ - result->vec128 = spu_insert( _z, result->vec128, 2 ); -} - -static inline float vmathP3GetZ( const VmathPoint3 *pnt ) -{ - return spu_extract( pnt->vec128, 2 ); -} - -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ) -{ - result->vec128 = spu_insert( value, result->vec128, idx ); -} - -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ) -{ - return spu_extract( pnt->vec128, idx ); -} - -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = spu_sub( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->vec128 = spu_add( pnt->vec128, vec1->vec128 ); -} - -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec1 ) -{ - result->vec128 = spu_sub( pnt->vec128, vec1->vec128 ); -} - -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = spu_mul( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = divf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = recipf4( pnt->vec128 ); -} - -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = sqrtf4( pnt->vec128 ); -} - -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = rsqrtf4( pnt->vec128 ); -} - -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ) -{ - result->vec128 = fabsf4( pnt->vec128 ); -} - -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = copysignf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = fmaxf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( pnt->vec128, 1 ), 0 ), pnt->vec128 ); - result = fmaxf4( spu_promote( spu_extract( pnt->vec128, 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - result->vec128 = fminf4( pnt0->vec128, pnt1->vec128 ); -} - -static inline float vmathP3MinElem( const VmathPoint3 *pnt ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( pnt->vec128, 1 ), 0 ), pnt->vec128 ); - result = fminf4( spu_promote( spu_extract( pnt->vec128, 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -static inline float vmathP3Sum( const VmathPoint3 *pnt ) -{ - return - spu_extract( pnt->vec128, 0 ) + - spu_extract( pnt->vec128, 1 ) + - spu_extract( pnt->vec128, 2 ); -} - -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromScalar( &tmpP3_0, scaleVal ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ) -{ - VmathPoint3 tmpP3_0; - vmathP3MakeFromV3( &tmpP3_0, scaleVec ); - vmathP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ) -{ - return spu_extract( _vmathVfDot3( pnt->vec128, unitVec->vec128 ), 0 ); -} - -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ) -{ - VmathVector3 tmpV3_0; - vmathV3MakeFromP3( &tmpV3_0, pnt ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3LengthSqr( &tmpV3_0 ); -} - -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ) -{ - VmathVector3 tmpV3_0; - vmathP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathV3Length( &tmpV3_0 ); -} - -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ) -{ - result->vec128 = spu_sel( pnt0->vec128, pnt1->vec128, spu_splats( (unsigned int)-(select1 > 0) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print( const VmathPoint3 *pnt ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt->vec128; - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt->vec128; - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h deleted file mode 100644 index 7cf0fa9cc..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_aos_v.h +++ /dev/null @@ -1,951 +0,0 @@ -/* - 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_VEC_AOS_V_C_H -#define _VECTORMATH_VEC_AOS_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathVector3 vmathV3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathVector3 result; - vmathV3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector3 result; - vmathV3MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ) -{ - VmathVector3 result; - vmathV3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ) -{ - VmathVector3 result; - vmathV3MakeFrom128(&result, vf4); - return result; -} - -static inline VmathVector3 vmathV3MakeXAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeXAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeYAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeYAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3MakeZAxis_V( ) -{ - VmathVector3 result; - vmathV3MakeZAxis(&result); - return result; -} - -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ) -{ - VmathVector3 result; - vmathV3Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ) -{ - return vmathV3Get128(&vec); -} - -static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ) -{ - vmathV3StoreXYZ(&vec, quad); -} - -static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ) -{ - vmathV3LoadXYZArray(vec0, vec1, vec2, vec3, threeQuads); -} - -static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ) -{ - vmathV3StoreXYZArray(&vec0, &vec1, &vec2, &vec3, threeQuads); -} - -static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ) -{ - vmathV3StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, &vec4, &vec5, &vec6, &vec7, threeQuads); -} - -static inline void vmathV3SetX_V( VmathVector3 *result, float _x ) -{ - vmathV3SetX(result, _x); -} - -static inline float vmathV3GetX_V( VmathVector3 vec ) -{ - return vmathV3GetX(&vec); -} - -static inline void vmathV3SetY_V( VmathVector3 *result, float _y ) -{ - vmathV3SetY(result, _y); -} - -static inline float vmathV3GetY_V( VmathVector3 vec ) -{ - return vmathV3GetY(&vec); -} - -static inline void vmathV3SetZ_V( VmathVector3 *result, float _z ) -{ - vmathV3SetZ(result, _z); -} - -static inline float vmathV3GetZ_V( VmathVector3 vec ) -{ - return vmathV3GetZ(&vec); -} - -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ) -{ - vmathV3SetElem(result, idx, value); -} - -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ) -{ - return vmathV3GetElem(&vec, idx); -} - -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathV3AddP3(&result, &vec, &pnt1); - return result; -} - -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ) -{ - VmathVector3 result; - vmathV3ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Neg(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MaxElem_V( VmathVector3 vec ) -{ - return vmathV3MaxElem(&vec); -} - -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV3MinElem_V( VmathVector3 vec ) -{ - return vmathV3MinElem(&vec); -} - -static inline float vmathV3Sum_V( VmathVector3 vec ) -{ - return vmathV3Sum(&vec); -} - -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - return vmathV3Dot(&vec0, &vec1); -} - -static inline float vmathV3LengthSqr_V( VmathVector3 vec ) -{ - return vmathV3LengthSqr(&vec); -} - -static inline float vmathV3Length_V( VmathVector3 vec ) -{ - return vmathV3Length(&vec); -} - -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ) -{ - VmathVector3 result; - vmathV3Normalize(&result, &vec); - return result; -} - -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ) -{ - VmathVector3 result; - vmathV3Cross(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ) -{ - VmathVector3 result; - vmathV3Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV3Print_V( VmathVector3 vec ) -{ - vmathV3Print(&vec); -} - -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ) -{ - vmathV3Prints(&vec, name); -} - -#endif - -static inline VmathVector4 vmathV4MakeFromElems_V( float _x, float _y, float _z, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float _w ) -{ - VmathVector4 result; - vmathV4MakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ) -{ - VmathVector4 result; - vmathV4MakeFromV3(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ) -{ - VmathVector4 result; - vmathV4MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ) -{ - VmathVector4 result; - vmathV4MakeFromQ(&result, &quat); - return result; -} - -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ) -{ - VmathVector4 result; - vmathV4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ) -{ - VmathVector4 result; - vmathV4MakeFrom128(&result, vf4); - return result; -} - -static inline VmathVector4 vmathV4MakeXAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeXAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeYAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeYAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeZAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeZAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4MakeWAxis_V( ) -{ - VmathVector4 result; - vmathV4MakeWAxis(&result); - return result; -} - -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ) -{ - VmathVector4 result; - vmathV4Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ) -{ - return vmathV4Get128(&vec); -} - -static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ) -{ - vmathV4StoreHalfFloats(&vec0, &vec1, &vec2, &vec3, twoQuads); -} - -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ) -{ - vmathV4SetXYZ(result, &vec); -} - -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ) -{ - VmathVector3 result; - vmathV4GetXYZ(&result, &vec); - return result; -} - -static inline void vmathV4SetX_V( VmathVector4 *result, float _x ) -{ - vmathV4SetX(result, _x); -} - -static inline float vmathV4GetX_V( VmathVector4 vec ) -{ - return vmathV4GetX(&vec); -} - -static inline void vmathV4SetY_V( VmathVector4 *result, float _y ) -{ - vmathV4SetY(result, _y); -} - -static inline float vmathV4GetY_V( VmathVector4 vec ) -{ - return vmathV4GetY(&vec); -} - -static inline void vmathV4SetZ_V( VmathVector4 *result, float _z ) -{ - vmathV4SetZ(result, _z); -} - -static inline float vmathV4GetZ_V( VmathVector4 vec ) -{ - return vmathV4GetZ(&vec); -} - -static inline void vmathV4SetW_V( VmathVector4 *result, float _w ) -{ - vmathV4SetW(result, _w); -} - -static inline float vmathV4GetW_V( VmathVector4 vec ) -{ - return vmathV4GetW(&vec); -} - -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ) -{ - vmathV4SetElem(result, idx, value); -} - -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ) -{ - return vmathV4GetElem(&vec, idx); -} - -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ) -{ - VmathVector4 result; - vmathV4ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Neg(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RecipPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4AbsPerElem(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MaxElem_V( VmathVector4 vec ) -{ - return vmathV4MaxElem(&vec); -} - -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - VmathVector4 result; - vmathV4MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline float vmathV4MinElem_V( VmathVector4 vec ) -{ - return vmathV4MinElem(&vec); -} - -static inline float vmathV4Sum_V( VmathVector4 vec ) -{ - return vmathV4Sum(&vec); -} - -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ) -{ - return vmathV4Dot(&vec0, &vec1); -} - -static inline float vmathV4LengthSqr_V( VmathVector4 vec ) -{ - return vmathV4LengthSqr(&vec); -} - -static inline float vmathV4Length_V( VmathVector4 vec ) -{ - return vmathV4Length(&vec); -} - -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ) -{ - VmathVector4 result; - vmathV4Normalize(&result, &vec); - return result; -} - -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ) -{ - VmathVector4 result; - vmathV4Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathV4Print_V( VmathVector4 vec ) -{ - vmathV4Print(&vec); -} - -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ) -{ - vmathV4Prints(&vec, name); -} - -#endif - -static inline VmathPoint3 vmathP3MakeFromElems_V( float _x, float _y, float _z ) -{ - VmathPoint3 result; - vmathP3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ) -{ - VmathPoint3 result; - vmathP3MakeFromV3(&result, &vec); - return result; -} - -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ) -{ - VmathPoint3 result; - vmathP3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ) -{ - VmathPoint3 result; - vmathP3MakeFrom128(&result, vf4); - return result; -} - -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3Lerp(&result, t, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ) -{ - return vmathP3Get128(&pnt); -} - -static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ) -{ - vmathP3StoreXYZ(&pnt, quad); -} - -static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ) -{ - vmathP3LoadXYZArray(pnt0, pnt1, pnt2, pnt3, threeQuads); -} - -static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ) -{ - vmathP3StoreXYZArray(&pnt0, &pnt1, &pnt2, &pnt3, threeQuads); -} - -static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ) -{ - vmathP3StoreHalfFloats(&pnt0, &pnt1, &pnt2, &pnt3, &pnt4, &pnt5, &pnt6, &pnt7, threeQuads); -} - -static inline void vmathP3SetX_V( VmathPoint3 *result, float _x ) -{ - vmathP3SetX(result, _x); -} - -static inline float vmathP3GetX_V( VmathPoint3 pnt ) -{ - return vmathP3GetX(&pnt); -} - -static inline void vmathP3SetY_V( VmathPoint3 *result, float _y ) -{ - vmathP3SetY(result, _y); -} - -static inline float vmathP3GetY_V( VmathPoint3 pnt ) -{ - return vmathP3GetY(&pnt); -} - -static inline void vmathP3SetZ_V( VmathPoint3 *result, float _z ) -{ - vmathP3SetZ(result, _z); -} - -static inline float vmathP3GetZ_V( VmathPoint3 pnt ) -{ - return vmathP3GetZ(&pnt); -} - -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ) -{ - vmathP3SetElem(result, idx, value); -} - -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ) -{ - return vmathP3GetElem(&pnt, idx); -} - -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathVector3 result; - vmathP3Sub(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3AddV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec1 ) -{ - VmathPoint3 result; - vmathP3SubV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MulPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3DivPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RecipPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3SqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3RsqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ) -{ - VmathPoint3 result; - vmathP3AbsPerElem(&result, &pnt); - return result; -} - -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3CopySignPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MaxPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ) -{ - return vmathP3MaxElem(&pnt); -} - -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - VmathPoint3 result; - vmathP3MinPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline float vmathP3MinElem_V( VmathPoint3 pnt ) -{ - return vmathP3MinElem(&pnt); -} - -static inline float vmathP3Sum_V( VmathPoint3 pnt ) -{ - return vmathP3Sum(&pnt); -} - -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ) -{ - VmathPoint3 result; - vmathP3Scale(&result, &pnt, scaleVal); - return result; -} - -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ) -{ - VmathPoint3 result; - vmathP3NonUniformScale(&result, &pnt, &scaleVec); - return result; -} - -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ) -{ - return vmathP3Projection(&pnt, &unitVec); -} - -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistSqrFromOrigin(&pnt); -} - -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ) -{ - return vmathP3DistFromOrigin(&pnt); -} - -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3DistSqr(&pnt0, &pnt1); -} - -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ) -{ - return vmathP3Dist(&pnt0, &pnt1); -} - -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ) -{ - VmathPoint3 result; - vmathP3Select(&result, &pnt0, &pnt1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathP3Print_V( VmathPoint3 pnt ) -{ - vmathP3Print(&pnt); -} - -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ) -{ - vmathP3Prints(&pnt, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa.h deleted file mode 100644 index 608b38562..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - 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_VEC_SOA_C_H -#define _VECTORMATH_VEC_SOA_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_float4 vec128 = vec->vec128; - result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); - result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); - result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); -} - -static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_ZCWD ); - result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); -} - -static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); -} - -static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ) -{ - vmathSoaV3MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vmathSoaV3Sub( &tmpV3_0, vec1, vec0 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathSoaV3Add( result, vec0, &tmpV3_1 ); -} - -static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaV3Dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - vmathSoaV3ScalarMul( &tmpV3_0, unitVec0, scale0 ); - vmathSoaV3ScalarMul( &tmpV3_1, unitVec1, scale1 ); - vmathSoaV3Add( result, &tmpV3_0, &tmpV3_1 ); -} - -static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) -{ - vec_float4 tmp0, tmp1; - tmp0 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_ZCWD ); - vmathV3MakeFrom128( result0, spu_shuffle( tmp0, vec->y, _VECTORMATH_SHUF_XAYB ) ); - vmathV3MakeFrom128( result1, spu_shuffle( tmp0, vec->y, _VECTORMATH_SHUF_ZBW0 ) ); - vmathV3MakeFrom128( result2, spu_shuffle( tmp1, vec->y, _VECTORMATH_SHUF_XCY0 ) ); - vmathV3MakeFrom128( result3, spu_shuffle( tmp1, vec->y, _VECTORMATH_SHUF_ZDW0 ) ); -} - -static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); - zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); - yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); - vmathSoaV3SetX( vec, spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); - vmathSoaV3SetY( vec, spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); - vmathSoaV3SetZ( vec, spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); -} - -static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = spu_shuffle( vec->x, vec->y, _VECTORMATH_SHUF_XAZC ); - zxzx = spu_shuffle( vec->z, vec->x, _VECTORMATH_SHUF_ZDXB ); - yzyz = spu_shuffle( vec->y, vec->z, _VECTORMATH_SHUF_YBWD ); - xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); - yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); - zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathSoaV3StoreXYZArray( vec0, xyz0 ); - vmathSoaV3StoreXYZArray( vec1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ) -{ - return vec->x; -} - -static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ) -{ - return vec->y; -} - -static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ) -{ - return vec->z; -} - -static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = spu_add( vec0->x, vec1->x ); - result->y = spu_add( vec0->y, vec1->y ); - result->z = spu_add( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = spu_sub( vec0->x, vec1->x ); - result->y = spu_sub( vec0->y, vec1->y ); - result->z = spu_sub( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt1 ) -{ - result->x = spu_add( vec->x, pnt1->x ); - result->y = spu_add( vec->y, pnt1->y ); - result->z = spu_add( vec->z, pnt1->z ); -} - -static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) -{ - result->x = spu_mul( vec->x, scalar ); - result->y = spu_mul( vec->y, scalar ); - result->z = spu_mul( vec->z, scalar ); -} - -static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ) -{ - result->x = divf4( vec->x, scalar ); - result->y = divf4( vec->y, scalar ); - result->z = divf4( vec->z, scalar ); -} - -static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = negatef4( vec->x ); - result->y = negatef4( vec->y ); - result->z = negatef4( vec->z ); -} - -static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = spu_mul( vec0->x, vec1->x ); - result->y = spu_mul( vec0->y, vec1->y ); - result->z = spu_mul( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = divf4( vec0->x, vec1->x ); - result->y = divf4( vec0->y, vec1->y ); - result->z = divf4( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = recipf4( vec->x ); - result->y = recipf4( vec->y ); - result->z = recipf4( vec->z ); -} - -static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = sqrtf4( vec->x ); - result->y = sqrtf4( vec->y ); - result->z = sqrtf4( vec->z ); -} - -static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = rsqrtf4( vec->x ); - result->y = rsqrtf4( vec->y ); - result->z = rsqrtf4( vec->z ); -} - -static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - result->x = fabsf4( vec->x ); - result->y = fabsf4( vec->y ); - result->z = fabsf4( vec->z ); -} - -static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = copysignf4( vec0->x, vec1->x ); - result->y = copysignf4( vec0->y, vec1->y ); - result->z = copysignf4( vec0->z, vec1->z ); -} - -static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = fmaxf4( vec0->x, vec1->x ); - result->y = fmaxf4( vec0->y, vec1->y ); - result->z = fmaxf4( vec0->z, vec1->z ); -} - -static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec->x, vec->y ); - result = fmaxf4( vec->z, result ); - return result; -} - -static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - result->x = fminf4( vec0->x, vec1->x ); - result->y = fminf4( vec0->y, vec1->y ); - result->z = fminf4( vec0->z, vec1->z ); -} - -static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = fminf4( vec->x, vec->y ); - result = fminf4( vec->z, result ); - return result; -} - -static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = spu_add( vec->x, vec->y ); - result = spu_add( result, vec->z ); - return result; -} - -static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0->x, vec1->x ); - result = spu_add( result, spu_mul( vec0->y, vec1->y ) ); - result = spu_add( result, spu_mul( vec0->z, vec1->z ) ); - return result; -} - -static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ) -{ - vec_float4 result; - result = spu_mul( vec->x, vec->x ); - result = spu_add( result, spu_mul( vec->y, vec->y ) ); - result = spu_add( result, spu_mul( vec->z, vec->z ) ); - return result; -} - -static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ) -{ - return sqrtf4( vmathSoaV3LengthSqr( vec ) ); -} - -static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaV3LengthSqr( vec ); - lenInv = rsqrtf4( lenSqr ); - result->x = spu_mul( vec->x, lenInv ); - result->y = spu_mul( vec->y, lenInv ); - result->z = spu_mul( vec->z, lenInv ); -} - -static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ) -{ - vec_float4 tmpX, tmpY, tmpZ; - tmpX = spu_sub( spu_mul( vec0->y, vec1->z ), spu_mul( vec0->z, vec1->y ) ); - tmpY = spu_sub( spu_mul( vec0->z, vec1->x ), spu_mul( vec0->x, vec1->z ) ); - tmpZ = spu_sub( spu_mul( vec0->x, vec1->y ), spu_mul( vec0->y, vec1->x ) ); - vmathSoaV3MakeFromElems( result, tmpX, tmpY, tmpZ ); -} - -static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ) -{ - result->x = spu_sel( vec0->x, vec1->x, select1 ); - result->y = spu_sel( vec0->y, vec1->y, select1 ); - result->z = spu_sel( vec0->z, vec1->z, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ) -{ - VmathVector3 vec0, vec1, vec2, vec3; - vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV3Print( &vec0 ); - printf("slot 1:\n"); - vmathV3Print( &vec1 ); - printf("slot 2:\n"); - vmathV3Print( &vec2 ); - printf("slot 3:\n"); - vmathV3Print( &vec3 ); -} - -static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ) -{ - VmathVector3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaV3Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV3Print( &vec0 ); - printf("slot 1:\n"); - vmathV3Print( &vec1 ); - printf("slot 2:\n"); - vmathV3Print( &vec2 ); - printf("slot 3:\n"); - vmathV3Print( &vec3 ); -} - -#endif - -static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = vec->w; -} - -static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - result->x = _x; - result->y = _y; - result->z = _z; - result->w = _w; -} - -static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 _w ) -{ - vmathSoaV4SetXYZ( result, xyz ); - vmathSoaV4SetW( result, _w ); -} - -static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; - result->w = spu_splats(0.0f); -} - -static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; - result->w = spu_splats(1.0f); -} - -static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ) -{ - result->x = quat->x; - result->y = quat->y; - result->z = quat->z; - result->w = quat->w; -} - -static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; - result->w = scalar; -} - -static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_float4 vec128 = vec->vec128; - result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); - result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); - result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); - result->w = spu_shuffle( vec128, vec128, shuffle_wwww ); -} - -static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( vec0->vec128, vec2->vec128, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( vec1->vec128, vec3->vec128, _VECTORMATH_SHUF_ZCWD ); - result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - result->w = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); -} - -static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); -} - -static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ) -{ - vmathSoaV4MakeFromElems( result, spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - VmathSoaVector4 tmpV4_0, tmpV4_1; - vmathSoaV4Sub( &tmpV4_0, vec1, vec0 ); - vmathSoaV4ScalarMul( &tmpV4_1, &tmpV4_0, t ); - vmathSoaV4Add( result, vec0, &tmpV4_1 ); -} - -static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ) -{ - VmathSoaVector4 tmpV4_0, tmpV4_1; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = vmathSoaV4Dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - vmathSoaV4ScalarMul( &tmpV4_0, unitVec0, scale0 ); - vmathSoaV4ScalarMul( &tmpV4_1, unitVec1, scale1 ); - vmathSoaV4Add( result, &tmpV4_0, &tmpV4_1 ); -} - -static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec->y, vec->w, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( vec->x, vec->z, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( vec->y, vec->w, _VECTORMATH_SHUF_ZCWD ); - vmathV4MakeFrom128( result0, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); - vmathV4MakeFrom128( result1, spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); - vmathV4MakeFrom128( result2, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); - vmathV4MakeFrom128( result3, spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); -} - -static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ) -{ - VmathVector4 v0, v1, v2, v3; - vmathSoaV4Get4Aos( vec, &v0, &v1, &v2, &v3 ); - twoQuads[0] = _vmath2VfToHalfFloats(v0.vec128, v1.vec128); - twoQuads[1] = _vmath2VfToHalfFloats(v2.vec128, v3.vec128); -} - -static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ) -{ - vmathSoaV3MakeFromElems( result, vec->x, vec->y, vec->z ); -} - -static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ) -{ - return vec->x; -} - -static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ) -{ - return vec->y; -} - -static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ) -{ - return vec->z; -} - -static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 _w ) -{ - result->w = _w; -} - -static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ) -{ - return vec->w; -} - -static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ) -{ - return *(&vec->x + idx); -} - -static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = spu_add( vec0->x, vec1->x ); - result->y = spu_add( vec0->y, vec1->y ); - result->z = spu_add( vec0->z, vec1->z ); - result->w = spu_add( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = spu_sub( vec0->x, vec1->x ); - result->y = spu_sub( vec0->y, vec1->y ); - result->z = spu_sub( vec0->z, vec1->z ); - result->w = spu_sub( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) -{ - result->x = spu_mul( vec->x, scalar ); - result->y = spu_mul( vec->y, scalar ); - result->z = spu_mul( vec->z, scalar ); - result->w = spu_mul( vec->w, scalar ); -} - -static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ) -{ - result->x = divf4( vec->x, scalar ); - result->y = divf4( vec->y, scalar ); - result->z = divf4( vec->z, scalar ); - result->w = divf4( vec->w, scalar ); -} - -static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = negatef4( vec->x ); - result->y = negatef4( vec->y ); - result->z = negatef4( vec->z ); - result->w = negatef4( vec->w ); -} - -static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = spu_mul( vec0->x, vec1->x ); - result->y = spu_mul( vec0->y, vec1->y ); - result->z = spu_mul( vec0->z, vec1->z ); - result->w = spu_mul( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = divf4( vec0->x, vec1->x ); - result->y = divf4( vec0->y, vec1->y ); - result->z = divf4( vec0->z, vec1->z ); - result->w = divf4( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = recipf4( vec->x ); - result->y = recipf4( vec->y ); - result->z = recipf4( vec->z ); - result->w = recipf4( vec->w ); -} - -static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = sqrtf4( vec->x ); - result->y = sqrtf4( vec->y ); - result->z = sqrtf4( vec->z ); - result->w = sqrtf4( vec->w ); -} - -static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = rsqrtf4( vec->x ); - result->y = rsqrtf4( vec->y ); - result->z = rsqrtf4( vec->z ); - result->w = rsqrtf4( vec->w ); -} - -static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - result->x = fabsf4( vec->x ); - result->y = fabsf4( vec->y ); - result->z = fabsf4( vec->z ); - result->w = fabsf4( vec->w ); -} - -static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = copysignf4( vec0->x, vec1->x ); - result->y = copysignf4( vec0->y, vec1->y ); - result->z = copysignf4( vec0->z, vec1->z ); - result->w = copysignf4( vec0->w, vec1->w ); -} - -static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = fmaxf4( vec0->x, vec1->x ); - result->y = fmaxf4( vec0->y, vec1->y ); - result->z = fmaxf4( vec0->z, vec1->z ); - result->w = fmaxf4( vec0->w, vec1->w ); -} - -static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = fmaxf4( vec->x, vec->y ); - result = fmaxf4( vec->z, result ); - result = fmaxf4( vec->w, result ); - return result; -} - -static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - result->x = fminf4( vec0->x, vec1->x ); - result->y = fminf4( vec0->y, vec1->y ); - result->z = fminf4( vec0->z, vec1->z ); - result->w = fminf4( vec0->w, vec1->w ); -} - -static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = fminf4( vec->x, vec->y ); - result = fminf4( vec->z, result ); - result = fminf4( vec->w, result ); - return result; -} - -static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = spu_add( vec->x, vec->y ); - result = spu_add( result, vec->z ); - result = spu_add( result, vec->w ); - return result; -} - -static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0->x, vec1->x ); - result = spu_add( result, spu_mul( vec0->y, vec1->y ) ); - result = spu_add( result, spu_mul( vec0->z, vec1->z ) ); - result = spu_add( result, spu_mul( vec0->w, vec1->w ) ); - return result; -} - -static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ) -{ - vec_float4 result; - result = spu_mul( vec->x, vec->x ); - result = spu_add( result, spu_mul( vec->y, vec->y ) ); - result = spu_add( result, spu_mul( vec->z, vec->z ) ); - result = spu_add( result, spu_mul( vec->w, vec->w ) ); - return result; -} - -static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ) -{ - return sqrtf4( vmathSoaV4LengthSqr( vec ) ); -} - -static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = vmathSoaV4LengthSqr( vec ); - lenInv = rsqrtf4( lenSqr ); - result->x = spu_mul( vec->x, lenInv ); - result->y = spu_mul( vec->y, lenInv ); - result->z = spu_mul( vec->z, lenInv ); - result->w = spu_mul( vec->w, lenInv ); -} - -static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ) -{ - result->x = spu_sel( vec0->x, vec1->x, select1 ); - result->y = spu_sel( vec0->y, vec1->y, select1 ); - result->z = spu_sel( vec0->z, vec1->z, select1 ); - result->w = spu_sel( vec0->w, vec1->w, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ) -{ - VmathVector4 vec0, vec1, vec2, vec3; - vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV4Print( &vec0 ); - printf("slot 1:\n"); - vmathV4Print( &vec1 ); - printf("slot 2:\n"); - vmathV4Print( &vec2 ); - printf("slot 3:\n"); - vmathV4Print( &vec3 ); -} - -static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ) -{ - VmathVector4 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaV4Get4Aos( vec, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathV4Print( &vec0 ); - printf("slot 1:\n"); - vmathV4Print( &vec1 ); - printf("slot 2:\n"); - vmathV4Print( &vec2 ); - printf("slot 3:\n"); - vmathV4Print( &vec3 ); -} - -#endif - -static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = pnt->x; - result->y = pnt->y; - result->z = pnt->z; -} - -static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - result->x = _x; - result->y = _y; - result->z = _z; -} - -static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ) -{ - result->x = vec->x; - result->y = vec->y; - result->z = vec->z; -} - -static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ) -{ - result->x = scalar; - result->y = scalar; - result->z = scalar; -} - -static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_float4 vec128 = pnt->vec128; - result->x = spu_shuffle( vec128, vec128, shuffle_xxxx ); - result->y = spu_shuffle( vec128, vec128, shuffle_yyyy ); - result->z = spu_shuffle( vec128, vec128, shuffle_zzzz ); -} - -static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( pnt0->vec128, pnt2->vec128, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( pnt1->vec128, pnt3->vec128, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( pnt0->vec128, pnt2->vec128, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( pnt1->vec128, pnt3->vec128, _VECTORMATH_SHUF_ZCWD ); - result->x = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - result->y = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - result->z = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); -} - -static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0, tmpV3_1; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - vmathSoaV3ScalarMul( &tmpV3_1, &tmpV3_0, t ); - vmathSoaP3AddV3( result, pnt0, &tmpV3_1 ); -} - -static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) -{ - vec_float4 tmp0, tmp1; - tmp0 = spu_shuffle( pnt->x, pnt->z, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( pnt->x, pnt->z, _VECTORMATH_SHUF_ZCWD ); - vmathP3MakeFrom128( result0, spu_shuffle( tmp0, pnt->y, _VECTORMATH_SHUF_XAYB ) ); - vmathP3MakeFrom128( result1, spu_shuffle( tmp0, pnt->y, _VECTORMATH_SHUF_ZBW0 ) ); - vmathP3MakeFrom128( result2, spu_shuffle( tmp1, pnt->y, _VECTORMATH_SHUF_XCY0 ) ); - vmathP3MakeFrom128( result3, spu_shuffle( tmp1, pnt->y, _VECTORMATH_SHUF_ZDW0 ) ); -} - -static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); - zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); - yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); - vmathSoaP3SetX( vec, spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); - vmathSoaP3SetY( vec, spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); - vmathSoaP3SetZ( vec, spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); -} - -static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *vec, vec_float4 *threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = spu_shuffle( vec->x, vec->y, _VECTORMATH_SHUF_XAZC ); - zxzx = spu_shuffle( vec->z, vec->x, _VECTORMATH_SHUF_ZDXB ); - yzyz = spu_shuffle( vec->y, vec->z, _VECTORMATH_SHUF_YBWD ); - xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); - yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); - zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - vmathSoaP3StoreXYZArray( pnt0, xyz0 ); - vmathSoaP3StoreXYZArray( pnt1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 _x ) -{ - result->x = _x; -} - -static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ) -{ - return pnt->x; -} - -static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 _y ) -{ - result->y = _y; -} - -static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ) -{ - return pnt->y; -} - -static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 _z ) -{ - result->z = _z; -} - -static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ) -{ - return pnt->z; -} - -static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ) -{ - *(&result->x + idx) = value; -} - -static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ) -{ - return *(&pnt->x + idx); -} - -static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = spu_sub( pnt0->x, pnt1->x ); - result->y = spu_sub( pnt0->y, pnt1->y ); - result->z = spu_sub( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) -{ - result->x = spu_add( pnt->x, vec1->x ); - result->y = spu_add( pnt->y, vec1->y ); - result->z = spu_add( pnt->z, vec1->z ); -} - -static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec1 ) -{ - result->x = spu_sub( pnt->x, vec1->x ); - result->y = spu_sub( pnt->y, vec1->y ); - result->z = spu_sub( pnt->z, vec1->z ); -} - -static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = spu_mul( pnt0->x, pnt1->x ); - result->y = spu_mul( pnt0->y, pnt1->y ); - result->z = spu_mul( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = divf4( pnt0->x, pnt1->x ); - result->y = divf4( pnt0->y, pnt1->y ); - result->z = divf4( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = recipf4( pnt->x ); - result->y = recipf4( pnt->y ); - result->z = recipf4( pnt->z ); -} - -static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = sqrtf4( pnt->x ); - result->y = sqrtf4( pnt->y ); - result->z = sqrtf4( pnt->z ); -} - -static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = rsqrtf4( pnt->x ); - result->y = rsqrtf4( pnt->y ); - result->z = rsqrtf4( pnt->z ); -} - -static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ) -{ - result->x = fabsf4( pnt->x ); - result->y = fabsf4( pnt->y ); - result->z = fabsf4( pnt->z ); -} - -static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = copysignf4( pnt0->x, pnt1->x ); - result->y = copysignf4( pnt0->y, pnt1->y ); - result->z = copysignf4( pnt0->z, pnt1->z ); -} - -static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = fmaxf4( pnt0->x, pnt1->x ); - result->y = fmaxf4( pnt0->y, pnt1->y ); - result->z = fmaxf4( pnt0->z, pnt1->z ); -} - -static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = fmaxf4( pnt->x, pnt->y ); - result = fmaxf4( pnt->z, result ); - return result; -} - -static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - result->x = fminf4( pnt0->x, pnt1->x ); - result->y = fminf4( pnt0->y, pnt1->y ); - result->z = fminf4( pnt0->z, pnt1->z ); -} - -static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = fminf4( pnt->x, pnt->y ); - result = fminf4( pnt->z, result ); - return result; -} - -static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ) -{ - vec_float4 result; - result = spu_add( pnt->x, pnt->y ); - result = spu_add( result, pnt->z ); - return result; -} - -static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ) -{ - VmathSoaPoint3 tmpP3_0; - vmathSoaP3MakeFromScalar( &tmpP3_0, scaleVal ); - vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ) -{ - VmathSoaPoint3 tmpP3_0; - vmathSoaP3MakeFromV3( &tmpP3_0, scaleVec ); - vmathSoaP3MulPerElem( result, pnt, &tmpP3_0 ); -} - -static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ) -{ - vec_float4 result; - result = spu_mul( pnt->x, unitVec->x ); - result = spu_add( result, spu_mul( pnt->y, unitVec->y ) ); - result = spu_add( result, spu_mul( pnt->z, unitVec->z ) ); - return result; -} - -static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); - return vmathSoaV3LengthSqr( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaV3MakeFromP3( &tmpV3_0, pnt ); - return vmathSoaV3Length( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathSoaV3LengthSqr( &tmpV3_0 ); -} - -static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ) -{ - VmathSoaVector3 tmpV3_0; - vmathSoaP3Sub( &tmpV3_0, pnt1, pnt0 ); - return vmathSoaV3Length( &tmpV3_0 ); -} - -static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ) -{ - result->x = spu_sel( pnt0->x, pnt1->x, select1 ); - result->y = spu_sel( pnt0->y, pnt1->y, select1 ); - result->z = spu_sel( pnt0->z, pnt1->z, select1 ); -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ) -{ - VmathPoint3 vec0, vec1, vec2, vec3; - vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathP3Print( &vec0 ); - printf("slot 1:\n"); - vmathP3Print( &vec1 ); - printf("slot 2:\n"); - vmathP3Print( &vec2 ); - printf("slot 3:\n"); - vmathP3Print( &vec3 ); -} - -static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ) -{ - VmathPoint3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vmathSoaP3Get4Aos( pnt, &vec0, &vec1, &vec2, &vec3 ); - printf("slot 0:\n"); - vmathP3Print( &vec0 ); - printf("slot 1:\n"); - vmathP3Print( &vec1 ); - printf("slot 2:\n"); - vmathP3Print( &vec2 ); - printf("slot 3:\n"); - vmathP3Print( &vec3 ); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h deleted file mode 100644 index 560356a77..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vec_soa_v.h +++ /dev/null @@ -1,962 +0,0 @@ -/* - 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_VEC_SOA_V_C_H -#define _VECTORMATH_VEC_SOA_V_C_H -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/*----------------------------------------------------------------------------- - * Constants - * for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - */ -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SLERP_TOL 0.999f - -/*----------------------------------------------------------------------------- - * Definitions - */ -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFromAos(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeXAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeYAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ) -{ - VmathSoaVector3 result; - vmathSoaV3MakeZAxis(&result); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ) -{ - vmathSoaV3Get4Aos(&vec, result0, result1, result2, result3); -} - -static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ) -{ - vmathSoaV3LoadXYZArray(vec, threeQuads); -} - -static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ) -{ - vmathSoaV3StoreXYZArray(&vec, threeQuads); -} - -static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ) -{ - vmathSoaV3StoreHalfFloats(&vec0, &vec1, threeQuads); -} - -static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 _x ) -{ - vmathSoaV3SetX(result, _x); -} - -static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetX(&vec); -} - -static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 _y ) -{ - vmathSoaV3SetY(result, _y); -} - -static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetY(&vec); -} - -static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 _z ) -{ - vmathSoaV3SetZ(result, _z); -} - -static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3GetZ(&vec); -} - -static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ) -{ - vmathSoaV3SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ) -{ - return vmathSoaV3GetElem(&vec, idx); -} - -static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaV3AddP3(&result, &vec, &pnt1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ) -{ - VmathSoaVector3 result; - vmathSoaV3ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3Neg(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3RecipPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3AbsPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3MaxElem(&vec); -} - -static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3MinElem(&vec); -} - -static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3Sum(&vec); -} - -static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - return vmathSoaV3Dot(&vec0, &vec1); -} - -static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3LengthSqr(&vec); -} - -static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ) -{ - return vmathSoaV3Length(&vec); -} - -static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ) -{ - VmathSoaVector3 result; - vmathSoaV3Normalize(&result, &vec); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Cross(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ) -{ - VmathSoaVector3 result; - vmathSoaV3Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ) -{ - vmathSoaV3Print(&vec); -} - -static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ) -{ - vmathSoaV3Prints(&vec, name); -} - -#endif - -static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromElems(&result, _x, _y, _z, _w); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 _w ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromV3Scalar(&result, &xyz, _w); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromV3(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromP3(&result, &pnt); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromQ(&result, &quat); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFromAos(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeFrom4Aos(&result, &vec0, &vec1, &vec2, &vec3); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeXAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeYAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeZAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ) -{ - VmathSoaVector4 result; - vmathSoaV4MakeWAxis(&result); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Lerp(&result, t, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Slerp(&result, t, &unitVec0, &unitVec1); - return result; -} - -static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ) -{ - vmathSoaV4Get4Aos(&vec, result0, result1, result2, result3); -} - -static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ) -{ - vmathSoaV4StoreHalfFloats(&vec, twoQuads); -} - -static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ) -{ - vmathSoaV4SetXYZ(result, &vec); -} - -static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ) -{ - VmathSoaVector3 result; - vmathSoaV4GetXYZ(&result, &vec); - return result; -} - -static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 _x ) -{ - vmathSoaV4SetX(result, _x); -} - -static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetX(&vec); -} - -static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 _y ) -{ - vmathSoaV4SetY(result, _y); -} - -static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetY(&vec); -} - -static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 _z ) -{ - vmathSoaV4SetZ(result, _z); -} - -static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetZ(&vec); -} - -static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 _w ) -{ - vmathSoaV4SetW(result, _w); -} - -static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4GetW(&vec); -} - -static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ) -{ - vmathSoaV4SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ) -{ - return vmathSoaV4GetElem(&vec, idx); -} - -static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Add(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Sub(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4ScalarMul(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ) -{ - VmathSoaVector4 result; - vmathSoaV4ScalarDiv(&result, &vec, scalar); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4Neg(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MulPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4DivPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4RecipPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4SqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4RsqrtPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4AbsPerElem(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4CopySignPerElem(&result, &vec0, &vec1); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MaxPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4MaxElem(&vec); -} - -static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - VmathSoaVector4 result; - vmathSoaV4MinPerElem(&result, &vec0, &vec1); - return result; -} - -static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4MinElem(&vec); -} - -static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4Sum(&vec); -} - -static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ) -{ - return vmathSoaV4Dot(&vec0, &vec1); -} - -static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4LengthSqr(&vec); -} - -static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ) -{ - return vmathSoaV4Length(&vec); -} - -static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ) -{ - VmathSoaVector4 result; - vmathSoaV4Normalize(&result, &vec); - return result; -} - -static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ) -{ - VmathSoaVector4 result; - vmathSoaV4Select(&result, &vec0, &vec1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ) -{ - vmathSoaV4Print(&vec); -} - -static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ) -{ - vmathSoaV4Prints(&vec, name); -} - -#endif - -static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromElems(&result, _x, _y, _z); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromV3(&result, &vec); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromScalar(&result, scalar); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFromAos(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MakeFrom4Aos(&result, &pnt0, &pnt1, &pnt2, &pnt3); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3Lerp(&result, t, &pnt0, &pnt1); - return result; -} - -static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ) -{ - vmathSoaP3Get4Aos(&pnt, result0, result1, result2, result3); -} - -static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *vec, const vec_float4 *threeQuads ) -{ - vmathSoaP3LoadXYZArray(vec, threeQuads); -} - -static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 vec, vec_float4 *threeQuads ) -{ - vmathSoaP3StoreXYZArray(&vec, threeQuads); -} - -static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ) -{ - vmathSoaP3StoreHalfFloats(&pnt0, &pnt1, threeQuads); -} - -static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 _x ) -{ - vmathSoaP3SetX(result, _x); -} - -static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetX(&pnt); -} - -static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 _y ) -{ - vmathSoaP3SetY(result, _y); -} - -static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetY(&pnt); -} - -static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 _z ) -{ - vmathSoaP3SetZ(result, _z); -} - -static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3GetZ(&pnt); -} - -static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ) -{ - vmathSoaP3SetElem(result, idx, value); -} - -static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ) -{ - return vmathSoaP3GetElem(&pnt, idx); -} - -static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaVector3 result; - vmathSoaP3Sub(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3AddV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3SubV3(&result, &pnt, &vec1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MulPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3DivPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3RecipPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3SqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3RsqrtPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ) -{ - VmathSoaPoint3 result; - vmathSoaP3AbsPerElem(&result, &pnt); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3CopySignPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MaxPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3MaxElem(&pnt); -} - -static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3MinPerElem(&result, &pnt0, &pnt1); - return result; -} - -static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3MinElem(&pnt); -} - -static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3Sum(&pnt); -} - -static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ) -{ - VmathSoaPoint3 result; - vmathSoaP3Scale(&result, &pnt, scaleVal); - return result; -} - -static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ) -{ - VmathSoaPoint3 result; - vmathSoaP3NonUniformScale(&result, &pnt, &scaleVec); - return result; -} - -static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ) -{ - return vmathSoaP3Projection(&pnt, &unitVec); -} - -static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3DistSqrFromOrigin(&pnt); -} - -static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ) -{ - return vmathSoaP3DistFromOrigin(&pnt); -} - -static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - return vmathSoaP3DistSqr(&pnt0, &pnt1); -} - -static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ) -{ - return vmathSoaP3Dist(&pnt0, &pnt1); -} - -static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ) -{ - VmathSoaPoint3 result; - vmathSoaP3Select(&result, &pnt0, &pnt1, select1); - return result; -} - -#ifdef _VECTORMATH_DEBUG - -static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ) -{ - vmathSoaP3Print(&pnt); -} - -static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ) -{ - vmathSoaP3Prints(&pnt, name); -} - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h deleted file mode 100644 index 3bd4e0fe2..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos.h +++ /dev/null @@ -1,1951 +0,0 @@ -/* - 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_AOS_C_SPU_H -#define _VECTORMATH_AOS_C_SPU_H - -#include -#include -#include - -#ifdef _VECTORMATH_DEBUG -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - vec_float4 vec128; -} VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - vec_float4 vec128; -} VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - vec_float4 vec128; -} VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - vec_float4 vec128; -} VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Copy a 3-D vector - */ -static inline void vmathV3Copy( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline void vmathV3MakeFromElems( VmathVector3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline void vmathV3MakeFromP3( VmathVector3 *result, const VmathPoint3 *pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline void vmathV3MakeFromScalar( VmathVector3 *result, float scalar ); - -/* - * Set vector float data in a 3-D vector - */ -static inline void vmathV3MakeFrom128( VmathVector3 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D vector - */ -static inline vec_float4 vmathV3Get128( const VmathVector3 *vec ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX( const VmathVector3 *vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY( const VmathVector3 *vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ( const VmathVector3 *vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem( const VmathVector3 *vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline void vmathV3Add( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline void vmathV3Sub( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline void vmathV3AddP3( VmathPoint3 *result, const VmathVector3 *vec, const VmathPoint3 *pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline void vmathV3ScalarMul( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline void vmathV3ScalarDiv( VmathVector3 *result, const VmathVector3 *vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline void vmathV3Neg( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV3MakeXAxis( VmathVector3 *result ); - -/* - * Construct y axis - */ -static inline void vmathV3MakeYAxis( VmathVector3 *result ); - -/* - * Construct z axis - */ -static inline void vmathV3MakeZAxis( VmathVector3 *result ); - -/* - * Multiply two 3-D vectors per element - */ -static inline void vmathV3MulPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV3DivPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV3RecipPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV3SqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV3RsqrtPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline void vmathV3AbsPerElem( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline void vmathV3CopySignPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline void vmathV3MaxPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline void vmathV3MinPerElem( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem( const VmathVector3 *vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem( const VmathVector3 *vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum( const VmathVector3 *vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot( const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr( const VmathVector3 *vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length( const VmathVector3 *vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV3Normalize( VmathVector3 *result, const VmathVector3 *vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline void vmathV3Cross( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline void vmathV3Outer( VmathMatrix3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - * NOTE: - * Slower than column post-multiply. - */ -static inline void vmathV3RowMul( VmathVector3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline void vmathV3CrossMatrix( VmathMatrix3 *result, const VmathVector3 *vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline void vmathV3CrossMatrixMul( VmathMatrix3 *result, const VmathVector3 *vec, const VmathMatrix3 *mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Lerp( VmathVector3 *result, float t, const VmathVector3 *vec0, const VmathVector3 *vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV3Slerp( VmathVector3 *result, float t, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathV3Select( VmathVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathV3StoreXYZ( const VmathVector3 *vec, vec_float4 *quad ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathV3LoadXYZArray( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D vectors in three quadwords - */ -static inline void vmathV3StoreXYZArray( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D vectors as half-floats - */ -static inline void vmathV3StoreHalfFloats( const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3, const VmathVector3 *vec4, const VmathVector3 *vec5, const VmathVector3 *vec6, const VmathVector3 *vec7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print( const VmathVector3 *vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints( const VmathVector3 *vec, const char *name ); - -#endif - -/* - * Copy a 4-D vector - */ -static inline void vmathV4Copy( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline void vmathV4MakeFromElems( VmathVector4 *result, float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline void vmathV4MakeFromV3Scalar( VmathVector4 *result, const VmathVector3 *xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline void vmathV4MakeFromV3( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline void vmathV4MakeFromP3( VmathVector4 *result, const VmathPoint3 *pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline void vmathV4MakeFromQ( VmathVector4 *result, const VmathQuat *quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline void vmathV4MakeFromScalar( VmathVector4 *result, float scalar ); - -/* - * Set vector float data in a 4-D vector - */ -static inline void vmathV4MakeFrom128( VmathVector4 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 4-D vector - */ -static inline vec_float4 vmathV4Get128( const VmathVector4 *vec ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ( VmathVector4 *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline void vmathV4GetXYZ( VmathVector3 *result, const VmathVector4 *vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX( const VmathVector4 *vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY( const VmathVector4 *vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ( const VmathVector4 *vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW( const VmathVector4 *vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem( const VmathVector4 *vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline void vmathV4Add( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline void vmathV4Sub( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline void vmathV4ScalarMul( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline void vmathV4ScalarDiv( VmathVector4 *result, const VmathVector4 *vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline void vmathV4Neg( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Construct x axis - */ -static inline void vmathV4MakeXAxis( VmathVector4 *result ); - -/* - * Construct y axis - */ -static inline void vmathV4MakeYAxis( VmathVector4 *result ); - -/* - * Construct z axis - */ -static inline void vmathV4MakeZAxis( VmathVector4 *result ); - -/* - * Construct w axis - */ -static inline void vmathV4MakeWAxis( VmathVector4 *result ); - -/* - * Multiply two 4-D vectors per element - */ -static inline void vmathV4MulPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathV4DivPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathV4RecipPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathV4SqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathV4RsqrtPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline void vmathV4AbsPerElem( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline void vmathV4CopySignPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline void vmathV4MaxPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline void vmathV4MinPerElem( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem( const VmathVector4 *vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem( const VmathVector4 *vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum( const VmathVector4 *vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot( const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr( const VmathVector4 *vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length( const VmathVector4 *vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathV4Normalize( VmathVector4 *result, const VmathVector4 *vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline void vmathV4Outer( VmathMatrix4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Lerp( VmathVector4 *result, float t, const VmathVector4 *vec0, const VmathVector4 *vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathV4Slerp( VmathVector4 *result, float t, const VmathVector4 *unitVec0, const VmathVector4 *unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathV4Select( VmathVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, unsigned int select1 ); - -/* - * Store four 4-D vectors as half-floats - */ -static inline void vmathV4StoreHalfFloats( const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print( const VmathVector4 *vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints( const VmathVector4 *vec, const char *name ); - -#endif - -/* - * Copy a 3-D point - */ -static inline void vmathP3Copy( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline void vmathP3MakeFromElems( VmathPoint3 *result, float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline void vmathP3MakeFromV3( VmathPoint3 *result, const VmathVector3 *vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline void vmathP3MakeFromScalar( VmathPoint3 *result, float scalar ); - -/* - * Set vector float data in a 3-D point - */ -static inline void vmathP3MakeFrom128( VmathPoint3 *result, vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D point - */ -static inline vec_float4 vmathP3Get128( const VmathPoint3 *pnt ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX( const VmathPoint3 *pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY( const VmathPoint3 *pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ( const VmathPoint3 *pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem( const VmathPoint3 *pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline void vmathP3Sub( VmathVector3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline void vmathP3AddV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline void vmathP3SubV3( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *vec ); - -/* - * Multiply two 3-D points per element - */ -static inline void vmathP3MulPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathP3DivPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathP3RecipPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathP3SqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathP3RsqrtPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline void vmathP3AbsPerElem( VmathPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline void vmathP3CopySignPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline void vmathP3MaxPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline void vmathP3MinPerElem( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem( const VmathPoint3 *pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem( const VmathPoint3 *pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum( const VmathPoint3 *pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline void vmathP3Scale( VmathPoint3 *result, const VmathPoint3 *pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline void vmathP3NonUniformScale( VmathPoint3 *result, const VmathPoint3 *pnt, const VmathVector3 *scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection( const VmathPoint3 *pnt, const VmathVector3 *unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin( const VmathPoint3 *pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathP3Lerp( VmathPoint3 *result, float t, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathP3Select( VmathPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D point in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathP3StoreXYZ( const VmathPoint3 *pnt, vec_float4 *quad ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathP3LoadXYZArray( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D points in three quadwords - */ -static inline void vmathP3StoreXYZArray( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D points as half-floats - */ -static inline void vmathP3StoreHalfFloats( const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3, const VmathPoint3 *pnt4, const VmathPoint3 *pnt5, const VmathPoint3 *pnt6, const VmathPoint3 *pnt7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print( const VmathPoint3 *pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints( const VmathPoint3 *pnt, const char *name ); - -#endif - -/* - * Copy a quaternion - */ -static inline void vmathQCopy( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline void vmathQMakeFromElems( VmathQuat *result, float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline void vmathQMakeFromV3Scalar( VmathQuat *result, const VmathVector3 *xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline void vmathQMakeFromV4( VmathQuat *result, const VmathVector4 *vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline void vmathQMakeFromM3( VmathQuat *result, const VmathMatrix3 *rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline void vmathQMakeFromScalar( VmathQuat *result, float scalar ); - -/* - * Set vector float data in a quaternion - */ -static inline void vmathQMakeFrom128( VmathQuat *result, vec_float4 vf4 ); - -/* - * Get vector float data from a quaternion - */ -static inline vec_float4 vmathQGet128( const VmathQuat *quat ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ( VmathQuat *result, const VmathVector3 *vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline void vmathQGetXYZ( VmathVector3 *result, const VmathQuat *quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX( const VmathQuat *quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY( const VmathQuat *quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ( const VmathQuat *quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW( const VmathQuat *quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem( const VmathQuat *quat, int idx ); - -/* - * Add two quaternions - */ -static inline void vmathQAdd( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline void vmathQSub( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply two quaternions - */ -static inline void vmathQMul( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline void vmathQScalarMul( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline void vmathQScalarDiv( VmathQuat *result, const VmathQuat *quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline void vmathQNeg( VmathQuat *result, const VmathQuat *quat ); - -/* - * Construct an identity quaternion - */ -static inline void vmathQMakeIdentity( VmathQuat *result ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline void vmathQMakeRotationArc( VmathQuat *result, const VmathVector3 *unitVec0, const VmathVector3 *unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline void vmathQMakeRotationAxis( VmathQuat *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline void vmathQMakeRotationX( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline void vmathQMakeRotationY( VmathQuat *result, float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline void vmathQMakeRotationZ( VmathQuat *result, float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline void vmathQConj( VmathQuat *result, const VmathQuat *quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline void vmathQRotate( VmathVector3 *result, const VmathQuat *unitQuat, const VmathVector3 *vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot( const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm( const VmathQuat *quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength( const VmathQuat *quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline void vmathQNormalize( VmathQuat *result, const VmathQuat *quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathQLerp( VmathQuat *result, float t, const VmathQuat *quat0, const VmathQuat *quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline void vmathQSlerp( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline void vmathQSquad( VmathQuat *result, float t, const VmathQuat *unitQuat0, const VmathQuat *unitQuat1, const VmathQuat *unitQuat2, const VmathQuat *unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathQSelect( VmathQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint( const VmathQuat *quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints( const VmathQuat *quat, const char *name ); - -#endif - -/* - * Copy a 3x3 matrix - */ -static inline void vmathM3Copy( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline void vmathM3MakeFromCols( VmathMatrix3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeFromQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline void vmathM3MakeFromScalar( VmathMatrix3 *result, float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0( VmathMatrix3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1( VmathMatrix3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2( VmathMatrix3 *result, const VmathVector3 *col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline void vmathM3GetCol0( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline void vmathM3GetCol1( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline void vmathM3GetCol2( VmathVector3 *result, const VmathMatrix3 *mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol( VmathMatrix3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow( VmathMatrix3 *result, int row, const VmathVector3 *vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetCol( VmathVector3 *result, const VmathMatrix3 *mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3GetRow( VmathVector3 *result, const VmathMatrix3 *mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem( const VmathMatrix3 *mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline void vmathM3Add( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline void vmathM3Sub( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline void vmathM3Neg( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline void vmathM3ScalarMul( VmathMatrix3 *result, const VmathMatrix3 *mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline void vmathM3MulV3( VmathVector3 *result, const VmathMatrix3 *mat, const VmathVector3 *vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline void vmathM3Mul( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline void vmathM3MakeIdentity( VmathMatrix3 *result ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline void vmathM3MakeRotationX( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline void vmathM3MakeRotationY( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline void vmathM3MakeRotationZ( VmathMatrix3 *result, float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM3MakeRotationZYX( VmathMatrix3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM3MakeRotationAxis( VmathMatrix3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM3MakeRotationQ( VmathMatrix3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline void vmathM3MakeScale( VmathMatrix3 *result, const VmathVector3 *scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3AppendScale( VmathMatrix3 *result, const VmathMatrix3 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM3PrependScale( VmathMatrix3 *result, const VmathVector3 *scaleVec, const VmathMatrix3 *mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline void vmathM3MulPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline void vmathM3AbsPerElem( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline void vmathM3Transpose( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM3Inverse( VmathMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant( const VmathMatrix3 *mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathM3Select( VmathMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print( const VmathMatrix3 *mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints( const VmathMatrix3 *mat, const char *name ); - -#endif - -/* - * Copy a 4x4 matrix - */ -static inline void vmathM4Copy( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline void vmathM4MakeFromCols( VmathMatrix4 *result, const VmathVector4 *col0, const VmathVector4 *col1, const VmathVector4 *col2, const VmathVector4 *col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline void vmathM4MakeFromT3( VmathMatrix4 *result, const VmathTransform3 *mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathM4MakeFromM3V3( VmathMatrix4 *result, const VmathMatrix3 *mat, const VmathVector3 *translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathM4MakeFromQV3( VmathMatrix4 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline void vmathM4MakeFromScalar( VmathMatrix4 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3( VmathMatrix4 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline void vmathM4GetUpper3x3( VmathMatrix3 *result, const VmathMatrix4 *mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline void vmathM4GetTranslation( VmathVector3 *result, const VmathMatrix4 *mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0( VmathMatrix4 *result, const VmathVector4 *col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1( VmathMatrix4 *result, const VmathVector4 *col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2( VmathMatrix4 *result, const VmathVector4 *col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3( VmathMatrix4 *result, const VmathVector4 *col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline void vmathM4GetCol0( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline void vmathM4GetCol1( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline void vmathM4GetCol2( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline void vmathM4GetCol3( VmathVector4 *result, const VmathMatrix4 *mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol( VmathMatrix4 *result, int col, const VmathVector4 *vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow( VmathMatrix4 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetCol( VmathVector4 *result, const VmathMatrix4 *mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4GetRow( VmathVector4 *result, const VmathMatrix4 *mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem( const VmathMatrix4 *mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline void vmathM4Add( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline void vmathM4Sub( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline void vmathM4Neg( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline void vmathM4ScalarMul( VmathMatrix4 *result, const VmathMatrix4 *mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline void vmathM4MulV4( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector4 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline void vmathM4MulV3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathVector3 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline void vmathM4MulP3( VmathVector4 *result, const VmathMatrix4 *mat, const VmathPoint3 *pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline void vmathM4Mul( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline void vmathM4MulT3( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathTransform3 *tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline void vmathM4MakeIdentity( VmathMatrix4 *result ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline void vmathM4MakeRotationX( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline void vmathM4MakeRotationY( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline void vmathM4MakeRotationZYX( VmathMatrix4 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathM4MakeRotationAxis( VmathMatrix4 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathM4MakeRotationQ( VmathMatrix4 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline void vmathM4MakeScale( VmathMatrix4 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline void vmathM4MakeTranslation( VmathMatrix4 *result, const VmathVector3 *translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline void vmathM4MakeLookAt( VmathMatrix4 *result, const VmathPoint3 *eyePos, const VmathPoint3 *lookAtPos, const VmathVector3 *upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline void vmathM4MakePerspective( VmathMatrix4 *result, float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline void vmathM4MakeFrustum( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline void vmathM4MakeOrthographic( VmathMatrix4 *result, float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4AppendScale( VmathMatrix4 *result, const VmathMatrix4 *mat, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathM4PrependScale( VmathMatrix4 *result, const VmathVector3 *scaleVec, const VmathMatrix4 *mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline void vmathM4MulPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline void vmathM4AbsPerElem( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline void vmathM4Transpose( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4Inverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathM4AffineInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline void vmathM4OrthoInverse( VmathMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant( const VmathMatrix4 *mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathM4Select( VmathMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print( const VmathMatrix4 *mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints( const VmathMatrix4 *mat, const char *name ); - -#endif - -/* - * Copy a 3x4 transformation matrix - */ -static inline void vmathT3Copy( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline void vmathT3MakeFromCols( VmathTransform3 *result, const VmathVector3 *col0, const VmathVector3 *col1, const VmathVector3 *col2, const VmathVector3 *col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathT3MakeFromM3V3( VmathTransform3 *result, const VmathMatrix3 *tfrm, const VmathVector3 *translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathT3MakeFromQV3( VmathTransform3 *result, const VmathQuat *unitQuat, const VmathVector3 *translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline void vmathT3MakeFromScalar( VmathTransform3 *result, float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3( VmathTransform3 *result, const VmathMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline void vmathT3GetUpper3x3( VmathMatrix3 *result, const VmathTransform3 *tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline void vmathT3GetTranslation( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0( VmathTransform3 *result, const VmathVector3 *col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1( VmathTransform3 *result, const VmathVector3 *col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2( VmathTransform3 *result, const VmathVector3 *col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3( VmathTransform3 *result, const VmathVector3 *col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol0( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol1( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol2( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3GetCol3( VmathVector3 *result, const VmathTransform3 *tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol( VmathTransform3 *result, int col, const VmathVector3 *vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow( VmathTransform3 *result, int row, const VmathVector4 *vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetCol( VmathVector3 *result, const VmathTransform3 *tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3GetRow( VmathVector4 *result, const VmathTransform3 *tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem( const VmathTransform3 *tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline void vmathT3MulV3( VmathVector3 *result, const VmathTransform3 *tfrm, const VmathVector3 *vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline void vmathT3MulP3( VmathPoint3 *result, const VmathTransform3 *tfrm, const VmathPoint3 *pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline void vmathT3Mul( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline void vmathT3MakeIdentity( VmathTransform3 *result ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline void vmathT3MakeRotationX( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline void vmathT3MakeRotationY( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline void vmathT3MakeRotationZ( VmathTransform3 *result, float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline void vmathT3MakeRotationZYX( VmathTransform3 *result, const VmathVector3 *radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathT3MakeRotationAxis( VmathTransform3 *result, float radians, const VmathVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathT3MakeRotationQ( VmathTransform3 *result, const VmathQuat *unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline void vmathT3MakeScale( VmathTransform3 *result, const VmathVector3 *scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline void vmathT3MakeTranslation( VmathTransform3 *result, const VmathVector3 *translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3AppendScale( VmathTransform3 *result, const VmathTransform3 *tfrm, const VmathVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathT3PrependScale( VmathTransform3 *result, const VmathVector3 *scaleVec, const VmathTransform3 *tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline void vmathT3MulPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline void vmathT3AbsPerElem( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline void vmathT3Inverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline void vmathT3OrthoInverse( VmathTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathT3Select( VmathTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print( const VmathTransform3 *tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints( const VmathTransform3 *tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h deleted file mode 100644 index cca0872f0..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_aos_v.h +++ /dev/null @@ -1,1916 +0,0 @@ -/* - 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_AOS_C_V_SPU_H -#define _VECTORMATH_AOS_C_V_SPU_H - -#include -#include - -#ifdef _VECTORMATH_DEBUG -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_AOS_C_TYPES_H -#define _VECTORMATH_AOS_C_TYPES_H - -/* A 3-D vector in array-of-structures format - */ -typedef struct _VmathVector3 -{ - vec_float4 vec128; -} VmathVector3; - -/* A 4-D vector in array-of-structures format - */ -typedef struct _VmathVector4 -{ - vec_float4 vec128; -} VmathVector4; - -/* A 3-D point in array-of-structures format - */ -typedef struct _VmathPoint3 -{ - vec_float4 vec128; -} VmathPoint3; - -/* A quaternion in array-of-structures format - */ -typedef struct _VmathQuat -{ - vec_float4 vec128; -} VmathQuat; - -/* A 3x3 matrix in array-of-structures format - */ -typedef struct _VmathMatrix3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; -} VmathMatrix3; - -/* A 4x4 matrix in array-of-structures format - */ -typedef struct _VmathMatrix4 -{ - VmathVector4 col0; - VmathVector4 col1; - VmathVector4 col2; - VmathVector4 col3; -} VmathMatrix4; - -/* A 3x4 transformation matrix in array-of-structures format - */ -typedef struct _VmathTransform3 -{ - VmathVector3 col0; - VmathVector3 col1; - VmathVector3 col2; - VmathVector3 col3; -} VmathTransform3; - -#endif - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 3-D vector - */ -static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D vector - */ -static inline vec_float4 vmathV3Get128_V( VmathVector3 vec ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathV3SetX_V( VmathVector3 *result, float x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathV3SetY_V( VmathVector3 *result, float y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathV3SetZ_V( VmathVector3 *result, float z ); - -/* - * Get the x element of a 3-D vector - */ -static inline float vmathV3GetX_V( VmathVector3 vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline float vmathV3GetY_V( VmathVector3 vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline float vmathV3GetZ_V( VmathVector3 vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline float vmathV3GetElem_V( VmathVector3 vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec ); - -/* - * Construct x axis - */ -static inline VmathVector3 vmathV3MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector3 vmathV3MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector3 vmathV3MakeZAxis_V( ); - -/* - * Multiply two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline float vmathV3MaxElem_V( VmathVector3 vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline float vmathV3MinElem_V( VmathVector3 vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline float vmathV3Sum_V( VmathVector3 vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline float vmathV3LengthSqr_V( VmathVector3 vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline float vmathV3Length_V( VmathVector3 vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - * NOTE: - * Slower than column post-multiply. - */ -static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D vector in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D vectors in three quadwords - */ -static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D vectors as half-floats - */ -static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Print_V( VmathVector3 vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV3Prints_V( VmathVector3 vec, const char *name ); - -#endif - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 4-D vector - */ -static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 4-D vector - */ -static inline vec_float4 vmathV4Get128_V( VmathVector4 vec ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathV4SetX_V( VmathVector4 *result, float x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathV4SetY_V( VmathVector4 *result, float y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathV4SetZ_V( VmathVector4 *result, float z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathV4SetW_V( VmathVector4 *result, float w ); - -/* - * Get the x element of a 4-D vector - */ -static inline float vmathV4GetX_V( VmathVector4 vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline float vmathV4GetY_V( VmathVector4 vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline float vmathV4GetZ_V( VmathVector4 vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline float vmathV4GetW_V( VmathVector4 vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline float vmathV4GetElem_V( VmathVector4 vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec ); - -/* - * Construct x axis - */ -static inline VmathVector4 vmathV4MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathVector4 vmathV4MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathVector4 vmathV4MakeZAxis_V( ); - -/* - * Construct w axis - */ -static inline VmathVector4 vmathV4MakeWAxis_V( ); - -/* - * Multiply two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline float vmathV4MaxElem_V( VmathVector4 vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline float vmathV4MinElem_V( VmathVector4 vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline float vmathV4Sum_V( VmathVector4 vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline float vmathV4LengthSqr_V( VmathVector4 vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline float vmathV4Length_V( VmathVector4 vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 ); - -/* - * Store four 4-D vectors as half-floats - */ -static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Print_V( VmathVector4 vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathV4Prints_V( VmathVector4 vec, const char *name ); - -#endif - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a 3-D point - */ -static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a 3-D point - */ -static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathP3SetX_V( VmathPoint3 *result, float x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathP3SetY_V( VmathPoint3 *result, float y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathP3SetZ_V( VmathPoint3 *result, float z ); - -/* - * Get the x element of a 3-D point - */ -static inline float vmathP3GetX_V( VmathPoint3 pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline float vmathP3GetY_V( VmathPoint3 pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline float vmathP3GetZ_V( VmathPoint3 pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec ); - -/* - * Multiply two 3-D points per element - */ -static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline float vmathP3MaxElem_V( VmathPoint3 pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline float vmathP3MinElem_V( VmathPoint3 pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline float vmathP3Sum_V( VmathPoint3 pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 ); - -/* - * Store x, y, and z elements of a 3-D point in the first three words of a quadword. - * The value of the fourth word (the word with the highest address) remains unchanged - */ -static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads ); - -/* - * Store four 3-D points in three quadwords - */ -static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads ); - -/* - * Store eight 3-D points as half-floats - */ -static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Print_V( VmathPoint3 pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name ); - -#endif - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline VmathQuat vmathQMakeFromScalar_V( float scalar ); - -/* - * Set vector float data in a quaternion - */ -static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 ); - -/* - * Get vector float data from a quaternion - */ -static inline vec_float4 vmathQGet128_V( VmathQuat quat ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathQSetX_V( VmathQuat *result, float x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathQSetY_V( VmathQuat *result, float y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathQSetZ_V( VmathQuat *result, float z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathQSetW_V( VmathQuat *result, float w ); - -/* - * Get the x element of a quaternion - */ -static inline float vmathQGetX_V( VmathQuat quat ); - -/* - * Get the y element of a quaternion - */ -static inline float vmathQGetY_V( VmathQuat quat ); - -/* - * Get the z element of a quaternion - */ -static inline float vmathQGetZ_V( VmathQuat quat ); - -/* - * Get the w element of a quaternion - */ -static inline float vmathQGetW_V( VmathQuat quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline float vmathQGetElem_V( VmathQuat quat, int idx ); - -/* - * Add two quaternions - */ -static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply two quaternions - */ -static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline VmathQuat vmathQNeg_V( VmathQuat quat ); - -/* - * Construct an identity quaternion - */ -static inline VmathQuat vmathQMakeIdentity_V( ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline VmathQuat vmathQMakeRotationX_V( float radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline VmathQuat vmathQMakeRotationY_V( float radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline VmathQuat vmathQMakeRotationZ_V( float radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline VmathQuat vmathQConj_V( VmathQuat quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline float vmathQNorm_V( VmathQuat quat ); - -/* - * Compute the length of a quaternion - */ -static inline float vmathQLength_V( VmathQuat quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline VmathQuat vmathQNormalize_V( VmathQuat quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrint_V( VmathQuat quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathQPrints_V( VmathQuat quat, const char *name ); - -#endif - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline VmathMatrix3 vmathM3MakeIdentity_V( ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline float vmathM3Determinant_V( VmathMatrix3 mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Print_V( VmathMatrix3 mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name ); - -#endif - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline VmathMatrix4 vmathM4MakeIdentity_V( ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline float vmathM4Determinant_V( VmathMatrix4 mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Print_V( VmathMatrix4 mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name ); - -#endif - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm ); - -/* - * Set translation component - */ -static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline VmathTransform3 vmathT3MakeIdentity_V( ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline VmathTransform3 vmathT3MakeRotationX_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline VmathTransform3 vmathT3MakeRotationY_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Print_V( VmathTransform3 tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vectormath_aos.h" -#include "vec_aos_v.h" -#include "quat_aos_v.h" -#include "mat_aos_v.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h deleted file mode 100644 index 6aa9b6ae7..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa.h +++ /dev/null @@ -1,2012 +0,0 @@ -/* - 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_SOA_C_SPU_H -#define _VECTORMATH_SOA_C_SPU_H - -#include -#include -#include "vectormath_aos.h" - -#ifdef _VECTORMATH_DEBUG -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_SOA_C_TYPES_H -#define _VECTORMATH_SOA_C_TYPES_H - -/* A set of four 3-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaVector3; - -/* A set of four 4-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector4 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaVector4; - -/* A set of four 3-D points in structure-of-arrays format - */ -typedef struct _VmathSoaPoint3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaPoint3; - -/* A set of four quaternions in structure-of-arrays format - */ -typedef struct _VmathSoaQuat -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaQuat; - -/* A set of four 3x3 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; -} VmathSoaMatrix3; - -/* A set of four 4x4 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix4 -{ - VmathSoaVector4 col0; - VmathSoaVector4 col1; - VmathSoaVector4 col2; - VmathSoaVector4 col3; -} VmathSoaMatrix4; - -/* A set of four 3x4 transformation matrices in structure-of-arrays format - */ -typedef struct _VmathSoaTransform3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; - VmathSoaVector3 col3; -} VmathSoaTransform3; - -#endif - -/* - * Copy a 3-D vector - */ -static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3-D vector - */ -static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec ); - -/* - * Insert four AoS 3-D vectors - */ -static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 ); - -/* - * Extract four AoS 3-D vectors - */ -static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Construct x axis - */ -static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result ); - -/* - * Construct y axis - */ -static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result ); - -/* - * Construct z axis - */ -static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result ); - -/* - * Multiply two 3-D vectors per element - */ -static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D vector in three quadwords - */ -static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D vectors as half-floats - */ -static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Print( const VmathSoaVector3 *vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name ); - -#endif - -/* - * Copy a 4-D vector - */ -static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 4-D vector - */ -static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec ); - -/* - * Insert four AoS 4-D vectors - */ -static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 ); - -/* - * Extract four AoS 4-D vectors - */ -static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 w ); - -/* - * Get the x element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Construct x axis - */ -static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result ); - -/* - * Construct y axis - */ -static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result ); - -/* - * Construct z axis - */ -static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result ); - -/* - * Construct w axis - */ -static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result ); - -/* - * Multiply two 4-D vectors per element - */ -static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 ); - -/* - * Store four slots of an SoA 4-D vector as half-floats - */ -static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Print( const VmathSoaVector4 *vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name ); - -#endif - -/* - * Copy a 3-D point - */ -static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3-D point - */ -static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt ); - -/* - * Insert four AoS 3-D points - */ -static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 ); - -/* - * Extract four AoS 3-D points - */ -static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec ); - -/* - * Multiply two 3-D points per element - */ -static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D point in three quadwords - */ -static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *pnt, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D points as half-floats - */ -static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name ); - -#endif - -/* - * Copy a quaternion - */ -static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar ); - -/* - * Replicate an AoS quaternion - */ -static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat ); - -/* - * Insert four AoS quaternions - */ -static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 ); - -/* - * Extract four AoS quaternions - */ -static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 w ); - -/* - * Get the x element of a quaternion - */ -static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat ); - -/* - * Get the y element of a quaternion - */ -static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat ); - -/* - * Get the z element of a quaternion - */ -static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat ); - -/* - * Get the w element of a quaternion - */ -static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx ); - -/* - * Add two quaternions - */ -static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Multiply two quaternions - */ -static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Construct an identity quaternion - */ -static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat ); - -/* - * Compute the length of a quaternion - */ -static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrint( const VmathSoaQuat *quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name ); - -#endif - -/* - * Copy a 3x3 matrix - */ -static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3x3 matrix - */ -static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat ); - -/* - * Insert four AoS 3x3 matrices - */ -static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 ); - -/* - * Extract four AoS 3x3 matrices - */ -static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name ); - -#endif - -/* - * Copy a 4x4 matrix - */ -static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0, const VmathSoaVector4 *col1, const VmathSoaVector4 *col2, const VmathSoaVector4 *col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 4x4 matrix - */ -static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat ); - -/* - * Insert four AoS 4x4 matrices - */ -static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 ); - -/* - * Extract four AoS 4x4 matrices - */ -static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name ); - -#endif - -/* - * Copy a 3x4 transformation matrix - */ -static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2, const VmathSoaVector3 *col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar ); - -/* - * Replicate an AoS 3x4 transformation matrix - */ -static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm ); - -/* - * Insert four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 ); - -/* - * Extract four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set translation component - */ -static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vec_soa.h" -#include "quat_soa.h" -#include "mat_soa.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h b/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h deleted file mode 100644 index 85ebed3ac..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/c/vectormath_soa_v.h +++ /dev/null @@ -1,1978 +0,0 @@ -/* - 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_SOA_C_V_SPU_H -#define _VECTORMATH_SOA_C_V_SPU_H - -#include -#include -#include "vectormath_aos_v.h" - -#ifdef _VECTORMATH_DEBUG -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef _VECTORMATH_SOA_C_TYPES_H -#define _VECTORMATH_SOA_C_TYPES_H - -/* A set of four 3-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaVector3; - -/* A set of four 4-D vectors in structure-of-arrays format - */ -typedef struct _VmathSoaVector4 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaVector4; - -/* A set of four 3-D points in structure-of-arrays format - */ -typedef struct _VmathSoaPoint3 -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; -} VmathSoaPoint3; - -/* A set of four quaternions in structure-of-arrays format - */ -typedef struct _VmathSoaQuat -{ - vec_float4 x; - vec_float4 y; - vec_float4 z; - vec_float4 w; -} VmathSoaQuat; - -/* A set of four 3x3 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; -} VmathSoaMatrix3; - -/* A set of four 4x4 matrices in structure-of-arrays format - */ -typedef struct _VmathSoaMatrix4 -{ - VmathSoaVector4 col0; - VmathSoaVector4 col1; - VmathSoaVector4 col2; - VmathSoaVector4 col3; -} VmathSoaMatrix4; - -/* A set of four 3x4 transformation matrices in structure-of-arrays format - */ -typedef struct _VmathSoaTransform3 -{ - VmathSoaVector3 col0; - VmathSoaVector3 col1; - VmathSoaVector3 col2; - VmathSoaVector3 col3; -} VmathSoaTransform3; - -#endif - -/* - * Construct a 3-D vector from x, y, and z elements - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D point into a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromP3_V( VmathSoaPoint3 pnt ); - -/* - * Set all elements of a 3-D vector to the same scalar value - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3MakeFromAos_V( VmathVector3 vec ); - -/* - * Insert four AoS 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3MakeFrom4Aos_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3 ); - -/* - * Extract four AoS 3-D vectors - */ -static inline void vmathSoaV3Get4Aos_V( VmathSoaVector3 vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 ); - -/* - * Set the x element of a 3-D vector - */ -static inline void vmathSoaV3SetX_V( VmathSoaVector3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D vector - */ -static inline void vmathSoaV3SetY_V( VmathSoaVector3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D vector - */ -static inline void vmathSoaV3SetZ_V( VmathSoaVector3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetX_V( VmathSoaVector3 vec ); - -/* - * Get the y element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetY_V( VmathSoaVector3 vec ); - -/* - * Get the z element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3GetZ_V( VmathSoaVector3 vec ); - -/* - * Set an x, y, or z element of a 3-D vector by index - */ -static inline void vmathSoaV3SetElem_V( VmathSoaVector3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D vector by index - */ -static inline vec_float4 vmathSoaV3GetElem_V( VmathSoaVector3 vec, int idx ); - -/* - * Add two 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3Add_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Subtract a 3-D vector from another 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3Sub_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Add a 3-D vector to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaV3AddP3_V( VmathSoaVector3 vec, VmathSoaPoint3 pnt ); - -/* - * Multiply a 3-D vector by a scalar - */ -static inline VmathSoaVector3 vmathSoaV3ScalarMul_V( VmathSoaVector3 vec, vec_float4 scalar ); - -/* - * Divide a 3-D vector by a scalar - */ -static inline VmathSoaVector3 vmathSoaV3ScalarDiv_V( VmathSoaVector3 vec, vec_float4 scalar ); - -/* - * Negate all elements of a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaV3Neg_V( VmathSoaVector3 vec ); - -/* - * Construct x axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathSoaVector3 vmathSoaV3MakeZAxis_V( ); - -/* - * Multiply two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MulPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Divide two 3-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaVector3 vmathSoaV3DivPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Compute the reciprocal of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaVector3 vmathSoaV3RecipPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaVector3 vmathSoaV3SqrtPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the reciprocal square root of a 3-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaVector3 vmathSoaV3RsqrtPerElem_V( VmathSoaVector3 vec ); - -/* - * Compute the absolute value of a 3-D vector per element - */ -static inline VmathSoaVector3 vmathSoaV3AbsPerElem_V( VmathSoaVector3 vec ); - -/* - * Copy sign from one 3-D vector to another, per element - */ -static inline VmathSoaVector3 vmathSoaV3CopySignPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Maximum of two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MaxPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Minimum of two 3-D vectors per element - */ -static inline VmathSoaVector3 vmathSoaV3MinPerElem_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Maximum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MaxElem_V( VmathSoaVector3 vec ); - -/* - * Minimum element of a 3-D vector - */ -static inline vec_float4 vmathSoaV3MinElem_V( VmathSoaVector3 vec ); - -/* - * Compute the sum of all elements of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Sum_V( VmathSoaVector3 vec ); - -/* - * Compute the dot product of two 3-D vectors - */ -static inline vec_float4 vmathSoaV3Dot_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Compute the square of the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3LengthSqr_V( VmathSoaVector3 vec ); - -/* - * Compute the length of a 3-D vector - */ -static inline vec_float4 vmathSoaV3Length_V( VmathSoaVector3 vec ); - -/* - * Normalize a 3-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathSoaVector3 vmathSoaV3Normalize_V( VmathSoaVector3 vec ); - -/* - * Compute cross product of two 3-D vectors - */ -static inline VmathSoaVector3 vmathSoaV3Cross_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Outer product of two 3-D vectors - */ -static inline VmathSoaMatrix3 vmathSoaV3Outer_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Pre-multiply a row vector by a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaV3RowMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); - -/* - * Cross-product matrix of a 3-D vector - */ -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrix_V( VmathSoaVector3 vec ); - -/* - * Create cross-product matrix and multiply - * NOTE: - * Faster than separately creating a cross-product matrix and multiplying. - */ -static inline VmathSoaMatrix3 vmathSoaV3CrossMatrixMul_V( VmathSoaVector3 vec, VmathSoaMatrix3 mat ); - -/* - * Linear interpolation between two 3-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector3 vmathSoaV3Lerp_V( vec_float4 t, VmathSoaVector3 vec0, VmathSoaVector3 vec1 ); - -/* - * Spherical linear interpolation between two 3-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector3 vmathSoaV3Slerp_V( vec_float4 t, VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); - -/* - * Conditionally select between two 3-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaVector3 vmathSoaV3Select_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D vectors, stored in three quadwords - */ -static inline void vmathSoaV3LoadXYZArray_V( VmathSoaVector3 *vec, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D vector in three quadwords - */ -static inline void vmathSoaV3StoreXYZArray_V( VmathSoaVector3 vec, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D vectors as half-floats - */ -static inline void vmathSoaV3StoreHalfFloats_V( VmathSoaVector3 vec0, VmathSoaVector3 vec1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Print_V( VmathSoaVector3 vec ); - -/* - * Print a 3-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV3Prints_V( VmathSoaVector3 vec, const char *name ); - -#endif - -/* - * Construct a 4-D vector from x, y, z, and w elements - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a 4-D vector from a 3-D vector and a scalar - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); - -/* - * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromV3_V( VmathSoaVector3 vec ); - -/* - * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromP3_V( VmathSoaPoint3 pnt ); - -/* - * Copy elements from a quaternion into a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromQ_V( VmathSoaQuat quat ); - -/* - * Set all elements of a 4-D vector to the same scalar value - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4MakeFromAos_V( VmathVector4 vec ); - -/* - * Insert four AoS 4-D vectors - */ -static inline VmathSoaVector4 vmathSoaV4MakeFrom4Aos_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3 ); - -/* - * Extract four AoS 4-D vectors - */ -static inline void vmathSoaV4Get4Aos_V( VmathSoaVector4 vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 ); - -/* - * Set the x, y, and z elements of a 4-D vector - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaV4SetXYZ_V( VmathSoaVector4 *result, VmathSoaVector3 vec ); - -/* - * Get the x, y, and z elements of a 4-D vector - */ -static inline VmathSoaVector3 vmathSoaV4GetXYZ_V( VmathSoaVector4 vec ); - -/* - * Set the x element of a 4-D vector - */ -static inline void vmathSoaV4SetX_V( VmathSoaVector4 *result, vec_float4 x ); - -/* - * Set the y element of a 4-D vector - */ -static inline void vmathSoaV4SetY_V( VmathSoaVector4 *result, vec_float4 y ); - -/* - * Set the z element of a 4-D vector - */ -static inline void vmathSoaV4SetZ_V( VmathSoaVector4 *result, vec_float4 z ); - -/* - * Set the w element of a 4-D vector - */ -static inline void vmathSoaV4SetW_V( VmathSoaVector4 *result, vec_float4 w ); - -/* - * Get the x element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetX_V( VmathSoaVector4 vec ); - -/* - * Get the y element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetY_V( VmathSoaVector4 vec ); - -/* - * Get the z element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetZ_V( VmathSoaVector4 vec ); - -/* - * Get the w element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4GetW_V( VmathSoaVector4 vec ); - -/* - * Set an x, y, z, or w element of a 4-D vector by index - */ -static inline void vmathSoaV4SetElem_V( VmathSoaVector4 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a 4-D vector by index - */ -static inline vec_float4 vmathSoaV4GetElem_V( VmathSoaVector4 vec, int idx ); - -/* - * Add two 4-D vectors - */ -static inline VmathSoaVector4 vmathSoaV4Add_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Subtract a 4-D vector from another 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4Sub_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Multiply a 4-D vector by a scalar - */ -static inline VmathSoaVector4 vmathSoaV4ScalarMul_V( VmathSoaVector4 vec, vec_float4 scalar ); - -/* - * Divide a 4-D vector by a scalar - */ -static inline VmathSoaVector4 vmathSoaV4ScalarDiv_V( VmathSoaVector4 vec, vec_float4 scalar ); - -/* - * Negate all elements of a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaV4Neg_V( VmathSoaVector4 vec ); - -/* - * Construct x axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeXAxis_V( ); - -/* - * Construct y axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeYAxis_V( ); - -/* - * Construct z axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeZAxis_V( ); - -/* - * Construct w axis - */ -static inline VmathSoaVector4 vmathSoaV4MakeWAxis_V( ); - -/* - * Multiply two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MulPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Divide two 4-D vectors per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaVector4 vmathSoaV4DivPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Compute the reciprocal of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaVector4 vmathSoaV4RecipPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaVector4 vmathSoaV4SqrtPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the reciprocal square root of a 4-D vector per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaVector4 vmathSoaV4RsqrtPerElem_V( VmathSoaVector4 vec ); - -/* - * Compute the absolute value of a 4-D vector per element - */ -static inline VmathSoaVector4 vmathSoaV4AbsPerElem_V( VmathSoaVector4 vec ); - -/* - * Copy sign from one 4-D vector to another, per element - */ -static inline VmathSoaVector4 vmathSoaV4CopySignPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Maximum of two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MaxPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Minimum of two 4-D vectors per element - */ -static inline VmathSoaVector4 vmathSoaV4MinPerElem_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Maximum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MaxElem_V( VmathSoaVector4 vec ); - -/* - * Minimum element of a 4-D vector - */ -static inline vec_float4 vmathSoaV4MinElem_V( VmathSoaVector4 vec ); - -/* - * Compute the sum of all elements of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Sum_V( VmathSoaVector4 vec ); - -/* - * Compute the dot product of two 4-D vectors - */ -static inline vec_float4 vmathSoaV4Dot_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Compute the square of the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4LengthSqr_V( VmathSoaVector4 vec ); - -/* - * Compute the length of a 4-D vector - */ -static inline vec_float4 vmathSoaV4Length_V( VmathSoaVector4 vec ); - -/* - * Normalize a 4-D vector - * NOTE: - * The result is unpredictable when all elements of vec are at or near zero. - */ -static inline VmathSoaVector4 vmathSoaV4Normalize_V( VmathSoaVector4 vec ); - -/* - * Outer product of two 4-D vectors - */ -static inline VmathSoaMatrix4 vmathSoaV4Outer_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Linear interpolation between two 4-D vectors - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector4 vmathSoaV4Lerp_V( vec_float4 t, VmathSoaVector4 vec0, VmathSoaVector4 vec1 ); - -/* - * Spherical linear interpolation between two 4-D vectors - * NOTE: - * The result is unpredictable if the vectors point in opposite directions. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaVector4 vmathSoaV4Slerp_V( vec_float4 t, VmathSoaVector4 unitVec0, VmathSoaVector4 unitVec1 ); - -/* - * Conditionally select between two 4-D vectors - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaVector4 vmathSoaV4Select_V( VmathSoaVector4 vec0, VmathSoaVector4 vec1, vec_uint4 select1 ); - -/* - * Store four slots of an SoA 4-D vector as half-floats - */ -static inline void vmathSoaV4StoreHalfFloats_V( VmathSoaVector4 vec, vec_ushort8 *twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4-D vector - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Print_V( VmathSoaVector4 vec ); - -/* - * Print a 4-D vector and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaV4Prints_V( VmathSoaVector4 vec, const char *name ); - -#endif - -/* - * Construct a 3-D point from x, y, and z elements - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z ); - -/* - * Copy elements from a 3-D vector into a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromV3_V( VmathSoaVector3 vec ); - -/* - * Set all elements of a 3-D point to the same scalar value - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFromAos_V( VmathPoint3 pnt ); - -/* - * Insert four AoS 3-D points - */ -static inline VmathSoaPoint3 vmathSoaP3MakeFrom4Aos_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3 ); - -/* - * Extract four AoS 3-D points - */ -static inline void vmathSoaP3Get4Aos_V( VmathSoaPoint3 pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 ); - -/* - * Set the x element of a 3-D point - */ -static inline void vmathSoaP3SetX_V( VmathSoaPoint3 *result, vec_float4 x ); - -/* - * Set the y element of a 3-D point - */ -static inline void vmathSoaP3SetY_V( VmathSoaPoint3 *result, vec_float4 y ); - -/* - * Set the z element of a 3-D point - */ -static inline void vmathSoaP3SetZ_V( VmathSoaPoint3 *result, vec_float4 z ); - -/* - * Get the x element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetX_V( VmathSoaPoint3 pnt ); - -/* - * Get the y element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetY_V( VmathSoaPoint3 pnt ); - -/* - * Get the z element of a 3-D point - */ -static inline vec_float4 vmathSoaP3GetZ_V( VmathSoaPoint3 pnt ); - -/* - * Set an x, y, or z element of a 3-D point by index - */ -static inline void vmathSoaP3SetElem_V( VmathSoaPoint3 *result, int idx, vec_float4 value ); - -/* - * Get an x, y, or z element of a 3-D point by index - */ -static inline vec_float4 vmathSoaP3GetElem_V( VmathSoaPoint3 pnt, int idx ); - -/* - * Subtract a 3-D point from another 3-D point - */ -static inline VmathSoaVector3 vmathSoaP3Sub_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Add a 3-D point to a 3-D vector - */ -static inline VmathSoaPoint3 vmathSoaP3AddV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); - -/* - * Subtract a 3-D vector from a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3SubV3_V( VmathSoaPoint3 pnt, VmathSoaVector3 vec ); - -/* - * Multiply two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MulPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Divide two 3-D points per element - * NOTE: - * Floating-point behavior matches standard library function divf4. - */ -static inline VmathSoaPoint3 vmathSoaP3DivPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Compute the reciprocal of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function recipf4. - */ -static inline VmathSoaPoint3 vmathSoaP3RecipPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function sqrtf4. - */ -static inline VmathSoaPoint3 vmathSoaP3SqrtPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the reciprocal square root of a 3-D point per element - * NOTE: - * Floating-point behavior matches standard library function rsqrtf4. - */ -static inline VmathSoaPoint3 vmathSoaP3RsqrtPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the absolute value of a 3-D point per element - */ -static inline VmathSoaPoint3 vmathSoaP3AbsPerElem_V( VmathSoaPoint3 pnt ); - -/* - * Copy sign from one 3-D point to another, per element - */ -static inline VmathSoaPoint3 vmathSoaP3CopySignPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Maximum of two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MaxPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Minimum of two 3-D points per element - */ -static inline VmathSoaPoint3 vmathSoaP3MinPerElem_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Maximum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MaxElem_V( VmathSoaPoint3 pnt ); - -/* - * Minimum element of a 3-D point - */ -static inline vec_float4 vmathSoaP3MinElem_V( VmathSoaPoint3 pnt ); - -/* - * Compute the sum of all elements of a 3-D point - */ -static inline vec_float4 vmathSoaP3Sum_V( VmathSoaPoint3 pnt ); - -/* - * Apply uniform scale to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3Scale_V( VmathSoaPoint3 pnt, vec_float4 scaleVal ); - -/* - * Apply non-uniform scale to a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaP3NonUniformScale_V( VmathSoaPoint3 pnt, VmathSoaVector3 scaleVec ); - -/* - * Scalar projection of a 3-D point on a unit-length 3-D vector - */ -static inline vec_float4 vmathSoaP3Projection_V( VmathSoaPoint3 pnt, VmathSoaVector3 unitVec ); - -/* - * Compute the square of the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistSqrFromOrigin_V( VmathSoaPoint3 pnt ); - -/* - * Compute the distance of a 3-D point from the coordinate-system origin - */ -static inline vec_float4 vmathSoaP3DistFromOrigin_V( VmathSoaPoint3 pnt ); - -/* - * Compute the square of the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3DistSqr_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Compute the distance between two 3-D points - */ -static inline vec_float4 vmathSoaP3Dist_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Linear interpolation between two 3-D points - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaPoint3 vmathSoaP3Lerp_V( vec_float4 t, VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1 ); - -/* - * Conditionally select between two 3-D points - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaPoint3 vmathSoaP3Select_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_uint4 select1 ); - -/* - * Load four three-float 3-D points, stored in three quadwords - */ -static inline void vmathSoaP3LoadXYZArray_V( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads ); - -/* - * Store four slots of an SoA 3-D point in three quadwords - */ -static inline void vmathSoaP3StoreXYZArray_V( VmathSoaPoint3 pnt, vec_float4 *threeQuads ); - -/* - * Store eight slots of two SoA 3-D points as half-floats - */ -static inline void vmathSoaP3StoreHalfFloats_V( VmathSoaPoint3 pnt0, VmathSoaPoint3 pnt1, vec_ushort8 *threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3-D point - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Print_V( VmathSoaPoint3 pnt ); - -/* - * Print a 3-D point and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaP3Prints_V( VmathSoaPoint3 pnt, const char *name ); - -#endif - -/* - * Construct a quaternion from x, y, z, and w elements - */ -static inline VmathSoaQuat vmathSoaQMakeFromElems_V( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - -/* - * Construct a quaternion from a 3-D vector and a scalar - */ -static inline VmathSoaQuat vmathSoaQMakeFromV3Scalar_V( VmathSoaVector3 xyz, vec_float4 w ); - -/* - * Copy elements from a 4-D vector into a quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromV4_V( VmathSoaVector4 vec ); - -/* - * Convert a rotation matrix to a unit-length quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromM3_V( VmathSoaMatrix3 rotMat ); - -/* - * Set all elements of a quaternion to the same scalar value - */ -static inline VmathSoaQuat vmathSoaQMakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeFromAos_V( VmathQuat quat ); - -/* - * Insert four AoS quaternions - */ -static inline VmathSoaQuat vmathSoaQMakeFrom4Aos_V( VmathQuat quat0, VmathQuat quat1, VmathQuat quat2, VmathQuat quat3 ); - -/* - * Extract four AoS quaternions - */ -static inline void vmathSoaQGet4Aos_V( VmathSoaQuat quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 ); - -/* - * Set the x, y, and z elements of a quaternion - * NOTE: - * This function does not change the w element. - */ -static inline void vmathSoaQSetXYZ_V( VmathSoaQuat *result, VmathSoaVector3 vec ); - -/* - * Get the x, y, and z elements of a quaternion - */ -static inline VmathSoaVector3 vmathSoaQGetXYZ_V( VmathSoaQuat quat ); - -/* - * Set the x element of a quaternion - */ -static inline void vmathSoaQSetX_V( VmathSoaQuat *result, vec_float4 x ); - -/* - * Set the y element of a quaternion - */ -static inline void vmathSoaQSetY_V( VmathSoaQuat *result, vec_float4 y ); - -/* - * Set the z element of a quaternion - */ -static inline void vmathSoaQSetZ_V( VmathSoaQuat *result, vec_float4 z ); - -/* - * Set the w element of a quaternion - */ -static inline void vmathSoaQSetW_V( VmathSoaQuat *result, vec_float4 w ); - -/* - * Get the x element of a quaternion - */ -static inline vec_float4 vmathSoaQGetX_V( VmathSoaQuat quat ); - -/* - * Get the y element of a quaternion - */ -static inline vec_float4 vmathSoaQGetY_V( VmathSoaQuat quat ); - -/* - * Get the z element of a quaternion - */ -static inline vec_float4 vmathSoaQGetZ_V( VmathSoaQuat quat ); - -/* - * Get the w element of a quaternion - */ -static inline vec_float4 vmathSoaQGetW_V( VmathSoaQuat quat ); - -/* - * Set an x, y, z, or w element of a quaternion by index - */ -static inline void vmathSoaQSetElem_V( VmathSoaQuat *result, int idx, vec_float4 value ); - -/* - * Get an x, y, z, or w element of a quaternion by index - */ -static inline vec_float4 vmathSoaQGetElem_V( VmathSoaQuat quat, int idx ); - -/* - * Add two quaternions - */ -static inline VmathSoaQuat vmathSoaQAdd_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Subtract a quaternion from another quaternion - */ -static inline VmathSoaQuat vmathSoaQSub_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Multiply two quaternions - */ -static inline VmathSoaQuat vmathSoaQMul_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Multiply a quaternion by a scalar - */ -static inline VmathSoaQuat vmathSoaQScalarMul_V( VmathSoaQuat quat, vec_float4 scalar ); - -/* - * Divide a quaternion by a scalar - */ -static inline VmathSoaQuat vmathSoaQScalarDiv_V( VmathSoaQuat quat, vec_float4 scalar ); - -/* - * Negate all elements of a quaternion - */ -static inline VmathSoaQuat vmathSoaQNeg_V( VmathSoaQuat quat ); - -/* - * Construct an identity quaternion - */ -static inline VmathSoaQuat vmathSoaQMakeIdentity_V( ); - -/* - * Construct a quaternion to rotate between two unit-length 3-D vectors - * NOTE: - * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - */ -static inline VmathSoaQuat vmathSoaQMakeRotationArc_V( VmathSoaVector3 unitVec0, VmathSoaVector3 unitVec1 ); - -/* - * Construct a quaternion to rotate around a unit-length 3-D vector - */ -static inline VmathSoaQuat vmathSoaQMakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a quaternion to rotate around the x axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationX_V( vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the y axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationY_V( vec_float4 radians ); - -/* - * Construct a quaternion to rotate around the z axis - */ -static inline VmathSoaQuat vmathSoaQMakeRotationZ_V( vec_float4 radians ); - -/* - * Compute the conjugate of a quaternion - */ -static inline VmathSoaQuat vmathSoaQConj_V( VmathSoaQuat quat ); - -/* - * Use a unit-length quaternion to rotate a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaQRotate_V( VmathSoaQuat unitQuat, VmathSoaVector3 vec ); - -/* - * Compute the dot product of two quaternions - */ -static inline vec_float4 vmathSoaQDot_V( VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Compute the norm of a quaternion - */ -static inline vec_float4 vmathSoaQNorm_V( VmathSoaQuat quat ); - -/* - * Compute the length of a quaternion - */ -static inline vec_float4 vmathSoaQLength_V( VmathSoaQuat quat ); - -/* - * Normalize a quaternion - * NOTE: - * The result is unpredictable when all elements of quat are at or near zero. - */ -static inline VmathSoaQuat vmathSoaQNormalize_V( VmathSoaQuat quat ); - -/* - * Linear interpolation between two quaternions - * NOTE: - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaQuat vmathSoaQLerp_V( vec_float4 t, VmathSoaQuat quat0, VmathSoaQuat quat1 ); - -/* - * Spherical linear interpolation between two quaternions - * NOTE: - * Interpolates along the shortest path between orientations. - * Does not clamp t between 0 and 1. - */ -static inline VmathSoaQuat vmathSoaQSlerp_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1 ); - -/* - * Spherical quadrangle interpolation - */ -static inline VmathSoaQuat vmathSoaQSquad_V( vec_float4 t, VmathSoaQuat unitQuat0, VmathSoaQuat unitQuat1, VmathSoaQuat unitQuat2, VmathSoaQuat unitQuat3 ); - -/* - * Conditionally select between two quaternions - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaQuat vmathSoaQSelect_V( VmathSoaQuat quat0, VmathSoaQuat quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a quaternion - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrint_V( VmathSoaQuat quat ); - -/* - * Print a quaternion and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaQPrints_V( VmathSoaQuat quat, const char *name ); - -#endif - -/* - * Construct a 3x3 matrix containing the specified columns - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2 ); - -/* - * Construct a 3x3 rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromQ_V( VmathSoaQuat unitQuat ); - -/* - * Set all elements of a 3x3 matrix to the same scalar value - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFromAos_V( VmathMatrix3 mat ); - -/* - * Insert four AoS 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeFrom4Aos_V( VmathMatrix3 mat0, VmathMatrix3 mat1, VmathMatrix3 mat2, VmathMatrix3 mat3 ); - -/* - * Extract four AoS 3x3 matrices - */ -static inline void vmathSoaM3Get4Aos_V( VmathSoaMatrix3 mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 ); - -/* - * Set column 0 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol0_V( VmathSoaMatrix3 *result, VmathSoaVector3 col0 ); - -/* - * Set column 1 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol1_V( VmathSoaMatrix3 *result, VmathSoaVector3 col1 ); - -/* - * Set column 2 of a 3x3 matrix - */ -static inline void vmathSoaM3SetCol2_V( VmathSoaMatrix3 *result, VmathSoaVector3 col2 ); - -/* - * Get column 0 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol0_V( VmathSoaMatrix3 mat ); - -/* - * Get column 1 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol1_V( VmathSoaMatrix3 mat ); - -/* - * Get column 2 of a 3x3 matrix - */ -static inline VmathSoaVector3 vmathSoaM3GetCol2_V( VmathSoaMatrix3 mat ); - -/* - * Set the column of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetCol_V( VmathSoaMatrix3 *result, int col, VmathSoaVector3 vec ); - -/* - * Set the row of a 3x3 matrix referred to by the specified index - */ -static inline void vmathSoaM3SetRow_V( VmathSoaMatrix3 *result, int row, VmathSoaVector3 vec ); - -/* - * Get the column of a 3x3 matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaM3GetCol_V( VmathSoaMatrix3 mat, int col ); - -/* - * Get the row of a 3x3 matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaM3GetRow_V( VmathSoaMatrix3 mat, int row ); - -/* - * Set the element of a 3x3 matrix referred to by column and row indices - */ -static inline void vmathSoaM3SetElem_V( VmathSoaMatrix3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x3 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM3GetElem_V( VmathSoaMatrix3 mat, int col, int row ); - -/* - * Add two 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3Add_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Subtract a 3x3 matrix from another 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Sub_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Negate all elements of a 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Neg_V( VmathSoaMatrix3 mat ); - -/* - * Multiply a 3x3 matrix by a scalar - */ -static inline VmathSoaMatrix3 vmathSoaM3ScalarMul_V( VmathSoaMatrix3 mat, vec_float4 scalar ); - -/* - * Multiply a 3x3 matrix by a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaM3MulV3_V( VmathSoaMatrix3 mat, VmathSoaVector3 vec ); - -/* - * Multiply two 3x3 matrices - */ -static inline VmathSoaMatrix3 vmathSoaM3Mul_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Construct an identity 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeIdentity_V( ); - -/* - * Construct a 3x3 matrix to rotate around the x axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the y axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the z axis - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 3x3 matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 3x3 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 3x3 matrix to perform scaling - */ -static inline VmathSoaMatrix3 vmathSoaM3MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix3 vmathSoaM3AppendScale_V( VmathSoaMatrix3 mat, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x3 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix3 vmathSoaM3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix3 mat ); - -/* - * Multiply two 3x3 matrices per element - */ -static inline VmathSoaMatrix3 vmathSoaM3MulPerElem_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1 ); - -/* - * Compute the absolute value of a 3x3 matrix per element - */ -static inline VmathSoaMatrix3 vmathSoaM3AbsPerElem_V( VmathSoaMatrix3 mat ); - -/* - * Transpose of a 3x3 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM3Transpose_V( VmathSoaMatrix3 mat ); - -/* - * Compute the inverse of a 3x3 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix3 vmathSoaM3Inverse_V( VmathSoaMatrix3 mat ); - -/* - * Determinant of a 3x3 matrix - */ -static inline vec_float4 vmathSoaM3Determinant_V( VmathSoaMatrix3 mat ); - -/* - * Conditionally select between two 3x3 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaMatrix3 vmathSoaM3Select_V( VmathSoaMatrix3 mat0, VmathSoaMatrix3 mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x3 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Print_V( VmathSoaMatrix3 mat ); - -/* - * Print a 3x3 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM3Prints_V( VmathSoaMatrix3 mat, const char *name ); - -#endif - -/* - * Construct a 4x4 matrix containing the specified columns - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromCols_V( VmathSoaVector4 col0, VmathSoaVector4 col1, VmathSoaVector4 col2, VmathSoaVector4 col3 ); - -/* - * Construct a 4x4 matrix from a 3x4 transformation matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromT3_V( VmathSoaTransform3 mat ); - -/* - * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromM3V3_V( VmathSoaMatrix3 mat, VmathSoaVector3 translateVec ); - -/* - * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); - -/* - * Set all elements of a 4x4 matrix to the same scalar value - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFromAos_V( VmathMatrix4 mat ); - -/* - * Insert four AoS 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFrom4Aos_V( VmathMatrix4 mat0, VmathMatrix4 mat1, VmathMatrix4 mat2, VmathMatrix4 mat3 ); - -/* - * Extract four AoS 4x4 matrices - */ -static inline void vmathSoaM4Get4Aos_V( VmathSoaMatrix4 mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetUpper3x3_V( VmathSoaMatrix4 *result, VmathSoaMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 4x4 matrix - */ -static inline VmathSoaMatrix3 vmathSoaM4GetUpper3x3_V( VmathSoaMatrix4 mat ); - -/* - * Set translation component - * NOTE: - * This function does not change the bottom row elements. - */ -static inline void vmathSoaM4SetTranslation_V( VmathSoaMatrix4 *result, VmathSoaVector3 translateVec ); - -/* - * Get the translation component of a 4x4 matrix - */ -static inline VmathSoaVector3 vmathSoaM4GetTranslation_V( VmathSoaMatrix4 mat ); - -/* - * Set column 0 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol0_V( VmathSoaMatrix4 *result, VmathSoaVector4 col0 ); - -/* - * Set column 1 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol1_V( VmathSoaMatrix4 *result, VmathSoaVector4 col1 ); - -/* - * Set column 2 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol2_V( VmathSoaMatrix4 *result, VmathSoaVector4 col2 ); - -/* - * Set column 3 of a 4x4 matrix - */ -static inline void vmathSoaM4SetCol3_V( VmathSoaMatrix4 *result, VmathSoaVector4 col3 ); - -/* - * Get column 0 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol0_V( VmathSoaMatrix4 mat ); - -/* - * Get column 1 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol1_V( VmathSoaMatrix4 mat ); - -/* - * Get column 2 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol2_V( VmathSoaMatrix4 mat ); - -/* - * Get column 3 of a 4x4 matrix - */ -static inline VmathSoaVector4 vmathSoaM4GetCol3_V( VmathSoaMatrix4 mat ); - -/* - * Set the column of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetCol_V( VmathSoaMatrix4 *result, int col, VmathSoaVector4 vec ); - -/* - * Set the row of a 4x4 matrix referred to by the specified index - */ -static inline void vmathSoaM4SetRow_V( VmathSoaMatrix4 *result, int row, VmathSoaVector4 vec ); - -/* - * Get the column of a 4x4 matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaM4GetCol_V( VmathSoaMatrix4 mat, int col ); - -/* - * Get the row of a 4x4 matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaM4GetRow_V( VmathSoaMatrix4 mat, int row ); - -/* - * Set the element of a 4x4 matrix referred to by column and row indices - */ -static inline void vmathSoaM4SetElem_V( VmathSoaMatrix4 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 4x4 matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaM4GetElem_V( VmathSoaMatrix4 mat, int col, int row ); - -/* - * Add two 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4Add_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Subtract a 4x4 matrix from another 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Sub_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Negate all elements of a 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Neg_V( VmathSoaMatrix4 mat ); - -/* - * Multiply a 4x4 matrix by a scalar - */ -static inline VmathSoaMatrix4 vmathSoaM4ScalarMul_V( VmathSoaMatrix4 mat, vec_float4 scalar ); - -/* - * Multiply a 4x4 matrix by a 4-D vector - */ -static inline VmathSoaVector4 vmathSoaM4MulV4_V( VmathSoaMatrix4 mat, VmathSoaVector4 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D vector - */ -static inline VmathSoaVector4 vmathSoaM4MulV3_V( VmathSoaMatrix4 mat, VmathSoaVector3 vec ); - -/* - * Multiply a 4x4 matrix by a 3-D point - */ -static inline VmathSoaVector4 vmathSoaM4MulP3_V( VmathSoaMatrix4 mat, VmathSoaPoint3 pnt ); - -/* - * Multiply two 4x4 matrices - */ -static inline VmathSoaMatrix4 vmathSoaM4Mul_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Multiply a 4x4 matrix by a 3x4 transformation matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MulT3_V( VmathSoaMatrix4 mat, VmathSoaTransform3 tfrm ); - -/* - * Construct an identity 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeIdentity_V( ); - -/* - * Construct a 4x4 matrix to rotate around the x axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the y axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the z axis - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 4x4 matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 4x4 matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 4x4 matrix to perform scaling - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Construct a 4x4 matrix to perform translation - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeTranslation_V( VmathSoaVector3 translateVec ); - -/* - * Construct viewing matrix based on eye position, position looked at, and up direction - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeLookAt_V( VmathSoaPoint3 eyePos, VmathSoaPoint3 lookAtPos, VmathSoaVector3 upVec ); - -/* - * Construct a perspective projection matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakePerspective_V( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct a perspective projection matrix based on frustum - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeFrustum_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Construct an orthographic projection matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4MakeOrthographic_V( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -/* - * Append (post-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix4 vmathSoaM4AppendScale_V( VmathSoaMatrix4 mat, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 4x4 matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaMatrix4 vmathSoaM4PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaMatrix4 mat ); - -/* - * Multiply two 4x4 matrices per element - */ -static inline VmathSoaMatrix4 vmathSoaM4MulPerElem_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1 ); - -/* - * Compute the absolute value of a 4x4 matrix per element - */ -static inline VmathSoaMatrix4 vmathSoaM4AbsPerElem_V( VmathSoaMatrix4 mat ); - -/* - * Transpose of a 4x4 matrix - */ -static inline VmathSoaMatrix4 vmathSoaM4Transpose_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix - * NOTE: - * Result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix4 vmathSoaM4Inverse_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. - */ -static inline VmathSoaMatrix4 vmathSoaM4AffineInverse_V( VmathSoaMatrix4 mat ); - -/* - * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. - */ -static inline VmathSoaMatrix4 vmathSoaM4OrthoInverse_V( VmathSoaMatrix4 mat ); - -/* - * Determinant of a 4x4 matrix - */ -static inline vec_float4 vmathSoaM4Determinant_V( VmathSoaMatrix4 mat ); - -/* - * Conditionally select between two 4x4 matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaMatrix4 vmathSoaM4Select_V( VmathSoaMatrix4 mat0, VmathSoaMatrix4 mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 4x4 matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Print_V( VmathSoaMatrix4 mat ); - -/* - * Print a 4x4 matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaM4Prints_V( VmathSoaMatrix4 mat, const char *name ); - -#endif - -/* - * Construct a 3x4 transformation matrix containing the specified columns - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromCols_V( VmathSoaVector3 col0, VmathSoaVector3 col1, VmathSoaVector3 col2, VmathSoaVector3 col3 ); - -/* - * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromM3V3_V( VmathSoaMatrix3 tfrm, VmathSoaVector3 translateVec ); - -/* - * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromQV3_V( VmathSoaQuat unitQuat, VmathSoaVector3 translateVec ); - -/* - * Set all elements of a 3x4 transformation matrix to the same scalar value - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromScalar_V( vec_float4 scalar ); - -/* - * Replicate an AoS 3x4 transformation matrix - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFromAos_V( VmathTransform3 tfrm ); - -/* - * Insert four AoS 3x4 transformation matrices - */ -static inline VmathSoaTransform3 vmathSoaT3MakeFrom4Aos_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, VmathTransform3 tfrm2, VmathTransform3 tfrm3 ); - -/* - * Extract four AoS 3x4 transformation matrices - */ -static inline void vmathSoaT3Get4Aos_V( VmathSoaTransform3 tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 ); - -/* - * Set the upper-left 3x3 submatrix - */ -static inline void vmathSoaT3SetUpper3x3_V( VmathSoaTransform3 *result, VmathSoaMatrix3 mat3 ); - -/* - * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - */ -static inline VmathSoaMatrix3 vmathSoaT3GetUpper3x3_V( VmathSoaTransform3 tfrm ); - -/* - * Set translation component - */ -static inline void vmathSoaT3SetTranslation_V( VmathSoaTransform3 *result, VmathSoaVector3 translateVec ); - -/* - * Get the translation component of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetTranslation_V( VmathSoaTransform3 tfrm ); - -/* - * Set column 0 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol0_V( VmathSoaTransform3 *result, VmathSoaVector3 col0 ); - -/* - * Set column 1 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol1_V( VmathSoaTransform3 *result, VmathSoaVector3 col1 ); - -/* - * Set column 2 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol2_V( VmathSoaTransform3 *result, VmathSoaVector3 col2 ); - -/* - * Set column 3 of a 3x4 transformation matrix - */ -static inline void vmathSoaT3SetCol3_V( VmathSoaTransform3 *result, VmathSoaVector3 col3 ); - -/* - * Get column 0 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol0_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 1 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol1_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 2 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol2_V( VmathSoaTransform3 tfrm ); - -/* - * Get column 3 of a 3x4 transformation matrix - */ -static inline VmathSoaVector3 vmathSoaT3GetCol3_V( VmathSoaTransform3 tfrm ); - -/* - * Set the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetCol_V( VmathSoaTransform3 *result, int col, VmathSoaVector3 vec ); - -/* - * Set the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline void vmathSoaT3SetRow_V( VmathSoaTransform3 *result, int row, VmathSoaVector4 vec ); - -/* - * Get the column of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathSoaVector3 vmathSoaT3GetCol_V( VmathSoaTransform3 tfrm, int col ); - -/* - * Get the row of a 3x4 transformation matrix referred to by the specified index - */ -static inline VmathSoaVector4 vmathSoaT3GetRow_V( VmathSoaTransform3 tfrm, int row ); - -/* - * Set the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline void vmathSoaT3SetElem_V( VmathSoaTransform3 *result, int col, int row, vec_float4 val ); - -/* - * Get the element of a 3x4 transformation matrix referred to by column and row indices - */ -static inline vec_float4 vmathSoaT3GetElem_V( VmathSoaTransform3 tfrm, int col, int row ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D vector - */ -static inline VmathSoaVector3 vmathSoaT3MulV3_V( VmathSoaTransform3 tfrm, VmathSoaVector3 vec ); - -/* - * Multiply a 3x4 transformation matrix by a 3-D point - */ -static inline VmathSoaPoint3 vmathSoaT3MulP3_V( VmathSoaTransform3 tfrm, VmathSoaPoint3 pnt ); - -/* - * Multiply two 3x4 transformation matrices - */ -static inline VmathSoaTransform3 vmathSoaT3Mul_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); - -/* - * Construct an identity 3x4 transformation matrix - */ -static inline VmathSoaTransform3 vmathSoaT3MakeIdentity_V( ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationX_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the y axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationY_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the z axis - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZ_V( vec_float4 radians ); - -/* - * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationZYX_V( VmathSoaVector3 radiansXYZ ); - -/* - * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationAxis_V( vec_float4 radians, VmathSoaVector3 unitVec ); - -/* - * Construct a rotation matrix from a unit-length quaternion - */ -static inline VmathSoaTransform3 vmathSoaT3MakeRotationQ_V( VmathSoaQuat unitQuat ); - -/* - * Construct a 3x4 transformation matrix to perform scaling - */ -static inline VmathSoaTransform3 vmathSoaT3MakeScale_V( VmathSoaVector3 scaleVec ); - -/* - * Construct a 3x4 transformation matrix to perform translation - */ -static inline VmathSoaTransform3 vmathSoaT3MakeTranslation_V( VmathSoaVector3 translateVec ); - -/* - * Append (post-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaTransform3 vmathSoaT3AppendScale_V( VmathSoaTransform3 tfrm, VmathSoaVector3 scaleVec ); - -/* - * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix - * NOTE: - * Faster than creating and multiplying a scale transformation matrix. - */ -static inline VmathSoaTransform3 vmathSoaT3PrependScale_V( VmathSoaVector3 scaleVec, VmathSoaTransform3 tfrm ); - -/* - * Multiply two 3x4 transformation matrices per element - */ -static inline VmathSoaTransform3 vmathSoaT3MulPerElem_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1 ); - -/* - * Compute the absolute value of a 3x4 transformation matrix per element - */ -static inline VmathSoaTransform3 vmathSoaT3AbsPerElem_V( VmathSoaTransform3 tfrm ); - -/* - * Inverse of a 3x4 transformation matrix - * NOTE: - * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. - */ -static inline VmathSoaTransform3 vmathSoaT3Inverse_V( VmathSoaTransform3 tfrm ); - -/* - * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix - * NOTE: - * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. - */ -static inline VmathSoaTransform3 vmathSoaT3OrthoInverse_V( VmathSoaTransform3 tfrm ); - -/* - * Conditionally select between two 3x4 transformation matrices - * NOTE: - * This function uses a conditional select instruction to avoid a branch. - */ -static inline VmathSoaTransform3 vmathSoaT3Select_V( VmathSoaTransform3 tfrm0, VmathSoaTransform3 tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -/* - * Print a 3x4 transformation matrix - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Print_V( VmathSoaTransform3 tfrm ); - -/* - * Print a 3x4 transformation matrix and an associated string identifier - * NOTE: - * Function is only defined when _VECTORMATH_DEBUG is defined. - */ -static inline void vmathSoaT3Prints_V( VmathSoaTransform3 tfrm, const char *name ); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#include "vectormath_soa.h" -#include "vec_soa_v.h" -#include "quat_soa_v.h" -#include "mat_soa_v.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h deleted file mode 100644 index 93a3ad29d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/boolInVec.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - 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 - -namespace Vectormath { - -class floatInVec; - -//-------------------------------------------------------------------------------------------------- -// boolInVec class -// - -class boolInVec -{ - private: - vec_uint4 mData; - - inline boolInVec(vec_uint4 vec); - public: - inline boolInVec() {} - - // matches standard type conversions - // - inline boolInVec(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 in the 0 word slot of vector as 0 (false) or -1 (true) - // - inline vec_uint4 get128() const; - - // operators - // - inline const boolInVec operator ! () const; - inline boolInVec& operator = (boolInVec vec); - inline boolInVec& operator &= (boolInVec vec); - inline boolInVec& operator ^= (boolInVec vec); - inline boolInVec& operator |= (boolInVec vec); - - // friend functions - // - friend inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); - friend inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); - friend inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); -}; - -//-------------------------------------------------------------------------------------------------- -// boolInVec functions -// - -// operators -// -inline const boolInVec operator == (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator != (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator & (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator ^ (boolInVec vec0, boolInVec vec1); -inline const boolInVec operator | (boolInVec vec0, boolInVec vec1); - -// select between vec0 and vec1 using boolInVec. -// false selects vec0, true selects vec1 -// -inline const boolInVec select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1); - -} // namespace Vectormath - -//-------------------------------------------------------------------------------------------------- -// boolInVec implementation -// - -#include "floatInVec.h" - -namespace Vectormath { - -inline -boolInVec::boolInVec(vec_uint4 vec) -{ - mData = vec; -} - -inline -boolInVec::boolInVec(floatInVec vec) -{ - *this = (vec != floatInVec(0.0f)); -} - -inline -boolInVec::boolInVec(bool scalar) -{ - mData = spu_promote((unsigned int)-scalar, 0); -} - -#ifdef _VECTORMATH_NO_SCALAR_CAST -inline -bool -boolInVec::getAsBool() const -#else -inline -boolInVec::operator bool() const -#endif -{ - return (bool)spu_extract(mData, 0); -} - -inline -vec_uint4 -boolInVec::get128() const -{ - return mData; -} - -inline -const boolInVec -boolInVec::operator ! () const -{ - return boolInVec(spu_nor(mData, 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(spu_cmpeq(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator != (boolInVec vec0, boolInVec vec1) -{ - return !(vec0 == vec1); -} - -inline -const boolInVec -operator & (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(spu_and(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator | (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(spu_or(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator ^ (boolInVec vec0, boolInVec vec1) -{ - return boolInVec(spu_xor(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -select(boolInVec vec0, boolInVec vec1, boolInVec select_vec1) -{ - return boolInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); -} - -} // namespace Vectormath - -#endif // boolInVec_h diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h deleted file mode 100644 index 7521c0c40..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/floatInVec.h +++ /dev/null @@ -1,339 +0,0 @@ -/* - 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 -#include -#include -#undef bool - -namespace Vectormath { - -class boolInVec; - -//-------------------------------------------------------------------------------------------------- -// floatInVec class -// - -class floatInVec -{ - private: - vec_float4 mData; - - inline floatInVec(vec_float4 vec); - public: - inline floatInVec() {} - - // matches standard type conversions - // - inline floatInVec(boolInVec vec); - - // construct from a slot of vec_float4 - // - inline floatInVec(vec_float4 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 in 0 word slot of vector - // - inline vec_float4 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 = (floatInVec vec); - inline floatInVec& operator *= (floatInVec vec); - inline floatInVec& operator /= (floatInVec vec); - inline floatInVec& operator += (floatInVec vec); - inline floatInVec& operator -= (floatInVec vec); - - // friend functions - // - friend inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); - friend inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); -}; - -//-------------------------------------------------------------------------------------------------- -// floatInVec functions -// - -// operators -// -inline const floatInVec operator * (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator / (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator + (floatInVec vec0, floatInVec vec1); -inline const floatInVec operator - (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator < (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator <= (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator > (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator >= (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator == (floatInVec vec0, floatInVec vec1); -inline const boolInVec operator != (floatInVec vec0, floatInVec vec1); - -// select between vec0 and vec1 using boolInVec. -// false selects vec0, true selects vec1 -// -inline const floatInVec select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1); - -} // namespace Vectormath - -//-------------------------------------------------------------------------------------------------- -// floatInVec implementation -// - -#include "boolInVec.h" - -namespace Vectormath { - -inline -floatInVec::floatInVec(vec_float4 vec) -{ - mData = vec; -} - -inline -floatInVec::floatInVec(boolInVec vec) -{ - mData = spu_sel(spu_splats(0.0f), spu_splats(1.0f), vec.get128()); -} - -inline -floatInVec::floatInVec(vec_float4 vec, int slot) -{ - mData = spu_promote(spu_extract(vec, slot), 0); -} - -inline -floatInVec::floatInVec(float scalar) -{ - mData = spu_promote(scalar, 0); -} - -#ifdef _VECTORMATH_NO_SCALAR_CAST -inline -float -floatInVec::getAsFloat() const -#else -inline -floatInVec::operator float() const -#endif -{ - return spu_extract(mData,0); -} - -inline -vec_float4 -floatInVec::get128() const -{ - return mData; -} - -inline -const floatInVec -floatInVec::operator ++ (int) -{ - vec_float4 olddata = mData; - operator ++(); - return floatInVec(olddata); -} - -inline -const floatInVec -floatInVec::operator -- (int) -{ - vec_float4 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((vec_float4)spu_xor((vec_uint4)mData, spu_splats(0x80000000))); -} - -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(spu_mul(vec0.get128(), vec1.get128())); -} - -inline -const floatInVec -operator / (floatInVec num, floatInVec den) -{ - return floatInVec(divf4(num.get128(), den.get128())); -} - -inline -const floatInVec -operator + (floatInVec vec0, floatInVec vec1) -{ - return floatInVec(spu_add(vec0.get128(), vec1.get128())); -} - -inline -const floatInVec -operator - (floatInVec vec0, floatInVec vec1) -{ - return floatInVec(spu_sub(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator < (floatInVec vec0, floatInVec vec1) -{ - return boolInVec(spu_cmpgt(vec1.get128(), vec0.get128())); -} - -inline -const boolInVec -operator <= (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 > vec1); -} - -inline -const boolInVec -operator > (floatInVec vec0, floatInVec vec1) -{ - return boolInVec(spu_cmpgt(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator >= (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 < vec1); -} - -inline -const boolInVec -operator == (floatInVec vec0, floatInVec vec1) -{ - return boolInVec(spu_cmpeq(vec0.get128(), vec1.get128())); -} - -inline -const boolInVec -operator != (floatInVec vec0, floatInVec vec1) -{ - return !(vec0 == vec1); -} - -inline -const floatInVec -select(floatInVec vec0, floatInVec vec1, boolInVec select_vec1) -{ - return floatInVec(spu_sel(vec0.get128(), vec1.get128(), select_vec1.get128())); -} - -} // namespace Vectormath - -#endif // floatInVec_h diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h deleted file mode 100644 index a2fd611ec..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_aos.h +++ /dev/null @@ -1,2027 +0,0 @@ -/* - 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_MAT_AOS_CPP_H -#define _VECTORMATH_MAT_AOS_CPP_H - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XYAB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZWCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_0ZB0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_C0X0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_YA00 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_YXWZ ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_Z }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCX ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X }) -#define _VECTORMATH_SHUF_YCXY ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y }) -#define _VECTORMATH_SHUF_CXYC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZAY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BZX0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_0ZYA ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A }) -#define _VECTORMATH_SHUF_Z0XB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YX0C ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_0, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_CZD0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_BBY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( Quat unitQuat ) -{ - vec_float4 xyzw_2, wwww, yzxw, zxyw, yzxw_2, zxyw_2; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_uint4 select_x = (vec_uint4)spu_maskb(0xf000); - vec_uint4 select_z = (vec_uint4)spu_maskb(0x00f0); - xyzw_2 = spu_add( unitQuat.get128(), unitQuat.get128() ); - wwww = spu_shuffle( unitQuat.get128(), unitQuat.get128(), shuffle_wwww ); - yzxw = spu_shuffle( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_SHUF_YZXW ); - zxyw = spu_shuffle( unitQuat.get128(), unitQuat.get128(), _VECTORMATH_SHUF_ZXYW ); - yzxw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_YZXW ); - zxyw_2 = spu_shuffle( xyzw_2, xyzw_2, _VECTORMATH_SHUF_ZXYW ); - tmp0 = spu_mul( yzxw_2, wwww ); - tmp1 = spu_nmsub( yzxw, yzxw_2, spu_splats(1.0f) ); - tmp2 = spu_mul( yzxw, xyzw_2 ); - tmp0 = spu_madd( zxyw, xyzw_2, tmp0 ); - tmp1 = spu_nmsub( zxyw, zxyw_2, tmp1 ); - tmp2 = spu_nmsub( zxyw_2, wwww, tmp2 ); - tmp3 = spu_sel( tmp0, tmp1, select_x ); - tmp4 = spu_sel( tmp1, tmp2, select_x ); - tmp5 = spu_sel( tmp2, tmp0, select_x ); - mCol0 = Vector3( spu_sel( tmp3, tmp2, select_z ) ); - mCol1 = Vector3( spu_sel( tmp4, tmp0, select_z ) ); - mCol2 = Vector3( spu_sel( tmp5, tmp1, select_z ) ); -} - -inline Matrix3::Matrix3( Vector3 _col0, Vector3 _col1, Vector3 _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3 & Matrix3::setCol0( Vector3 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( Vector3 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( Vector3 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, Vector3 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, Vector3 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline float Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, res0, res1, res2; - tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); - res0 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); - res1 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); - res2 = spu_shuffle( tmp1, mat.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet, inv0, inv1, inv2; - tmp2 = _vmathVfCross( mat.getCol0().get128(), mat.getCol1().get128() ); - tmp0 = _vmathVfCross( mat.getCol1().get128(), mat.getCol2().get128() ); - tmp1 = _vmathVfCross( mat.getCol2().get128(), mat.getCol0().get128() ); - dot = _vmathVfDot3( tmp2, mat.getCol2().get128() ); - dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); - invdet = recipf4( dot ); - tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); - tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); - inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); - inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); - inv0 = spu_mul( inv0, invdet ); - inv1 = spu_mul( inv1, invdet ); - inv2 = spu_mul( inv2, invdet ); - return Matrix3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ) - ); -} - -inline float determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( float scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); - res = spu_mul( mCol0.get128(), xxxx ); - res = spu_madd( mCol1.get128(), yyyy, res ); - res = spu_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - return Matrix3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 Matrix3::rotationY( float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - return Matrix3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ.get128(); - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - return Matrix3( - Vector3( spu_mul( Z0, Y0 ) ), - Vector3( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), - Vector3( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( float radians, Vector3 unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - axis = unitVec.get128(); - sincosf4( spu_splats( radians ), &s, &c ); - xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); - yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); - zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - axisS = spu_mul( axis, s ); - negAxisS = negatef4( axisS ); - tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); - tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); - tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); - tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); - tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); - tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); - return Matrix3( - Vector3( spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector3( spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector3( spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( Quat unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( Vector3 scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - return Matrix3( - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( float scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( mat.getCol3(), 1.0f ); -} - -inline Matrix4::Matrix4( Vector4 _col0, Vector4 _col1, Vector4 _col2, Vector4 _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, Vector3 translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4::Matrix4( Quat unitQuat, Vector3 translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), 0.0f ); - mCol1 = Vector4( mat.getCol1(), 0.0f ); - mCol2 = Vector4( mat.getCol2(), 0.0f ); - mCol3 = Vector4( translateVec, 1.0f ); -} - -inline Matrix4 & Matrix4::setCol0( Vector4 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( Vector4 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( Vector4 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( Vector4 _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, Vector4 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, Vector4 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline float Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, res0, res1, res2, res3; - tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat.getCol1().get128(), mat.getCol3().get128(), _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( mat.getCol1().get128(), mat.getCol3().get128(), _VECTORMATH_SHUF_ZCWD ); - res0 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - res1 = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - res2 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - res3 = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4( res2 ), - Vector4( res3 ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 in0, in1, in2, in3; - vec_float4 tmp0, tmp1, tmp2, tmp3; - vec_float4 cof0, cof1, cof2, cof3; - vec_float4 t0, t1, t2, t3; - vec_float4 t01, t02, t03, t12, t23; - vec_float4 t1r, t2r; - vec_float4 t01r, t02r, t03r, t12r, t23r; - vec_float4 t1r3, t1r3r; - vec_float4 det, det1, det2, det3, invdet; - in0 = mat.getCol0().get128(); - in1 = mat.getCol1().get128(); - in2 = mat.getCol2().get128(); - in3 = mat.getCol3().get128(); - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ - tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ - tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ - tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ - t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ - t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ - t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ - t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = spu_mul(t2, t3); /* CL GP KD OH */ - t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ - cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ - cof1 = spu_mul(t0, t23); /* AGP ECL IOH MKD */ - t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ - cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ - cof1 = spu_msub(t0, t23r, cof1); /* AOH EKD IGP MCL - cof1 */ - cof1 = spu_rlqwbyte(cof1, 8); /* IGP MCL AOH EKD - IOH MKD AGP ECL */ - - t12 = spu_mul(t1, t2); /* JC NG BK FO */ - t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ - cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - cof3 = spu_mul(t0, t12); /* ANG EJC IFO MBK */ - t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ - cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - cof3 = spu_msub(t0, t12r, cof3); /* AFO EBK ING MJC - cof3 */ - cof3 = spu_rlqwbyte(cof3, 8); /* ING MJC AFO EBK - IFO MBK ANG EJC */ - t1r = spu_rlqwbyte(t1, 8); /* B F J N */ - t2r = spu_rlqwbyte(t2, 8); /* K O C G */ - t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ - t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ - cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - cof2 = spu_mul(t0, t1r3); /* AFP EBL INH MJD */ - t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ - cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - cof2 = spu_msub(t0, t1r3r, cof2); /* ANH EJD IFP MBL - cof2 */ - cof2 = spu_rlqwbyte(cof2, 8); /* IFP MBL ANH EJD - INH MJD AFP EBL */ - t01 = spu_mul(t0, t1); /* AJ EN IB MF */ - t01 = spu_shuffle(t01, t01, _VECTORMATH_SHUF_YXWZ); /* EN AJ MF IB */ - cof2 = spu_madd(t3, t01, cof2); /* LEN PAJ DMF HIB + cof2 */ - cof3 = spu_msub(t2r, t01, cof3); /* KEN OAJ CMF GIB - cof3 */ - t01r = spu_rlqwbyte(t01, 8); /* MF IB EN AJ */ - cof2 = spu_msub(t3, t01r, cof2); /* LMF PIB DEN HAJ - cof2 */ - cof3 = spu_nmsub(t2r, t01r, cof3); /* cof3 - KMF OIB CEN GAJ */ - t03 = spu_mul(t0, t3); /* AL EP ID MH */ - t03 = spu_shuffle(t03, t03, _VECTORMATH_SHUF_YXWZ); /* EP AL MH ID */ - cof1 = spu_nmsub(t2r, t03, cof1); /* cof1 - KEP OAL CMH GID */ - cof2 = spu_madd(t1, t03, cof2); /* JEP NAL BMH FID + cof2 */ - t03r = spu_rlqwbyte(t03, 8); /* MH ID EP AL */ - cof1 = spu_madd(t2r, t03r, cof1); /* KMH OID CEP GAL + cof1 */ - cof2 = spu_nmsub(t1, t03r, cof2); /* cof2 - JMH NID BEP FAL */ - t02 = spu_mul(t0, t2r); /* AK EO IC MG */ - t02 = spu_shuffle(t02, t02, _VECTORMATH_SHUF_YXWZ); /* E0 AK MG IC */ - cof1 = spu_madd(t3, t02, cof1); /* LEO PAK DMG HIC + cof1 */ - cof3 = spu_nmsub(t1, t02, cof3); /* cof3 - JEO NAK BMG FIC */ - t02r = spu_rlqwbyte(t02, 8); /* MG IC EO AK */ - cof1 = spu_nmsub(t3, t02r, cof1); /* cof1 - LMG PIC DEO HAK */ - cof3 = spu_madd(t1, t02r, cof3); /* JMG NIC BEO FAK + cof3 */ - /* Compute the determinant of the matrix - * - * det = sum_across(t0 * cof0); - * - * We perform a sum across the entire vector so that - * we don't have to splat the result when multiplying the - * cofactors by the inverse of the determinant. - */ - det = spu_mul(t0, cof0); - det1 = spu_rlqwbyte(det, 4); - det2 = spu_rlqwbyte(det, 8); - det3 = spu_rlqwbyte(det, 12); - det = spu_add(det, det1); - det2 = spu_add(det2, det3); - det = spu_add(det, det2); - /* Compute the reciprocal of the determinant. - */ - invdet = recipf4(det); - /* Multiply the cofactors by the reciprocal of the determinant. - */ - return Matrix4( - Vector4( spu_mul(cof0, invdet) ), - Vector4( spu_mul(cof1, invdet) ), - Vector4( spu_mul(cof2, invdet) ), - Vector4( spu_mul(cof3, invdet) ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline float determinant( const Matrix4 & mat ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 in0, in1, in2, in3; - vec_float4 tmp0, tmp1, tmp2, tmp3; - vec_float4 cof0; - vec_float4 t0, t1, t2, t3; - vec_float4 t12, t23; - vec_float4 t1r, t2r; - vec_float4 t12r, t23r; - vec_float4 t1r3, t1r3r; - in0 = mat.getCol0().get128(); - in1 = mat.getCol1().get128(); - in2 = mat.getCol2().get128(); - in3 = mat.getCol3().get128(); - /* Perform transform of the input matrix of the form: - * A B C D - * E F G H - * I J K L - * M N O P - * - * The pseudo transpose of the input matrix is trans: - * A E I M - * J N B F - * C G K O - * L P D H - */ - tmp0 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_XAZC); /* A E C G */ - tmp1 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_XAZC); /* I M K O */ - tmp2 = spu_shuffle(in0, in1, _VECTORMATH_SHUF_YBWD); /* B F D H */ - tmp3 = spu_shuffle(in2, in3, _VECTORMATH_SHUF_YBWD); /* J N L P */ - t0 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_XYAB); /* A E I M */ - t1 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_XYAB); /* J N B F */ - t2 = spu_shuffle(tmp0, tmp1, _VECTORMATH_SHUF_ZWCD); /* C G K O */ - t3 = spu_shuffle(tmp3, tmp2, _VECTORMATH_SHUF_ZWCD); /* L P D H */ - /* Generate a cofactor matrix. The computed cofactors reside in - * cof0, cof1, cof2, cof3. - */ - t23 = spu_mul(t2, t3); /* CL GP KD OH */ - t23 = spu_shuffle(t23, t23, _VECTORMATH_SHUF_YXWZ); /* GP CL OH KD */ - cof0 = spu_mul(t1, t23); /* JGP NCL BOH FKD */ - t23r = spu_rlqwbyte(t23, 8); /* OH KD GP CL */ - cof0 = spu_msub(t1, t23r, cof0); /* JOH NKD BGP FCL - cof0 */ - - t12 = spu_mul(t1, t2); /* JC NG BK FO */ - t12 = spu_shuffle(t12, t12, _VECTORMATH_SHUF_YXWZ); /* NG JC FO BK */ - cof0 = spu_madd(t3, t12, cof0); /* LNG PJC DFO HBK + cof0 */ - t12r = spu_rlqwbyte(t12, 8); /* FO BK NG JC */ - cof0 = spu_nmsub(t3, t12r, cof0); /* cof0 - LFO PBK DNG HJC */ - t1r = spu_rlqwbyte(t1, 8); /* B F J N */ - t2r = spu_rlqwbyte(t2, 8); /* K O C G */ - t1r3 = spu_mul(t1r, t3); /* BL FP JD NH */ - t1r3 = spu_shuffle(t1r3, t1r3, _VECTORMATH_SHUF_YXWZ); /* FP BL NH JD */ - cof0 = spu_madd(t2r, t1r3, cof0); /* KFP OBL CNH GJD + cof0 */ - t1r3r = spu_rlqwbyte(t1r3, 8); /* NH JD FP BL */ - cof0 = spu_nmsub(t2r, t1r3r, cof0); /* cof0 - KNH OJD CFP GBL */ - return spu_extract( _vmathVfDot4(t0,cof0), 0 ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( float scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( Vector4 vec ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz, wwww; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); - wwww = spu_shuffle( vec.get128(), vec.get128(), shuffle_wwww ); - tmp0 = spu_mul( mCol0.get128(), xxxx ); - tmp1 = spu_mul( mCol1.get128(), yyyy ); - tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = spu_madd( mCol3.get128(), wwww, tmp1 ); - res = spu_add( tmp0, tmp1 ); - return Vector4( res ); -} - -inline const Vector4 Matrix4::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); - res = spu_mul( mCol0.get128(), xxxx ); - res = spu_madd( mCol1.get128(), yyyy, res ); - res = spu_madd( mCol2.get128(), zzzz, res ); - return Vector4( res ); -} - -inline const Vector4 Matrix4::operator *( Point3 pnt ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_zzzz ); - tmp0 = spu_mul( mCol0.get128(), xxxx ); - tmp1 = spu_mul( mCol1.get128(), yyyy ); - tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = spu_add( mCol3.get128(), tmp1 ); - res = spu_add( tmp0, tmp1 ); - return Vector4( res ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( Vector3 translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - return Matrix4( - Vector4::xAxis( ), - Vector4( res1 ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - return Matrix4( - Vector4( res0 ), - Vector4::yAxis( ), - Vector4( res2 ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - return Matrix4( - Vector4( res0 ), - Vector4( res1 ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ.get128(); - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - return Matrix4( - Vector4( spu_mul( Z0, Y0 ) ), - Vector4( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), - Vector4( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( float radians, Vector3 unitVec ) -{ - vec_float4 axis, s, c, oneMinusC, axisS, negAxisS, xxxx, yyyy, zzzz, tmp0, tmp1, tmp2, zeroW; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - axis = unitVec.get128(); - sincosf4( spu_splats( radians ), &s, &c ); - xxxx = spu_shuffle( axis, axis, shuffle_xxxx ); - yyyy = spu_shuffle( axis, axis, shuffle_yyyy ); - zzzz = spu_shuffle( axis, axis, shuffle_zzzz ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - axisS = spu_mul( axis, s ); - negAxisS = negatef4( axisS ); - tmp0 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_0ZB0 ); - tmp1 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_C0X0 ); - tmp2 = spu_shuffle( axisS, negAxisS, _VECTORMATH_SHUF_YA00 ); - tmp0 = spu_sel( tmp0, c, (vec_uint4)spu_maskb(0xf000) ); - tmp1 = spu_sel( tmp1, c, (vec_uint4)spu_maskb(0x0f00) ); - tmp2 = spu_sel( tmp2, c, (vec_uint4)spu_maskb(0x00f0) ); - zeroW = (vec_float4)spu_maskb(0x000f); - axis = spu_andc( axis, zeroW ); - return Matrix4( - Vector4( spu_madd( spu_mul( axis, xxxx ), oneMinusC, tmp0 ) ), - Vector4( spu_madd( spu_mul( axis, yyyy ), oneMinusC, tmp1 ) ), - Vector4( spu_madd( spu_mul( axis, zzzz ), oneMinusC, tmp2 ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( Quat unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( Vector3 scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - return Matrix4( - Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), - Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), - Vector4( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, 1.0f ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( Vector3 translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, 1.0f ) - ); -} - -inline const Matrix4 Matrix4::lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( float fovyRadians, float aspect, float zNear, float zFar ) -{ - float f, rangeInv; - vec_float4 zero, col0, col1, col2, col3; - f = tanf( _VECTORMATH_PI_OVER_2 - fovyRadians * 0.5f ); - rangeInv = 1.0f / ( zNear - zFar ); - zero = spu_splats(0.0f); - col0 = zero; - col1 = zero; - col2 = zero; - col3 = zero; - col0 = spu_insert( f / aspect, col0, 0 ); - col1 = spu_insert( f, col1, 1 ); - col2 = spu_insert( ( zNear + zFar ) * rangeInv, col2, 2 ); - col2 = spu_insert( -1.0f, col2, 3 ); - col3 = spu_insert( zNear * zFar * rangeInv * 2.0f, col3, 2 ); - return Matrix4( - Vector4( col0 ), - Vector4( col1 ), - Vector4( col2 ), - Vector4( col3 ) - ); -} - -inline const Matrix4 Matrix4::frustum( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff; - vec_float4 diagonal, column, near2; - vec_float4 zero = spu_splats(0.0f); - lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); - lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); - diff = spu_sub( rtn, lbf ); - sum = spu_add( rtn, lbf ); - inv_diff = recipf4( diff ); - near2 = spu_splats( zNear ); - near2 = spu_add( near2, near2 ); - diagonal = spu_mul( near2, inv_diff ); - column = spu_mul( sum, inv_diff ); - return Matrix4( - Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ) ), - Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ) ), - Vector4( spu_sel( column, spu_splats(-1.0f), (vec_uint4)spu_maskb(0x000f) ) ), - Vector4( spu_sel( zero, spu_mul( diagonal, spu_splats(zFar) ), (vec_uint4)spu_maskb(0x00f0) ) ) - ); -} - -inline const Matrix4 Matrix4::orthographic( float left, float right, float bottom, float top, float zNear, float zFar ) -{ - /* function implementation based on code from STIDC SDK: */ - /* -------------------------------------------------------------- */ - /* PLEASE DO NOT MODIFY THIS SECTION */ - /* This prolog section is automatically generated. */ - /* */ - /* (C)Copyright */ - /* Sony Computer Entertainment, Inc., */ - /* Toshiba Corporation, */ - /* International Business Machines Corporation, */ - /* 2001,2002. */ - /* S/T/I Confidential Information */ - /* -------------------------------------------------------------- */ - vec_float4 lbf, rtn; - vec_float4 diff, sum, inv_diff, neg_inv_diff; - vec_float4 diagonal, column; - vec_float4 zero = spu_splats(0.0f); - lbf = spu_shuffle( spu_promote(left,0), spu_promote(zFar,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( spu_promote(right,0), spu_promote(zNear,0), _VECTORMATH_SHUF_XAYB ); - lbf = spu_shuffle( lbf, spu_promote(bottom,0), _VECTORMATH_SHUF_XAYB ); - rtn = spu_shuffle( rtn, spu_promote(top,0), _VECTORMATH_SHUF_XAYB ); - diff = spu_sub( rtn, lbf ); - sum = spu_add( rtn, lbf ); - inv_diff = recipf4( diff ); - neg_inv_diff = negatef4( inv_diff ); - diagonal = spu_add( inv_diff, inv_diff ); - column = spu_mul( sum, spu_sel( neg_inv_diff, inv_diff, (vec_uint4)spu_maskb(0x00f0) ) ); - return Matrix4( - Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0xf000) ) ), - Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x0f00) ) ), - Vector4( spu_sel( zero, diagonal, (vec_uint4)spu_maskb(0x00f0) ) ), - Vector4( spu_sel( column, spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ) ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - print( mat.getRow( 0 ) ); - print( mat.getRow( 1 ) ); - print( mat.getRow( 2 ) ); - print( mat.getRow( 3 ) ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( float scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( Vector3 _col0, Vector3 _col1, Vector3 _col2, Vector3 _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, Vector3 translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( Quat unitQuat, Vector3 translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3 & Transform3::setCol0( Vector3 _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( Vector3 _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( Vector3 _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( Vector3 _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, Vector3 vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, Vector4 vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, float val ) -{ - (*this)[col].setElem(row, val); - return *this; -} - -inline float Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1, tmp2, tmp3, tmp4, dot, invdet; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp2 = _vmathVfCross( tfrm.getCol0().get128(), tfrm.getCol1().get128() ); - tmp0 = _vmathVfCross( tfrm.getCol1().get128(), tfrm.getCol2().get128() ); - tmp1 = _vmathVfCross( tfrm.getCol2().get128(), tfrm.getCol0().get128() ); - inv3 = negatef4( tfrm.getCol3().get128() ); - dot = _vmathVfDot3( tmp2, tfrm.getCol2().get128() ); - dot = spu_shuffle( dot, dot, shuffle_xxxx ); - invdet = recipf4( dot ); - tmp3 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_XAYB ); - tmp4 = spu_shuffle( tmp0, tmp2, _VECTORMATH_SHUF_ZCWD ); - inv0 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_XAYB ); - xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); - inv1 = spu_shuffle( tmp3, tmp1, _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp4, tmp1, _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); - zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); - inv3 = spu_mul( inv0, xxxx ); - inv3 = spu_madd( inv1, yyyy, inv3 ); - inv3 = spu_madd( inv2, zzzz, inv3 ); - inv0 = spu_mul( inv0, invdet ); - inv1 = spu_mul( inv1, invdet ); - inv2 = spu_mul( inv2, invdet ); - inv3 = spu_mul( inv3, invdet ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - vec_float4 inv0, inv1, inv2, inv3; - vec_float4 tmp0, tmp1; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp0 = spu_shuffle( tfrm.getCol0().get128(), tfrm.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( tfrm.getCol0().get128(), tfrm.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); - inv3 = negatef4( tfrm.getCol3().get128() ); - inv0 = spu_shuffle( tmp0, tfrm.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); - xxxx = spu_shuffle( inv3, inv3, shuffle_xxxx ); - inv1 = spu_shuffle( tmp0, tfrm.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); - inv2 = spu_shuffle( tmp1, tfrm.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( inv3, inv3, shuffle_yyyy ); - zzzz = spu_shuffle( inv3, inv3, shuffle_zzzz ); - inv3 = spu_mul( inv0, xxxx ); - inv3 = spu_madd( inv1, yyyy, inv3 ); - inv3 = spu_madd( inv2, zzzz, inv3 ); - return Transform3( - Vector3( inv0 ), - Vector3( inv1 ), - Vector3( inv2 ), - Vector3( inv3 ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( Vector3 vec ) const -{ - vec_float4 res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); - res = spu_mul( mCol0.get128(), xxxx ); - res = spu_madd( mCol1.get128(), yyyy, res ); - res = spu_madd( mCol2.get128(), zzzz, res ); - return Vector3( res ); -} - -inline const Point3 Transform3::operator *( Point3 pnt ) const -{ - vec_float4 tmp0, tmp1, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - xxxx = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_xxxx ); - yyyy = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_yyyy ); - zzzz = spu_shuffle( pnt.get128(), pnt.get128(), shuffle_zzzz ); - tmp0 = spu_mul( mCol0.get128(), xxxx ); - tmp1 = spu_mul( mCol1.get128(), yyyy ); - tmp0 = spu_madd( mCol2.get128(), zzzz, tmp0 ); - tmp1 = spu_add( mCol3.get128(), tmp1 ); - res = spu_add( tmp0, tmp1 ); - return Point3( res ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( Vector3 translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( float radians ) -{ - vec_float4 s, c, res1, res2; - vec_uint4 select_y, select_z; - vec_float4 zero; - select_y = (vec_uint4)spu_maskb(0x0f00); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res1 = spu_sel( zero, c, select_y ); - res1 = spu_sel( res1, s, select_z ); - res2 = spu_sel( zero, negatef4(s), select_y ); - res2 = spu_sel( res2, c, select_z ); - return Transform3( - Vector3::xAxis( ), - Vector3( res1 ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationY( float radians ) -{ - vec_float4 s, c, res0, res2; - vec_uint4 select_x, select_z; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_z = (vec_uint4)spu_maskb(0x00f0); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, negatef4(s), select_z ); - res2 = spu_sel( zero, s, select_x ); - res2 = spu_sel( res2, c, select_z ); - return Transform3( - Vector3( res0 ), - Vector3::yAxis( ), - Vector3( res2 ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZ( float radians ) -{ - vec_float4 s, c, res0, res1; - vec_uint4 select_x, select_y; - vec_float4 zero; - select_x = (vec_uint4)spu_maskb(0xf000); - select_y = (vec_uint4)spu_maskb(0x0f00); - zero = spu_splats(0.0f); - sincosf4( spu_splats(radians), &s, &c ); - res0 = spu_sel( zero, c, select_x ); - res0 = spu_sel( res0, s, select_y ); - res1 = spu_sel( zero, negatef4(s), select_x ); - res1 = spu_sel( res1, c, select_y ); - return Transform3( - Vector3( res0 ), - Vector3( res1 ), - Vector3::zAxis( ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotationZYX( Vector3 radiansXYZ ) -{ - vec_float4 angles, s, negS, c, X0, X1, Y0, Y1, Z0, Z1, tmp; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - angles = radiansXYZ.get128(); - angles = spu_insert( 0.0f, angles, 3 ); - sincosf4( angles, &s, &c ); - negS = negatef4( s ); - Z0 = spu_shuffle( s, c, _VECTORMATH_SHUF_CZD0 ); - Z1 = spu_shuffle( c, negS, _VECTORMATH_SHUF_CZD0 ); - Y0 = spu_shuffle( negS, c, _VECTORMATH_SHUF_BBY0 ); - Y1 = spu_shuffle( c, s, _VECTORMATH_SHUF_BBY0 ); - X0 = spu_shuffle( s, s, shuffle_xxxx ); - X1 = spu_shuffle( c, c, shuffle_xxxx ); - tmp = spu_mul( Z0, Y1 ); - return Transform3( - Vector3( spu_mul( Z0, Y0 ) ), - Vector3( spu_madd( Z1, X1, spu_mul( tmp, X0 ) ) ), - Vector3( spu_nmsub( Z1, X0, spu_mul( tmp, X1 ) ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 Transform3::rotation( float radians, Vector3 unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::rotation( Quat unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( 0.0f ) ); -} - -inline const Transform3 Transform3::scale( Vector3 scaleVec ) -{ - vec_float4 zero = spu_splats(0.0f); - return Transform3( - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0xf000) ) ), - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x0f00) ) ), - Vector3( spu_sel( zero, scaleVec.get128(), (vec_uint4)spu_maskb(0x00f0) ) ), - Vector3( 0.0f ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( Vector3 translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - print( tfrm.getRow( 0 ) ); - print( tfrm.getRow( 1 ) ); - print( tfrm.getRow( 2 ) ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - vec_float4 res; - vec_float4 col0, col1, col2; - vec_float4 xx_yy, xx_yy_zz_xx, yy_zz_xx_yy, zz_xx_yy_zz, diagSum, diagDiff; - vec_float4 zy_xz_yx, yz_zx_xy, sum, diff; - vec_float4 radicand, invSqrt, scale; - vec_float4 res0, res1, res2, res3; - vec_float4 xx, yy, zz; - vec_uint4 select_x = (vec_uint4)spu_maskb( 0xf000 ); - vec_uint4 select_y = (vec_uint4)spu_maskb( 0x0f00 ); - vec_uint4 select_z = (vec_uint4)spu_maskb( 0x00f0 ); - vec_uint4 select_w = (vec_uint4)spu_maskb( 0x000f ); - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((unsigned int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((unsigned int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((unsigned int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((unsigned int)0x0c0d0e0f); - - col0 = tfrm.getCol0().get128(); - col1 = tfrm.getCol1().get128(); - col2 = tfrm.getCol2().get128(); - - /* four cases: */ - /* trace > 0 */ - /* else */ - /* xx largest diagonal element */ - /* yy largest diagonal element */ - /* zz largest diagonal element */ - - /* compute quaternion for each case */ - - xx_yy = spu_sel( col0, col1, select_y ); - xx_yy_zz_xx = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_XYCX ); - yy_zz_xx_yy = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_YCXY ); - zz_xx_yy_zz = spu_shuffle( xx_yy, col2, _VECTORMATH_SHUF_CXYC ); - - diagSum = spu_add( spu_add( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - diagDiff = spu_sub( spu_sub( xx_yy_zz_xx, yy_zz_xx_yy ), zz_xx_yy_zz ); - radicand = spu_add( spu_sel( diagDiff, diagSum, select_w ), spu_splats(1.0f) ); - invSqrt = rsqrtf4( radicand ); - - zy_xz_yx = spu_sel( col0, col1, select_z ); - zy_xz_yx = spu_shuffle( zy_xz_yx, col2, _VECTORMATH_SHUF_ZAY0 ); - yz_zx_xy = spu_sel( col0, col1, select_x ); - yz_zx_xy = spu_shuffle( yz_zx_xy, col2, _VECTORMATH_SHUF_BZX0 ); - - sum = spu_add( zy_xz_yx, yz_zx_xy ); - diff = spu_sub( zy_xz_yx, yz_zx_xy ); - - scale = spu_mul( invSqrt, spu_splats(0.5f) ); - res0 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_0ZYA ); - res1 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_Z0XB ); - res2 = spu_shuffle( sum, diff, _VECTORMATH_SHUF_YX0C ); - res3 = diff; - res0 = spu_sel( res0, radicand, select_x ); - res1 = spu_sel( res1, radicand, select_y ); - res2 = spu_sel( res2, radicand, select_z ); - res3 = spu_sel( res3, radicand, select_w ); - res0 = spu_mul( res0, spu_shuffle( scale, scale, shuffle_xxxx ) ); - res1 = spu_mul( res1, spu_shuffle( scale, scale, shuffle_yyyy ) ); - res2 = spu_mul( res2, spu_shuffle( scale, scale, shuffle_zzzz ) ); - res3 = spu_mul( res3, spu_shuffle( scale, scale, shuffle_wwww ) ); - - /* determine case and select answer */ - - xx = spu_shuffle( col0, col0, shuffle_xxxx ); - yy = spu_shuffle( col1, col1, shuffle_yyyy ); - zz = spu_shuffle( col2, col2, shuffle_zzzz ); - res = spu_sel( res0, res1, spu_cmpgt( yy, xx ) ); - res = spu_sel( res, res2, spu_and( spu_cmpgt( zz, xx ), spu_cmpgt( zz, yy ) ) ); - res = spu_sel( res, res3, spu_cmpgt( spu_shuffle( diagSum, diagSum, shuffle_xxxx ), spu_splats(0.0f) ) ); - mVec128 = res; -} - -inline const Matrix3 outer( Vector3 tfrm0, Vector3 tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( Vector4 tfrm0, Vector4 tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ) -{ - vec_float4 tmp0, tmp1, mcol0, mcol1, mcol2, res; - vec_float4 xxxx, yyyy, zzzz; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - tmp0 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mat.getCol0().get128(), mat.getCol2().get128(), _VECTORMATH_SHUF_ZCWD ); - xxxx = spu_shuffle( vec.get128(), vec.get128(), shuffle_xxxx ); - mcol0 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_XAYB ); - mcol1 = spu_shuffle( tmp0, mat.getCol1().get128(), _VECTORMATH_SHUF_ZBW0 ); - mcol2 = spu_shuffle( tmp1, mat.getCol1().get128(), _VECTORMATH_SHUF_XCY0 ); - yyyy = spu_shuffle( vec.get128(), vec.get128(), shuffle_yyyy ); - res = spu_mul( mcol0, xxxx ); - zzzz = spu_shuffle( vec.get128(), vec.get128(), shuffle_zzzz ); - res = spu_madd( mcol1, yyyy, res ); - res = spu_madd( mcol2, zzzz, res ); - return Vector3( res ); -} - -inline const Matrix3 crossMatrix( Vector3 vec ) -{ - vec_float4 neg, res0, res1, res2; - neg = negatef4( vec.get128() ); - res0 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_0ZB0 ); - res1 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_C0X0 ); - res2 = spu_shuffle( vec.get128(), neg, _VECTORMATH_SHUF_YA00 ); - return Matrix3( - Vector3( res0 ), - Vector3( res1 ), - Vector3( res2 ) - ); -} - -inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h deleted file mode 100644 index 8c884d593..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/mat_soa.h +++ /dev/null @@ -1,1744 +0,0 @@ -/* - 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_MAT_SOA_CPP_H -#define _VECTORMATH_MAT_SOA_CPP_H - -namespace Vectormath { -namespace Soa { - -//----------------------------------------------------------------------------- -// Constants - -#define _VECTORMATH_PI_OVER_2 1.570796327f - -//----------------------------------------------------------------------------- -// Definitions - -inline Matrix3::Matrix3( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; -} - -inline Matrix3::Matrix3( vec_float4 scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); -} - -inline Matrix3::Matrix3( const Quat & unitQuat ) -{ - vec_float4 qx, qy, qz, qw, qx2, qy2, qz2, qxqx2, qyqy2, qzqz2, qxqy2, qyqz2, qzqw2, qxqz2, qyqw2, qxqw2; - qx = unitQuat.getX(); - qy = unitQuat.getY(); - qz = unitQuat.getZ(); - qw = unitQuat.getW(); - qx2 = spu_add( qx, qx ); - qy2 = spu_add( qy, qy ); - qz2 = spu_add( qz, qz ); - qxqx2 = spu_mul( qx, qx2 ); - qxqy2 = spu_mul( qx, qy2 ); - qxqz2 = spu_mul( qx, qz2 ); - qxqw2 = spu_mul( qw, qx2 ); - qyqy2 = spu_mul( qy, qy2 ); - qyqz2 = spu_mul( qy, qz2 ); - qyqw2 = spu_mul( qw, qy2 ); - qzqz2 = spu_mul( qz, qz2 ); - qzqw2 = spu_mul( qw, qz2 ); - mCol0 = Vector3( spu_sub( spu_sub( spu_splats(1.0f), qyqy2 ), qzqz2 ), spu_add( qxqy2, qzqw2 ), spu_sub( qxqz2, qyqw2 ) ); - mCol1 = Vector3( spu_sub( qxqy2, qzqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qzqz2 ), spu_add( qyqz2, qxqw2 ) ); - mCol2 = Vector3( spu_add( qxqz2, qyqw2 ), spu_sub( qyqz2, qxqw2 ), spu_sub( spu_sub( spu_splats(1.0f), qxqx2 ), qyqy2 ) ); -} - -inline Matrix3::Matrix3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; -} - -inline Matrix3::Matrix3( const Aos::Matrix3 & mat ) -{ - mCol0 = Vector3( mat.getCol0() ); - mCol1 = Vector3( mat.getCol1() ); - mCol2 = Vector3( mat.getCol2() ); -} - -inline Matrix3::Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ) -{ - mCol0 = Vector3( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); - mCol1 = Vector3( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); - mCol2 = Vector3( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); -} - -inline void Matrix3::get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const -{ - Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol0( tmpV3_0 ); - result1.setCol0( tmpV3_1 ); - result2.setCol0( tmpV3_2 ); - result3.setCol0( tmpV3_3 ); - mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol1( tmpV3_0 ); - result1.setCol1( tmpV3_1 ); - result2.setCol1( tmpV3_2 ); - result3.setCol1( tmpV3_3 ); - mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol2( tmpV3_0 ); - result1.setCol2( tmpV3_1 ); - result2.setCol2( tmpV3_2 ); - result3.setCol2( tmpV3_3 ); -} - -inline Matrix3 & Matrix3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix3 & Matrix3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix3 & Matrix3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix3 & Matrix3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix3 & Matrix3::setRow( int row, const Vector3 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - return *this; -} - -inline Matrix3 & Matrix3::setElem( int col, int row, vec_float4 val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Matrix3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Matrix3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Matrix3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Matrix3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Matrix3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::getRow( int row ) const -{ - return Vector3( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ) ); -} - -inline Vector3 & Matrix3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Matrix3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix3 & Matrix3::operator =( const Matrix3 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - return *this; -} - -inline const Matrix3 transpose( const Matrix3 & mat ) -{ - return Matrix3( - Vector3( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX() ), - Vector3( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY() ), - Vector3( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ() ) - ); -} - -inline const Matrix3 inverse( const Matrix3 & mat ) -{ - Vector3 tmp0, tmp1, tmp2; - vec_float4 detinv; - tmp0 = cross( mat.getCol1(), mat.getCol2() ); - tmp1 = cross( mat.getCol2(), mat.getCol0() ); - tmp2 = cross( mat.getCol0(), mat.getCol1() ); - detinv = recipf4( dot( mat.getCol2(), tmp2 ) ); - return Matrix3( - Vector3( spu_mul( tmp0.getX(), detinv ), spu_mul( tmp1.getX(), detinv ), spu_mul( tmp2.getX(), detinv ) ), - Vector3( spu_mul( tmp0.getY(), detinv ), spu_mul( tmp1.getY(), detinv ), spu_mul( tmp2.getY(), detinv ) ), - Vector3( spu_mul( tmp0.getZ(), detinv ), spu_mul( tmp1.getZ(), detinv ), spu_mul( tmp2.getZ(), detinv ) ) - ); -} - -inline vec_float4 determinant( const Matrix3 & mat ) -{ - return dot( mat.getCol2(), cross( mat.getCol0(), mat.getCol1() ) ); -} - -inline const Matrix3 Matrix3::operator +( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ) - ); -} - -inline const Matrix3 Matrix3::operator -( const Matrix3 & mat ) const -{ - return Matrix3( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator +=( const Matrix3 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix3 & Matrix3::operator -=( const Matrix3 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix3 Matrix3::operator -( ) const -{ - return Matrix3( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ) - ); -} - -inline const Matrix3 absPerElem( const Matrix3 & mat ) -{ - return Matrix3( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::operator *( vec_float4 scalar ) const -{ - return Matrix3( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ) - ); -} - -inline Matrix3 & Matrix3::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ) -{ - return mat * scalar; -} - -inline const Vector3 Matrix3::operator *( const Vector3 & vec ) const -{ - return Vector3( - spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ) - ); -} - -inline const Matrix3 Matrix3::operator *( const Matrix3 & mat ) const -{ - return Matrix3( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ) - ); -} - -inline Matrix3 & Matrix3::operator *=( const Matrix3 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ) -{ - return Matrix3( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ) - ); -} - -inline const Matrix3 Matrix3::identity( ) -{ - return Matrix3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3::xAxis( ), - Vector3( spu_splats(0.0f), c, s ), - Vector3( spu_splats(0.0f), negatef4( s ), c ) - ); -} - -inline const Matrix3 Matrix3::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3( c, spu_splats(0.0f), negatef4( s ) ), - Vector3::yAxis( ), - Vector3( s, spu_splats(0.0f), c ) - ); -} - -inline const Matrix3 Matrix3::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix3( - Vector3( c, s, spu_splats(0.0f) ), - Vector3( negatef4( s ), c, spu_splats(0.0f) ), - Vector3::zAxis( ) - ); -} - -inline const Matrix3 Matrix3::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - return Matrix3( - Vector3( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ), - Vector3( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ), - Vector3( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = spu_mul( x, y ); - yz = spu_mul( y, z ); - zx = spu_mul( z, x ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - return Matrix3( - Vector3( spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ) ), - Vector3( spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ) ), - Vector3( spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ) ) - ); -} - -inline const Matrix3 Matrix3::rotation( const Quat & unitQuat ) -{ - return Matrix3( unitQuat ); -} - -inline const Matrix3 Matrix3::scale( const Vector3 & scaleVec ) -{ - return Matrix3( - Vector3( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f) ), - Vector3( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f) ), - Vector3( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ() ) - ); -} - -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ) -{ - return Matrix3( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ) - ); -} - -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ) -{ - return Matrix3( - mulPerElem( mat.getCol0(), scaleVec ), - mulPerElem( mat.getCol1(), scaleVec ), - mulPerElem( mat.getCol2(), scaleVec ) - ); -} - -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ) -{ - return Matrix3( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix3 & mat ) -{ - Aos::Matrix3 mat0, mat1, mat2, mat3; - mat.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Matrix3 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Matrix4::Matrix4( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; -} - -inline Matrix4::Matrix4( vec_float4 scalar ) -{ - mCol0 = Vector4( scalar ); - mCol1 = Vector4( scalar ); - mCol2 = Vector4( scalar ); - mCol3 = Vector4( scalar ); -} - -inline Matrix4::Matrix4( const Transform3 & mat ) -{ - mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); - mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); - mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); - mCol3 = Vector4( mat.getCol3(), spu_splats(1.0f) ); -} - -inline Matrix4::Matrix4( const Vector4 & _col0, const Vector4 & _col1, const Vector4 & _col2, const Vector4 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Matrix4::Matrix4( const Matrix3 & mat, const Vector3 & translateVec ) -{ - mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); - mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); - mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); - mCol3 = Vector4( translateVec, spu_splats(1.0f) ); -} - -inline Matrix4::Matrix4( const Quat & unitQuat, const Vector3 & translateVec ) -{ - Matrix3 mat; - mat = Matrix3( unitQuat ); - mCol0 = Vector4( mat.getCol0(), spu_splats(0.0f) ); - mCol1 = Vector4( mat.getCol1(), spu_splats(0.0f) ); - mCol2 = Vector4( mat.getCol2(), spu_splats(0.0f) ); - mCol3 = Vector4( translateVec, spu_splats(1.0f) ); -} - -inline Matrix4::Matrix4( const Aos::Matrix4 & mat ) -{ - mCol0 = Vector4( mat.getCol0() ); - mCol1 = Vector4( mat.getCol1() ); - mCol2 = Vector4( mat.getCol2() ); - mCol3 = Vector4( mat.getCol3() ); -} - -inline Matrix4::Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ) -{ - mCol0 = Vector4( mat0.getCol0(), mat1.getCol0(), mat2.getCol0(), mat3.getCol0() ); - mCol1 = Vector4( mat0.getCol1(), mat1.getCol1(), mat2.getCol1(), mat3.getCol1() ); - mCol2 = Vector4( mat0.getCol2(), mat1.getCol2(), mat2.getCol2(), mat3.getCol2() ); - mCol3 = Vector4( mat0.getCol3(), mat1.getCol3(), mat2.getCol3(), mat3.getCol3() ); -} - -inline void Matrix4::get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const -{ - Aos::Vector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - mCol0.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol0( tmpV4_0 ); - result1.setCol0( tmpV4_1 ); - result2.setCol0( tmpV4_2 ); - result3.setCol0( tmpV4_3 ); - mCol1.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol1( tmpV4_0 ); - result1.setCol1( tmpV4_1 ); - result2.setCol1( tmpV4_2 ); - result3.setCol1( tmpV4_3 ); - mCol2.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol2( tmpV4_0 ); - result1.setCol2( tmpV4_1 ); - result2.setCol2( tmpV4_2 ); - result3.setCol2( tmpV4_3 ); - mCol3.get4Aos( tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3 ); - result0.setCol3( tmpV4_0 ); - result1.setCol3( tmpV4_1 ); - result2.setCol3( tmpV4_2 ); - result3.setCol3( tmpV4_3 ); -} - -inline Matrix4 & Matrix4::setCol0( const Vector4 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Matrix4 & Matrix4::setCol1( const Vector4 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Matrix4 & Matrix4::setCol2( const Vector4 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Matrix4 & Matrix4::setCol3( const Vector4 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Matrix4 & Matrix4::setCol( int col, const Vector4 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Matrix4 & Matrix4::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Matrix4 & Matrix4::setElem( int col, int row, vec_float4 val ) -{ - Vector4 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Matrix4::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector4 Matrix4::getCol0( ) const -{ - return mCol0; -} - -inline const Vector4 Matrix4::getCol1( ) const -{ - return mCol1; -} - -inline const Vector4 Matrix4::getCol2( ) const -{ - return mCol2; -} - -inline const Vector4 Matrix4::getCol3( ) const -{ - return mCol3; -} - -inline const Vector4 Matrix4::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector4 & Matrix4::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector4 Matrix4::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Matrix4 & Matrix4::operator =( const Matrix4 & mat ) -{ - mCol0 = mat.mCol0; - mCol1 = mat.mCol1; - mCol2 = mat.mCol2; - mCol3 = mat.mCol3; - return *this; -} - -inline const Matrix4 transpose( const Matrix4 & mat ) -{ - return Matrix4( - Vector4( mat.getCol0().getX(), mat.getCol1().getX(), mat.getCol2().getX(), mat.getCol3().getX() ), - Vector4( mat.getCol0().getY(), mat.getCol1().getY(), mat.getCol2().getY(), mat.getCol3().getY() ), - Vector4( mat.getCol0().getZ(), mat.getCol1().getZ(), mat.getCol2().getZ(), mat.getCol3().getZ() ), - Vector4( mat.getCol0().getW(), mat.getCol1().getW(), mat.getCol2().getW(), mat.getCol3().getW() ) - ); -} - -inline const Matrix4 inverse( const Matrix4 & mat ) -{ - Vector4 res0, res1, res2, res3; - vec_float4 mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, detInv; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); - tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); - tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); - tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); - tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); - tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); - res0.setX( spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ) ); - res0.setY( spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ) ); - res0.setZ( spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ) ); - res0.setW( spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ) ); - detInv = recipf4( spu_add( spu_add( spu_add( spu_mul( mA, res0.getX() ), spu_mul( mE, res0.getY() ) ), spu_mul( mI, res0.getZ() ) ), spu_mul( mM, res0.getW() ) ) ); - res1.setX( spu_mul( mI, tmp1 ) ); - res1.setY( spu_mul( mM, tmp0 ) ); - res1.setZ( spu_mul( mA, tmp1 ) ); - res1.setW( spu_mul( mE, tmp0 ) ); - res3.setX( spu_mul( mI, tmp3 ) ); - res3.setY( spu_mul( mM, tmp2 ) ); - res3.setZ( spu_mul( mA, tmp3 ) ); - res3.setW( spu_mul( mE, tmp2 ) ); - res2.setX( spu_mul( mI, tmp5 ) ); - res2.setY( spu_mul( mM, tmp4 ) ); - res2.setZ( spu_mul( mA, tmp5 ) ); - res2.setW( spu_mul( mE, tmp4 ) ); - tmp0 = spu_sub( spu_mul( mI, mB ), spu_mul( mA, mJ ) ); - tmp1 = spu_sub( spu_mul( mM, mF ), spu_mul( mE, mN ) ); - tmp2 = spu_sub( spu_mul( mI, mD ), spu_mul( mA, mL ) ); - tmp3 = spu_sub( spu_mul( mM, mH ), spu_mul( mE, mP ) ); - tmp4 = spu_sub( spu_mul( mI, mC ), spu_mul( mA, mK ) ); - tmp5 = spu_sub( spu_mul( mM, mG ), spu_mul( mE, mO ) ); - res2.setX( spu_add( spu_sub( spu_mul( mL, tmp1 ), spu_mul( mJ, tmp3 ) ), res2.getX() ) ); - res2.setY( spu_add( spu_sub( spu_mul( mP, tmp0 ), spu_mul( mN, tmp2 ) ), res2.getY() ) ); - res2.setZ( spu_sub( spu_sub( spu_mul( mB, tmp3 ), spu_mul( mD, tmp1 ) ), res2.getZ() ) ); - res2.setW( spu_sub( spu_sub( spu_mul( mF, tmp2 ), spu_mul( mH, tmp0 ) ), res2.getW() ) ); - res3.setX( spu_add( spu_sub( spu_mul( mJ, tmp5 ), spu_mul( mK, tmp1 ) ), res3.getX() ) ); - res3.setY( spu_add( spu_sub( spu_mul( mN, tmp4 ), spu_mul( mO, tmp0 ) ), res3.getY() ) ); - res3.setZ( spu_sub( spu_sub( spu_mul( mC, tmp1 ), spu_mul( mB, tmp5 ) ), res3.getZ() ) ); - res3.setW( spu_sub( spu_sub( spu_mul( mG, tmp0 ), spu_mul( mF, tmp4 ) ), res3.getW() ) ); - res1.setX( spu_sub( spu_sub( spu_mul( mK, tmp3 ), spu_mul( mL, tmp5 ) ), res1.getX() ) ); - res1.setY( spu_sub( spu_sub( spu_mul( mO, tmp2 ), spu_mul( mP, tmp4 ) ), res1.getY() ) ); - res1.setZ( spu_add( spu_sub( spu_mul( mD, tmp5 ), spu_mul( mC, tmp3 ) ), res1.getZ() ) ); - res1.setW( spu_add( spu_sub( spu_mul( mH, tmp4 ), spu_mul( mG, tmp2 ) ), res1.getW() ) ); - return Matrix4( - ( res0 * detInv ), - ( res1 * detInv ), - ( res2 * detInv ), - ( res3 * detInv ) - ); -} - -inline const Matrix4 affineInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( inverse( affineMat ) ); -} - -inline const Matrix4 orthoInverse( const Matrix4 & mat ) -{ - Transform3 affineMat; - affineMat.setCol0( mat.getCol0().getXYZ( ) ); - affineMat.setCol1( mat.getCol1().getXYZ( ) ); - affineMat.setCol2( mat.getCol2().getXYZ( ) ); - affineMat.setCol3( mat.getCol3().getXYZ( ) ); - return Matrix4( orthoInverse( affineMat ) ); -} - -inline vec_float4 determinant( const Matrix4 & mat ) -{ - vec_float4 dx, dy, dz, dw, mA, mB, mC, mD, mE, mF, mG, mH, mI, mJ, mK, mL, mM, mN, mO, mP, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; - mA = mat.getCol0().getX(); - mB = mat.getCol0().getY(); - mC = mat.getCol0().getZ(); - mD = mat.getCol0().getW(); - mE = mat.getCol1().getX(); - mF = mat.getCol1().getY(); - mG = mat.getCol1().getZ(); - mH = mat.getCol1().getW(); - mI = mat.getCol2().getX(); - mJ = mat.getCol2().getY(); - mK = mat.getCol2().getZ(); - mL = mat.getCol2().getW(); - mM = mat.getCol3().getX(); - mN = mat.getCol3().getY(); - mO = mat.getCol3().getZ(); - mP = mat.getCol3().getW(); - tmp0 = spu_sub( spu_mul( mK, mD ), spu_mul( mC, mL ) ); - tmp1 = spu_sub( spu_mul( mO, mH ), spu_mul( mG, mP ) ); - tmp2 = spu_sub( spu_mul( mB, mK ), spu_mul( mJ, mC ) ); - tmp3 = spu_sub( spu_mul( mF, mO ), spu_mul( mN, mG ) ); - tmp4 = spu_sub( spu_mul( mJ, mD ), spu_mul( mB, mL ) ); - tmp5 = spu_sub( spu_mul( mN, mH ), spu_mul( mF, mP ) ); - dx = spu_sub( spu_sub( spu_mul( mJ, tmp1 ), spu_mul( mL, tmp3 ) ), spu_mul( mK, tmp5 ) ); - dy = spu_sub( spu_sub( spu_mul( mN, tmp0 ), spu_mul( mP, tmp2 ) ), spu_mul( mO, tmp4 ) ); - dz = spu_sub( spu_add( spu_mul( mD, tmp3 ), spu_mul( mC, tmp5 ) ), spu_mul( mB, tmp1 ) ); - dw = spu_sub( spu_add( spu_mul( mH, tmp2 ), spu_mul( mG, tmp4 ) ), spu_mul( mF, tmp0 ) ); - return spu_add( spu_add( spu_add( spu_mul( mA, dx ), spu_mul( mE, dy ) ), spu_mul( mI, dz ) ), spu_mul( mM, dw ) ); -} - -inline const Matrix4 Matrix4::operator +( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 + mat.mCol0 ), - ( mCol1 + mat.mCol1 ), - ( mCol2 + mat.mCol2 ), - ( mCol3 + mat.mCol3 ) - ); -} - -inline const Matrix4 Matrix4::operator -( const Matrix4 & mat ) const -{ - return Matrix4( - ( mCol0 - mat.mCol0 ), - ( mCol1 - mat.mCol1 ), - ( mCol2 - mat.mCol2 ), - ( mCol3 - mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator +=( const Matrix4 & mat ) -{ - *this = *this + mat; - return *this; -} - -inline Matrix4 & Matrix4::operator -=( const Matrix4 & mat ) -{ - *this = *this - mat; - return *this; -} - -inline const Matrix4 Matrix4::operator -( ) const -{ - return Matrix4( - ( -mCol0 ), - ( -mCol1 ), - ( -mCol2 ), - ( -mCol3 ) - ); -} - -inline const Matrix4 absPerElem( const Matrix4 & mat ) -{ - return Matrix4( - absPerElem( mat.getCol0() ), - absPerElem( mat.getCol1() ), - absPerElem( mat.getCol2() ), - absPerElem( mat.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::operator *( vec_float4 scalar ) const -{ - return Matrix4( - ( mCol0 * scalar ), - ( mCol1 * scalar ), - ( mCol2 * scalar ), - ( mCol3 * scalar ) - ); -} - -inline Matrix4 & Matrix4::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ) -{ - return mat * scalar; -} - -inline const Vector4 Matrix4::operator *( const Vector4 & vec ) const -{ - return Vector4( - spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), spu_mul( mCol3.getX(), vec.getW() ) ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), spu_mul( mCol3.getY(), vec.getW() ) ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ), spu_mul( mCol3.getZ(), vec.getW() ) ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getW(), vec.getX() ), spu_mul( mCol1.getW(), vec.getY() ) ), spu_mul( mCol2.getW(), vec.getZ() ) ), spu_mul( mCol3.getW(), vec.getW() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Vector3 & vec ) const -{ - return Vector4( - spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getW(), vec.getX() ), spu_mul( mCol1.getW(), vec.getY() ) ), spu_mul( mCol2.getW(), vec.getZ() ) ) - ); -} - -inline const Vector4 Matrix4::operator *( const Point3 & pnt ) const -{ - return Vector4( - spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), pnt.getX() ), spu_mul( mCol1.getX(), pnt.getY() ) ), spu_mul( mCol2.getX(), pnt.getZ() ) ), mCol3.getX() ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), pnt.getX() ), spu_mul( mCol1.getY(), pnt.getY() ) ), spu_mul( mCol2.getY(), pnt.getZ() ) ), mCol3.getY() ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), pnt.getX() ), spu_mul( mCol1.getZ(), pnt.getY() ) ), spu_mul( mCol2.getZ(), pnt.getZ() ) ), mCol3.getZ() ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getW(), pnt.getX() ), spu_mul( mCol1.getW(), pnt.getY() ) ), spu_mul( mCol2.getW(), pnt.getZ() ) ), mCol3.getW() ) - ); -} - -inline const Matrix4 Matrix4::operator *( const Matrix4 & mat ) const -{ - return Matrix4( - ( *this * mat.mCol0 ), - ( *this * mat.mCol1 ), - ( *this * mat.mCol2 ), - ( *this * mat.mCol3 ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Matrix4 & mat ) -{ - *this = *this * mat; - return *this; -} - -inline const Matrix4 Matrix4::operator *( const Transform3 & tfrm ) const -{ - return Matrix4( - ( *this * tfrm.getCol0() ), - ( *this * tfrm.getCol1() ), - ( *this * tfrm.getCol2() ), - ( *this * Point3( tfrm.getCol3() ) ) - ); -} - -inline Matrix4 & Matrix4::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ) -{ - return Matrix4( - mulPerElem( mat0.getCol0(), mat1.getCol0() ), - mulPerElem( mat0.getCol1(), mat1.getCol1() ), - mulPerElem( mat0.getCol2(), mat1.getCol2() ), - mulPerElem( mat0.getCol3(), mat1.getCol3() ) - ); -} - -inline const Matrix4 Matrix4::identity( ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline Matrix4 & Matrix4::setUpper3x3( const Matrix3 & mat3 ) -{ - mCol0.setXYZ( mat3.getCol0() ); - mCol1.setXYZ( mat3.getCol1() ); - mCol2.setXYZ( mat3.getCol2() ); - return *this; -} - -inline const Matrix3 Matrix4::getUpper3x3( ) const -{ - return Matrix3( - mCol0.getXYZ( ), - mCol1.getXYZ( ), - mCol2.getXYZ( ) - ); -} - -inline Matrix4 & Matrix4::setTranslation( const Vector3 & translateVec ) -{ - mCol3.setXYZ( translateVec ); - return *this; -} - -inline const Vector3 Matrix4::getTranslation( ) const -{ - return mCol3.getXYZ( ); -} - -inline const Matrix4 Matrix4::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4::xAxis( ), - Vector4( spu_splats(0.0f), c, s, spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), negatef4( s ), c, spu_splats(0.0f) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4( c, spu_splats(0.0f), negatef4( s ), spu_splats(0.0f) ), - Vector4::yAxis( ), - Vector4( s, spu_splats(0.0f), c, spu_splats(0.0f) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Matrix4( - Vector4( c, s, spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( negatef4( s ), c, spu_splats(0.0f), spu_splats(0.0f) ), - Vector4::zAxis( ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - return Matrix4( - Vector4( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ), spu_splats(0.0f) ), - Vector4( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ), spu_splats(0.0f) ), - Vector4( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ), spu_splats(0.0f) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 x, y, z, s, c, oneMinusC, xy, yz, zx; - sincosf4( radians, &s, &c ); - x = unitVec.getX(); - y = unitVec.getY(); - z = unitVec.getZ(); - xy = spu_mul( x, y ); - yz = spu_mul( y, z ); - zx = spu_mul( z, x ); - oneMinusC = spu_sub( spu_splats(1.0f), c ); - return Matrix4( - Vector4( spu_add( spu_mul( spu_mul( x, x ), oneMinusC ), c ), spu_add( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_sub( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_splats(0.0f) ), - Vector4( spu_sub( spu_mul( xy, oneMinusC ), spu_mul( z, s ) ), spu_add( spu_mul( spu_mul( y, y ), oneMinusC ), c ), spu_add( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_splats(0.0f) ), - Vector4( spu_add( spu_mul( zx, oneMinusC ), spu_mul( y, s ) ), spu_sub( spu_mul( yz, oneMinusC ), spu_mul( x, s ) ), spu_add( spu_mul( spu_mul( z, z ), oneMinusC ), c ), spu_splats(0.0f) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 Matrix4::rotation( const Quat & unitQuat ) -{ - return Matrix4( Transform3::rotation( unitQuat ) ); -} - -inline const Matrix4 Matrix4::scale( const Vector3 & scaleVec ) -{ - return Matrix4( - Vector4( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ(), spu_splats(0.0f) ), - Vector4::wAxis( ) - ); -} - -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ) -{ - return Matrix4( - ( mat.getCol0() * scaleVec.getX( ) ), - ( mat.getCol1() * scaleVec.getY( ) ), - ( mat.getCol2() * scaleVec.getZ( ) ), - mat.getCol3() - ); -} - -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ) -{ - Vector4 scale4; - scale4 = Vector4( scaleVec, spu_splats(1.0f) ); - return Matrix4( - mulPerElem( mat.getCol0(), scale4 ), - mulPerElem( mat.getCol1(), scale4 ), - mulPerElem( mat.getCol2(), scale4 ), - mulPerElem( mat.getCol3(), scale4 ) - ); -} - -inline const Matrix4 Matrix4::translation( const Vector3 & translateVec ) -{ - return Matrix4( - Vector4::xAxis( ), - Vector4::yAxis( ), - Vector4::zAxis( ), - Vector4( translateVec, spu_splats(1.0f) ) - ); -} - -inline const Matrix4 Matrix4::lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ) -{ - Matrix4 m4EyeFrame; - Vector3 v3X, v3Y, v3Z; - v3Y = normalize( upVec ); - v3Z = normalize( ( eyePos - lookAtPos ) ); - v3X = normalize( cross( v3Y, v3Z ) ); - v3Y = cross( v3Z, v3X ); - m4EyeFrame = Matrix4( Vector4( v3X ), Vector4( v3Y ), Vector4( v3Z ), Vector4( eyePos ) ); - return orthoInverse( m4EyeFrame ); -} - -inline const Matrix4 Matrix4::perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 f, rangeInv; - f = tanf4( spu_sub( spu_splats( _VECTORMATH_PI_OVER_2 ), spu_mul( spu_splats(0.5f), fovyRadians ) ) ); - rangeInv = recipf4( spu_sub( zNear, zFar ) ); - return Matrix4( - Vector4( divf4( f, aspect ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), f, spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_add( zNear, zFar ), rangeInv ), spu_splats(-1.0f) ), - Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( spu_mul( zNear, zFar ), rangeInv ), spu_splats(2.0f) ), spu_splats(0.0f) ) - ); -} - -inline const Matrix4 Matrix4::frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf, n2; - sum_rl = spu_add( right, left ); - sum_tb = spu_add( top, bottom ); - sum_nf = spu_add( zNear, zFar ); - inv_rl = recipf4( spu_sub( right, left ) ); - inv_tb = recipf4( spu_sub( top, bottom ) ); - inv_nf = recipf4( spu_sub( zNear, zFar ) ); - n2 = spu_add( zNear, zNear ); - return Matrix4( - Vector4( spu_mul( n2, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), spu_mul( n2, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_mul( sum_rl, inv_rl ), spu_mul( sum_tb, inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(-1.0f) ), - Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_mul( spu_mul( n2, inv_nf ), zFar ), spu_splats(0.0f) ) - ); -} - -inline const Matrix4 Matrix4::orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ) -{ - vec_float4 sum_rl, sum_tb, sum_nf, inv_rl, inv_tb, inv_nf; - sum_rl = spu_add( right, left ); - sum_tb = spu_add( top, bottom ); - sum_nf = spu_add( zNear, zFar ); - inv_rl = recipf4( spu_sub( right, left ) ); - inv_tb = recipf4( spu_sub( top, bottom ) ); - inv_nf = recipf4( spu_sub( zNear, zFar ) ); - return Matrix4( - Vector4( spu_add( inv_rl, inv_rl ), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), spu_add( inv_tb, inv_tb ), spu_splats(0.0f), spu_splats(0.0f) ), - Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_add( inv_nf, inv_nf ), spu_splats(0.0f) ), - Vector4( spu_mul( negatef4( sum_rl ), inv_rl ), spu_mul( negatef4( sum_tb ), inv_tb ), spu_mul( sum_nf, inv_nf ), spu_splats(1.0f) ) - ); -} - -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ) -{ - return Matrix4( - select( mat0.getCol0(), mat1.getCol0(), select1 ), - select( mat0.getCol1(), mat1.getCol1(), select1 ), - select( mat0.getCol2(), mat1.getCol2(), select1 ), - select( mat0.getCol3(), mat1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Matrix4 & mat ) -{ - Aos::Matrix4 mat0, mat1, mat2, mat3; - mat.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Matrix4 & mat, const char * name ) -{ - printf("%s:\n", name); - print( mat ); -} - -#endif - -inline Transform3::Transform3( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; -} - -inline Transform3::Transform3( vec_float4 scalar ) -{ - mCol0 = Vector3( scalar ); - mCol1 = Vector3( scalar ); - mCol2 = Vector3( scalar ); - mCol3 = Vector3( scalar ); -} - -inline Transform3::Transform3( const Vector3 & _col0, const Vector3 & _col1, const Vector3 & _col2, const Vector3 & _col3 ) -{ - mCol0 = _col0; - mCol1 = _col1; - mCol2 = _col2; - mCol3 = _col3; -} - -inline Transform3::Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ) -{ - this->setUpper3x3( tfrm ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Quat & unitQuat, const Vector3 & translateVec ) -{ - this->setUpper3x3( Matrix3( unitQuat ) ); - this->setTranslation( translateVec ); -} - -inline Transform3::Transform3( const Aos::Transform3 & tfrm ) -{ - mCol0 = Vector3( tfrm.getCol0() ); - mCol1 = Vector3( tfrm.getCol1() ); - mCol2 = Vector3( tfrm.getCol2() ); - mCol3 = Vector3( tfrm.getCol3() ); -} - -inline Transform3::Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ) -{ - mCol0 = Vector3( tfrm0.getCol0(), tfrm1.getCol0(), tfrm2.getCol0(), tfrm3.getCol0() ); - mCol1 = Vector3( tfrm0.getCol1(), tfrm1.getCol1(), tfrm2.getCol1(), tfrm3.getCol1() ); - mCol2 = Vector3( tfrm0.getCol2(), tfrm1.getCol2(), tfrm2.getCol2(), tfrm3.getCol2() ); - mCol3 = Vector3( tfrm0.getCol3(), tfrm1.getCol3(), tfrm2.getCol3(), tfrm3.getCol3() ); -} - -inline void Transform3::get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const -{ - Aos::Vector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - mCol0.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol0( tmpV3_0 ); - result1.setCol0( tmpV3_1 ); - result2.setCol0( tmpV3_2 ); - result3.setCol0( tmpV3_3 ); - mCol1.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol1( tmpV3_0 ); - result1.setCol1( tmpV3_1 ); - result2.setCol1( tmpV3_2 ); - result3.setCol1( tmpV3_3 ); - mCol2.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol2( tmpV3_0 ); - result1.setCol2( tmpV3_1 ); - result2.setCol2( tmpV3_2 ); - result3.setCol2( tmpV3_3 ); - mCol3.get4Aos( tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3 ); - result0.setCol3( tmpV3_0 ); - result1.setCol3( tmpV3_1 ); - result2.setCol3( tmpV3_2 ); - result3.setCol3( tmpV3_3 ); -} - -inline Transform3 & Transform3::setCol0( const Vector3 & _col0 ) -{ - mCol0 = _col0; - return *this; -} - -inline Transform3 & Transform3::setCol1( const Vector3 & _col1 ) -{ - mCol1 = _col1; - return *this; -} - -inline Transform3 & Transform3::setCol2( const Vector3 & _col2 ) -{ - mCol2 = _col2; - return *this; -} - -inline Transform3 & Transform3::setCol3( const Vector3 & _col3 ) -{ - mCol3 = _col3; - return *this; -} - -inline Transform3 & Transform3::setCol( int col, const Vector3 & vec ) -{ - *(&mCol0 + col) = vec; - return *this; -} - -inline Transform3 & Transform3::setRow( int row, const Vector4 & vec ) -{ - mCol0.setElem( row, vec.getElem( 0 ) ); - mCol1.setElem( row, vec.getElem( 1 ) ); - mCol2.setElem( row, vec.getElem( 2 ) ); - mCol3.setElem( row, vec.getElem( 3 ) ); - return *this; -} - -inline Transform3 & Transform3::setElem( int col, int row, vec_float4 val ) -{ - Vector3 tmpV3_0; - tmpV3_0 = this->getCol( col ); - tmpV3_0.setElem( row, val ); - this->setCol( col, tmpV3_0 ); - return *this; -} - -inline vec_float4 Transform3::getElem( int col, int row ) const -{ - return this->getCol( col ).getElem( row ); -} - -inline const Vector3 Transform3::getCol0( ) const -{ - return mCol0; -} - -inline const Vector3 Transform3::getCol1( ) const -{ - return mCol1; -} - -inline const Vector3 Transform3::getCol2( ) const -{ - return mCol2; -} - -inline const Vector3 Transform3::getCol3( ) const -{ - return mCol3; -} - -inline const Vector3 Transform3::getCol( int col ) const -{ - return *(&mCol0 + col); -} - -inline const Vector4 Transform3::getRow( int row ) const -{ - return Vector4( mCol0.getElem( row ), mCol1.getElem( row ), mCol2.getElem( row ), mCol3.getElem( row ) ); -} - -inline Vector3 & Transform3::operator []( int col ) -{ - return *(&mCol0 + col); -} - -inline const Vector3 Transform3::operator []( int col ) const -{ - return *(&mCol0 + col); -} - -inline Transform3 & Transform3::operator =( const Transform3 & tfrm ) -{ - mCol0 = tfrm.mCol0; - mCol1 = tfrm.mCol1; - mCol2 = tfrm.mCol2; - mCol3 = tfrm.mCol3; - return *this; -} - -inline const Transform3 inverse( const Transform3 & tfrm ) -{ - Vector3 tmp0, tmp1, tmp2, inv0, inv1, inv2; - vec_float4 detinv; - tmp0 = cross( tfrm.getCol1(), tfrm.getCol2() ); - tmp1 = cross( tfrm.getCol2(), tfrm.getCol0() ); - tmp2 = cross( tfrm.getCol0(), tfrm.getCol1() ); - detinv = recipf4( dot( tfrm.getCol2(), tmp2 ) ); - inv0 = Vector3( spu_mul( tmp0.getX(), detinv ), spu_mul( tmp1.getX(), detinv ), spu_mul( tmp2.getX(), detinv ) ); - inv1 = Vector3( spu_mul( tmp0.getY(), detinv ), spu_mul( tmp1.getY(), detinv ), spu_mul( tmp2.getY(), detinv ) ); - inv2 = Vector3( spu_mul( tmp0.getZ(), detinv ), spu_mul( tmp1.getZ(), detinv ), spu_mul( tmp2.getZ(), detinv ) ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 orthoInverse( const Transform3 & tfrm ) -{ - Vector3 inv0, inv1, inv2; - inv0 = Vector3( tfrm.getCol0().getX(), tfrm.getCol1().getX(), tfrm.getCol2().getX() ); - inv1 = Vector3( tfrm.getCol0().getY(), tfrm.getCol1().getY(), tfrm.getCol2().getY() ); - inv2 = Vector3( tfrm.getCol0().getZ(), tfrm.getCol1().getZ(), tfrm.getCol2().getZ() ); - return Transform3( - inv0, - inv1, - inv2, - Vector3( ( -( ( inv0 * tfrm.getCol3().getX() ) + ( ( inv1 * tfrm.getCol3().getY() ) + ( inv2 * tfrm.getCol3().getZ() ) ) ) ) ) - ); -} - -inline const Transform3 absPerElem( const Transform3 & tfrm ) -{ - return Transform3( - absPerElem( tfrm.getCol0() ), - absPerElem( tfrm.getCol1() ), - absPerElem( tfrm.getCol2() ), - absPerElem( tfrm.getCol3() ) - ); -} - -inline const Vector3 Transform3::operator *( const Vector3 & vec ) const -{ - return Vector3( - spu_add( spu_add( spu_mul( mCol0.getX(), vec.getX() ), spu_mul( mCol1.getX(), vec.getY() ) ), spu_mul( mCol2.getX(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getY(), vec.getX() ), spu_mul( mCol1.getY(), vec.getY() ) ), spu_mul( mCol2.getY(), vec.getZ() ) ), - spu_add( spu_add( spu_mul( mCol0.getZ(), vec.getX() ), spu_mul( mCol1.getZ(), vec.getY() ) ), spu_mul( mCol2.getZ(), vec.getZ() ) ) - ); -} - -inline const Point3 Transform3::operator *( const Point3 & pnt ) const -{ - return Point3( - spu_add( spu_add( spu_add( spu_mul( mCol0.getX(), pnt.getX() ), spu_mul( mCol1.getX(), pnt.getY() ) ), spu_mul( mCol2.getX(), pnt.getZ() ) ), mCol3.getX() ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getY(), pnt.getX() ), spu_mul( mCol1.getY(), pnt.getY() ) ), spu_mul( mCol2.getY(), pnt.getZ() ) ), mCol3.getY() ), - spu_add( spu_add( spu_add( spu_mul( mCol0.getZ(), pnt.getX() ), spu_mul( mCol1.getZ(), pnt.getY() ) ), spu_mul( mCol2.getZ(), pnt.getZ() ) ), mCol3.getZ() ) - ); -} - -inline const Transform3 Transform3::operator *( const Transform3 & tfrm ) const -{ - return Transform3( - ( *this * tfrm.mCol0 ), - ( *this * tfrm.mCol1 ), - ( *this * tfrm.mCol2 ), - Vector3( ( *this * Point3( tfrm.mCol3 ) ) ) - ); -} - -inline Transform3 & Transform3::operator *=( const Transform3 & tfrm ) -{ - *this = *this * tfrm; - return *this; -} - -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ) -{ - return Transform3( - mulPerElem( tfrm0.getCol0(), tfrm1.getCol0() ), - mulPerElem( tfrm0.getCol1(), tfrm1.getCol1() ), - mulPerElem( tfrm0.getCol2(), tfrm1.getCol2() ), - mulPerElem( tfrm0.getCol3(), tfrm1.getCol3() ) - ); -} - -inline const Transform3 Transform3::identity( ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline Transform3 & Transform3::setUpper3x3( const Matrix3 & tfrm ) -{ - mCol0 = tfrm.getCol0(); - mCol1 = tfrm.getCol1(); - mCol2 = tfrm.getCol2(); - return *this; -} - -inline const Matrix3 Transform3::getUpper3x3( ) const -{ - return Matrix3( mCol0, mCol1, mCol2 ); -} - -inline Transform3 & Transform3::setTranslation( const Vector3 & translateVec ) -{ - mCol3 = translateVec; - return *this; -} - -inline const Vector3 Transform3::getTranslation( ) const -{ - return mCol3; -} - -inline const Transform3 Transform3::rotationX( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3::xAxis( ), - Vector3( spu_splats(0.0f), c, s ), - Vector3( spu_splats(0.0f), negatef4( s ), c ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline const Transform3 Transform3::rotationY( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3( c, spu_splats(0.0f), negatef4( s ) ), - Vector3::yAxis( ), - Vector3( s, spu_splats(0.0f), c ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline const Transform3 Transform3::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c; - sincosf4( radians, &s, &c ); - return Transform3( - Vector3( c, s, spu_splats(0.0f) ), - Vector3( negatef4( s ), c, spu_splats(0.0f) ), - Vector3::zAxis( ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline const Transform3 Transform3::rotationZYX( const Vector3 & radiansXYZ ) -{ - vec_float4 sX, cX, sY, cY, sZ, cZ, tmp0, tmp1; - sincosf4( radiansXYZ.getX(), &sX, &cX ); - sincosf4( radiansXYZ.getY(), &sY, &cY ); - sincosf4( radiansXYZ.getZ(), &sZ, &cZ ); - tmp0 = spu_mul( cZ, sY ); - tmp1 = spu_mul( sZ, sY ); - return Transform3( - Vector3( spu_mul( cZ, cY ), spu_mul( sZ, cY ), negatef4( sY ) ), - Vector3( spu_sub( spu_mul( tmp0, sX ), spu_mul( sZ, cX ) ), spu_add( spu_mul( tmp1, sX ), spu_mul( cZ, cX ) ), spu_mul( cY, sX ) ), - Vector3( spu_add( spu_mul( tmp0, cX ), spu_mul( sZ, sX ) ), spu_sub( spu_mul( tmp1, cX ), spu_mul( cZ, sX ) ), spu_mul( cY, cX ) ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline const Transform3 Transform3::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - return Transform3( Matrix3::rotation( radians, unitVec ), Vector3( spu_splats(0.0f) ) ); -} - -inline const Transform3 Transform3::rotation( const Quat & unitQuat ) -{ - return Transform3( Matrix3( unitQuat ), Vector3( spu_splats(0.0f) ) ); -} - -inline const Transform3 Transform3::scale( const Vector3 & scaleVec ) -{ - return Transform3( - Vector3( scaleVec.getX(), spu_splats(0.0f), spu_splats(0.0f) ), - Vector3( spu_splats(0.0f), scaleVec.getY(), spu_splats(0.0f) ), - Vector3( spu_splats(0.0f), spu_splats(0.0f), scaleVec.getZ() ), - Vector3( spu_splats(0.0f) ) - ); -} - -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ) -{ - return Transform3( - ( tfrm.getCol0() * scaleVec.getX( ) ), - ( tfrm.getCol1() * scaleVec.getY( ) ), - ( tfrm.getCol2() * scaleVec.getZ( ) ), - tfrm.getCol3() - ); -} - -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ) -{ - return Transform3( - mulPerElem( tfrm.getCol0(), scaleVec ), - mulPerElem( tfrm.getCol1(), scaleVec ), - mulPerElem( tfrm.getCol2(), scaleVec ), - mulPerElem( tfrm.getCol3(), scaleVec ) - ); -} - -inline const Transform3 Transform3::translation( const Vector3 & translateVec ) -{ - return Transform3( - Vector3::xAxis( ), - Vector3::yAxis( ), - Vector3::zAxis( ), - translateVec - ); -} - -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ) -{ - return Transform3( - select( tfrm0.getCol0(), tfrm1.getCol0(), select1 ), - select( tfrm0.getCol1(), tfrm1.getCol1(), select1 ), - select( tfrm0.getCol2(), tfrm1.getCol2(), select1 ), - select( tfrm0.getCol3(), tfrm1.getCol3(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Transform3 & tfrm ) -{ - Aos::Transform3 mat0, mat1, mat2, mat3; - tfrm.get4Aos( mat0, mat1, mat2, mat3 ); - printf("slot 0:\n"); - print( mat0 ); - printf("slot 1:\n"); - print( mat1 ); - printf("slot 2:\n"); - print( mat2 ); - printf("slot 3:\n"); - print( mat3 ); -} - -inline void print( const Transform3 & tfrm, const char * name ) -{ - printf("%s:\n", name); - print( tfrm ); -} - -#endif - -inline Quat::Quat( const Matrix3 & tfrm ) -{ - vec_float4 trace, radicand, scale, xx, yx, zx, xy, yy, zy, xz, yz, zz, tmpx, tmpy, tmpz, tmpw, qx, qy, qz, qw; - vec_uint4 negTrace, ZgtX, ZgtY, YgtX; - vec_uint4 largestXorY, largestYorZ, largestZorX; - - xx = tfrm.getCol0().getX(); - yx = tfrm.getCol0().getY(); - zx = tfrm.getCol0().getZ(); - xy = tfrm.getCol1().getX(); - yy = tfrm.getCol1().getY(); - zy = tfrm.getCol1().getZ(); - xz = tfrm.getCol2().getX(); - yz = tfrm.getCol2().getY(); - zz = tfrm.getCol2().getZ(); - - trace = spu_add( spu_add( xx, yy ), zz ); - - negTrace = spu_cmpgt( spu_splats(0.0f), trace ); - ZgtX = spu_cmpgt( zz, xx ); - ZgtY = spu_cmpgt( zz, yy ); - YgtX = spu_cmpgt( yy, xx ); - largestXorY = spu_and( negTrace, spu_nand( ZgtX, ZgtY ) ); - largestYorZ = spu_and( negTrace, spu_or( YgtX, ZgtX ) ); - largestZorX = spu_and( negTrace, spu_orc( ZgtY, YgtX ) ); - - zz = spu_sel( zz, negatef4(zz), largestXorY ); - xy = spu_sel( xy, negatef4(xy), largestXorY ); - xx = spu_sel( xx, negatef4(xx), largestYorZ ); - yz = spu_sel( yz, negatef4(yz), largestYorZ ); - yy = spu_sel( yy, negatef4(yy), largestZorX ); - zx = spu_sel( zx, negatef4(zx), largestZorX ); - - radicand = spu_add( spu_add( spu_add( xx, yy ), zz ), spu_splats(1.0f) ); - scale = spu_mul( spu_splats(0.5f), rsqrtf4( radicand ) ); - - tmpx = spu_mul( spu_sub( zy, yz ), scale ); - tmpy = spu_mul( spu_sub( xz, zx ), scale ); - tmpz = spu_mul( spu_sub( yx, xy ), scale ); - tmpw = spu_mul( radicand, scale ); - qx = tmpx; - qy = tmpy; - qz = tmpz; - qw = tmpw; - - qx = spu_sel( qx, tmpw, largestXorY ); - qy = spu_sel( qy, tmpz, largestXorY ); - qz = spu_sel( qz, tmpy, largestXorY ); - qw = spu_sel( qw, tmpx, largestXorY ); - tmpx = qx; - tmpz = qz; - qx = spu_sel( qx, qy, largestYorZ ); - qy = spu_sel( qy, tmpx, largestYorZ ); - qz = spu_sel( qz, qw, largestYorZ ); - qw = spu_sel( qw, tmpz, largestYorZ ); - - mX = qx; - mY = qy; - mZ = qz; - mW = qw; -} - -inline const Matrix3 outer( const Vector3 & tfrm0, const Vector3 & tfrm1 ) -{ - return Matrix3( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ) - ); -} - -inline const Matrix4 outer( const Vector4 & tfrm0, const Vector4 & tfrm1 ) -{ - return Matrix4( - ( tfrm0 * tfrm1.getX( ) ), - ( tfrm0 * tfrm1.getY( ) ), - ( tfrm0 * tfrm1.getZ( ) ), - ( tfrm0 * tfrm1.getW( ) ) - ); -} - -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Vector3( - spu_add( spu_add( spu_mul( vec.getX(), mat.getCol0().getX() ), spu_mul( vec.getY(), mat.getCol0().getY() ) ), spu_mul( vec.getZ(), mat.getCol0().getZ() ) ), - spu_add( spu_add( spu_mul( vec.getX(), mat.getCol1().getX() ), spu_mul( vec.getY(), mat.getCol1().getY() ) ), spu_mul( vec.getZ(), mat.getCol1().getZ() ) ), - spu_add( spu_add( spu_mul( vec.getX(), mat.getCol2().getX() ), spu_mul( vec.getY(), mat.getCol2().getY() ) ), spu_mul( vec.getZ(), mat.getCol2().getZ() ) ) - ); -} - -inline const Matrix3 crossMatrix( const Vector3 & vec ) -{ - return Matrix3( - Vector3( spu_splats(0.0f), vec.getZ(), negatef4( vec.getY() ) ), - Vector3( negatef4( vec.getZ() ), spu_splats(0.0f), vec.getX() ), - Vector3( vec.getY(), negatef4( vec.getX() ), spu_splats(0.0f) ) - ); -} - -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ) -{ - return Matrix3( cross( vec, mat.getCol0() ), cross( vec, mat.getCol1() ), cross( vec, mat.getCol2() ) ); -} - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h deleted file mode 100644 index a41bc69aa..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_aos.h +++ /dev/null @@ -1,417 +0,0 @@ -/* - 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 { - -inline Quat::Quat( float _x, float _y, float _z, float _w ) -{ - mVec128 = (vec_float4){ _x, _y, _z, _w }; -} - -inline Quat::Quat( Vector3 xyz, float _w ) -{ - mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); -} - -inline Quat::Quat( Vector4 vec ) -{ - mVec128 = vec.get128(); -} - -inline Quat::Quat( float scalar ) -{ - mVec128 = spu_splats( scalar ); -} - -inline Quat::Quat( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Quat Quat::identity( ) -{ - return Quat( _VECTORMATH_UNIT_0001 ); -} - -inline const Quat lerp( float t, Quat quat0, Quat quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ) -{ - Quat start; - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot4( unitQuat0.get128(), unitQuat1.get128() ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); - cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start = Quat( spu_sel( unitQuat0.get128(), negatef4( unitQuat0.get128() ), selectMask ) ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - return Quat( spu_madd( start.get128(), scale0, spu_mul( unitQuat1.get128(), scale1 ) ) ); -} - -inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, 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 vec_float4 Quat::get128( ) const -{ - return mVec128; -} - -inline Quat & Quat::operator =( Quat quat ) -{ - mVec128 = quat.mVec128; - return *this; -} - -inline Quat & Quat::setXYZ( Vector3 vec ) -{ - mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) ); - return *this; -} - -inline const Vector3 Quat::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -inline Quat & Quat::setX( float _x ) -{ - mVec128 = spu_insert( _x, mVec128, 0 ); - return *this; -} - -inline float Quat::getX( ) const -{ - return spu_extract( mVec128, 0 ); -} - -inline Quat & Quat::setY( float _y ) -{ - mVec128 = spu_insert( _y, mVec128, 1 ); - return *this; -} - -inline float Quat::getY( ) const -{ - return spu_extract( mVec128, 1 ); -} - -inline Quat & Quat::setZ( float _z ) -{ - mVec128 = spu_insert( _z, mVec128, 2 ); - return *this; -} - -inline float Quat::getZ( ) const -{ - return spu_extract( mVec128, 2 ); -} - -inline Quat & Quat::setW( float _w ) -{ - mVec128 = spu_insert( _w, mVec128, 3 ); - return *this; -} - -inline float Quat::getW( ) const -{ - return spu_extract( mVec128, 3 ); -} - -inline Quat & Quat::setElem( int idx, float value ) -{ - mVec128 = spu_insert( value, mVec128, idx ); - return *this; -} - -inline float Quat::getElem( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline VecIdx Quat::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline float Quat::operator []( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline const Quat Quat::operator +( Quat quat ) const -{ - return Quat( spu_add( mVec128, quat.mVec128 ) ); -} - -inline const Quat Quat::operator -( Quat quat ) const -{ - return Quat( spu_sub( mVec128, quat.mVec128 ) ); -} - -inline const Quat Quat::operator *( float scalar ) const -{ - return Quat( spu_mul( mVec128, spu_splats(scalar) ) ); -} - -inline Quat & Quat::operator +=( Quat quat ) -{ - *this = *this + quat; - return *this; -} - -inline Quat & Quat::operator -=( 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( divf4( mVec128, spu_splats(scalar) ) ); -} - -inline Quat & Quat::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Quat Quat::operator -( ) const -{ - return Quat( negatef4( mVec128 ) ); -} - -inline const Quat operator *( float scalar, Quat quat ) -{ - return quat * scalar; -} - -inline float dot( Quat quat0, Quat quat1 ) -{ - return spu_extract( _vmathVfDot4( quat0.get128(), quat1.get128() ), 0 ); -} - -inline float norm( Quat quat ) -{ - return spu_extract( _vmathVfDot4( quat.get128(), quat.get128() ), 0 ); -} - -inline float length( Quat quat ) -{ - return sqrtf( norm( quat ) ); -} - -inline const Quat normalize( Quat quat ) -{ - vec_float4 dot = _vmathVfDot4( quat.get128(), quat.get128() ); - return Quat( spu_mul( quat.get128(), rsqrtf4( dot ) ) ); -} - -inline const Quat Quat::rotation( Vector3 unitVec0, Vector3 unitVec1 ) -{ - Vector3 crossVec; - vec_float4 cosAngle, cosAngleX2Plus2, recipCosHalfAngleX2, cosHalfAngleX2, res; - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - cosAngle = spu_shuffle( cosAngle, cosAngle, (vec_uchar16)spu_splats(0x00010203) ); - cosAngleX2Plus2 = spu_madd( cosAngle, spu_splats(2.0f), spu_splats(2.0f) ); - recipCosHalfAngleX2 = rsqrtf4( cosAngleX2Plus2 ); - cosHalfAngleX2 = spu_mul( recipCosHalfAngleX2, cosAngleX2Plus2 ); - crossVec = cross( unitVec0, unitVec1 ); - res = spu_mul( crossVec.get128(), recipCosHalfAngleX2 ); - res = spu_sel( res, spu_mul( cosHalfAngleX2, spu_splats(0.5f) ), (vec_uint4)spu_maskb(0x000f) ); - return Quat( res ); -} - -inline const Quat Quat::rotation( float radians, Vector3 unitVec ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_mul( unitVec.get128(), s ), c, (vec_uint4)spu_maskb(0x000f) ); - return Quat( res ); -} - -inline const Quat Quat::rotationX( float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0xf000) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - return Quat( res ); -} - -inline const Quat Quat::rotationY( float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x0f00) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - return Quat( res ); -} - -inline const Quat Quat::rotationZ( float radians ) -{ - vec_float4 s, c, angle, res; - angle = spu_mul( spu_splats(radians), spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - res = spu_sel( spu_splats(0.0f), s, (vec_uint4)spu_maskb(0x00f0) ); - res = spu_sel( res, c, (vec_uint4)spu_maskb(0x000f) ); - return Quat( res ); -} - -inline const Quat Quat::operator *( Quat quat ) const -{ - vec_float4 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; - vec_float4 product, l_wxyz, r_wxyz, xy, qw; - ldata = mVec128; - rdata = quat.mVec128; - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - tmp0 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( ldata, ldata, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( rdata, rdata, _VECTORMATH_SHUF_YZXW ); - qv = spu_mul( spu_shuffle( ldata, ldata, shuffle_wwww ), rdata ); - qv = spu_madd( spu_shuffle( rdata, rdata, shuffle_wwww ), ldata, qv ); - qv = spu_madd( tmp0, tmp1, qv ); - qv = spu_nmsub( tmp2, tmp3, qv ); - product = spu_mul( ldata, rdata ); - l_wxyz = spu_rlqwbyte( ldata, 12 ); - r_wxyz = spu_rlqwbyte( rdata, 12 ); - qw = spu_nmsub( l_wxyz, r_wxyz, product ); - xy = spu_madd( l_wxyz, r_wxyz, product ); - qw = spu_sub( qw, spu_rlqwbyte( xy, 8 ) ); - return Quat( spu_sel( qv, qw, (vec_uint4)spu_maskb( 0x000f ) ) ); -} - -inline Quat & Quat::operator *=( Quat quat ) -{ - *this = *this * quat; - return *this; -} - -inline const Vector3 rotate( Quat quat, Vector3 vec ) -{ - vec_float4 qdata, vdata, product, tmp0, tmp1, tmp2, tmp3, wwww, qv, qw, res; - qdata = quat.get128(); - vdata = vec.get128(); - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - tmp0 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( qdata, qdata, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( vdata, vdata, _VECTORMATH_SHUF_YZXW ); - wwww = spu_shuffle( qdata, qdata, shuffle_wwww ); - qv = spu_mul( wwww, vdata ); - qv = spu_madd( tmp0, tmp1, qv ); - qv = spu_nmsub( tmp2, tmp3, qv ); - product = spu_mul( qdata, vdata ); - qw = spu_madd( spu_rlqwbyte( qdata, 4 ), spu_rlqwbyte( vdata, 4 ), product ); - qw = spu_add( spu_rlqwbyte( product, 8 ), qw ); - tmp1 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( qv, qv, _VECTORMATH_SHUF_YZXW ); - res = spu_mul( spu_shuffle( qw, qw, shuffle_xxxx ), qdata ); - res = spu_madd( wwww, qv, res ); - res = spu_madd( tmp0, tmp1, res ); - res = spu_nmsub( tmp2, tmp3, res ); - return Vector3( res ); -} - -inline const Quat conj( Quat quat ) -{ - return Quat( spu_xor( quat.get128(), ((vec_float4)(vec_int4){0x80000000,0x80000000,0x80000000,0}) ) ); -} - -inline const Quat select( Quat quat0, Quat quat1, bool select1 ) -{ - return Quat( spu_sel( quat0.get128(), quat1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Quat quat ) -{ - union { vec_float4 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] ); -} - -inline void print( Quat quat, const char * name ) -{ - union { vec_float4 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 diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h deleted file mode 100644 index 88c2884fa..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/quat_soa.h +++ /dev/null @@ -1,483 +0,0 @@ -/* - 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_SOA_CPP_H -#define _VECTORMATH_QUAT_SOA_CPP_H -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Soa { - -inline Quat::Quat( const Quat & quat ) -{ - mX = quat.mX; - mY = quat.mY; - mZ = quat.mZ; - mW = quat.mW; -} - -inline Quat::Quat( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Quat::Quat( const Vector3 & xyz, vec_float4 _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( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline Quat::Quat( Aos::Quat quat ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_float4 vec128 = quat.get128(); - mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); - mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); - mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); - mW = spu_shuffle( vec128, vec128, shuffle_wwww ); -} - -inline Quat::Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( quat0.get128(), quat2.get128(), _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( quat1.get128(), quat3.get128(), _VECTORMATH_SHUF_ZCWD ); - mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); -} - -inline const Quat Quat::identity( ) -{ - return Quat( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ) -{ - return ( quat0 + ( ( quat1 - quat0 ) * t ) ); -} - -inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ) -{ - Quat start; - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitQuat0, unitQuat1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(0.0f), cosAngle ); - cosAngle = spu_sel( cosAngle, negatef4( cosAngle ), selectMask ); - start.setX( spu_sel( unitQuat0.getX(), negatef4( unitQuat0.getX() ), selectMask ) ); - start.setY( spu_sel( unitQuat0.getY(), negatef4( unitQuat0.getY() ), selectMask ) ); - start.setZ( spu_sel( unitQuat0.getZ(), negatef4( unitQuat0.getZ() ), selectMask ) ); - start.setW( spu_sel( unitQuat0.getW(), negatef4( unitQuat0.getW() ), selectMask ) ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - return ( ( start * scale0 ) + ( unitQuat1 * scale1 ) ); -} - -inline const Quat squad( vec_float4 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( spu_mul( spu_mul( spu_splats(2.0f), t ), spu_sub( spu_splats(1.0f), t ) ), tmp0, tmp1 ); -} - -inline void Quat::get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD ); - result0 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); - result1 = Aos::Quat( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); - result2 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); - result3 = Aos::Quat( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); -} - -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( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Quat::getX( ) const -{ - return mX; -} - -inline Quat & Quat::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Quat::getY( ) const -{ - return mY; -} - -inline Quat & Quat::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Quat::getZ( ) const -{ - return mZ; -} - -inline Quat & Quat::setW( vec_float4 _w ) -{ - mW = _w; - return *this; -} - -inline vec_float4 Quat::getW( ) const -{ - return mW; -} - -inline Quat & Quat::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Quat::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Quat::vec_float4_t & Quat::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Quat::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Quat Quat::operator +( const Quat & quat ) const -{ - return Quat( - spu_add( mX, quat.mX ), - spu_add( mY, quat.mY ), - spu_add( mZ, quat.mZ ), - spu_add( mW, quat.mW ) - ); -} - -inline const Quat Quat::operator -( const Quat & quat ) const -{ - return Quat( - spu_sub( mX, quat.mX ), - spu_sub( mY, quat.mY ), - spu_sub( mZ, quat.mZ ), - spu_sub( mW, quat.mW ) - ); -} - -inline const Quat Quat::operator *( vec_float4 scalar ) const -{ - return Quat( - spu_mul( mX, scalar ), - spu_mul( mY, scalar ), - spu_mul( mZ, scalar ), - spu_mul( 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 *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Quat Quat::operator /( vec_float4 scalar ) const -{ - return Quat( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ), - divf4( mW, scalar ) - ); -} - -inline Quat & Quat::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Quat Quat::operator -( ) const -{ - return Quat( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ), - negatef4( mW ) - ); -} - -inline const Quat operator *( vec_float4 scalar, const Quat & quat ) -{ - return quat * scalar; -} - -inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ) -{ - vec_float4 result; - result = spu_mul( quat0.getX(), quat1.getX() ); - result = spu_add( result, spu_mul( quat0.getY(), quat1.getY() ) ); - result = spu_add( result, spu_mul( quat0.getZ(), quat1.getZ() ) ); - result = spu_add( result, spu_mul( quat0.getW(), quat1.getW() ) ); - return result; -} - -inline vec_float4 norm( const Quat & quat ) -{ - vec_float4 result; - result = spu_mul( quat.getX(), quat.getX() ); - result = spu_add( result, spu_mul( quat.getY(), quat.getY() ) ); - result = spu_add( result, spu_mul( quat.getZ(), quat.getZ() ) ); - result = spu_add( result, spu_mul( quat.getW(), quat.getW() ) ); - return result; -} - -inline vec_float4 length( const Quat & quat ) -{ - return sqrtf4( norm( quat ) ); -} - -inline const Quat normalize( const Quat & quat ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = norm( quat ); - lenInv = rsqrtf4( lenSqr ); - return Quat( - spu_mul( quat.getX(), lenInv ), - spu_mul( quat.getY(), lenInv ), - spu_mul( quat.getZ(), lenInv ), - spu_mul( quat.getW(), lenInv ) - ); -} - -inline const Quat Quat::rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - vec_float4 cosHalfAngleX2, recipCosHalfAngleX2; - cosHalfAngleX2 = sqrtf4( spu_mul( spu_splats(2.0f), spu_add( spu_splats(1.0f), dot( unitVec0, unitVec1 ) ) ) ); - recipCosHalfAngleX2 = recipf4( cosHalfAngleX2 ); - return Quat( ( cross( unitVec0, unitVec1 ) * recipCosHalfAngleX2 ), spu_mul( cosHalfAngleX2, spu_splats(0.5f) ) ); -} - -inline const Quat Quat::rotation( vec_float4 radians, const Vector3 & unitVec ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - return Quat( ( unitVec * s ), c ); -} - -inline const Quat Quat::rotationX( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - return Quat( s, spu_splats(0.0f), spu_splats(0.0f), c ); -} - -inline const Quat Quat::rotationY( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - return Quat( spu_splats(0.0f), s, spu_splats(0.0f), c ); -} - -inline const Quat Quat::rotationZ( vec_float4 radians ) -{ - vec_float4 s, c, angle; - angle = spu_mul( radians, spu_splats(0.5f) ); - sincosf4( angle, &s, &c ); - return Quat( spu_splats(0.0f), spu_splats(0.0f), s, c ); -} - -inline const Quat Quat::operator *( const Quat & quat ) const -{ - return Quat( - spu_sub( spu_add( spu_add( spu_mul( mW, quat.mX ), spu_mul( mX, quat.mW ) ), spu_mul( mY, quat.mZ ) ), spu_mul( mZ, quat.mY ) ), - spu_sub( spu_add( spu_add( spu_mul( mW, quat.mY ), spu_mul( mY, quat.mW ) ), spu_mul( mZ, quat.mX ) ), spu_mul( mX, quat.mZ ) ), - spu_sub( spu_add( spu_add( spu_mul( mW, quat.mZ ), spu_mul( mZ, quat.mW ) ), spu_mul( mX, quat.mY ) ), spu_mul( mY, quat.mX ) ), - spu_sub( spu_sub( spu_sub( spu_mul( mW, quat.mW ), spu_mul( mX, quat.mX ) ), spu_mul( mY, quat.mY ) ), spu_mul( 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 ) -{ - vec_float4 tmpX, tmpY, tmpZ, tmpW; - tmpX = spu_sub( spu_add( spu_mul( quat.getW(), vec.getX() ), spu_mul( quat.getY(), vec.getZ() ) ), spu_mul( quat.getZ(), vec.getY() ) ); - tmpY = spu_sub( spu_add( spu_mul( quat.getW(), vec.getY() ), spu_mul( quat.getZ(), vec.getX() ) ), spu_mul( quat.getX(), vec.getZ() ) ); - tmpZ = spu_sub( spu_add( spu_mul( quat.getW(), vec.getZ() ), spu_mul( quat.getX(), vec.getY() ) ), spu_mul( quat.getY(), vec.getX() ) ); - tmpW = spu_add( spu_add( spu_mul( quat.getX(), vec.getX() ), spu_mul( quat.getY(), vec.getY() ) ), spu_mul( quat.getZ(), vec.getZ() ) ); - return Vector3( - spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getX() ), spu_mul( tmpX, quat.getW() ) ), spu_mul( tmpY, quat.getZ() ) ), spu_mul( tmpZ, quat.getY() ) ), - spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getY() ), spu_mul( tmpY, quat.getW() ) ), spu_mul( tmpZ, quat.getX() ) ), spu_mul( tmpX, quat.getZ() ) ), - spu_add( spu_sub( spu_add( spu_mul( tmpW, quat.getZ() ), spu_mul( tmpZ, quat.getW() ) ), spu_mul( tmpX, quat.getY() ) ), spu_mul( tmpY, quat.getX() ) ) - ); -} - -inline const Quat conj( const Quat & quat ) -{ - return Quat( negatef4( quat.getX() ), negatef4( quat.getY() ), negatef4( quat.getZ() ), quat.getW() ); -} - -inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ) -{ - return Quat( - spu_sel( quat0.getX(), quat1.getX(), select1 ), - spu_sel( quat0.getY(), quat1.getY(), select1 ), - spu_sel( quat0.getZ(), quat1.getZ(), select1 ), - spu_sel( quat0.getW(), quat1.getW(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Quat & quat ) -{ - Aos::Quat vec0, vec1, vec2, vec3; - quat.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Quat & quat, const char * name ) -{ - Aos::Quat vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - quat.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h deleted file mode 100644 index c983f1817..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_aos.h +++ /dev/null @@ -1,1167 +0,0 @@ -/* - 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_VEC_AOS_CPP_H -#define _VECTORMATH_VEC_AOS_CPP_H -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_ZXYW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_YZXW (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_W } -#define _VECTORMATH_SHUF_WABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_SHUF_ZWAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_XYZA (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A } -#define _VECTORMATH_SHUF_YZAB (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B } -#define _VECTORMATH_SHUF_ZABC (vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_C } -#define _VECTORMATH_UNIT_1000 (vec_float4){ 1.0f, 0.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0100 (vec_float4){ 0.0f, 1.0f, 0.0f, 0.0f } -#define _VECTORMATH_UNIT_0010 (vec_float4){ 0.0f, 0.0f, 1.0f, 0.0f } -#define _VECTORMATH_UNIT_0001 (vec_float4){ 0.0f, 0.0f, 0.0f, 1.0f } -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -static inline vec_float4 _vmathVfDot3( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result ); -} - -static inline vec_float4 _vmathVfDot4( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0, vec1 ); - result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result ); - return spu_add( spu_rlqwbyte( result, 8 ), result ); -} - -static inline vec_float4 _vmathVfCross( vec_float4 vec0, vec_float4 vec1 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3, result; - tmp0 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_YZXW ); - tmp1 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_ZXYW ); - tmp2 = spu_shuffle( vec0, vec0, _VECTORMATH_SHUF_ZXYW ); - tmp3 = spu_shuffle( vec1, vec1, _VECTORMATH_SHUF_YZXW ); - result = spu_mul( tmp0, tmp1 ); - result = spu_nmsub( tmp2, tmp3, result ); - return result; -} - -static inline vec_uint4 _vmathVfToHalfFloatsUnpacked(vec_float4 v) -{ - vec_int4 bexp; - vec_uint4 mant, sign, hfloat; - vec_uint4 notZero, isInf; - const vec_uint4 hfloatInf = spu_splats(0x00007c00u); - const vec_uint4 mergeMant = spu_splats(0x000003ffu); - const vec_uint4 mergeSign = spu_splats(0x00008000u); - - sign = spu_rlmask((vec_uint4)v, -16); - mant = spu_rlmask((vec_uint4)v, -13); - bexp = spu_and(spu_rlmask((vec_int4)v, -23), 0xff); - - notZero = spu_cmpgt(bexp, 112); - isInf = spu_cmpgt(bexp, 142); - - bexp = spu_add(bexp, -112); - bexp = spu_sl(bexp, 10); - - hfloat = spu_sel((vec_uint4)bexp, mant, mergeMant); - hfloat = spu_sel(spu_splats(0u), hfloat, notZero); - hfloat = spu_sel(hfloat, hfloatInf, isInf); - hfloat = spu_sel(hfloat, sign, mergeSign); - - return hfloat; -} - -static inline vec_ushort8 _vmath2VfToHalfFloats(vec_float4 u, vec_float4 v) -{ - vec_uint4 hfloat_u, hfloat_v; - const vec_uchar16 pack = (vec_uchar16){2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31}; - hfloat_u = _vmathVfToHalfFloatsUnpacked(u); - hfloat_v = _vmathVfToHalfFloatsUnpacked(v); - return (vec_ushort8)spu_shuffle(hfloat_u, hfloat_v, pack); -} - -#endif - -namespace Vectormath { -namespace Aos { - -inline VecIdx::operator float() const -{ - return spu_extract( ref, i ); -} - -inline float VecIdx::operator =( float scalar ) -{ - ref = spu_insert( scalar, ref, i ); - return scalar; -} - -inline float VecIdx::operator =( const VecIdx& scalar ) -{ - return *this = float(scalar); -} - -inline float VecIdx::operator *=( float scalar ) -{ - float tmp = spu_extract( ref, i ) * scalar; - ref = spu_insert( tmp, ref, i ); - return tmp; -} - -inline float VecIdx::operator /=( float scalar ) -{ - float tmp = spu_extract( ref, i ) / scalar; - ref = spu_insert( tmp, ref, i ); - return tmp; -} - -inline float VecIdx::operator +=( float scalar ) -{ - float tmp = spu_extract( ref, i ) + scalar; - ref = spu_insert( tmp, ref, i ); - return tmp; -} - -inline float VecIdx::operator -=( float scalar ) -{ - float tmp = spu_extract( ref, i ) - scalar; - ref = spu_insert( tmp, ref, i ); - return tmp; -} - -inline Vector3::Vector3( float _x, float _y, float _z ) -{ - mVec128 = (vec_float4){ _x, _y, _z, 0.0f }; -} - -inline Vector3::Vector3( Point3 pnt ) -{ - mVec128 = pnt.get128(); -} - -inline Vector3::Vector3( float scalar ) -{ - mVec128 = spu_splats( scalar ); -} - -inline Vector3::Vector3( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_1000 ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0100 ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( _VECTORMATH_UNIT_0010 ); -} - -inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot3( unitVec0.get128(), unitVec1.get128() ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - return Vector3( spu_madd( unitVec0.get128(), scale0, spu_mul( unitVec1.get128(), scale1 ) ) ); -} - -inline vec_float4 Vector3::get128( ) const -{ - return mVec128; -} - -inline void storeXYZ( Vector3 vec, vec_float4 * quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); - dstVec = spu_sel(vec.get128(), dstVec, mask); - *quad = dstVec; -} - -inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); - xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); - xyz3 = spu_rlqwbyte( zxyz, 4 ); - vec0 = Vector3( xyzx ); - vec1 = Vector3( xyz1 ); - vec2 = Vector3( xyz2 ); - vec3 = Vector3( xyz3 ); -} - -inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = spu_shuffle( vec0.get128(), vec1.get128(), _VECTORMATH_SHUF_XYZA ); - yzxy = spu_shuffle( vec1.get128(), vec2.get128(), _VECTORMATH_SHUF_YZAB ); - zxyz = spu_shuffle( vec2.get128(), vec3.get128(), _VECTORMATH_SHUF_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( vec0, vec1, vec2, vec3, xyz0 ); - storeXYZArray( vec4, vec5, vec6, vec7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Vector3 & Vector3::operator =( Vector3 vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -inline Vector3 & Vector3::setX( float _x ) -{ - mVec128 = spu_insert( _x, mVec128, 0 ); - return *this; -} - -inline float Vector3::getX( ) const -{ - return spu_extract( mVec128, 0 ); -} - -inline Vector3 & Vector3::setY( float _y ) -{ - mVec128 = spu_insert( _y, mVec128, 1 ); - return *this; -} - -inline float Vector3::getY( ) const -{ - return spu_extract( mVec128, 1 ); -} - -inline Vector3 & Vector3::setZ( float _z ) -{ - mVec128 = spu_insert( _z, mVec128, 2 ); - return *this; -} - -inline float Vector3::getZ( ) const -{ - return spu_extract( mVec128, 2 ); -} - -inline Vector3 & Vector3::setElem( int idx, float value ) -{ - mVec128 = spu_insert( value, mVec128, idx ); - return *this; -} - -inline float Vector3::getElem( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline VecIdx Vector3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline float Vector3::operator []( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline const Vector3 Vector3::operator +( Vector3 vec ) const -{ - return Vector3( spu_add( mVec128, vec.mVec128 ) ); -} - -inline const Vector3 Vector3::operator -( Vector3 vec ) const -{ - return Vector3( spu_sub( mVec128, vec.mVec128 ) ); -} - -inline const Point3 Vector3::operator +( Point3 pnt ) const -{ - return Point3( spu_add( mVec128, pnt.get128() ) ); -} - -inline const Vector3 Vector3::operator *( float scalar ) const -{ - return Vector3( spu_mul( mVec128, spu_splats(scalar) ) ); -} - -inline Vector3 & Vector3::operator +=( Vector3 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( Vector3 vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( float scalar ) const -{ - return Vector3( divf4( mVec128, spu_splats(scalar) ) ); -} - -inline Vector3 & Vector3::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( negatef4( mVec128 ) ); -} - -inline const Vector3 operator *( float scalar, Vector3 vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( spu_mul( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( divf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 recipPerElem( Vector3 vec ) -{ - return Vector3( recipf4( vec.get128() ) ); -} - -inline const Vector3 sqrtPerElem( Vector3 vec ) -{ - return Vector3( sqrtf4( vec.get128() ) ); -} - -inline const Vector3 rsqrtPerElem( Vector3 vec ) -{ - return Vector3( rsqrtf4( vec.get128() ) ); -} - -inline const Vector3 absPerElem( Vector3 vec ) -{ - return Vector3( fabsf4( vec.get128() ) ); -} - -inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( copysignf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( fmaxf4( vec0.get128(), vec1.get128() ) ); -} - -inline float maxElem( Vector3 vec ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); - result = fmaxf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( fminf4( vec0.get128(), vec1.get128() ) ); -} - -inline float minElem( Vector3 vec ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); - result = fminf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline float sum( Vector3 vec ) -{ - return - spu_extract( vec.get128(), 0 ) + - spu_extract( vec.get128(), 1 ) + - spu_extract( vec.get128(), 2 ); -} - -inline float dot( Vector3 vec0, Vector3 vec1 ) -{ - return spu_extract( _vmathVfDot3( vec0.get128(), vec1.get128() ), 0 ); -} - -inline float lengthSqr( Vector3 vec ) -{ - return spu_extract( _vmathVfDot3( vec.get128(), vec.get128() ), 0 ); -} - -inline float length( Vector3 vec ) -{ - return sqrtf( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( Vector3 vec ) -{ - vec_float4 dot = _vmathVfDot3( vec.get128(), vec.get128() ); - dot = spu_shuffle( dot, dot, (vec_uchar16)spu_splats(0x00010203) ); - return Vector3( spu_mul( vec.get128(), rsqrtf4( dot ) ) ); -} - -inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ) -{ - return Vector3( _vmathVfCross( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ) -{ - return Vector3( spu_sel( vec0.get128(), vec1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Vector3 vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -inline void print( Vector3 vec, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -inline Vector4::Vector4( float _x, float _y, float _z, float _w ) -{ - mVec128 = (vec_float4){ _x, _y, _z, _w }; -} - -inline Vector4::Vector4( Vector3 xyz, float _w ) -{ - mVec128 = spu_shuffle( xyz.get128(), spu_promote( _w, 0 ), _VECTORMATH_SHUF_XYZA ); -} - -inline Vector4::Vector4( Vector3 vec ) -{ - mVec128 = spu_sel( vec.get128(), spu_splats(0.0f), (vec_uint4)spu_maskb(0x000f) ); -} - -inline Vector4::Vector4( Point3 pnt ) -{ - mVec128 = spu_sel( pnt.get128(), spu_splats(1.0f), (vec_uint4)spu_maskb(0x000f) ); -} - -inline Vector4::Vector4( Quat quat ) -{ - mVec128 = quat.get128(); -} - -inline Vector4::Vector4( float scalar ) -{ - mVec128 = spu_splats( scalar ); -} - -inline Vector4::Vector4( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_1000 ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0100 ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0010 ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( _VECTORMATH_UNIT_0001 ); -} - -inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ) -{ - vec_float4 scales, scale0, scale1, cosAngle, angle, tttt, oneMinusT, angles, sines; - vec_uint4 selectMask; - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - cosAngle = _vmathVfDot4( unitVec0.get128(), unitVec1.get128() ); - cosAngle = spu_shuffle( cosAngle, cosAngle, shuffle_xxxx ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - tttt = spu_splats(t); - oneMinusT = spu_sub( spu_splats(1.0f), tttt ); - angles = spu_sel( spu_splats(1.0f), oneMinusT, (vec_uint4)spu_maskb(0x0f00) ); - angles = spu_sel( angles, tttt, (vec_uint4)spu_maskb(0x00f0) ); - angles = spu_mul( angles, angle ); - sines = sinf4( angles ); - scales = divf4( sines, spu_shuffle( sines, sines, shuffle_xxxx ) ); - scale0 = spu_sel( oneMinusT, spu_shuffle( scales, scales, shuffle_yyyy ), selectMask ); - scale1 = spu_sel( tttt, spu_shuffle( scales, scales, shuffle_zzzz ), selectMask ); - return Vector4( spu_madd( unitVec0.get128(), scale0, spu_mul( unitVec1.get128(), scale1 ) ) ); -} - -inline vec_float4 Vector4::get128( ) const -{ - return mVec128; -} - -inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ) -{ - twoQuads[0] = _vmath2VfToHalfFloats(vec0.get128(), vec1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(vec2.get128(), vec3.get128()); -} - -inline Vector4 & Vector4::operator =( Vector4 vec ) -{ - mVec128 = vec.mVec128; - return *this; -} - -inline Vector4 & Vector4::setXYZ( Vector3 vec ) -{ - mVec128 = spu_sel( vec.get128(), mVec128, (vec_uint4)spu_maskb(0x000f) ); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mVec128 ); -} - -inline Vector4 & Vector4::setX( float _x ) -{ - mVec128 = spu_insert( _x, mVec128, 0 ); - return *this; -} - -inline float Vector4::getX( ) const -{ - return spu_extract( mVec128, 0 ); -} - -inline Vector4 & Vector4::setY( float _y ) -{ - mVec128 = spu_insert( _y, mVec128, 1 ); - return *this; -} - -inline float Vector4::getY( ) const -{ - return spu_extract( mVec128, 1 ); -} - -inline Vector4 & Vector4::setZ( float _z ) -{ - mVec128 = spu_insert( _z, mVec128, 2 ); - return *this; -} - -inline float Vector4::getZ( ) const -{ - return spu_extract( mVec128, 2 ); -} - -inline Vector4 & Vector4::setW( float _w ) -{ - mVec128 = spu_insert( _w, mVec128, 3 ); - return *this; -} - -inline float Vector4::getW( ) const -{ - return spu_extract( mVec128, 3 ); -} - -inline Vector4 & Vector4::setElem( int idx, float value ) -{ - mVec128 = spu_insert( value, mVec128, idx ); - return *this; -} - -inline float Vector4::getElem( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline VecIdx Vector4::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline float Vector4::operator []( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline const Vector4 Vector4::operator +( Vector4 vec ) const -{ - return Vector4( spu_add( mVec128, vec.mVec128 ) ); -} - -inline const Vector4 Vector4::operator -( Vector4 vec ) const -{ - return Vector4( spu_sub( mVec128, vec.mVec128 ) ); -} - -inline const Vector4 Vector4::operator *( float scalar ) const -{ - return Vector4( spu_mul( mVec128, spu_splats(scalar) ) ); -} - -inline Vector4 & Vector4::operator +=( Vector4 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( Vector4 vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( float scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( float scalar ) const -{ - return Vector4( divf4( mVec128, spu_splats(scalar) ) ); -} - -inline Vector4 & Vector4::operator /=( float scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( negatef4( mVec128 ) ); -} - -inline const Vector4 operator *( float scalar, Vector4 vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( spu_mul( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( divf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector4 recipPerElem( Vector4 vec ) -{ - return Vector4( recipf4( vec.get128() ) ); -} - -inline const Vector4 sqrtPerElem( Vector4 vec ) -{ - return Vector4( sqrtf4( vec.get128() ) ); -} - -inline const Vector4 rsqrtPerElem( Vector4 vec ) -{ - return Vector4( rsqrtf4( vec.get128() ) ); -} - -inline const Vector4 absPerElem( Vector4 vec ) -{ - return Vector4( fabsf4( vec.get128() ) ); -} - -inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( copysignf4( vec0.get128(), vec1.get128() ) ); -} - -inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( fmaxf4( vec0.get128(), vec1.get128() ) ); -} - -inline float maxElem( Vector4 vec ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); - result = fmaxf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); - result = fmaxf4( spu_promote( spu_extract( vec.get128(), 3 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ) -{ - return Vector4( fminf4( vec0.get128(), vec1.get128() ) ); -} - -inline float minElem( Vector4 vec ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( vec.get128(), 1 ), 0 ), vec.get128() ); - result = fminf4( spu_promote( spu_extract( vec.get128(), 2 ), 0 ), result ); - result = fminf4( spu_promote( spu_extract( vec.get128(), 3 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline float sum( Vector4 vec ) -{ - return - spu_extract( vec.get128(), 0 ) + - spu_extract( vec.get128(), 1 ) + - spu_extract( vec.get128(), 2 ) + - spu_extract( vec.get128(), 3 ); -} - -inline float dot( Vector4 vec0, Vector4 vec1 ) -{ - return spu_extract( _vmathVfDot4( vec0.get128(), vec1.get128() ), 0 ); -} - -inline float lengthSqr( Vector4 vec ) -{ - return spu_extract( _vmathVfDot4( vec.get128(), vec.get128() ), 0 ); -} - -inline float length( Vector4 vec ) -{ - return sqrtf( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( Vector4 vec ) -{ - vec_float4 dot = _vmathVfDot4( vec.get128(), vec.get128() ); - return Vector4( spu_mul( vec.get128(), rsqrtf4( dot ) ) ); -} - -inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ) -{ - return Vector4( spu_sel( vec0.get128(), vec1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Vector4 vec ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "( %f %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -inline void print( Vector4 vec, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = vec.get128(); - printf( "%s: ( %f %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2], tmp.s[3] ); -} - -#endif - -inline Point3::Point3( float _x, float _y, float _z ) -{ - mVec128 = (vec_float4){ _x, _y, _z, 0.0f }; -} - -inline Point3::Point3( Vector3 vec ) -{ - mVec128 = vec.get128(); -} - -inline Point3::Point3( float scalar ) -{ - mVec128 = spu_splats( scalar ); -} - -inline Point3::Point3( vec_float4 vf4 ) -{ - mVec128 = vf4; -} - -inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline vec_float4 Point3::get128( ) const -{ - return mVec128; -} - -inline void storeXYZ( Point3 pnt, vec_float4 * quad ) -{ - vec_float4 dstVec = *quad; - vec_uint4 mask = (vec_uint4)spu_maskb(0x000f); - dstVec = spu_sel(pnt.get128(), dstVec, mask); - *quad = dstVec; -} - -inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyz1, xyz2, xyz3; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyz1 = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_WABC ); - xyz2 = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_ZWAB ); - xyz3 = spu_rlqwbyte( zxyz, 4 ); - pnt0 = Point3( xyzx ); - pnt1 = Point3( xyz1 ); - pnt2 = Point3( xyz2 ); - pnt3 = Point3( xyz3 ); -} - -inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz; - xyzx = spu_shuffle( pnt0.get128(), pnt1.get128(), _VECTORMATH_SHUF_XYZA ); - yzxy = spu_shuffle( pnt1.get128(), pnt2.get128(), _VECTORMATH_SHUF_YZAB ); - zxyz = spu_shuffle( pnt2.get128(), pnt3.get128(), _VECTORMATH_SHUF_ZABC ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( pnt0, pnt1, pnt2, pnt3, xyz0 ); - storeXYZArray( pnt4, pnt5, pnt6, pnt7, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Point3 & Point3::operator =( Point3 pnt ) -{ - mVec128 = pnt.mVec128; - return *this; -} - -inline Point3 & Point3::setX( float _x ) -{ - mVec128 = spu_insert( _x, mVec128, 0 ); - return *this; -} - -inline float Point3::getX( ) const -{ - return spu_extract( mVec128, 0 ); -} - -inline Point3 & Point3::setY( float _y ) -{ - mVec128 = spu_insert( _y, mVec128, 1 ); - return *this; -} - -inline float Point3::getY( ) const -{ - return spu_extract( mVec128, 1 ); -} - -inline Point3 & Point3::setZ( float _z ) -{ - mVec128 = spu_insert( _z, mVec128, 2 ); - return *this; -} - -inline float Point3::getZ( ) const -{ - return spu_extract( mVec128, 2 ); -} - -inline Point3 & Point3::setElem( int idx, float value ) -{ - mVec128 = spu_insert( value, mVec128, idx ); - return *this; -} - -inline float Point3::getElem( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline VecIdx Point3::operator []( int idx ) -{ - return VecIdx( mVec128, idx ); -} - -inline float Point3::operator []( int idx ) const -{ - return spu_extract( mVec128, idx ); -} - -inline const Vector3 Point3::operator -( Point3 pnt ) const -{ - return Vector3( spu_sub( mVec128, pnt.mVec128 ) ); -} - -inline const Point3 Point3::operator +( Vector3 vec ) const -{ - return Point3( spu_add( mVec128, vec.get128() ) ); -} - -inline const Point3 Point3::operator -( Vector3 vec ) const -{ - return Point3( spu_sub( mVec128, vec.get128() ) ); -} - -inline Point3 & Point3::operator +=( Vector3 vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( Vector3 vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( spu_mul( pnt0.get128(), pnt1.get128() ) ); -} - -inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( divf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const Point3 recipPerElem( Point3 pnt ) -{ - return Point3( recipf4( pnt.get128() ) ); -} - -inline const Point3 sqrtPerElem( Point3 pnt ) -{ - return Point3( sqrtf4( pnt.get128() ) ); -} - -inline const Point3 rsqrtPerElem( Point3 pnt ) -{ - return Point3( rsqrtf4( pnt.get128() ) ); -} - -inline const Point3 absPerElem( Point3 pnt ) -{ - return Point3( fabsf4( pnt.get128() ) ); -} - -inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( copysignf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( fmaxf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline float maxElem( Point3 pnt ) -{ - vec_float4 result; - result = fmaxf4( spu_promote( spu_extract( pnt.get128(), 1 ), 0 ), pnt.get128() ); - result = fmaxf4( spu_promote( spu_extract( pnt.get128(), 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ) -{ - return Point3( fminf4( pnt0.get128(), pnt1.get128() ) ); -} - -inline float minElem( Point3 pnt ) -{ - vec_float4 result; - result = fminf4( spu_promote( spu_extract( pnt.get128(), 1 ), 0 ), pnt.get128() ); - result = fminf4( spu_promote( spu_extract( pnt.get128(), 2 ), 0 ), result ); - return spu_extract( result, 0 ); -} - -inline float sum( Point3 pnt ) -{ - return - spu_extract( pnt.get128(), 0 ) + - spu_extract( pnt.get128(), 1 ) + - spu_extract( pnt.get128(), 2 ); -} - -inline const Point3 scale( Point3 pnt, float scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( Point3 pnt, Vector3 scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline float projection( Point3 pnt, Vector3 unitVec ) -{ - return spu_extract( _vmathVfDot3( pnt.get128(), unitVec.get128() ), 0 ); -} - -inline float distSqrFromOrigin( Point3 pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline float distFromOrigin( Point3 pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline float distSqr( Point3 pnt0, Point3 pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline float dist( Point3 pnt0, Point3 pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ) -{ - return Point3( spu_sel( pnt0.get128(), pnt1.get128(), spu_splats( (unsigned int)-(select1 > 0) ) ) ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( Point3 pnt ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "( %f %f %f )\n", tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -inline void print( Point3 pnt, const char * name ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = pnt.get128(); - printf( "%s: ( %f %f %f )\n", name, tmp.s[0], tmp.s[1], tmp.s[2] ); -} - -#endif - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h deleted file mode 100644 index 1ac657732..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vec_soa.h +++ /dev/null @@ -1,1439 +0,0 @@ -/* - 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_VEC_SOA_CPP_H -#define _VECTORMATH_VEC_SOA_CPP_H -//----------------------------------------------------------------------------- -// Constants -// for shuffles, words are labeled [x,y,z,w] [a,b,c,d] - -#define _VECTORMATH_SHUF_X 0x00010203 -#define _VECTORMATH_SHUF_Y 0x04050607 -#define _VECTORMATH_SHUF_Z 0x08090a0b -#define _VECTORMATH_SHUF_W 0x0c0d0e0f -#define _VECTORMATH_SHUF_A 0x10111213 -#define _VECTORMATH_SHUF_B 0x14151617 -#define _VECTORMATH_SHUF_C 0x18191a1b -#define _VECTORMATH_SHUF_D 0x1c1d1e1f -#define _VECTORMATH_SHUF_0 0x80808080 -#define _VECTORMATH_SHUF_XAYB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_ZCWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_ZBW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XCY0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_ZDW0 ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_0 }) -#define _VECTORMATH_SHUF_XAZC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZDXB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YBWD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XDZB ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D, _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B }) -#define _VECTORMATH_SHUF_YAWC ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_A, _VECTORMATH_SHUF_W, _VECTORMATH_SHUF_C }) -#define _VECTORMATH_SHUF_ZBXD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_Z, _VECTORMATH_SHUF_B, _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SHUF_XYCD ((vec_uchar16)(vec_uint4){ _VECTORMATH_SHUF_X, _VECTORMATH_SHUF_Y, _VECTORMATH_SHUF_C, _VECTORMATH_SHUF_D }) -#define _VECTORMATH_SLERP_TOL 0.999f - -//----------------------------------------------------------------------------- -// Definitions - -#ifndef _VECTORMATH_INTERNAL_FUNCTIONS -#define _VECTORMATH_INTERNAL_FUNCTIONS - -#endif - -namespace Vectormath { -namespace Soa { - -inline Vector3::Vector3( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; -} - -inline Vector3::Vector3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Vector3::Vector3( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); -} - -inline Vector3::Vector3( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline Vector3::Vector3( Aos::Vector3 vec ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_float4 vec128 = vec.get128(); - mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); - mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); - mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); -} - -inline Vector3::Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_ZCWD ); - mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); -} - -inline const Vector3 Vector3::xAxis( ) -{ - return Vector3( spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -inline const Vector3 Vector3::yAxis( ) -{ - return Vector3( spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); -} - -inline const Vector3 Vector3::zAxis( ) -{ - return Vector3( spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ) -{ - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void Vector3::get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const -{ - vec_float4 tmp0, tmp1; - tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); - result0 = Aos::Vector3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_XAYB ) ); - result1 = Aos::Vector3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_ZBW0 ) ); - result2 = Aos::Vector3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_XCY0 ) ); - result3 = Aos::Vector3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_ZDW0 ) ); -} - -inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); - zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); - yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); - vec.setX( spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); - vec.setY( spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); - vec.setZ( spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); -} - -inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = spu_shuffle( vec.getX(), vec.getY(), _VECTORMATH_SHUF_XAZC ); - zxzx = spu_shuffle( vec.getZ(), vec.getX(), _VECTORMATH_SHUF_ZDXB ); - yzyz = spu_shuffle( vec.getY(), vec.getZ(), _VECTORMATH_SHUF_YBWD ); - xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); - yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); - zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( vec0, xyz0 ); - storeXYZArray( vec1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Vector3 & Vector3::operator =( const Vector3 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - return *this; -} - -inline Vector3 & Vector3::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Vector3::getX( ) const -{ - return mX; -} - -inline Vector3 & Vector3::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Vector3::getY( ) const -{ - return mY; -} - -inline Vector3 & Vector3::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Vector3::getZ( ) const -{ - return mZ; -} - -inline Vector3 & Vector3::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Vector3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Vector3::vec_float4_t & Vector3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Vector3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Vector3::operator +( const Vector3 & vec ) const -{ - return Vector3( - spu_add( mX, vec.mX ), - spu_add( mY, vec.mY ), - spu_add( mZ, vec.mZ ) - ); -} - -inline const Vector3 Vector3::operator -( const Vector3 & vec ) const -{ - return Vector3( - spu_sub( mX, vec.mX ), - spu_sub( mY, vec.mY ), - spu_sub( mZ, vec.mZ ) - ); -} - -inline const Point3 Vector3::operator +( const Point3 & pnt ) const -{ - return Point3( - spu_add( mX, pnt.getX() ), - spu_add( mY, pnt.getY() ), - spu_add( mZ, pnt.getZ() ) - ); -} - -inline const Vector3 Vector3::operator *( vec_float4 scalar ) const -{ - return Vector3( - spu_mul( mX, scalar ), - spu_mul( mY, scalar ), - spu_mul( mZ, scalar ) - ); -} - -inline Vector3 & Vector3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector3 & Vector3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector3 & Vector3::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector3 Vector3::operator /( vec_float4 scalar ) const -{ - return Vector3( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ) - ); -} - -inline Vector3 & Vector3::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector3 Vector3::operator -( ) const -{ - return Vector3( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ) - ); -} - -inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ) -{ - return vec * scalar; -} - -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - spu_mul( vec0.getX(), vec1.getX() ), - spu_mul( vec0.getY(), vec1.getY() ), - spu_mul( vec0.getZ(), vec1.getZ() ) - ); -} - -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - divf4( vec0.getX(), vec1.getX() ), - divf4( vec0.getY(), vec1.getY() ), - divf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline const Vector3 recipPerElem( const Vector3 & vec ) -{ - return Vector3( - recipf4( vec.getX() ), - recipf4( vec.getY() ), - recipf4( vec.getZ() ) - ); -} - -inline const Vector3 sqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - sqrtf4( vec.getX() ), - sqrtf4( vec.getY() ), - sqrtf4( vec.getZ() ) - ); -} - -inline const Vector3 rsqrtPerElem( const Vector3 & vec ) -{ - return Vector3( - rsqrtf4( vec.getX() ), - rsqrtf4( vec.getY() ), - rsqrtf4( vec.getZ() ) - ); -} - -inline const Vector3 absPerElem( const Vector3 & vec ) -{ - return Vector3( - fabsf4( vec.getX() ), - fabsf4( vec.getY() ), - fabsf4( vec.getZ() ) - ); -} - -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - copysignf4( vec0.getX(), vec1.getX() ), - copysignf4( vec0.getY(), vec1.getY() ), - copysignf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - fmaxf4( vec0.getX(), vec1.getX() ), - fmaxf4( vec0.getY(), vec1.getY() ), - fmaxf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline vec_float4 maxElem( const Vector3 & vec ) -{ - vec_float4 result; - result = fmaxf4( vec.getX(), vec.getY() ); - result = fmaxf4( vec.getZ(), result ); - return result; -} - -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - fminf4( vec0.getX(), vec1.getX() ), - fminf4( vec0.getY(), vec1.getY() ), - fminf4( vec0.getZ(), vec1.getZ() ) - ); -} - -inline vec_float4 minElem( const Vector3 & vec ) -{ - vec_float4 result; - result = fminf4( vec.getX(), vec.getY() ); - result = fminf4( vec.getZ(), result ); - return result; -} - -inline vec_float4 sum( const Vector3 & vec ) -{ - vec_float4 result; - result = spu_add( vec.getX(), vec.getY() ); - result = spu_add( result, vec.getZ() ); - return result; -} - -inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0.getX(), vec1.getX() ); - result = spu_add( result, spu_mul( vec0.getY(), vec1.getY() ) ); - result = spu_add( result, spu_mul( vec0.getZ(), vec1.getZ() ) ); - return result; -} - -inline vec_float4 lengthSqr( const Vector3 & vec ) -{ - vec_float4 result; - result = spu_mul( vec.getX(), vec.getX() ); - result = spu_add( result, spu_mul( vec.getY(), vec.getY() ) ); - result = spu_add( result, spu_mul( vec.getZ(), vec.getZ() ) ); - return result; -} - -inline vec_float4 length( const Vector3 & vec ) -{ - return sqrtf4( lengthSqr( vec ) ); -} - -inline const Vector3 normalize( const Vector3 & vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = rsqrtf4( lenSqr ); - return Vector3( - spu_mul( vec.getX(), lenInv ), - spu_mul( vec.getY(), lenInv ), - spu_mul( vec.getZ(), lenInv ) - ); -} - -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ) -{ - return Vector3( - spu_sub( spu_mul( vec0.getY(), vec1.getZ() ), spu_mul( vec0.getZ(), vec1.getY() ) ), - spu_sub( spu_mul( vec0.getZ(), vec1.getX() ), spu_mul( vec0.getX(), vec1.getZ() ) ), - spu_sub( spu_mul( vec0.getX(), vec1.getY() ), spu_mul( vec0.getY(), vec1.getX() ) ) - ); -} - -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ) -{ - return Vector3( - spu_sel( vec0.getX(), vec1.getX(), select1 ), - spu_sel( vec0.getY(), vec1.getY(), select1 ), - spu_sel( vec0.getZ(), vec1.getZ(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector3 & vec ) -{ - Aos::Vector3 vec0, vec1, vec2, vec3; - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Vector3 & vec, const char * name ) -{ - Aos::Vector3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -inline Vector4::Vector4( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; -} - -inline Vector4::Vector4( vec_float4 _x, vec_float4 _y, vec_float4 _z, vec_float4 _w ) -{ - mX = _x; - mY = _y; - mZ = _z; - mW = _w; -} - -inline Vector4::Vector4( const Vector3 & xyz, vec_float4 _w ) -{ - this->setXYZ( xyz ); - this->setW( _w ); -} - -inline Vector4::Vector4( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - mW = spu_splats(0.0f); -} - -inline Vector4::Vector4( const Point3 & pnt ) -{ - mX = pnt.getX(); - mY = pnt.getY(); - mZ = pnt.getZ(); - mW = spu_splats(1.0f); -} - -inline Vector4::Vector4( const Quat & quat ) -{ - mX = quat.getX(); - mY = quat.getY(); - mZ = quat.getZ(); - mW = quat.getW(); -} - -inline Vector4::Vector4( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; - mW = scalar; -} - -inline Vector4::Vector4( Aos::Vector4 vec ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_uchar16 shuffle_wwww = (vec_uchar16)spu_splats((int)0x0c0d0e0f); - vec_float4 vec128 = vec.get128(); - mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); - mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); - mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); - mW = spu_shuffle( vec128, vec128, shuffle_wwww ); -} - -inline Vector4::Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( vec0.get128(), vec2.get128(), _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( vec1.get128(), vec3.get128(), _VECTORMATH_SHUF_ZCWD ); - mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); - mW = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ); -} - -inline const Vector4 Vector4::xAxis( ) -{ - return Vector4( spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -inline const Vector4 Vector4::yAxis( ) -{ - return Vector4( spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f), spu_splats(0.0f) ); -} - -inline const Vector4 Vector4::zAxis( ) -{ - return Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f), spu_splats(0.0f) ); -} - -inline const Vector4 Vector4::wAxis( ) -{ - return Vector4( spu_splats(0.0f), spu_splats(0.0f), spu_splats(0.0f), spu_splats(1.0f) ); -} - -inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ) -{ - return ( vec0 + ( ( vec1 - vec0 ) * t ) ); -} - -inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ) -{ - vec_float4 recipSinAngle, scale0, scale1, cosAngle, angle; - vec_uint4 selectMask; - cosAngle = dot( unitVec0, unitVec1 ); - selectMask = (vec_uint4)spu_cmpgt( spu_splats(_VECTORMATH_SLERP_TOL), cosAngle ); - angle = acosf4( cosAngle ); - recipSinAngle = recipf4( sinf4( angle ) ); - scale0 = spu_sel( spu_sub( spu_splats(1.0f), t ), spu_mul( sinf4( spu_mul( spu_sub( spu_splats(1.0f), t ), angle ) ), recipSinAngle ), selectMask ); - scale1 = spu_sel( t, spu_mul( sinf4( spu_mul( t, angle ) ), recipSinAngle ), selectMask ); - return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) ); -} - -inline void Vector4::get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( mY, mW, _VECTORMATH_SHUF_ZCWD ); - result0 = Aos::Vector4( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ) ); - result1 = Aos::Vector4( spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ) ); - result2 = Aos::Vector4( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ) ); - result3 = Aos::Vector4( spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_ZCWD ) ); -} - -inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ) -{ - Aos::Vector4 v0, v1, v2, v3; - vec.get4Aos( v0, v1, v2, v3 ); - twoQuads[0] = _vmath2VfToHalfFloats(v0.get128(), v1.get128()); - twoQuads[1] = _vmath2VfToHalfFloats(v2.get128(), v3.get128()); -} - -inline Vector4 & Vector4::operator =( const Vector4 & vec ) -{ - mX = vec.mX; - mY = vec.mY; - mZ = vec.mZ; - mW = vec.mW; - return *this; -} - -inline Vector4 & Vector4::setXYZ( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); - return *this; -} - -inline const Vector3 Vector4::getXYZ( ) const -{ - return Vector3( mX, mY, mZ ); -} - -inline Vector4 & Vector4::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Vector4::getX( ) const -{ - return mX; -} - -inline Vector4 & Vector4::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Vector4::getY( ) const -{ - return mY; -} - -inline Vector4 & Vector4::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Vector4::getZ( ) const -{ - return mZ; -} - -inline Vector4 & Vector4::setW( vec_float4 _w ) -{ - mW = _w; - return *this; -} - -inline vec_float4 Vector4::getW( ) const -{ - return mW; -} - -inline Vector4 & Vector4::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Vector4::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Vector4::vec_float4_t & Vector4::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Vector4::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector4 Vector4::operator +( const Vector4 & vec ) const -{ - return Vector4( - spu_add( mX, vec.mX ), - spu_add( mY, vec.mY ), - spu_add( mZ, vec.mZ ), - spu_add( mW, vec.mW ) - ); -} - -inline const Vector4 Vector4::operator -( const Vector4 & vec ) const -{ - return Vector4( - spu_sub( mX, vec.mX ), - spu_sub( mY, vec.mY ), - spu_sub( mZ, vec.mZ ), - spu_sub( mW, vec.mW ) - ); -} - -inline const Vector4 Vector4::operator *( vec_float4 scalar ) const -{ - return Vector4( - spu_mul( mX, scalar ), - spu_mul( mY, scalar ), - spu_mul( mZ, scalar ), - spu_mul( mW, scalar ) - ); -} - -inline Vector4 & Vector4::operator +=( const Vector4 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Vector4 & Vector4::operator -=( const Vector4 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline Vector4 & Vector4::operator *=( vec_float4 scalar ) -{ - *this = *this * scalar; - return *this; -} - -inline const Vector4 Vector4::operator /( vec_float4 scalar ) const -{ - return Vector4( - divf4( mX, scalar ), - divf4( mY, scalar ), - divf4( mZ, scalar ), - divf4( mW, scalar ) - ); -} - -inline Vector4 & Vector4::operator /=( vec_float4 scalar ) -{ - *this = *this / scalar; - return *this; -} - -inline const Vector4 Vector4::operator -( ) const -{ - return Vector4( - negatef4( mX ), - negatef4( mY ), - negatef4( mZ ), - negatef4( mW ) - ); -} - -inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ) -{ - return vec * scalar; -} - -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - spu_mul( vec0.getX(), vec1.getX() ), - spu_mul( vec0.getY(), vec1.getY() ), - spu_mul( vec0.getZ(), vec1.getZ() ), - spu_mul( vec0.getW(), vec1.getW() ) - ); -} - -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - divf4( vec0.getX(), vec1.getX() ), - divf4( vec0.getY(), vec1.getY() ), - divf4( vec0.getZ(), vec1.getZ() ), - divf4( vec0.getW(), vec1.getW() ) - ); -} - -inline const Vector4 recipPerElem( const Vector4 & vec ) -{ - return Vector4( - recipf4( vec.getX() ), - recipf4( vec.getY() ), - recipf4( vec.getZ() ), - recipf4( vec.getW() ) - ); -} - -inline const Vector4 sqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - sqrtf4( vec.getX() ), - sqrtf4( vec.getY() ), - sqrtf4( vec.getZ() ), - sqrtf4( vec.getW() ) - ); -} - -inline const Vector4 rsqrtPerElem( const Vector4 & vec ) -{ - return Vector4( - rsqrtf4( vec.getX() ), - rsqrtf4( vec.getY() ), - rsqrtf4( vec.getZ() ), - rsqrtf4( vec.getW() ) - ); -} - -inline const Vector4 absPerElem( const Vector4 & vec ) -{ - return Vector4( - fabsf4( vec.getX() ), - fabsf4( vec.getY() ), - fabsf4( vec.getZ() ), - fabsf4( vec.getW() ) - ); -} - -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - copysignf4( vec0.getX(), vec1.getX() ), - copysignf4( vec0.getY(), vec1.getY() ), - copysignf4( vec0.getZ(), vec1.getZ() ), - copysignf4( vec0.getW(), vec1.getW() ) - ); -} - -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - fmaxf4( vec0.getX(), vec1.getX() ), - fmaxf4( vec0.getY(), vec1.getY() ), - fmaxf4( vec0.getZ(), vec1.getZ() ), - fmaxf4( vec0.getW(), vec1.getW() ) - ); -} - -inline vec_float4 maxElem( const Vector4 & vec ) -{ - vec_float4 result; - result = fmaxf4( vec.getX(), vec.getY() ); - result = fmaxf4( vec.getZ(), result ); - result = fmaxf4( vec.getW(), result ); - return result; -} - -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ) -{ - return Vector4( - fminf4( vec0.getX(), vec1.getX() ), - fminf4( vec0.getY(), vec1.getY() ), - fminf4( vec0.getZ(), vec1.getZ() ), - fminf4( vec0.getW(), vec1.getW() ) - ); -} - -inline vec_float4 minElem( const Vector4 & vec ) -{ - vec_float4 result; - result = fminf4( vec.getX(), vec.getY() ); - result = fminf4( vec.getZ(), result ); - result = fminf4( vec.getW(), result ); - return result; -} - -inline vec_float4 sum( const Vector4 & vec ) -{ - vec_float4 result; - result = spu_add( vec.getX(), vec.getY() ); - result = spu_add( result, vec.getZ() ); - result = spu_add( result, vec.getW() ); - return result; -} - -inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ) -{ - vec_float4 result; - result = spu_mul( vec0.getX(), vec1.getX() ); - result = spu_add( result, spu_mul( vec0.getY(), vec1.getY() ) ); - result = spu_add( result, spu_mul( vec0.getZ(), vec1.getZ() ) ); - result = spu_add( result, spu_mul( vec0.getW(), vec1.getW() ) ); - return result; -} - -inline vec_float4 lengthSqr( const Vector4 & vec ) -{ - vec_float4 result; - result = spu_mul( vec.getX(), vec.getX() ); - result = spu_add( result, spu_mul( vec.getY(), vec.getY() ) ); - result = spu_add( result, spu_mul( vec.getZ(), vec.getZ() ) ); - result = spu_add( result, spu_mul( vec.getW(), vec.getW() ) ); - return result; -} - -inline vec_float4 length( const Vector4 & vec ) -{ - return sqrtf4( lengthSqr( vec ) ); -} - -inline const Vector4 normalize( const Vector4 & vec ) -{ - vec_float4 lenSqr, lenInv; - lenSqr = lengthSqr( vec ); - lenInv = rsqrtf4( lenSqr ); - return Vector4( - spu_mul( vec.getX(), lenInv ), - spu_mul( vec.getY(), lenInv ), - spu_mul( vec.getZ(), lenInv ), - spu_mul( vec.getW(), lenInv ) - ); -} - -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ) -{ - return Vector4( - spu_sel( vec0.getX(), vec1.getX(), select1 ), - spu_sel( vec0.getY(), vec1.getY(), select1 ), - spu_sel( vec0.getZ(), vec1.getZ(), select1 ), - spu_sel( vec0.getW(), vec1.getW(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Vector4 & vec ) -{ - Aos::Vector4 vec0, vec1, vec2, vec3; - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Vector4 & vec, const char * name ) -{ - Aos::Vector4 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - vec.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -inline Point3::Point3( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; -} - -inline Point3::Point3( vec_float4 _x, vec_float4 _y, vec_float4 _z ) -{ - mX = _x; - mY = _y; - mZ = _z; -} - -inline Point3::Point3( const Vector3 & vec ) -{ - mX = vec.getX(); - mY = vec.getY(); - mZ = vec.getZ(); -} - -inline Point3::Point3( vec_float4 scalar ) -{ - mX = scalar; - mY = scalar; - mZ = scalar; -} - -inline Point3::Point3( Aos::Point3 pnt ) -{ - vec_uchar16 shuffle_xxxx = (vec_uchar16)spu_splats((int)0x00010203); - vec_uchar16 shuffle_yyyy = (vec_uchar16)spu_splats((int)0x04050607); - vec_uchar16 shuffle_zzzz = (vec_uchar16)spu_splats((int)0x08090a0b); - vec_float4 vec128 = pnt.get128(); - mX = spu_shuffle( vec128, vec128, shuffle_xxxx ); - mY = spu_shuffle( vec128, vec128, shuffle_yyyy ); - mZ = spu_shuffle( vec128, vec128, shuffle_zzzz ); -} - -inline Point3::Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ) -{ - vec_float4 tmp0, tmp1, tmp2, tmp3; - tmp0 = spu_shuffle( pnt0.get128(), pnt2.get128(), _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( pnt1.get128(), pnt3.get128(), _VECTORMATH_SHUF_XAYB ); - tmp2 = spu_shuffle( pnt0.get128(), pnt2.get128(), _VECTORMATH_SHUF_ZCWD ); - tmp3 = spu_shuffle( pnt1.get128(), pnt3.get128(), _VECTORMATH_SHUF_ZCWD ); - mX = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_XAYB ); - mY = spu_shuffle( tmp0, tmp1, _VECTORMATH_SHUF_ZCWD ); - mZ = spu_shuffle( tmp2, tmp3, _VECTORMATH_SHUF_XAYB ); -} - -inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ) -{ - return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) ); -} - -inline void Point3::get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const -{ - vec_float4 tmp0, tmp1; - tmp0 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_XAYB ); - tmp1 = spu_shuffle( mX, mZ, _VECTORMATH_SHUF_ZCWD ); - result0 = Aos::Point3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_XAYB ) ); - result1 = Aos::Point3( spu_shuffle( tmp0, mY, _VECTORMATH_SHUF_ZBW0 ) ); - result2 = Aos::Point3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_XCY0 ) ); - result3 = Aos::Point3( spu_shuffle( tmp1, mY, _VECTORMATH_SHUF_ZDW0 ) ); -} - -inline void loadXYZArray( Point3 & vec, const vec_float4 * threeQuads ) -{ - vec_float4 xyxy, yzyz, zxzx, xyzx, yzxy, zxyz; - xyzx = threeQuads[0]; - yzxy = threeQuads[1]; - zxyz = threeQuads[2]; - xyxy = spu_shuffle( xyzx, yzxy, _VECTORMATH_SHUF_XYCD ); - zxzx = spu_shuffle( zxyz, xyzx, _VECTORMATH_SHUF_XYCD ); - yzyz = spu_shuffle( yzxy, zxyz, _VECTORMATH_SHUF_XYCD ); - vec.setX( spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XDZB ) ); - vec.setY( spu_shuffle( xyxy, yzyz, _VECTORMATH_SHUF_YAWC ) ); - vec.setZ( spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_ZBXD ) ); -} - -inline void storeXYZArray( const Point3 & vec, vec_float4 * threeQuads ) -{ - vec_float4 xyzx, yzxy, zxyz, xyxy, zxzx, yzyz; - xyxy = spu_shuffle( vec.getX(), vec.getY(), _VECTORMATH_SHUF_XAZC ); - zxzx = spu_shuffle( vec.getZ(), vec.getX(), _VECTORMATH_SHUF_ZDXB ); - yzyz = spu_shuffle( vec.getY(), vec.getZ(), _VECTORMATH_SHUF_YBWD ); - xyzx = spu_shuffle( xyxy, zxzx, _VECTORMATH_SHUF_XYCD ); - yzxy = spu_shuffle( yzyz, xyxy, _VECTORMATH_SHUF_XYCD ); - zxyz = spu_shuffle( zxzx, yzyz, _VECTORMATH_SHUF_XYCD ); - threeQuads[0] = xyzx; - threeQuads[1] = yzxy; - threeQuads[2] = zxyz; -} - -inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ) -{ - vec_float4 xyz0[3]; - vec_float4 xyz1[3]; - storeXYZArray( pnt0, xyz0 ); - storeXYZArray( pnt1, xyz1 ); - threeQuads[0] = _vmath2VfToHalfFloats(xyz0[0], xyz0[1]); - threeQuads[1] = _vmath2VfToHalfFloats(xyz0[2], xyz1[0]); - threeQuads[2] = _vmath2VfToHalfFloats(xyz1[1], xyz1[2]); -} - -inline Point3 & Point3::operator =( const Point3 & pnt ) -{ - mX = pnt.mX; - mY = pnt.mY; - mZ = pnt.mZ; - return *this; -} - -inline Point3 & Point3::setX( vec_float4 _x ) -{ - mX = _x; - return *this; -} - -inline vec_float4 Point3::getX( ) const -{ - return mX; -} - -inline Point3 & Point3::setY( vec_float4 _y ) -{ - mY = _y; - return *this; -} - -inline vec_float4 Point3::getY( ) const -{ - return mY; -} - -inline Point3 & Point3::setZ( vec_float4 _z ) -{ - mZ = _z; - return *this; -} - -inline vec_float4 Point3::getZ( ) const -{ - return mZ; -} - -inline Point3 & Point3::setElem( int idx, vec_float4 value ) -{ - *(&mX + idx) = value; - return *this; -} - -inline vec_float4 Point3::getElem( int idx ) const -{ - return *(&mX + idx); -} - -inline Point3::vec_float4_t & Point3::operator []( int idx ) -{ - return *(&mX + idx); -} - -inline vec_float4 Point3::operator []( int idx ) const -{ - return *(&mX + idx); -} - -inline const Vector3 Point3::operator -( const Point3 & pnt ) const -{ - return Vector3( - spu_sub( mX, pnt.mX ), - spu_sub( mY, pnt.mY ), - spu_sub( mZ, pnt.mZ ) - ); -} - -inline const Point3 Point3::operator +( const Vector3 & vec ) const -{ - return Point3( - spu_add( mX, vec.getX() ), - spu_add( mY, vec.getY() ), - spu_add( mZ, vec.getZ() ) - ); -} - -inline const Point3 Point3::operator -( const Vector3 & vec ) const -{ - return Point3( - spu_sub( mX, vec.getX() ), - spu_sub( mY, vec.getY() ), - spu_sub( mZ, vec.getZ() ) - ); -} - -inline Point3 & Point3::operator +=( const Vector3 & vec ) -{ - *this = *this + vec; - return *this; -} - -inline Point3 & Point3::operator -=( const Vector3 & vec ) -{ - *this = *this - vec; - return *this; -} - -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - spu_mul( pnt0.getX(), pnt1.getX() ), - spu_mul( pnt0.getY(), pnt1.getY() ), - spu_mul( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - divf4( pnt0.getX(), pnt1.getX() ), - divf4( pnt0.getY(), pnt1.getY() ), - divf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline const Point3 recipPerElem( const Point3 & pnt ) -{ - return Point3( - recipf4( pnt.getX() ), - recipf4( pnt.getY() ), - recipf4( pnt.getZ() ) - ); -} - -inline const Point3 sqrtPerElem( const Point3 & pnt ) -{ - return Point3( - sqrtf4( pnt.getX() ), - sqrtf4( pnt.getY() ), - sqrtf4( pnt.getZ() ) - ); -} - -inline const Point3 rsqrtPerElem( const Point3 & pnt ) -{ - return Point3( - rsqrtf4( pnt.getX() ), - rsqrtf4( pnt.getY() ), - rsqrtf4( pnt.getZ() ) - ); -} - -inline const Point3 absPerElem( const Point3 & pnt ) -{ - return Point3( - fabsf4( pnt.getX() ), - fabsf4( pnt.getY() ), - fabsf4( pnt.getZ() ) - ); -} - -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - copysignf4( pnt0.getX(), pnt1.getX() ), - copysignf4( pnt0.getY(), pnt1.getY() ), - copysignf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - fmaxf4( pnt0.getX(), pnt1.getX() ), - fmaxf4( pnt0.getY(), pnt1.getY() ), - fmaxf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline vec_float4 maxElem( const Point3 & pnt ) -{ - vec_float4 result; - result = fmaxf4( pnt.getX(), pnt.getY() ); - result = fmaxf4( pnt.getZ(), result ); - return result; -} - -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return Point3( - fminf4( pnt0.getX(), pnt1.getX() ), - fminf4( pnt0.getY(), pnt1.getY() ), - fminf4( pnt0.getZ(), pnt1.getZ() ) - ); -} - -inline vec_float4 minElem( const Point3 & pnt ) -{ - vec_float4 result; - result = fminf4( pnt.getX(), pnt.getY() ); - result = fminf4( pnt.getZ(), result ); - return result; -} - -inline vec_float4 sum( const Point3 & pnt ) -{ - vec_float4 result; - result = spu_add( pnt.getX(), pnt.getY() ); - result = spu_add( result, pnt.getZ() ); - return result; -} - -inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ) -{ - return mulPerElem( pnt, Point3( scaleVal ) ); -} - -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ) -{ - return mulPerElem( pnt, Point3( scaleVec ) ); -} - -inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ) -{ - vec_float4 result; - result = spu_mul( pnt.getX(), unitVec.getX() ); - result = spu_add( result, spu_mul( pnt.getY(), unitVec.getY() ) ); - result = spu_add( result, spu_mul( pnt.getZ(), unitVec.getZ() ) ); - return result; -} - -inline vec_float4 distSqrFromOrigin( const Point3 & pnt ) -{ - return lengthSqr( Vector3( pnt ) ); -} - -inline vec_float4 distFromOrigin( const Point3 & pnt ) -{ - return length( Vector3( pnt ) ); -} - -inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return lengthSqr( ( pnt1 - pnt0 ) ); -} - -inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ) -{ - return length( ( pnt1 - pnt0 ) ); -} - -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ) -{ - return Point3( - spu_sel( pnt0.getX(), pnt1.getX(), select1 ), - spu_sel( pnt0.getY(), pnt1.getY(), select1 ), - spu_sel( pnt0.getZ(), pnt1.getZ(), select1 ) - ); -} - -#ifdef _VECTORMATH_DEBUG - -inline void print( const Point3 & pnt ) -{ - Aos::Point3 vec0, vec1, vec2, vec3; - pnt.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -inline void print( const Point3 & pnt, const char * name ) -{ - Aos::Point3 vec0, vec1, vec2, vec3; - printf( "%s:\n", name ); - pnt.get4Aos( vec0, vec1, vec2, vec3 ); - printf("slot 0:\n"); - print( vec0 ); - printf("slot 1:\n"); - print( vec1 ); - printf("slot 2:\n"); - print( vec2 ); - printf("slot 3:\n"); - print( vec3 ); -} - -#endif - -} // namespace Soa -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h deleted file mode 100644 index f5309153d..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vecidx_aos.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - 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 - -namespace Vectormath { -namespace Aos { - -//----------------------------------------------------------------------------- -// VecIdx -// Used in setting elements of Vector3, Vector4, Point3, or Quat with the -// subscripting operator. -// - -class VecIdx -{ -private: - typedef vec_float4 vec_float4_t; - vec_float4_t &ref __attribute__ ((aligned(16))); - int i __attribute__ ((aligned(16))); -public: - inline VecIdx( vec_float4& vec, int idx ): ref(vec) { i = idx; } - inline operator float() const; - inline float operator =( float scalar ); - inline float operator =( const VecIdx& scalar ); - inline float operator *=( float scalar ); - inline float operator /=( float scalar ); - inline float operator +=( float scalar ); - inline float operator -=( float scalar ); -}; - -} // namespace Aos -} // namespace Vectormath - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h deleted file mode 100644 index f876c5382..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_aos.h +++ /dev/null @@ -1,1851 +0,0 @@ -/* - 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_AOS_CPP_SPU_H -#define _VECTORMATH_AOS_CPP_SPU_H - -#include -#include -#include "floatInVec.h" -#include "boolInVec.h" -#include "vecidx_aos.h" -#include - -#ifdef _VECTORMATH_DEBUG -#endif - -namespace Vectormath { - -namespace Aos { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A 3-D vector in array-of-structures format -// -class Vector3 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( float x, float y, float z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( Point3 pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( float scalar ); - - // Set vector float data in a 3-D vector - // - explicit inline Vector3( vec_float4 vf4 ); - - // Get vector float data from a 3-D vector - // - inline vec_float4 get128( ) const; - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( Vector3 vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( float x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( float y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( float z ); - - // Get the x element of a 3-D vector - // - inline float getX( ) const; - - // Get the y element of a 3-D vector - // - inline float getY( ) const; - - // Get the z element of a 3-D vector - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( Vector3 vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( Vector3 vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( Point3 pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( float scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( Vector3 vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( Vector3 vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( float scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( float scalar, Vector3 vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( Vector3 vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( Vector3 vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( Vector3 vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( Vector3 vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 ); - -// Maximum element of a 3-D vector -// -inline float maxElem( Vector3 vec ); - -// Minimum element of a 3-D vector -// -inline float minElem( Vector3 vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline float sum( Vector3 vec ); - -// Compute the dot product of two 3-D vectors -// -inline float dot( Vector3 vec0, Vector3 vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline float lengthSqr( Vector3 vec ); - -// Compute the length of a 3-D vector -// -inline float length( Vector3 vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( Vector3 vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( Vector3 vec0, Vector3 vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( Vector3 vec0, Vector3 vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// NOTE: -// Slower than column post-multiply. -// -inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( Vector3 vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 ); - -// Store x, y, and z elements of a 3-D vector in the first three words of a quadword. -// The value of the fourth word (the word with the highest address) remains unchanged -// -inline void storeXYZ( Vector3 vec, vec_float4 * quad ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads ); - -// Store four 3-D vectors in three quadwords -// -inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads ); - -// Store eight 3-D vectors as half-floats -// -inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector3 vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector3 vec, const char * name ); - -#endif - -// A 4-D vector in array-of-structures format -// -class Vector4 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( float x, float y, float z, float w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( Vector3 xyz, float w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( Vector3 vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( Point3 pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( Quat quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( float scalar ); - - // Set vector float data in a 4-D vector - // - explicit inline Vector4( vec_float4 vf4 ); - - // Get vector float data from a 4-D vector - // - inline vec_float4 get128( ) const; - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( Vector4 vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( Vector3 vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( float x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( float y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( float z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( float w ); - - // Get the x element of a 4-D vector - // - inline float getX( ) const; - - // Get the y element of a 4-D vector - // - inline float getY( ) const; - - // Get the z element of a 4-D vector - // - inline float getZ( ) const; - - // Get the w element of a 4-D vector - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( Vector4 vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( Vector4 vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( float scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( float scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( Vector4 vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( Vector4 vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( float scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( float scalar, Vector4 vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( Vector4 vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( Vector4 vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( Vector4 vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( Vector4 vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 ); - -// Maximum element of a 4-D vector -// -inline float maxElem( Vector4 vec ); - -// Minimum element of a 4-D vector -// -inline float minElem( Vector4 vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline float sum( Vector4 vec ); - -// Compute the dot product of two 4-D vectors -// -inline float dot( Vector4 vec0, Vector4 vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline float lengthSqr( Vector4 vec ); - -// Compute the length of a 4-D vector -// -inline float length( Vector4 vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( Vector4 vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( Vector4 vec0, Vector4 vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 ); - -// Store four 4-D vectors as half-floats -// -inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector4 vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Vector4 vec, const char * name ); - -#endif - -// A 3-D point in array-of-structures format -// -class Point3 -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( float x, float y, float z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( Vector3 vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( float scalar ); - - // Set vector float data in a 3-D point - // - explicit inline Point3( vec_float4 vf4 ); - - // Get vector float data from a 3-D point - // - inline vec_float4 get128( ) const; - - // Assign one 3-D point to another - // - inline Point3 & operator =( Point3 pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( float x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( float y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( float z ); - - // Get the x element of a 3-D point - // - inline float getX( ) const; - - // Get the y element of a 3-D point - // - inline float getY( ) const; - - // Get the z element of a 3-D point - // - inline float getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, float value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( Point3 pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( Vector3 vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( Vector3 vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( Vector3 vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( Vector3 vec ); - -}; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( Point3 pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( Point3 pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( Point3 pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( Point3 pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 ); - -// Maximum element of a 3-D point -// -inline float maxElem( Point3 pnt ); - -// Minimum element of a 3-D point -// -inline float minElem( Point3 pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline float sum( Point3 pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( Point3 pnt, float scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( Point3 pnt, Vector3 scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline float projection( Point3 pnt, Vector3 unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline float distSqrFromOrigin( Point3 pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline float distFromOrigin( Point3 pnt ); - -// Compute the square of the distance between two 3-D points -// -inline float distSqr( Point3 pnt0, Point3 pnt1 ); - -// Compute the distance between two 3-D points -// -inline float dist( Point3 pnt0, Point3 pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 ); - -// Store x, y, and z elements of a 3-D point in the first three words of a quadword. -// The value of the fourth word (the word with the highest address) remains unchanged -// -inline void storeXYZ( Point3 pnt, vec_float4 * quad ); - -// Load four three-float 3-D points, stored in three quadwords -// -inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads ); - -// Store four 3-D points in three quadwords -// -inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads ); - -// Store eight 3-D points as half-floats -// -inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Point3 pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Point3 pnt, const char * name ); - -#endif - -// A quaternion in array-of-structures format -// -class Quat -{ - vec_float4 mVec128; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( float x, float y, float z, float w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( Vector3 xyz, float w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( Vector4 vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( float scalar ); - - // Set vector float data in a quaternion - // - explicit inline Quat( vec_float4 vf4 ); - - // Get vector float data from a quaternion - // - inline vec_float4 get128( ) const; - - // Assign one quaternion to another - // - inline Quat & operator =( Quat quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( Vector3 vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( float x ); - - // Set the y element of a quaternion - // - inline Quat & setY( float y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( float z ); - - // Set the w element of a quaternion - // - inline Quat & setW( float w ); - - // Get the x element of a quaternion - // - inline float getX( ) const; - - // Get the y element of a quaternion - // - inline float getY( ) const; - - // Get the z element of a quaternion - // - inline float getZ( ) const; - - // Get the w element of a quaternion - // - inline float getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, float value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline float getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline VecIdx operator []( int idx ); - - // Subscripting operator to get an element - // - inline float operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( Quat quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( Quat quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( Quat quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( float scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( float scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( Quat quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( Quat quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( Quat quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( float scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( float scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( Vector3 unitVec0, Vector3 unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( float radians, Vector3 unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( float radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( float radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( float radians ); - -}; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( float scalar, Quat quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( Quat quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( Quat unitQuat, Vector3 vec ); - -// Compute the dot product of two quaternions -// -inline float dot( Quat quat0, Quat quat1 ); - -// Compute the norm of a quaternion -// -inline float norm( Quat quat ); - -// Compute the length of a quaternion -// -inline float length( Quat quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( Quat quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( float t, Quat quat0, Quat quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Quat select( Quat quat0, Quat quat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Quat quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( Quat quat, const char * name ); - -#endif - -// A 3x3 matrix in array-of-structures format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( Vector3 col0, Vector3 col1, Vector3 col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( Quat unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( float scalar ); - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( Vector3 col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( Vector3 col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( Vector3 col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, Vector3 vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, Vector3 vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, float val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( float scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( Vector3 vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( float radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( float radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( float radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( float radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( Quat unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( Vector3 scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( float scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline float determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A 4x4 matrix in array-of-structures format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( Vector4 col0, Vector4 col1, Vector4 col2, Vector4 col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, Vector3 translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( Quat unitQuat, Vector3 translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( float scalar ); - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( Vector3 translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( Vector4 col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( Vector4 col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( Vector4 col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( Vector4 col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, Vector4 vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, Vector4 vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, float val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( float scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( Vector4 vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( Vector3 vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( Point3 pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( float scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( float radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( float radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( float radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( float radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( Quat unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( Vector3 scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( Vector3 translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( float scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline float determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A 3x4 transformation matrix in array-of-structures format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( Vector3 col0, Vector3 col1, Vector3 col2, Vector3 col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, Vector3 translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( Quat unitQuat, Vector3 translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( float scalar ); - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( Vector3 translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( Vector3 col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( Vector3 col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( Vector3 col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( Vector3 col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, Vector3 vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, Vector4 vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, float val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline float getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( Vector3 vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( Point3 pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( float radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( Vector3 radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( float radians, Vector3 unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( Quat unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( Vector3 scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( Vector3 translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Aos -} // namespace Vectormath - -#include "vec_aos.h" -#include "quat_aos.h" -#include "mat_aos.h" - -#endif diff --git a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h b/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h deleted file mode 100644 index c37927b38..000000000 --- a/Extras/vectormathlibrary/include/vectormath/spu/cpp/vectormath_soa.h +++ /dev/null @@ -1,1921 +0,0 @@ -/* - 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_SOA_CPP_SPU_H -#define _VECTORMATH_SOA_CPP_SPU_H - -#include -#include -#include "floatInVec.h" -#include "boolInVec.h" -#include "vectormath_aos.h" -#include - -#ifdef _VECTORMATH_DEBUG -#endif - -namespace Vectormath { - -namespace Soa { - -//----------------------------------------------------------------------------- -// Forward Declarations -// - -class Vector3; -class Vector4; -class Point3; -class Quat; -class Matrix3; -class Matrix4; -class Transform3; - -// A set of four 3-D vectors in structure-of-arrays format -// -class Vector3 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - -public: - // Default constructor; does no initialization - // - inline Vector3( ) { }; - - // Copy a 3-D vector - // - inline Vector3( const Vector3 & vec ); - - // Construct a 3-D vector from x, y, and z elements - // - inline Vector3( vec_float4 x, vec_float4 y, vec_float4 z ); - - // Copy elements from a 3-D point into a 3-D vector - // - explicit inline Vector3( const Point3 & pnt ); - - // Set all elements of a 3-D vector to the same scalar value - // - explicit inline Vector3( vec_float4 scalar ); - - // Replicate an AoS 3-D vector - // - inline Vector3( Aos::Vector3 vec ); - - // Insert four AoS 3-D vectors - // - inline Vector3( Aos::Vector3 vec0, Aos::Vector3 vec1, Aos::Vector3 vec2, Aos::Vector3 vec3 ); - - // Extract four AoS 3-D vectors - // - inline void get4Aos( Aos::Vector3 & result0, Aos::Vector3 & result1, Aos::Vector3 & result2, Aos::Vector3 & result3 ) const; - - // Assign one 3-D vector to another - // - inline Vector3 & operator =( const Vector3 & vec ); - - // Set the x element of a 3-D vector - // - inline Vector3 & setX( vec_float4 x ); - - // Set the y element of a 3-D vector - // - inline Vector3 & setY( vec_float4 y ); - - // Set the z element of a 3-D vector - // - inline Vector3 & setZ( vec_float4 z ); - - // Get the x element of a 3-D vector - // - inline vec_float4 getX( ) const; - - // Get the y element of a 3-D vector - // - inline vec_float4 getY( ) const; - - // Get the z element of a 3-D vector - // - inline vec_float4 getZ( ) const; - - // Set an x, y, or z element of a 3-D vector by index - // - inline Vector3 & setElem( int idx, vec_float4 value ); - - // Get an x, y, or z element of a 3-D vector by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two 3-D vectors - // - inline const Vector3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from another 3-D vector - // - inline const Vector3 operator -( const Vector3 & vec ) const; - - // Add a 3-D vector to a 3-D point - // - inline const Point3 operator +( const Point3 & pnt ) const; - - // Multiply a 3-D vector by a scalar - // - inline const Vector3 operator *( vec_float4 scalar ) const; - - // Divide a 3-D vector by a scalar - // - inline const Vector3 operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Vector3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Vector3 & operator -=( const Vector3 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector3 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector3 & operator /=( vec_float4 scalar ); - - // Negate all elements of a 3-D vector - // - inline const Vector3 operator -( ) const; - - // Construct x axis - // - static inline const Vector3 xAxis( ); - - // Construct y axis - // - static inline const Vector3 yAxis( ); - - // Construct z axis - // - static inline const Vector3 zAxis( ); - -}; - -// Multiply a 3-D vector by a scalar -// -inline const Vector3 operator *( vec_float4 scalar, const Vector3 & vec ); - -// Multiply two 3-D vectors per element -// -inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Divide two 3-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the reciprocal of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector3 recipPerElem( const Vector3 & vec ); - -// Compute the square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector3 sqrtPerElem( const Vector3 & vec ); - -// Compute the reciprocal square root of a 3-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector3 rsqrtPerElem( const Vector3 & vec ); - -// Compute the absolute value of a 3-D vector per element -// -inline const Vector3 absPerElem( const Vector3 & vec ); - -// Copy sign from one 3-D vector to another, per element -// -inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum of two 3-D vectors per element -// -inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Minimum of two 3-D vectors per element -// -inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 ); - -// Maximum element of a 3-D vector -// -inline vec_float4 maxElem( const Vector3 & vec ); - -// Minimum element of a 3-D vector -// -inline vec_float4 minElem( const Vector3 & vec ); - -// Compute the sum of all elements of a 3-D vector -// -inline vec_float4 sum( const Vector3 & vec ); - -// Compute the dot product of two 3-D vectors -// -inline vec_float4 dot( const Vector3 & vec0, const Vector3 & vec1 ); - -// Compute the square of the length of a 3-D vector -// -inline vec_float4 lengthSqr( const Vector3 & vec ); - -// Compute the length of a 3-D vector -// -inline vec_float4 length( const Vector3 & vec ); - -// Normalize a 3-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector3 normalize( const Vector3 & vec ); - -// Compute cross product of two 3-D vectors -// -inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 ); - -// Outer product of two 3-D vectors -// -inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 ); - -// Pre-multiply a row vector by a 3x3 matrix -// -inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat ); - -// Cross-product matrix of a 3-D vector -// -inline const Matrix3 crossMatrix( const Vector3 & vec ); - -// Create cross-product matrix and multiply -// NOTE: -// Faster than separately creating a cross-product matrix and multiplying. -// -inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat ); - -// Linear interpolation between two 3-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector3 lerp( vec_float4 t, const Vector3 & vec0, const Vector3 & vec1 ); - -// Spherical linear interpolation between two 3-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector3 slerp( vec_float4 t, const Vector3 & unitVec0, const Vector3 & unitVec1 ); - -// Conditionally select between two 3-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, vec_uint4 select1 ); - -// Load four three-float 3-D vectors, stored in three quadwords -// -inline void loadXYZArray( Vector3 & vec, const vec_float4 * threeQuads ); - -// Store four slots of an SoA 3-D vector in three quadwords -// -inline void storeXYZArray( const Vector3 & vec, vec_float4 * threeQuads ); - -// Store eight slots of two SoA 3-D vectors as half-floats -// -inline void storeHalfFloats( const Vector3 & vec0, const Vector3 & vec1, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec ); - -// Print a 3-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector3 & vec, const char * name ); - -#endif - -// A set of four 4-D vectors in structure-of-arrays format -// -class Vector4 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - vec_float4 mW; - -public: - // Default constructor; does no initialization - // - inline Vector4( ) { }; - - // Copy a 4-D vector - // - inline Vector4( const Vector4 & vec ); - - // Construct a 4-D vector from x, y, z, and w elements - // - inline Vector4( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - - // Construct a 4-D vector from a 3-D vector and a scalar - // - inline Vector4( const Vector3 & xyz, vec_float4 w ); - - // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0 - // - explicit inline Vector4( const Vector3 & vec ); - - // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1 - // - explicit inline Vector4( const Point3 & pnt ); - - // Copy elements from a quaternion into a 4-D vector - // - explicit inline Vector4( const Quat & quat ); - - // Set all elements of a 4-D vector to the same scalar value - // - explicit inline Vector4( vec_float4 scalar ); - - // Replicate an AoS 4-D vector - // - inline Vector4( Aos::Vector4 vec ); - - // Insert four AoS 4-D vectors - // - inline Vector4( Aos::Vector4 vec0, Aos::Vector4 vec1, Aos::Vector4 vec2, Aos::Vector4 vec3 ); - - // Extract four AoS 4-D vectors - // - inline void get4Aos( Aos::Vector4 & result0, Aos::Vector4 & result1, Aos::Vector4 & result2, Aos::Vector4 & result3 ) const; - - // Assign one 4-D vector to another - // - inline Vector4 & operator =( const Vector4 & vec ); - - // Set the x, y, and z elements of a 4-D vector - // NOTE: - // This function does not change the w element. - // - inline Vector4 & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a 4-D vector - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a 4-D vector - // - inline Vector4 & setX( vec_float4 x ); - - // Set the y element of a 4-D vector - // - inline Vector4 & setY( vec_float4 y ); - - // Set the z element of a 4-D vector - // - inline Vector4 & setZ( vec_float4 z ); - - // Set the w element of a 4-D vector - // - inline Vector4 & setW( vec_float4 w ); - - // Get the x element of a 4-D vector - // - inline vec_float4 getX( ) const; - - // Get the y element of a 4-D vector - // - inline vec_float4 getY( ) const; - - // Get the z element of a 4-D vector - // - inline vec_float4 getZ( ) const; - - // Get the w element of a 4-D vector - // - inline vec_float4 getW( ) const; - - // Set an x, y, z, or w element of a 4-D vector by index - // - inline Vector4 & setElem( int idx, vec_float4 value ); - - // Get an x, y, z, or w element of a 4-D vector by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two 4-D vectors - // - inline const Vector4 operator +( const Vector4 & vec ) const; - - // Subtract a 4-D vector from another 4-D vector - // - inline const Vector4 operator -( const Vector4 & vec ) const; - - // Multiply a 4-D vector by a scalar - // - inline const Vector4 operator *( vec_float4 scalar ) const; - - // Divide a 4-D vector by a scalar - // - inline const Vector4 operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a 4-D vector - // - inline Vector4 & operator +=( const Vector4 & vec ); - - // Perform compound assignment and subtraction by a 4-D vector - // - inline Vector4 & operator -=( const Vector4 & vec ); - - // Perform compound assignment and multiplication by a scalar - // - inline Vector4 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Vector4 & operator /=( vec_float4 scalar ); - - // Negate all elements of a 4-D vector - // - inline const Vector4 operator -( ) const; - - // Construct x axis - // - static inline const Vector4 xAxis( ); - - // Construct y axis - // - static inline const Vector4 yAxis( ); - - // Construct z axis - // - static inline const Vector4 zAxis( ); - - // Construct w axis - // - static inline const Vector4 wAxis( ); - -}; - -// Multiply a 4-D vector by a scalar -// -inline const Vector4 operator *( vec_float4 scalar, const Vector4 & vec ); - -// Multiply two 4-D vectors per element -// -inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Divide two 4-D vectors per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the reciprocal of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Vector4 recipPerElem( const Vector4 & vec ); - -// Compute the square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Vector4 sqrtPerElem( const Vector4 & vec ); - -// Compute the reciprocal square root of a 4-D vector per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Vector4 rsqrtPerElem( const Vector4 & vec ); - -// Compute the absolute value of a 4-D vector per element -// -inline const Vector4 absPerElem( const Vector4 & vec ); - -// Copy sign from one 4-D vector to another, per element -// -inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum of two 4-D vectors per element -// -inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Minimum of two 4-D vectors per element -// -inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 ); - -// Maximum element of a 4-D vector -// -inline vec_float4 maxElem( const Vector4 & vec ); - -// Minimum element of a 4-D vector -// -inline vec_float4 minElem( const Vector4 & vec ); - -// Compute the sum of all elements of a 4-D vector -// -inline vec_float4 sum( const Vector4 & vec ); - -// Compute the dot product of two 4-D vectors -// -inline vec_float4 dot( const Vector4 & vec0, const Vector4 & vec1 ); - -// Compute the square of the length of a 4-D vector -// -inline vec_float4 lengthSqr( const Vector4 & vec ); - -// Compute the length of a 4-D vector -// -inline vec_float4 length( const Vector4 & vec ); - -// Normalize a 4-D vector -// NOTE: -// The result is unpredictable when all elements of vec are at or near zero. -// -inline const Vector4 normalize( const Vector4 & vec ); - -// Outer product of two 4-D vectors -// -inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 ); - -// Linear interpolation between two 4-D vectors -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Vector4 lerp( vec_float4 t, const Vector4 & vec0, const Vector4 & vec1 ); - -// Spherical linear interpolation between two 4-D vectors -// NOTE: -// The result is unpredictable if the vectors point in opposite directions. -// Does not clamp t between 0 and 1. -// -inline const Vector4 slerp( vec_float4 t, const Vector4 & unitVec0, const Vector4 & unitVec1 ); - -// Conditionally select between two 4-D vectors -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, vec_uint4 select1 ); - -// Store four slots of an SoA 4-D vector as half-floats -// -inline void storeHalfFloats( const Vector4 & vec, vec_ushort8 * twoQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4-D vector -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec ); - -// Print a 4-D vector and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Vector4 & vec, const char * name ); - -#endif - -// A set of four 3-D points in structure-of-arrays format -// -class Point3 -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - -public: - // Default constructor; does no initialization - // - inline Point3( ) { }; - - // Copy a 3-D point - // - inline Point3( const Point3 & pnt ); - - // Construct a 3-D point from x, y, and z elements - // - inline Point3( vec_float4 x, vec_float4 y, vec_float4 z ); - - // Copy elements from a 3-D vector into a 3-D point - // - explicit inline Point3( const Vector3 & vec ); - - // Set all elements of a 3-D point to the same scalar value - // - explicit inline Point3( vec_float4 scalar ); - - // Replicate an AoS 3-D point - // - inline Point3( Aos::Point3 pnt ); - - // Insert four AoS 3-D points - // - inline Point3( Aos::Point3 pnt0, Aos::Point3 pnt1, Aos::Point3 pnt2, Aos::Point3 pnt3 ); - - // Extract four AoS 3-D points - // - inline void get4Aos( Aos::Point3 & result0, Aos::Point3 & result1, Aos::Point3 & result2, Aos::Point3 & result3 ) const; - - // Assign one 3-D point to another - // - inline Point3 & operator =( const Point3 & pnt ); - - // Set the x element of a 3-D point - // - inline Point3 & setX( vec_float4 x ); - - // Set the y element of a 3-D point - // - inline Point3 & setY( vec_float4 y ); - - // Set the z element of a 3-D point - // - inline Point3 & setZ( vec_float4 z ); - - // Get the x element of a 3-D point - // - inline vec_float4 getX( ) const; - - // Get the y element of a 3-D point - // - inline vec_float4 getY( ) const; - - // Get the z element of a 3-D point - // - inline vec_float4 getZ( ) const; - - // Set an x, y, or z element of a 3-D point by index - // - inline Point3 & setElem( int idx, vec_float4 value ); - - // Get an x, y, or z element of a 3-D point by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Subtract a 3-D point from another 3-D point - // - inline const Vector3 operator -( const Point3 & pnt ) const; - - // Add a 3-D point to a 3-D vector - // - inline const Point3 operator +( const Vector3 & vec ) const; - - // Subtract a 3-D vector from a 3-D point - // - inline const Point3 operator -( const Vector3 & vec ) const; - - // Perform compound assignment and addition with a 3-D vector - // - inline Point3 & operator +=( const Vector3 & vec ); - - // Perform compound assignment and subtraction by a 3-D vector - // - inline Point3 & operator -=( const Vector3 & vec ); - -}; - -// Multiply two 3-D points per element -// -inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Divide two 3-D points per element -// NOTE: -// Floating-point behavior matches standard library function divf4. -// -inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the reciprocal of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function recipf4. -// -inline const Point3 recipPerElem( const Point3 & pnt ); - -// Compute the square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function sqrtf4. -// -inline const Point3 sqrtPerElem( const Point3 & pnt ); - -// Compute the reciprocal square root of a 3-D point per element -// NOTE: -// Floating-point behavior matches standard library function rsqrtf4. -// -inline const Point3 rsqrtPerElem( const Point3 & pnt ); - -// Compute the absolute value of a 3-D point per element -// -inline const Point3 absPerElem( const Point3 & pnt ); - -// Copy sign from one 3-D point to another, per element -// -inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum of two 3-D points per element -// -inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Minimum of two 3-D points per element -// -inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 ); - -// Maximum element of a 3-D point -// -inline vec_float4 maxElem( const Point3 & pnt ); - -// Minimum element of a 3-D point -// -inline vec_float4 minElem( const Point3 & pnt ); - -// Compute the sum of all elements of a 3-D point -// -inline vec_float4 sum( const Point3 & pnt ); - -// Apply uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, vec_float4 scaleVal ); - -// Apply non-uniform scale to a 3-D point -// -inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec ); - -// Scalar projection of a 3-D point on a unit-length 3-D vector -// -inline vec_float4 projection( const Point3 & pnt, const Vector3 & unitVec ); - -// Compute the square of the distance of a 3-D point from the coordinate-system origin -// -inline vec_float4 distSqrFromOrigin( const Point3 & pnt ); - -// Compute the distance of a 3-D point from the coordinate-system origin -// -inline vec_float4 distFromOrigin( const Point3 & pnt ); - -// Compute the square of the distance between two 3-D points -// -inline vec_float4 distSqr( const Point3 & pnt0, const Point3 & pnt1 ); - -// Compute the distance between two 3-D points -// -inline vec_float4 dist( const Point3 & pnt0, const Point3 & pnt1 ); - -// Linear interpolation between two 3-D points -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Point3 lerp( vec_float4 t, const Point3 & pnt0, const Point3 & pnt1 ); - -// Conditionally select between two 3-D points -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, vec_uint4 select1 ); - -// Load four three-float 3-D points, stored in three quadwords -// -inline void loadXYZArray( Point3 & pnt, const vec_float4 * threeQuads ); - -// Store four slots of an SoA 3-D point in three quadwords -// -inline void storeXYZArray( const Point3 & pnt, vec_float4 * threeQuads ); - -// Store eight slots of two SoA 3-D points as half-floats -// -inline void storeHalfFloats( const Point3 & pnt0, const Point3 & pnt1, vec_ushort8 * threeQuads ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3-D point -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt ); - -// Print a 3-D point and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Point3 & pnt, const char * name ); - -#endif - -// A set of four quaternions in structure-of-arrays format -// -class Quat -{ - typedef vec_float4 vec_float4_t; - vec_float4 mX; - vec_float4 mY; - vec_float4 mZ; - vec_float4 mW; - -public: - // Default constructor; does no initialization - // - inline Quat( ) { }; - - // Copy a quaternion - // - inline Quat( const Quat & quat ); - - // Construct a quaternion from x, y, z, and w elements - // - inline Quat( vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w ); - - // Construct a quaternion from a 3-D vector and a scalar - // - inline Quat( const Vector3 & xyz, vec_float4 w ); - - // Copy elements from a 4-D vector into a quaternion - // - explicit inline Quat( const Vector4 & vec ); - - // Convert a rotation matrix to a unit-length quaternion - // - explicit inline Quat( const Matrix3 & rotMat ); - - // Set all elements of a quaternion to the same scalar value - // - explicit inline Quat( vec_float4 scalar ); - - // Replicate an AoS quaternion - // - inline Quat( Aos::Quat quat ); - - // Insert four AoS quaternions - // - inline Quat( Aos::Quat quat0, Aos::Quat quat1, Aos::Quat quat2, Aos::Quat quat3 ); - - // Extract four AoS quaternions - // - inline void get4Aos( Aos::Quat & result0, Aos::Quat & result1, Aos::Quat & result2, Aos::Quat & result3 ) const; - - // Assign one quaternion to another - // - inline Quat & operator =( const Quat & quat ); - - // Set the x, y, and z elements of a quaternion - // NOTE: - // This function does not change the w element. - // - inline Quat & setXYZ( const Vector3 & vec ); - - // Get the x, y, and z elements of a quaternion - // - inline const Vector3 getXYZ( ) const; - - // Set the x element of a quaternion - // - inline Quat & setX( vec_float4 x ); - - // Set the y element of a quaternion - // - inline Quat & setY( vec_float4 y ); - - // Set the z element of a quaternion - // - inline Quat & setZ( vec_float4 z ); - - // Set the w element of a quaternion - // - inline Quat & setW( vec_float4 w ); - - // Get the x element of a quaternion - // - inline vec_float4 getX( ) const; - - // Get the y element of a quaternion - // - inline vec_float4 getY( ) const; - - // Get the z element of a quaternion - // - inline vec_float4 getZ( ) const; - - // Get the w element of a quaternion - // - inline vec_float4 getW( ) const; - - // Set an x, y, z, or w element of a quaternion by index - // - inline Quat & setElem( int idx, vec_float4 value ); - - // Get an x, y, z, or w element of a quaternion by index - // - inline vec_float4 getElem( int idx ) const; - - // Subscripting operator to set or get an element - // - inline vec_float4_t & operator []( int idx ); - - // Subscripting operator to get an element - // - inline vec_float4 operator []( int idx ) const; - - // Add two quaternions - // - inline const Quat operator +( const Quat & quat ) const; - - // Subtract a quaternion from another quaternion - // - inline const Quat operator -( const Quat & quat ) const; - - // Multiply two quaternions - // - inline const Quat operator *( const Quat & quat ) const; - - // Multiply a quaternion by a scalar - // - inline const Quat operator *( vec_float4 scalar ) const; - - // Divide a quaternion by a scalar - // - inline const Quat operator /( vec_float4 scalar ) const; - - // Perform compound assignment and addition with a quaternion - // - inline Quat & operator +=( const Quat & quat ); - - // Perform compound assignment and subtraction by a quaternion - // - inline Quat & operator -=( const Quat & quat ); - - // Perform compound assignment and multiplication by a quaternion - // - inline Quat & operator *=( const Quat & quat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Quat & operator *=( vec_float4 scalar ); - - // Perform compound assignment and division by a scalar - // - inline Quat & operator /=( vec_float4 scalar ); - - // Negate all elements of a quaternion - // - inline const Quat operator -( ) const; - - // Construct an identity quaternion - // - static inline const Quat identity( ); - - // Construct a quaternion to rotate between two unit-length 3-D vectors - // NOTE: - // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions. - // - static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 ); - - // Construct a quaternion to rotate around a unit-length 3-D vector - // - static inline const Quat rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a quaternion to rotate around the x axis - // - static inline const Quat rotationX( vec_float4 radians ); - - // Construct a quaternion to rotate around the y axis - // - static inline const Quat rotationY( vec_float4 radians ); - - // Construct a quaternion to rotate around the z axis - // - static inline const Quat rotationZ( vec_float4 radians ); - -}; - -// Multiply a quaternion by a scalar -// -inline const Quat operator *( vec_float4 scalar, const Quat & quat ); - -// Compute the conjugate of a quaternion -// -inline const Quat conj( const Quat & quat ); - -// Use a unit-length quaternion to rotate a 3-D vector -// -inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec ); - -// Compute the dot product of two quaternions -// -inline vec_float4 dot( const Quat & quat0, const Quat & quat1 ); - -// Compute the norm of a quaternion -// -inline vec_float4 norm( const Quat & quat ); - -// Compute the length of a quaternion -// -inline vec_float4 length( const Quat & quat ); - -// Normalize a quaternion -// NOTE: -// The result is unpredictable when all elements of quat are at or near zero. -// -inline const Quat normalize( const Quat & quat ); - -// Linear interpolation between two quaternions -// NOTE: -// Does not clamp t between 0 and 1. -// -inline const Quat lerp( vec_float4 t, const Quat & quat0, const Quat & quat1 ); - -// Spherical linear interpolation between two quaternions -// NOTE: -// Interpolates along the shortest path between orientations. -// Does not clamp t between 0 and 1. -// -inline const Quat slerp( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1 ); - -// Spherical quadrangle interpolation -// -inline const Quat squad( vec_float4 t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 ); - -// Conditionally select between two quaternions -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Quat select( const Quat & quat0, const Quat & quat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a quaternion -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat ); - -// Print a quaternion and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Quat & quat, const char * name ); - -#endif - -// A set of four 3x3 matrices in structure-of-arrays format -// -class Matrix3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - -public: - // Default constructor; does no initialization - // - inline Matrix3( ) { }; - - // Copy a 3x3 matrix - // - inline Matrix3( const Matrix3 & mat ); - - // Construct a 3x3 matrix containing the specified columns - // - inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 ); - - // Construct a 3x3 rotation matrix from a unit-length quaternion - // - explicit inline Matrix3( const Quat & unitQuat ); - - // Set all elements of a 3x3 matrix to the same scalar value - // - explicit inline Matrix3( vec_float4 scalar ); - - // Replicate an AoS 3x3 matrix - // - inline Matrix3( const Aos::Matrix3 & mat ); - - // Insert four AoS 3x3 matrices - // - inline Matrix3( const Aos::Matrix3 & mat0, const Aos::Matrix3 & mat1, const Aos::Matrix3 & mat2, const Aos::Matrix3 & mat3 ); - - // Extract four AoS 3x3 matrices - // - inline void get4Aos( Aos::Matrix3 & result0, Aos::Matrix3 & result1, Aos::Matrix3 & result2, Aos::Matrix3 & result3 ) const; - - // Assign one 3x3 matrix to another - // - inline Matrix3 & operator =( const Matrix3 & mat ); - - // Set column 0 of a 3x3 matrix - // - inline Matrix3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x3 matrix - // - inline Matrix3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x3 matrix - // - inline Matrix3 & setCol2( const Vector3 & col2 ); - - // Get column 0 of a 3x3 matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x3 matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x3 matrix - // - inline const Vector3 getCol2( ) const; - - // Set the column of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x3 matrix referred to by the specified index - // - inline Matrix3 & setRow( int row, const Vector3 & vec ); - - // Get the column of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x3 matrix referred to by the specified index - // - inline const Vector3 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x3 matrix referred to by column and row indices - // - inline Matrix3 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 3x3 matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Add two 3x3 matrices - // - inline const Matrix3 operator +( const Matrix3 & mat ) const; - - // Subtract a 3x3 matrix from another 3x3 matrix - // - inline const Matrix3 operator -( const Matrix3 & mat ) const; - - // Negate all elements of a 3x3 matrix - // - inline const Matrix3 operator -( ) const; - - // Multiply a 3x3 matrix by a scalar - // - inline const Matrix3 operator *( vec_float4 scalar ) const; - - // Multiply a 3x3 matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply two 3x3 matrices - // - inline const Matrix3 operator *( const Matrix3 & mat ) const; - - // Perform compound assignment and addition with a 3x3 matrix - // - inline Matrix3 & operator +=( const Matrix3 & mat ); - - // Perform compound assignment and subtraction by a 3x3 matrix - // - inline Matrix3 & operator -=( const Matrix3 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix3 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and multiplication by a 3x3 matrix - // - inline Matrix3 & operator *=( const Matrix3 & mat ); - - // Construct an identity 3x3 matrix - // - static inline const Matrix3 identity( ); - - // Construct a 3x3 matrix to rotate around the x axis - // - static inline const Matrix3 rotationX( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the y axis - // - static inline const Matrix3 rotationY( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the z axis - // - static inline const Matrix3 rotationZ( vec_float4 radians ); - - // Construct a 3x3 matrix to rotate around the x, y, and z axes - // - static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x3 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix3 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix3 rotation( const Quat & unitQuat ); - - // Construct a 3x3 matrix to perform scaling - // - static inline const Matrix3 scale( const Vector3 & scaleVec ); - -}; -// Multiply a 3x3 matrix by a scalar -// -inline const Matrix3 operator *( vec_float4 scalar, const Matrix3 & mat ); - -// Append (post-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x3 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat ); - -// Multiply two 3x3 matrices per element -// -inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 ); - -// Compute the absolute value of a 3x3 matrix per element -// -inline const Matrix3 absPerElem( const Matrix3 & mat ); - -// Transpose of a 3x3 matrix -// -inline const Matrix3 transpose( const Matrix3 & mat ); - -// Compute the inverse of a 3x3 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix3 inverse( const Matrix3 & mat ); - -// Determinant of a 3x3 matrix -// -inline vec_float4 determinant( const Matrix3 & mat ); - -// Conditionally select between two 3x3 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x3 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat ); - -// Print a 3x3 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix3 & mat, const char * name ); - -#endif - -// A set of four 4x4 matrices in structure-of-arrays format -// -class Matrix4 -{ - Vector4 mCol0; - Vector4 mCol1; - Vector4 mCol2; - Vector4 mCol3; - -public: - // Default constructor; does no initialization - // - inline Matrix4( ) { }; - - // Copy a 4x4 matrix - // - inline Matrix4( const Matrix4 & mat ); - - // Construct a 4x4 matrix containing the specified columns - // - inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 ); - - // Construct a 4x4 matrix from a 3x4 transformation matrix - // - explicit inline Matrix4( const Transform3 & mat ); - - // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector - // - inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec ); - - // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector - // - inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 4x4 matrix to the same scalar value - // - explicit inline Matrix4( vec_float4 scalar ); - - // Replicate an AoS 4x4 matrix - // - inline Matrix4( const Aos::Matrix4 & mat ); - - // Insert four AoS 4x4 matrices - // - inline Matrix4( const Aos::Matrix4 & mat0, const Aos::Matrix4 & mat1, const Aos::Matrix4 & mat2, const Aos::Matrix4 & mat3 ); - - // Extract four AoS 4x4 matrices - // - inline void get4Aos( Aos::Matrix4 & result0, Aos::Matrix4 & result1, Aos::Matrix4 & result2, Aos::Matrix4 & result3 ) const; - - // Assign one 4x4 matrix to another - // - inline Matrix4 & operator =( const Matrix4 & mat ); - - // Set the upper-left 3x3 submatrix - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 4x4 matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // NOTE: - // This function does not change the bottom row elements. - // - inline Matrix4 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 4x4 matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 4x4 matrix - // - inline Matrix4 & setCol0( const Vector4 & col0 ); - - // Set column 1 of a 4x4 matrix - // - inline Matrix4 & setCol1( const Vector4 & col1 ); - - // Set column 2 of a 4x4 matrix - // - inline Matrix4 & setCol2( const Vector4 & col2 ); - - // Set column 3 of a 4x4 matrix - // - inline Matrix4 & setCol3( const Vector4 & col3 ); - - // Get column 0 of a 4x4 matrix - // - inline const Vector4 getCol0( ) const; - - // Get column 1 of a 4x4 matrix - // - inline const Vector4 getCol1( ) const; - - // Get column 2 of a 4x4 matrix - // - inline const Vector4 getCol2( ) const; - - // Get column 3 of a 4x4 matrix - // - inline const Vector4 getCol3( ) const; - - // Set the column of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setCol( int col, const Vector4 & vec ); - - // Set the row of a 4x4 matrix referred to by the specified index - // - inline Matrix4 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getCol( int col ) const; - - // Get the row of a 4x4 matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector4 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector4 operator []( int col ) const; - - // Set the element of a 4x4 matrix referred to by column and row indices - // - inline Matrix4 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 4x4 matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Add two 4x4 matrices - // - inline const Matrix4 operator +( const Matrix4 & mat ) const; - - // Subtract a 4x4 matrix from another 4x4 matrix - // - inline const Matrix4 operator -( const Matrix4 & mat ) const; - - // Negate all elements of a 4x4 matrix - // - inline const Matrix4 operator -( ) const; - - // Multiply a 4x4 matrix by a scalar - // - inline const Matrix4 operator *( vec_float4 scalar ) const; - - // Multiply a 4x4 matrix by a 4-D vector - // - inline const Vector4 operator *( const Vector4 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D vector - // - inline const Vector4 operator *( const Vector3 & vec ) const; - - // Multiply a 4x4 matrix by a 3-D point - // - inline const Vector4 operator *( const Point3 & pnt ) const; - - // Multiply two 4x4 matrices - // - inline const Matrix4 operator *( const Matrix4 & mat ) const; - - // Multiply a 4x4 matrix by a 3x4 transformation matrix - // - inline const Matrix4 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and addition with a 4x4 matrix - // - inline Matrix4 & operator +=( const Matrix4 & mat ); - - // Perform compound assignment and subtraction by a 4x4 matrix - // - inline Matrix4 & operator -=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a scalar - // - inline Matrix4 & operator *=( vec_float4 scalar ); - - // Perform compound assignment and multiplication by a 4x4 matrix - // - inline Matrix4 & operator *=( const Matrix4 & mat ); - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Matrix4 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 4x4 matrix - // - static inline const Matrix4 identity( ); - - // Construct a 4x4 matrix to rotate around the x axis - // - static inline const Matrix4 rotationX( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the y axis - // - static inline const Matrix4 rotationY( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the z axis - // - static inline const Matrix4 rotationZ( vec_float4 radians ); - - // Construct a 4x4 matrix to rotate around the x, y, and z axes - // - static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 4x4 matrix to rotate around a unit-length 3-D vector - // - static inline const Matrix4 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Matrix4 rotation( const Quat & unitQuat ); - - // Construct a 4x4 matrix to perform scaling - // - static inline const Matrix4 scale( const Vector3 & scaleVec ); - - // Construct a 4x4 matrix to perform translation - // - static inline const Matrix4 translation( const Vector3 & translateVec ); - - // Construct viewing matrix based on eye position, position looked at, and up direction - // - static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec ); - - // Construct a perspective projection matrix - // - static inline const Matrix4 perspective( vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar ); - - // Construct a perspective projection matrix based on frustum - // - static inline const Matrix4 frustum( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - - // Construct an orthographic projection matrix - // - static inline const Matrix4 orthographic( vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar ); - -}; -// Multiply a 4x4 matrix by a scalar -// -inline const Matrix4 operator *( vec_float4 scalar, const Matrix4 & mat ); - -// Append (post-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 4x4 matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat ); - -// Multiply two 4x4 matrices per element -// -inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 ); - -// Compute the absolute value of a 4x4 matrix per element -// -inline const Matrix4 absPerElem( const Matrix4 & mat ); - -// Transpose of a 4x4 matrix -// -inline const Matrix4 transpose( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix -// NOTE: -// Result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 inverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0. -// -inline const Matrix4 affineInverse( const Matrix4 & mat ); - -// Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. -// -inline const Matrix4 orthoInverse( const Matrix4 & mat ); - -// Determinant of a 4x4 matrix -// -inline vec_float4 determinant( const Matrix4 & mat ); - -// Conditionally select between two 4x4 matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 4x4 matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat ); - -// Print a 4x4 matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Matrix4 & mat, const char * name ); - -#endif - -// A set of four 3x4 transformation matrices in structure-of-arrays format -// -class Transform3 -{ - Vector3 mCol0; - Vector3 mCol1; - Vector3 mCol2; - Vector3 mCol3; - -public: - // Default constructor; does no initialization - // - inline Transform3( ) { }; - - // Copy a 3x4 transformation matrix - // - inline Transform3( const Transform3 & tfrm ); - - // Construct a 3x4 transformation matrix containing the specified columns - // - inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 ); - - // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector - // - inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec ); - - // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector - // - inline Transform3( const Quat & unitQuat, const Vector3 & translateVec ); - - // Set all elements of a 3x4 transformation matrix to the same scalar value - // - explicit inline Transform3( vec_float4 scalar ); - - // Replicate an AoS 3x4 transformation matrix - // - inline Transform3( const Aos::Transform3 & tfrm ); - - // Insert four AoS 3x4 transformation matrices - // - inline Transform3( const Aos::Transform3 & tfrm0, const Aos::Transform3 & tfrm1, const Aos::Transform3 & tfrm2, const Aos::Transform3 & tfrm3 ); - - // Extract four AoS 3x4 transformation matrices - // - inline void get4Aos( Aos::Transform3 & result0, Aos::Transform3 & result1, Aos::Transform3 & result2, Aos::Transform3 & result3 ) const; - - // Assign one 3x4 transformation matrix to another - // - inline Transform3 & operator =( const Transform3 & tfrm ); - - // Set the upper-left 3x3 submatrix - // - inline Transform3 & setUpper3x3( const Matrix3 & mat3 ); - - // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix - // - inline const Matrix3 getUpper3x3( ) const; - - // Set translation component - // - inline Transform3 & setTranslation( const Vector3 & translateVec ); - - // Get the translation component of a 3x4 transformation matrix - // - inline const Vector3 getTranslation( ) const; - - // Set column 0 of a 3x4 transformation matrix - // - inline Transform3 & setCol0( const Vector3 & col0 ); - - // Set column 1 of a 3x4 transformation matrix - // - inline Transform3 & setCol1( const Vector3 & col1 ); - - // Set column 2 of a 3x4 transformation matrix - // - inline Transform3 & setCol2( const Vector3 & col2 ); - - // Set column 3 of a 3x4 transformation matrix - // - inline Transform3 & setCol3( const Vector3 & col3 ); - - // Get column 0 of a 3x4 transformation matrix - // - inline const Vector3 getCol0( ) const; - - // Get column 1 of a 3x4 transformation matrix - // - inline const Vector3 getCol1( ) const; - - // Get column 2 of a 3x4 transformation matrix - // - inline const Vector3 getCol2( ) const; - - // Get column 3 of a 3x4 transformation matrix - // - inline const Vector3 getCol3( ) const; - - // Set the column of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setCol( int col, const Vector3 & vec ); - - // Set the row of a 3x4 transformation matrix referred to by the specified index - // - inline Transform3 & setRow( int row, const Vector4 & vec ); - - // Get the column of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector3 getCol( int col ) const; - - // Get the row of a 3x4 transformation matrix referred to by the specified index - // - inline const Vector4 getRow( int row ) const; - - // Subscripting operator to set or get a column - // - inline Vector3 & operator []( int col ); - - // Subscripting operator to get a column - // - inline const Vector3 operator []( int col ) const; - - // Set the element of a 3x4 transformation matrix referred to by column and row indices - // - inline Transform3 & setElem( int col, int row, vec_float4 val ); - - // Get the element of a 3x4 transformation matrix referred to by column and row indices - // - inline vec_float4 getElem( int col, int row ) const; - - // Multiply a 3x4 transformation matrix by a 3-D vector - // - inline const Vector3 operator *( const Vector3 & vec ) const; - - // Multiply a 3x4 transformation matrix by a 3-D point - // - inline const Point3 operator *( const Point3 & pnt ) const; - - // Multiply two 3x4 transformation matrices - // - inline const Transform3 operator *( const Transform3 & tfrm ) const; - - // Perform compound assignment and multiplication by a 3x4 transformation matrix - // - inline Transform3 & operator *=( const Transform3 & tfrm ); - - // Construct an identity 3x4 transformation matrix - // - static inline const Transform3 identity( ); - - // Construct a 3x4 transformation matrix to rotate around the x axis - // - static inline const Transform3 rotationX( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the y axis - // - static inline const Transform3 rotationY( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the z axis - // - static inline const Transform3 rotationZ( vec_float4 radians ); - - // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes - // - static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ ); - - // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector - // - static inline const Transform3 rotation( vec_float4 radians, const Vector3 & unitVec ); - - // Construct a rotation matrix from a unit-length quaternion - // - static inline const Transform3 rotation( const Quat & unitQuat ); - - // Construct a 3x4 transformation matrix to perform scaling - // - static inline const Transform3 scale( const Vector3 & scaleVec ); - - // Construct a 3x4 transformation matrix to perform translation - // - static inline const Transform3 translation( const Vector3 & translateVec ); - -}; -// Append (post-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec ); - -// Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix -// NOTE: -// Faster than creating and multiplying a scale transformation matrix. -// -inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm ); - -// Multiply two 3x4 transformation matrices per element -// -inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 ); - -// Compute the absolute value of a 3x4 transformation matrix per element -// -inline const Transform3 absPerElem( const Transform3 & tfrm ); - -// Inverse of a 3x4 transformation matrix -// NOTE: -// Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0. -// -inline const Transform3 inverse( const Transform3 & tfrm ); - -// Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix -// NOTE: -// This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions. -// -inline const Transform3 orthoInverse( const Transform3 & tfrm ); - -// Conditionally select between two 3x4 transformation matrices -// NOTE: -// This function uses a conditional select instruction to avoid a branch. -// -inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, vec_uint4 select1 ); - -#ifdef _VECTORMATH_DEBUG - -// Print a 3x4 transformation matrix -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm ); - -// Print a 3x4 transformation matrix and an associated string identifier -// NOTE: -// Function is only defined when _VECTORMATH_DEBUG is defined. -// -inline void print( const Transform3 & tfrm, const char * name ); - -#endif - -} // namespace Soa -} // namespace Vectormath - -#include "vec_soa.h" -#include "quat_soa.h" -#include "mat_soa.h" - -#endif diff --git a/Extras/vectormathlibrary/tests/Makefile b/Extras/vectormathlibrary/tests/Makefile deleted file mode 100644 index f1c8bc183..000000000 --- a/Extras/vectormathlibrary/tests/Makefile +++ /dev/null @@ -1,138 +0,0 @@ -# Makefile for vector math library testsuite. -# -# 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. - -topdir = .. - -ARCH = scalar - -TESTS_all = \ - test1_aos_c.elf \ - test1_soa_c.elf \ - test2_aos_c.elf \ - test2_soa_c.elf \ - test3_aos_c.elf \ - test3_soa_c.elf \ - test4_aos_c.elf \ - test4_soa_c.elf \ - test1_aos_cpp.elf \ - test1_soa_cpp.elf \ - test2_aos_cpp.elf \ - test2_soa_cpp.elf \ - test3_aos_cpp.elf \ - test3_soa_cpp.elf \ - test4_aos_cpp.elf \ - test4_soa_cpp.elf - -TESTS_ppu = $(TESTS_all) -ARCH_CFLAGS_ppu = -maltivec -mabi=altivec -I$(SIMDMATH_DIR)/common -ARCH_LDFLAGS_ppu = -L$(SIMDMATH_DIR)/ppu -lsimdmath -static - -CROSS_spu = spu- -TESTS_spu = $(TESTS_all) -ARCH_CFLAGS_spu = -I$(SIMDMATH_DIR)/common -ARCH_LDFLAGS_spu = -L$(SIMDMATH_DIR)/spu -lsimdmath - -TESTS_SSE = \ - test1_aos_cpp.elf \ - test2_aos_cpp.elf \ - test3_aos_cpp.elf \ - test4_aos_cpp.elf -ARCH_CFLAGS_SSE = -msse - -TESTS_scalar = \ - test1_aos_c.elf \ - test2_aos_c.elf \ - test3_aos_c.elf \ - test4_aos_c.elf \ - test1_aos_cpp.elf \ - test2_aos_cpp.elf \ - test3_aos_cpp.elf \ - test4_aos_cpp.elf - -TESTS = $(TESTS_$(ARCH)) -ARCH_CFLAGS = $(ARCH_CFLAGS_$(ARCH)) -ARCH_LDFLAGS = $(ARCH_LDFLAGS_$(ARCH)) - -SIMDMATH_DIR = $(topdir)/../simdmathlibrary - -RESULTS = $(TESTS:.elf=.$(ARCH).out) -DIFFS = $(RESULTS:.out=.cmp) - -CROSS = $(CROSS_$(ARCH)) -CC = $(CROSS)gcc -CXX = $(CROSS)g++ -LD = $(CC) -LDXX = $(CXX) - -CFLAGS = -O2 -W -Wall -D_VECTORMATH_DEBUG $(ARCH_CFLAGS) -LDFLAGS = -lm $(ARCH_LDFLAGS) - -C_INCLUDES = -I$(topdir)/include/vectormath/c -CXX_INCLUDES = -I$(topdir)/include/vectormath/cpp - -PERL = perl - -all: $(TESTS) - -check: $(DIFFS) - -clean: - -rm -f *.elf - -distclean: clean - -rm -f *.out *.cmp *~ - -%_c.elf: %_c.c - $(CC) $(CFLAGS) $(C_INCLUDES) -o $@ $< $(LDFLAGS) - -%_cpp.elf: %_cpp.cpp - $(CXX) $(CFLAGS) $(CXX_INCLUDES) -o $@ $< $(LDFLAGS) - -%.$(ARCH).out: %.elf - ./$< > $@ - -test1_%.cmp: test1_%.out - $(PERL) ./clean.pl < $< > $<.tmp - $(PERL) ./compare.pl $<.tmp test1_reference.txt | tee $@ - rm $<.tmp - -test2_%.cmp: test2_%.out - $(PERL) ./clean.pl < $< > $<.tmp - $(PERL) ./compare.pl $<.tmp test2_reference.txt | tee $@ - rm $<.tmp - -test3_%.cmp: test3_%.out - $(PERL) ./clean.pl < $< > $<.tmp - $(PERL) ./compare.pl $<.tmp test3_reference.txt | tee $@ - rm $<.tmp - -test4_%.cmp: test4_%.out - $(PERL) ./clean.pl < $< > $<.tmp - $(PERL) ./compare.pl $<.tmp test4_reference.txt | tee $@ - rm $<.tmp diff --git a/Extras/vectormathlibrary/tests/clean.pl b/Extras/vectormathlibrary/tests/clean.pl deleted file mode 100644 index 412f596cc..000000000 --- a/Extras/vectormathlibrary/tests/clean.pl +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/perl - -# -# 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. -# - -$lineno = 0; - -sub getLine -{ - local( $line ); - - $line = ; - - while( $line =~ m/^lv2\([^\)]*\)\:$/ ) - { - $line = ; - } - - $line =~ s/^lv2\([^\)]*\)\: //; - - return $line; -} - -while(($line = ) !~ m/__begin__/) -{ -} - -$countSlotLines = 0; - -while( $line = &getLine ) -{ - $lineno++; - - if ( $line =~ m/__end__/ ) - { - exit; - } - - # if soa print, only save first slot - - if ( $line =~ m/^slot ([1-3])/ ) - { - while ( $line =~ m/^slot [1-3]/ ) - { - # skip all lines for this slot - - for ( $i = 0; $i < $slotLines; $i++ ) - { - $line = &getLine; - } - - # get next line - - $line = &getLine; - } - - # stop counting slot lines - - $countSlotLines = 0; - } - elsif ( $countSlotLines ) - { - $slotLines++; - } - - if ( $line =~ m/^slot 0\:(.?)/ ) - { - $countSlotLines = 1; - - if ( $1 eq ' ' ) - { - $line =~ s/^slot 0\: //; - $slotLines = 0; - } - else - { - $line = &getLine; - $slotLines = 1; - } - } - - print $line; -} diff --git a/Extras/vectormathlibrary/tests/compare.pl b/Extras/vectormathlibrary/tests/compare.pl deleted file mode 100644 index ed4c929a3..000000000 --- a/Extras/vectormathlibrary/tests/compare.pl +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/perl - -# -# 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. -# - -$file1 = $ARGV[0]; -$file2 = $ARGV[1]; - -if (!open(FILE1, "<$file1")) -{ - print "Couldn't open $file1\n"; - exit; -} - -if (!open(FILE2, "<$file2")) -{ - print "Couldn't open $file2\n"; - exit; -} - -print "Comparing $file1 $file2\n"; - -$lineno1 = 0; -$lineno2 = 0; - -while(($line1 = ) && ($line2 = )) -{ - $lineno1++; - $lineno2++; - - if ( $line1 =~ m/\:$/ ) - { - $line1 = ; - $lineno1++; - } - - if ( $line2 =~ m/\:$/ ) - { - $line2 = ; - $lineno2++; - } - - $line1 =~ s/^.*\: //g; - $line2 =~ s/^.*\: //g; - - @words1 = split(/ /,$line1); - @words2 = split(/ /,$line2); - - for ($i = 0; $i < @words1; $i++) - { - $word1 = $words1[$i]; - $word2 = $words2[$i]; - - $word1 =~ s/\s//g; - $word2 =~ s/\s//g; - - if ( $word1 ne $word2 ) - { - $error = abs($word1 - $word2); - - $limit = abs(1e-4 * $word1); - - if ( $error > $limit && !( abs($word1) < 1e-4 && $error < 1e-4 ) ) - { - print "$lineno1: $word1 $lineno2: $word2\n"; - } - } - } -} diff --git a/Extras/vectormathlibrary/tests/main_vmtest.cpp b/Extras/vectormathlibrary/tests/main_vmtest.cpp deleted file mode 100644 index 2e8262bc5..000000000 --- a/Extras/vectormathlibrary/tests/main_vmtest.cpp +++ /dev/null @@ -1,163 +0,0 @@ - -///Testfile to test differences between vectormath and Bullet LinearMath - -#ifdef __PPU__ -#include "include/vectormath/ppu/cpp/vectormath_aos.h" -#elif defined __SPU__ -#include "include/vectormath/spu/cpp/vectormath_aos.h" -#else -#include "include/vectormath/SSE/cpp/vectormath_aos.h" -//#include "include/vectormath/scalar/cpp/vectormath_aos.h" -#endif - -#include "../../src/LinearMath/btTransform.h" -#include - -//Bullet, a btVector can be used for both points and vectors. -//it is up to the user/developer to use the right multiplication: btTransform for points, and btQuaternion or btMatrix3x3 for vectors. -void BulletTest() -{ - - printf("Bullet Linearmath\n"); - - btTransform tr; - tr.setIdentity(); - - tr.setOrigin(btVector3(10,0,0)); - //initialization - btVector3 pointA(0,0,0); - btVector3 pointB,pointC,pointD,pointE; - //assignment - pointB = pointA; - //in-place initialization - pointB.setValue(1,2,3); - //transform over tr - pointB = tr * pointA; - printf("pointB = tr * pointA = (%f,%f,%f)\n",pointB.getX(),pointB.getY(),pointB.getZ()); - //transform over tr - pointE = tr(pointA); - //inverse transform - pointC = tr.inverse() * pointA; - printf("pointC = tr.inverse() * pointA = (%f,%f,%f)\n",pointC.getX(),pointC.getY(),pointC.getZ()); - //inverse transform - pointD = tr.invXform( pointA ); - btScalar x; - //dot product - x = pointD.dot(pointE); - //square length - x = pointD.length2(); - //length - x = pointD.length(); - - const btVector3& constPointD = pointD; - - //get a normalized vector from constPointD, without changing constPointD - btVector3 norm = constPointD.normalized(); - - //in-place normalize pointD - pointD.normalize(); - - //quaternions & matrices - btQuaternion quat(0,0,0,1); - btQuaternion quat1(btVector3(0,1,0),90.f * SIMD_RADS_PER_DEG); - btMatrix3x3 mat0(quat1); - btMatrix3x3 mat1 = mat0.inverse(); - btMatrix3x3 mat2 = mat0.transpose(); - btTransform tr1(mat2,btVector3(0,10,0)); - btTransform tr2 =tr1.inverse(); - btVector3 pt0(1,1,1); - btVector3 pt1 = tr2 * pt0; - - printf("btVector3 pt1 = tr2 * pt0 = (%f,%f,%f)\n",pt1.getX(),pt1.getY(),pt1.getZ()); - - - btVector3 pt2 = tr2.getBasis() * pt0; - btVector3 pt3 = pt0 * tr2.getBasis(); - btVector3 pt4 = tr2.getBasis().inverse() * pt0; - btTransform tr3 = tr2.inverseTimes(tr2); - - - -} - -//vectormath makes a difference between point and vector. -void VectormathTest() -{ - - printf("Vectormath\n"); - - Vectormath::Aos::Transform3 tr; - tr = Vectormath::Aos::Transform3::identity(); - - tr.setTranslation(Vectormath::Aos::Vector3(10,0,0)); - //initialization - Vectormath::Aos::Point3 pointA(0,0,0); - Vectormath::Aos::Point3 pointB,pointC,pointE; - Vectormath::Aos::Vector3 pointD; - //assignment - pointB = pointA; - //in-place initialization - pointB = Vectormath::Aos::Point3(1,2,3); //or - pointB.setElem(0,1); //or - pointB.setX(1); - - //transform over tr - pointB = tr * pointA; - - printf("pointB = tr * pointA = (%f,%f,%f)\n",(float)pointB.getX(),(float)pointB.getY(),(float)pointB.getZ()); - //transform over tr - //pointE = tr(pointA); - //inverse transform - pointC = Vectormath::Aos::inverse(tr) * pointA; - printf("Vectormath::Aos::inverse(tr) * pointA = (%f,%f,%f)\n",(float)pointC.getX(),(float)pointC.getY(),(float)pointC.getZ()); - - - - btScalar x; - //dot product - x = Vectormath::Aos::dot(Vectormath::Aos::Vector3(pointD),Vectormath::Aos::Vector3(pointE)); - //square length - x = Vectormath::Aos::lengthSqr(Vectormath::Aos::Vector3(pointD)); - //length - x = Vectormath::Aos::length(Vectormath::Aos::Vector3(pointD)); - - const Vectormath::Aos::Vector3& constPointD = (Vectormath::Aos::Vector3&)pointD; - - //get a normalized vector from constPointD, without changing constPointD - Vectormath::Aos::Vector3 norm = Vectormath::Aos::normalize(constPointD); - - //in-place normalize pointD - pointD = Vectormath::Aos::normalize(Vectormath::Aos::Vector3(pointD)); - - //quaternions & matrices - Vectormath::Aos::Quat quat(0,0,0,1); - Vectormath::Aos::Quat quat1; - quat1 = Vectormath::Aos::Quat::rotationY(90.f * SIMD_RADS_PER_DEG); - - Vectormath::Aos::Matrix3 mat0(quat1); - - Vectormath::Aos::Matrix3 mat1 = Vectormath::Aos::inverse(mat0); - Vectormath::Aos::Matrix3 mat2 = Vectormath::Aos::transpose(mat0); - Vectormath::Aos::Transform3 tr1(mat2,Vectormath::Aos::Vector3(0,10,0)); - Vectormath::Aos::Transform3 tr2 = Vectormath::Aos::inverse(tr1); - Vectormath::Aos::Point3 pt0(1,1,1); - Vectormath::Aos::Point3 pt1 = tr2 * pt0; - printf("Vectormath::Aos::Vector3 pt1 = tr2 * pt0; = (%f,%f,%f)\n",(float)pt1.getX(),(float)pt1.getY(),(float)pt1.getZ()); - - Vectormath::Aos::Vector3 pt2 = tr2.getUpper3x3() * Vectormath::Aos::Vector3(pt0); - //Vectormath::Aos::Vector3 pt3 = pt0 * tr2.getUpper3x3(); - Vectormath::Aos::Vector3 pt3 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0); - Vectormath::Aos::Vector3 pt4 = Vectormath::Aos::inverse(tr2.getUpper3x3()) * Vectormath::Aos::Vector3(pt0); - Vectormath::Aos::Transform3 tr3 = Vectormath::Aos::inverse(tr2) * tr2; - -} - -int main() -{ - - BulletTest(); - - VectormathTest(); - - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test.h b/Extras/vectormathlibrary/tests/test.h deleted file mode 100644 index bc231ea68..000000000 --- a/Extras/vectormathlibrary/tests/test.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - 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_TEST_H -#define _VECTORMATH_TEST_H - -#if defined(__SPU__) -# define vec_splats_float(v) spu_splats(v) -# define vec_mul_float(a, b) spu_mul(a, b) -# define vec_add_float(a, b) spu_add(a, b) -# define vec_sub_float(a, b) spu_sub(a, b) -#elif defined(__ALTIVEC__) -# define vec_splats_float(v) ((vec_float4){(float)(v),(float)(v),(float)(v),(float)(v)}) -# define vec_mul_float(a, b) vec_madd(a, b, vec_splats_float(0.0f)) -# define vec_add_float(a, b) vec_add(a, b) -# define vec_sub_float(a, b) vec_sub(a, b) -#elif defined(__SSE__) -# error "Not implemented." -#else -# define _VECTORMATH_SCALAR_TEST -#endif - -float randfloats[1024] = { - -0.658343927787421f,0.499803960969928f,-0.807256688752865f,0.740930454054151f, - 0.154607013590216f,0.571598517679348f,0.38438830691728f,-0.262467460159158f, - 0.747808153723618f,0.49019019690013f,-0.107908181813777f,-0.292543593813249f, - 0.465039264005078f,-0.47955599783424f,-0.211412450152245f,0.553579902451233f, - 0.690070275160572f,0.151576400965553f,0.431077190337326f,-0.833991507852247f, - -0.0883497426804851f,-0.780106371638709f,0.0904560476331469f,-0.218626858702649f, - 0.137170846428894f,0.918132898976751f,0.735438192918274f,-0.673620979495283f, - -0.448982146263369f,-0.479277810255866f,0.848189483738331f,-0.12815472579463f, - 0.578921731104181f,-0.744765966376519f,-0.83558862791913f,0.881284032895692f, - -0.948850147493964f,-0.691578137344351f,-0.235635149443688f,-0.690526600666615f, - 0.0586668362339609f,0.753696982166502f,-0.138777123323202f,-0.472187547315841f, - -0.372811001953572f,0.540183371709446f,-0.78521823389179f,0.542084510391291f, - 0.410391117788897f,-0.562720682584484f,0.523587985711991f,-0.176573908842087f, - 0.297653645858226f,0.859912509814734f,0.00483713119734119f,0.374881358857735f, - -0.127818103705344f,0.21660181589948f,0.153117267270737f,0.265243421428139f, - -0.0731487047425148f,0.264487579220173f,-0.723410134701346f,0.921522835850382f, - -0.711249997824318f,-0.106633857864438f,-0.350831080309241f,0.905168155184938f, - -0.283632179037646f,-0.203583555015513f,-0.797436915535236f,0.910171471305759f, - 0.96923389534215f,0.151940162902974f,0.731827470770519f,-0.700248217534451f, - 0.818300860563319f,0.302505017280083f,-0.872278290470156f,0.909998773124912f, - 0.932525528551317f,0.571086770427939f,0.610329635790002f,0.142507359591505f, - -0.43482856009151f,0.925102103935927f,0.158954117892613f,-0.126282746058862f, - -0.249127650925452f,0.846815218386041f,-0.942601239873774f,0.537719955431001f, - 0.446213543435171f,0.181938699625931f,-0.148222922840326f,0.284286118166037f, - 0.493525458201255f,-0.861962900371793f,-0.893410102755276f,0.548627291142694f, - 0.407006961478977f,-0.757467096890906f,-0.393126176069536f,-0.850984293029867f, - 0.375719573110992f,-0.270087780463427f,0.45888819784826f,-0.610827766442796f, - -0.690815628408266f,-0.676415221072347f,0.664465776005038f,0.101873923854313f, - -0.365713939355025f,0.0554727439164822f,-0.133556089035984f,-0.572643072647438f, - 0.459209235899415f,-0.997261395030506f,0.172408991295974f,-0.0451240115316551f, - 0.879715937508259f,0.524317125330867f,-0.744532077249495f,-0.970443523820151f, - -1.32784686215359e-05f,0.689543072301063f,0.704297111725616f,-0.817983008667298f, - 0.71550535643383f,0.577868436783262f,0.156952383805468f,-0.80102179210472f, - 0.65633547615213f,0.494393128677046f,0.816743155389922f,0.0242848471199721f, - 0.769131722839866f,0.923894866655701f,0.133021600755988f,-0.0522193159450097f, - -0.164886284373118f,0.300690282133047f,0.760403145270168f,0.171869369152077f, - -0.554975788488598f,0.998693253807744f,-0.681641007087912f,0.391194738828759f, - 0.403058705852153f,0.972411306067528f,0.297195187773745f,0.309761312769567f, - 0.688408077837671f,0.363539666742895f,0.94029653976505f,-0.336683042511069f, - 0.600164345782652f,-0.681271587780742f,0.726558239385319f,0.205513360229233f, - -0.16008221686365f,0.962714155748642f,0.737793770111715f,-0.0719258703692134f, - -0.506312816314299f,0.689277082946518f,0.686485424709581f,0.473013144786293f, - -0.735610421404026f,-0.0463900680836105f,0.568673968586005f,-0.00481466271939723f, - 0.137636823654454f,-0.111879120785687f,-0.929542605813147f,-0.336303463382606f, - -0.146740182632236f,0.165140351947514f,-0.823874099621072f,0.349776463047661f, - 0.174872304411146f,-0.528584334304156f,0.489291834762803f,0.916707538240686f, - 0.728510889338118f,-0.851139787348188f,0.0796199799283031f,-0.234369971523549f, - -0.996308342568362f,0.433228819394486f,-0.892684128206504f,-0.95791073791078f, - 0.517122298113016f,0.257920984044574f,0.862028434359466f,0.0958813977553206f, - -0.171932523577503f,-0.214077886807473f,-0.604841274532937f,-0.38383141210609f, - -0.58149997525441f,0.222182734948547f,-0.2561203625418f,-0.678699493062183f, - -0.0795530448181339f,0.605960090732907f,-0.633147389976791f,0.435875222532317f, - -0.0466270522618899f,-0.71649136999298f,0.267317414957141f,-0.514873596167021f, - -0.751699524124625f,0.742958874040227f,-0.793179510948171f,0.508814009999512f, - -0.238839286150373f,0.113471002014307f,-0.843523253083085f,-0.245249991279181f, - 0.250368454758338f,0.579243470287253f,-0.157280074848025f,0.648487464157242f, - 0.103833079240538f,0.456401128469849f,-0.0223720820167514f,-0.475631368950744f, - -0.0041782226245104f,-0.0208652308868125f,-0.0169971127675765f,0.699143621917685f, - 0.83779636548531f,-0.276082033737794f,0.0915817913013015f,0.209063902268738f, - 0.219316780269516f,-0.118359453100055f,0.413442003735092f,-0.567697560481989f, - 0.531358299984625f,-0.387225776610819f,0.572489506868486f,-0.820417090039186f, - 0.797191361229615f,0.867177919412683f,0.934764375062564f,0.237092079542023f, - -0.866161864691826f,-0.773938728379676f,0.261310530107004f,-0.851569556583101f, - 0.114814425111355f,-0.531592190789155f,0.223924683490957f,0.869104561345111f, - 0.143404566999386f,0.148517529008075f,-0.0711363985626363f,-0.758291614176514f, - -0.527633502740933f,0.99721511923596f,0.114439963849399f,0.72755837253878f, - -0.425760405626697f,0.459888066153781f,0.642515762634126f,-0.0225335867899474f, - 0.186094961562027f,-0.775678571017551f,-0.683400976752644f,0.398133764191002f, - 0.189642093838877f,0.765986315134853f,-0.137794739254879f,-0.579843714684088f, - -0.63564699482432f,0.374970154657689f,-0.563749876868947f,-0.471075422601373f, - -0.553799500723066f,-0.0146881150006948f,-0.464365244644604f,-0.10788986146774f, - -0.527503023060852f,-0.406422760262416f,0.301261161950258f,0.499528573888128f, - 0.385179609005043f,-0.150218387266079f,0.519111879977139f,-0.203208683924331f, - -0.252017508479717f,0.282193567323901f,0.0676372217166588f,0.798376368300907f, - 0.310782163860559f,0.861334103612307f,-0.980345166653173f,-0.655105604450725f, - 0.286765236319503f,0.532078410709602f,0.352670966735097f,0.540977184819425f, - 0.510961465933072f,0.791871139829084f,-0.564378698589145f,0.273199199047909f, - 0.194378063163676f,0.244636363558442f,-0.2696079922111f,-0.858162214209599f, - -0.495023067522474f,-0.277797538673553f,-0.0327403642191157f,0.00741169596342672f, - -0.420178428178723f,-0.522576683894926f,0.324971970060567f,0.795389045001329f, - 0.342900104539247f,-0.913636452280628f,0.675221839440177f,0.144052833646484f, - -0.632328982629893f,-0.947119831218089f,-0.0493673719309484f,0.126332763266575f, - -0.66420574517786f,0.220879155225703f,0.284218535482147f,-0.387215543918998f, - 0.913567998448777f,0.531906099678991f,0.271995095904906f,-0.862600551020719f, - -0.738693635668703f,0.514248487507359f,-0.0393632803376036f,0.429389595727585f, - -0.769468991576751f,0.28133632724311f,-0.203301313955485f,0.412585911285348f, - 0.567925862321268f,0.410131004328946f,-0.462918277454527f,0.560952548692129f, - -0.731715443500342f,-0.446157565377547f,-0.837491324975311f,-0.573480361464263f, - -0.607819850918752f,0.23841499693998f,0.213445432027605f,0.0986122683758737f, - 0.135072190814675f,-0.749273552937012f,-0.855977160741141f,0.765675059673342f, - -0.693447453911567f,0.131554184087008f,-0.366756547983336f,-0.330409262236842f, - -0.588815619465343f,0.352532978762866f,-0.920522750723883f,-0.915255088789323f, - 0.631923943060777f,-0.870739292438145f,0.415604498050605f,-0.180973894496887f, - 0.775697838994837f,0.879356890591083f,-0.993957564335638f,-0.298451942545356f, - 0.876855036440425f,0.982846031192253f,-0.282564044364371f,0.95346849594155f, - -0.947311505090191f,-0.317822974923359f,0.692391664998802f,-0.123566763365389f, - 0.407041678839057f,0.141204372181107f,-0.793069847914673f,-0.638275471740698f, - -0.51955405631346f,0.368499710074474f,0.970213689037045f,0.0272163305900648f, - 0.801791483976395f,-0.0663635812993562f,-0.0512834823579524f,-0.184935295126749f, - 0.516982835871183f,-0.769951152485618f,-0.708267044537941f,0.398266880674086f, - -0.479614543356881f,0.0604142126476859f,-0.867394563338259f,-0.702364045743693f, - -0.18260171523908f,-0.83280747136078f,0.278190893454216f,-0.967562302471109f, - -0.52029595778054f,0.160191201466318f,-0.677989785356466f,-0.470750261667419f, - -0.846579999787899f,-0.705750757861409f,-0.825367487626302f,-0.712890462610304f, - -0.0644873847193068f,0.444064587944183f,-0.0452257881147275f,0.116544259603998f, - -0.00728451932408092f,-0.838230133415692f,-0.410766823165496f,-0.40929905742685f, - -0.336682948179195f,-0.830699768111344f,-0.801729180453698f,-0.595152571835385f, - -0.784671779507129f,-0.653655236426147f,0.670791046451306f,0.653571468806589f, - 0.850715654625567f,0.0714334825891569f,-0.0577154211012854f,0.401895373758876f, - 0.0168605144772656f,0.5354384129881f,0.965901293540405f,-0.0726753529456374f, - 0.341689326326282f,0.781662445971847f,0.707322369548329f,0.505889413040066f, - 0.43279006682301f,-0.82579284323046f,0.597718837056043f,-0.250904847502525f, - -0.085712490334565f,-0.27284668464705f,0.552644217406645f,0.19420250718521f, - -0.884426763638054f,-0.756791257372726f,0.121106956043313f,0.312482778322803f, - -0.873316960494485f,0.0450805196969668f,0.687443898195021f,-0.684625629977333f, - -0.994046624794031f,0.800365484075002f,-0.565640229111075f,-0.625626063021869f, - 0.932584676112249f,0.636927568286012f,0.420250137262336f,0.175862511828669f, - 0.362158342804186f,0.547495978208275f,-0.534422794348934f,-0.563030463450744f, - -0.254488285756501f,0.647777595706543f,-0.674240168502628f,0.224344628949055f, - -0.754563097553635f,-0.12881655237274f,-0.997838330250381f,0.0369162049154141f, - -0.077549312424928f,0.376025736059717f,-0.935044655882827f,-0.189804125597547f, - 0.00764933224392195f,-0.440298102088747f,0.994796322297979f,-0.271484040660724f, - -0.2590701870053f,0.902148580301628f,-0.836501451887365f,0.229092669621153f, - 0.5863932076197f,-0.287825592948792f,0.942655407357726f,-0.634432455852235f, - -0.140437555704573f,0.570869095619685f,-0.764965080867434f,0.0675228424859284f, - -0.514589062662218f,0.233090988246516f,0.554487773397391f,-0.633529215840056f, - -0.0193735702003366f,0.869258510751365f,-0.369818396412519f,-0.280689998188947f, - -0.797208739895403f,-0.255233407527697f,0.780605315236578f,0.789803426518219f, - 0.974261893445153f,-0.785980203848396f,-0.701385987245636f,0.871088183435759f, - 0.566742533772562f,0.75227294222347f,-0.476301298243307f,-0.747341931420877f, - 0.0773855838641069f,-0.305599507084935f,-0.229193881336336f,-0.260009071921601f, - -0.0515187258224827f,0.459831012841761f,0.861793377659517f,-0.00839510548009059f, - -0.0535644390132504f,0.912885769359548f,-0.402379747450233f,-0.10435292389046f, - 0.644045025641198f,-0.235395897167933f,0.454549452554879f,-0.303775931682779f, - 0.321575614700528f,0.724025709176772f,0.330082831646187f,0.609903689400269f, - 0.851604270169993f,-0.356715440425745f,-0.0455002843413084f,0.13772975575408f, - -0.148995564903764f,0.892453960056798f,-0.821676934893254f,-0.14847536459807f, - -0.381886292618752f,0.398820351836747f,-0.292289360617424f,0.0702858731114446f, - -0.772469821167697f,0.474357996692333f,0.857792314833965f,-0.720558506386439f, - 0.888908862188352f,-0.950919194501893f,-0.196258139903655f,-0.59980821479941f, - -0.794413298851502f,-0.927635622930836f,-0.18747758800405f,-0.113038430406718f, - 0.366119602275866f,-0.483786056117111f,0.622670249344587f,-0.801805699607442f, - 0.295383348060291f,0.0220054959489744f,-0.000678144987013241f,-0.68933407333013f, - 0.266537772395942f,-0.785099000882013f,-0.572664686201399f,0.772760435300924f, - 0.97189582826514f,-0.961362535549199f,0.723449439795125f,-0.758441529489218f, - -0.733158222482722f,0.13966678591575f,-0.73814671277507f,0.727223546774141f, - 0.0899213092919311f,-0.113118130362636f,-0.364554501988017f,-0.137644753297124f, - 0.933846571857863f,0.615857754190102f,0.442837902751755f,0.691293553853697f, - 0.862436507424839f,-0.769632706987466f,-0.069558455823973f,-0.216368763497925f, - -0.240286864167238f,-0.494147338088084f,-0.732343541285623f,0.247500097354347f, - 0.238013165932848f,-0.0222504081638135f,0.0354097573205863f,0.562870060908224f, - -0.443182852051812f,-0.148476065390099f,-0.785559583638936f,-0.534284390277335f, - 0.804060941136193f,0.161693072162677f,0.626454348053834f,0.564290128221401f, - 0.414242183673117f,-0.314079097076757f,0.871460392700492f,-0.586016607169839f, - 0.446183340840953f,0.670697807509214f,-0.31261251323f,-0.34635111476409f, - -0.32237160168031f,0.0615992346122596f,0.108866036772035f,-0.96854607364277f, - -0.0900520153269255f,-0.000638517939648864f,-0.497526906200939f,0.0210549572282304f, - -0.513626724036349f,0.219974002433304f,-0.406318097379831f,0.829310754424156f, - 0.139888080843043f,-0.409132737685127f,-0.0296375827238435f,-0.713853913104842f, - 0.286946651436075f,-0.734473045715816f,0.649341057254212f,0.0281454231254514f, - -0.188432361127518f,-0.683807673918693f,0.432885949511977f,-0.0361810926016091f, - 0.438347837417645f,0.710651677026334f,0.673928786874676f,-0.0546809333762468f, - 0.826058562813905f,-0.832265197271681f,-0.668493142354613f,0.35502470967181f, - 0.5354983136667f,0.82137347039f,-0.143300610352533f,0.713426364459551f, - -0.297806605505109f,0.340760003596245f,-0.564118270640485f,-0.0240265108522948f, - -0.60137093958766f,-0.178866127631323f,-0.229680331692812f,0.741055717732976f, - -0.219526898682084f,0.534269946476002f,0.133115059442581f,-0.249583317941799f, - 0.811487242943805f,0.699282902509054f,-0.43331663912921f,0.71961761681392f, - 0.943524928147106f,0.523603303061634f,-0.677065472025312f,-0.636492873531878f, - 0.0384525794274069f,-0.377124785497273f,0.967031372742831f,0.435091298236713f, - 0.161520957813146f,-0.15972397671726f,-0.166845254078147f,-0.587937091804449f, - 0.910419348982238f,0.764819474485904f,-0.987496701506423f,-0.838882086564368f, - -0.41301635023239f,0.740276015423035f,0.951437768918503f,0.284889876776347f, - -0.158434377954073f,0.73838340645338f,-0.370863653408783f,0.989946556977472f, - -0.848079748582045f,-0.449771614068709f,0.663499305019705f,-0.93185425837116f, - 0.523896920061681f,-0.232489928806984f,-0.538281594630583f,-0.899682373052556f, - -0.338756398325579f,0.951550867830917f,0.494550167204373f,0.194556783574981f, - 0.243717136517866f,0.224354070146973f,0.143792613511486f,-0.333553884855363f, - 0.229952471240104f,-0.204077808365582f,0.469903146410694f,-0.958373658125808f, - -0.226054823628623f,0.229899490605959f,0.196501423332386f,0.879845549743308f, - 0.577560209175438f,0.641089277668982f,0.642316105885037f,0.232802361926147f, - -0.381538604113949f,0.640474533642731f,-0.913151229860155f,-0.614188561923768f, - 0.171776090268345f,-0.645757746280538f,-0.122217277374411f,0.00689941379876302f, - 0.019433549917359f,-0.0675691088088968f,-0.373650414044171f,-0.67103881780362f, - 0.504459382741295f,-0.14911057310502f,0.148122926701966f,0.694898716737626f, - 0.585837578674649f,-0.750790936323284f,0.853926520879604f,0.15730556487317f, - -0.113618219173468f,0.320367463625416f,-0.552134285767956f,-0.920422170186882f, - -0.338845809007829f,-0.810536065394189f,-0.177695639626343f,0.351905028679525f, - 0.0633494717407146f,-0.865174843305965f,0.634557634797282f,-0.787750206138512f, - -0.379512173859858f,0.791878043518267f,-0.704956748246282f,-0.670757904173982f, - 0.684751731590218f,-0.953277716787511f,0.985770879077755f,0.122219634876117f, - 0.1721202012071f,-0.388256876288864f,-0.73825752183587f,0.906019401398325f, - -0.803381430261645f,-0.74941181755554f,0.0727255174881734f,-0.221605735994771f, - -0.564223723915198f,-0.213656403861052f,-0.608162856680174f,0.921170937654253f, - 0.0847855661657562f,0.417987807384179f,-0.330418934403873f,0.648809934312297f, - 0.0796460930869003f,0.550628835897015f,-0.92719924470385f,0.877452232036589f, - 0.559779671355166f,-0.0896538710039181f,0.849093177103803f,-0.747330460544603f, - -0.87952842676733f,0.791614152693995f,-0.483542677352212f,0.795053306558017f, - -0.246444636768096f,-0.967515102978155f,0.159471890174437f,0.210810164441753f, - -0.874227023772981f,-0.0805964482800334f,0.567497201138046f,-0.137743608785641f, - -0.710773819308763f,-0.589571113738941f,0.83391847788473f,0.474349423613731f, - -0.495444643831966f,-0.415319533683743f,-0.688818445640273f,0.923238489082379f, - 0.688452278243922f,-0.639758117768224f,0.353458578584501f,-0.352412753977475f, - -0.667399029986676f,0.586965778853283f,0.352610916528867f,0.360697015758419f, - -0.502839728688848f,-0.539644214882799f,0.365329906944815f,-0.379932106654209f, - -0.269280779163601f,0.694895571222645f,0.727823970732565f,0.51105486079409f, - -0.761212733299821f,-0.551940664095241f,0.953323471475834f,-0.915964879494524f, - 0.199091342904332f,0.0392241713497299f,-0.19261671908783f,-0.6074206562147f, - 0.345256597791838f,0.031516093623793f,0.563117849295644f,-0.0626584858579093f, - -0.491887339392029f,-0.758788812866925f,0.265995340863064f,0.23182766277084f, - 0.069408408971249f,-0.758115582411847f,-0.495213306068685f,-0.941798830898321f, - -0.244099121724069f,-0.496495655783264f,0.217102928532306f,-0.958590442403207f, - -0.951376141167081f,-0.454184666450089f,0.886300276933433f,0.487002988091731f, - 0.0249044829036293f,-0.482416930998085f,0.949278378895364f,0.332136035903019f, - 0.667897336691517f,-0.903192712329542f,0.0759824890853551f,-0.338269985337703f, - -0.29518903317139f,-0.768719116695905f,-0.648362986306786f,0.935201134387952f, - 0.661626711929564f,0.224599917215244f,0.348525351988449f,-0.972641665331466f, - 0.996220202383405f,-0.72814219793807f,-0.921619408688976f,-0.134878186992026f, - 0.496907260713279f,0.544992091878385f,0.238303715804555f,-0.924062793629034f, - -0.630686074442814f,-0.865452949495847f,-0.222028734920293f,0.171739204767604f, - 0.997130539607845f,0.918172604643416f,-0.694626556063078f,0.672880204329672f, - -0.175982089302543f,-0.876546457819273f,-0.699672836718442f,0.809662568756764f, - 0.393205100623341f,-0.108144983913576f,-0.486322989569125f,-0.613674712751319f, - -0.317080956716971f,0.471134684264513f,-0.30417867085874f,0.696115419091356f, - -0.469268432777419f,0.236211281027806f,-0.772378939124543f,0.460249824926805f, - -0.654534877200454f,-0.934852798470303f,0.032756384083477f,-0.66677857258658f, - 0.314980215822125f,-0.289198088561079f,-0.0476688874127049f,0.0583547444711741f, - 0.941740852748786f,0.774296795413221f,-0.414622097461695f,0.638345821607103f, - -0.358465167682304f,-0.700596445490135f,0.374529194857949f,0.45456008092971f, - -0.853620900176985f,0.494280579565469f,-0.217619888424174f,0.956186128386705f, - 0.0389822381652678f,-0.19316201021536f,0.00512085504598048f,-0.0427176575011998f, - 0.547932129275615f,0.721865358296469f,0.456248153651011f,0.618884232413038f, - 0.0410425055490649f,-0.0673903257300594f,-0.218781418704999f,0.528492225462415f, - -0.0837068514807342f,0.718697939323846f,-0.603328224259776f,0.875509849594366f, - -0.0909494938322766f,-0.280637910576161f,-0.645530682341054f,-0.705120660981081f, - -0.529475884017096f,0.140296797228785f,-0.0133440668494202f,0.529843637228154f, - -0.25828493683013f,0.619866268930593f,0.47419437241583f,0.447278725151833f, - 0.821711397258731f,-0.617272470973745f,-0.212155578716597f,-0.794533711360103f, - -0.762402399229636f,-0.66554198883216f,0.86799064535122f,-0.61415791629922f, - 0.650236475570502f,0.838917668255732f,-0.658036726366966f,0.79973808497526f, - -0.583232188921549f,-0.958456594727579f,-0.670917275207309f,-0.607735262211108f, - 0.374114548594356f,0.758519548998692f,-0.831818710697753f,-0.606668498198204f, - 0.461609482669083f,0.676995424711095f,0.338856030176508f,0.5967074997629f, - -0.925180531336558f,0.4696830362291f,-0.0384243216844951f,0.649557593176482f, - 0.502765260428653f,0.513967467262376f,-0.515358199072217f,-0.444119277197828f, - -0.230720891612428f,0.348053063903166f,0.335781438011331f,0.567805000835321f, - -0.345275268793607f,0.452852845315761f,-0.823034642564643f,-0.629914051647049f, - -0.248509141280827f,0.107760047194603f,0.103293698795021f,0.347988561161273f, - -0.103424145197316f,0.151822355394586f,-0.272890315097335f,0.940838684544033f, - 0.174472591496773f,0.741124360281646f,-0.950217097467039f,-0.922017392413252f, - 0.496955384825533f,-0.588424819191232f,-0.285012984144181f,-0.292976024259858f, - 0.30303004349728f,0.748249196092075f,-0.565826698130202f,0.973592191086922f, - 0.598249548946463f,-0.926358493656323f,-0.241048287909827f,0.996364548389252f, - -0.0599127959717052f,0.174629249412504f,-0.96587410625029f,0.980693566420129f, - -0.696388116912935f,-0.900221651108609f,-0.706671628163384f,0.990309443320101f, - -0.585908086908283,0.414355789768166f,0.456957525423029f,-0.308246583228438f, -}; - -#ifdef _VECTORMATH_SOA_TEST -inline float getfloat( vec_float4 val ) -{ - union { vec_float4 v; float s[4]; } tmp; - tmp.v = val; - return tmp.s[0]; -} - -vec_float4 randfloat() -{ - static int randfloat_count = 0; - int idx = randfloat_count; - vec_float4 tmp = (vec_float4){randfloats[idx],randfloats[idx],randfloats[idx],randfloats[idx]}; - randfloat_count = (randfloat_count+1) % 1024; - return tmp; -} - -#else -inline float getfloat( float val ) -{ - return val; -} - -float randfloat() -{ - static int randfloat_count = 0; - float tmp = randfloats[randfloat_count]; - randfloat_count = (randfloat_count+1) % 1024; - return tmp; -} -#endif - -#ifdef _VECTORMATH_SCALAR_TEST -# define scalar_float(v) (v) -#else -# define scalar_float(v) floatInVec(v) -#endif - -#endif diff --git a/Extras/vectormathlibrary/tests/test1_aos_c.c b/Extras/vectormathlibrary/tests/test1_aos_c.c deleted file mode 100644 index 527434ea2..000000000 --- a/Extras/vectormathlibrary/tests/test1_aos_c.c +++ /dev/null @@ -1,1153 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -void -Vector3_methods_test() -{ - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - VmathVector3 tmpV3_8, tmpV3_9; - VmathPoint3 tmpP3_0; - VmathVector3 tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21, tmpV3_22, tmpV3_23, tmpV3_24, tmpV3_25; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - float xyz4[12] __attribute__ ((aligned(16))); -#ifndef _VECTORMATH_SCALAR_TEST - vec_float4 quad; -#endif - xyz4[0] = randfloat(); - xyz4[1] = randfloat(); - xyz4[2] = randfloat(); - xyz4[3] = randfloat(); - xyz4[4] = randfloat(); - xyz4[5] = randfloat(); - xyz4[6] = randfloat(); - xyz4[7] = randfloat(); - xyz4[8] = randfloat(); - xyz4[9] = randfloat(); - xyz4[10] = randfloat(); - xyz4[11] = randfloat(); - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3MakeFromScalar( &c_Vector3, 0.0f ); - vmathV3MakeFromScalar( &d_Vector3, 0.0f ); - vmathV3MakeFromScalar( &e_Vector3, 0.0f ); - vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4MakeFromScalar( &c_Vector4, 0.0f ); - vmathV4MakeFromScalar( &d_Vector4, 0.0f ); - vmathV4MakeFromScalar( &e_Vector4, 0.0f ); - vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3MakeFromScalar( &c_Point3, 0.0f ); - vmathP3MakeFromScalar( &d_Point3, 0.0f ); - vmathP3MakeFromScalar( &e_Point3, 0.0f ); - vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQMakeFromScalar( &c_Quat, 0.0f ); - vmathQMakeFromScalar( &d_Quat, 0.0f ); - vmathQMakeFromScalar( &e_Quat, 0.0f ); - vmathQPrints( &c_Quat, "set Quat elements to zero" ); - vmathQPrints( &d_Quat, "set Quat elements to zero" ); - vmathQPrints( &e_Quat, "set Quat elements to zero" ); - vmathV3MakeFromP3( &a_Vector3, &a_Point3 ); - vmathV3Prints( &a_Vector3, "construct Vector3 with Point3" ); - vmathV3MakeFromScalar( &a_Vector3, randfloat() ); - vmathV3Prints( &a_Vector3, "set Vector3 with float" ); - vmathV3MakeFromScalar( &a_Vector3, randfloat() ); - vmathV3Prints( &a_Vector3, "set Vector3 with float" ); - vmathV3MakeFromElems( &aos_Vector3_0, 0.0f, 1.0f, 2.0f ); - vmathV3MakeFromElems( &aos_Vector3_1, 3.0f, 4.0f, 5.0f ); - vmathV3MakeFromElems( &aos_Vector3_2, 6.0f, 7.0f, 8.0f ); - vmathV3MakeFromElems( &aos_Vector3_3, 9.0f, 10.0f, 11.0f ); - vmathV3Prints( &aos_Vector3_3, "aos type 0" ); - vmathV3Prints( &aos_Vector3_2, "aos type 1" ); - vmathV3Prints( &aos_Vector3_1, "aos type 2" ); - vmathV3Prints( &aos_Vector3_0, "aos type 3" ); - vmathV3Select( &tmpV3_4, &a_Vector3, &b_Vector3, 0 ); - vmathV3Prints( &tmpV3_4, "select 0" ); - vmathV3Select( &tmpV3_5, &a_Vector3, &b_Vector3, 1 ); - vmathV3Prints( &tmpV3_5, "select 1" ); - vmathV3Select( &tmpV3_6, &a_Vector3, &b_Vector3, 0 ); - vmathV3Prints( &tmpV3_6, "select 2" ); - vmathV3Select( &tmpV3_7, &a_Vector3, &b_Vector3, (unsigned int)-1 ); - vmathV3Prints( &tmpV3_7, "select 3" ); - vmathV3MakeFromElems( &a_Vector3, xyz4[0], xyz4[1], xyz4[2] ); - vmathV3Prints( &a_Vector3, "load XYZ array" ); - xyz4[0] = -xyz4[0]; - xyz4[1] = -xyz4[1]; - xyz4[2] = -xyz4[2]; - xyz4[3] = -xyz4[3]; - xyz4[4] = -xyz4[4]; - xyz4[5] = -xyz4[5]; - xyz4[6] = -xyz4[6]; - xyz4[7] = -xyz4[7]; - xyz4[8] = -xyz4[8]; - xyz4[9] = -xyz4[9]; - xyz4[10] = -xyz4[10]; - xyz4[11] = -xyz4[11]; - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); -#ifndef _VECTORMATH_SCALAR_TEST - vmathV3LoadXYZArray( &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3, (const vec_float4 *)xyz4 ); - xyz4[0] = 0; - xyz4[1] = 1; - xyz4[2] = 2; - xyz4[3] = 3; - xyz4[4] = 4; - xyz4[5] = 5; - xyz4[6] = 6; - xyz4[7] = 7; - xyz4[8] = 8; - xyz4[9] = 9; - xyz4[10] = 10; - xyz4[11] = 11; - vmathV3StoreXYZArray( &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3, (vec_float4 *)xyz4 ); -#endif - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); -#ifdef _VECTORMATH_SCALAR_TEST - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); -#else - quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; - a_Vector3.vec128 = quad; - quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; - vmathV3StoreXYZ( &a_Vector3, &quad ); - printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); -#endif - vmathV3Copy( &a_Vector3, &b_Vector3 ); - vmathV3Prints( &a_Vector3, "assign to Vector3 from Vector3" ); - vmathV3MakeFromScalar( &a_Vector3, 0.0f ); - vmathV3Prints( &a_Vector3, "set Vector3 elements to zero" ); - vmathV3MakeXAxis( &a_Vector3 ); - vmathV3Prints( &a_Vector3, "set to x axis" ); - vmathV3MakeYAxis( &a_Vector3 ); - vmathV3Prints( &a_Vector3, "set to y axis" ); - vmathV3MakeZAxis( &a_Vector3 ); - vmathV3Prints( &a_Vector3, "set to z axis" ); - vmathV3SetElem( &a_Vector3, 0, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::set( 0, float )" ); - vmathV3SetElem( &a_Vector3, 0, randfloat() ); - vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) * randfloat() ) ); - vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) / randfloat() ) ); - vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) + randfloat() ) ); - vmathV3SetElem( &a_Vector3, 0, ( vmathV3GetElem( &a_Vector3, 0 ) - randfloat() ) ); - vmathV3Prints( &a_Vector3, "Vector3::operator [](0)" ); - vmathV3SetX( &a_Vector3, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::setX()" ); - vmathV3SetElem( &a_Vector3, 1, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::set( 1, float )" ); - vmathV3SetElem( &a_Vector3, 1, randfloat() ); - vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) * randfloat() ) ); - vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) / randfloat() ) ); - vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) + randfloat() ) ); - vmathV3SetElem( &a_Vector3, 1, ( vmathV3GetElem( &a_Vector3, 1 ) - randfloat() ) ); - vmathV3Prints( &a_Vector3, "Vector3::operator [](1)" ); - vmathV3SetY( &a_Vector3, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::setY()" ); - vmathV3SetElem( &a_Vector3, 2, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::set( 2, float )" ); - vmathV3SetElem( &a_Vector3, 2, randfloat() ); - vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) * randfloat() ) ); - vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) / randfloat() ) ); - vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) + randfloat() ) ); - vmathV3SetElem( &a_Vector3, 2, ( vmathV3GetElem( &a_Vector3, 2 ) - randfloat() ) ); - vmathV3Prints( &a_Vector3, "Vector3::operator [](2)" ); - vmathV3SetZ( &a_Vector3, randfloat() ); - vmathV3Prints( &a_Vector3, "Vector3::setZ()" ); - printf("Vector3::get( 0 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 0 )) ); - printf("Vector3::operator []( 0 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 0 )) ); - printf("Vector3::getX(): %f\n", getfloat(vmathV3GetX( &a_Vector3 )) ); - printf("Vector3::get( 1 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 1 )) ); - printf("Vector3::operator []( 1 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 1 )) ); - printf("Vector3::getY(): %f\n", getfloat(vmathV3GetY( &a_Vector3 )) ); - printf("Vector3::get( 2 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 2 )) ); - printf("Vector3::operator []( 2 ): %f\n", getfloat(vmathV3GetElem( &a_Vector3, 2 )) ); - printf("Vector3::getZ(): %f\n", getfloat(vmathV3GetZ( &a_Vector3 )) ); - vmathV3Add( &tmpV3_8, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_8, "Vector3 + Vector3" ); - vmathV3Sub( &tmpV3_9, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_9, "Vector3 - Vector3" ); - vmathV3AddP3( &tmpP3_0, &a_Vector3, &b_Point3 ); - vmathP3Prints( &tmpP3_0, "Vector3 + Point3" ); - vmathV3ScalarMul( &tmpV3_10, &a_Vector3, randfloat() ); - vmathV3Prints( &tmpV3_10, "Vector3 * float" ); - vmathV3ScalarDiv( &tmpV3_11, &a_Vector3, randfloat() ); - vmathV3Prints( &tmpV3_11, "Vector3 / float" ); - vmathV3ScalarMul( &tmpV3_12, &a_Vector3, randfloat() ); - vmathV3Prints( &tmpV3_12, "float * Vector3" ); - vmathV3Neg( &tmpV3_13, &a_Vector3 ); - vmathV3Prints( &tmpV3_13, "Vector3 negate" ); - vmathV3MulPerElem( &tmpV3_14, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_14, "mulPerElem( Vector3, Vector3 )" ); - vmathV3DivPerElem( &tmpV3_15, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_15, "divPerElem( Vector3, Vector3 )" ); - vmathV3RecipPerElem( &tmpV3_16, &a_Vector3 ); - vmathV3Prints( &tmpV3_16, "Vector3 recip" ); - vmathV3AbsPerElem( &tmpV3_17, &a_Vector3 ); - vmathV3SqrtPerElem( &tmpV3_18, &tmpV3_17 ); - vmathV3Prints( &tmpV3_18, "Vector3 sqrt" ); - vmathV3AbsPerElem( &tmpV3_19, &a_Vector3 ); - vmathV3RsqrtPerElem( &tmpV3_20, &tmpV3_19 ); - vmathV3Prints( &tmpV3_20, "Vector3 rsqrt" ); - vmathV3AbsPerElem( &tmpV3_21, &a_Vector3 ); - vmathV3Prints( &tmpV3_21, "Vector3 abs" ); - vmathV3CopySignPerElem( &tmpV3_22, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_22, "Vector3 copySign" ); - vmathV3MaxPerElem( &tmpV3_23, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_23, "Vector3 maximum Vector3" ); - vmathV3MinPerElem( &tmpV3_24, &a_Vector3, &b_Vector3 ); - vmathV3Prints( &tmpV3_24, "Vector3 minimum Vector3" ); - printf("Vector3 maximum of elements: %f\n", getfloat(vmathV3MaxElem( &a_Vector3 ))); - printf("Vector3 minimum of elements: %f\n", getfloat(vmathV3MinElem( &a_Vector3 ))); - printf("Vector3 sum of elements: %f\n", getfloat(vmathV3Sum( &a_Vector3 ))); - printf("Vector3 dot Vector3: %f\n", getfloat(vmathV3Dot( &a_Vector3, &b_Vector3 ))); - printf("Vector3 lengthSqr: %f\n", getfloat(vmathV3LengthSqr( &a_Vector3 ))); - printf("Vector3 length: %f\n", getfloat(vmathV3Length( &a_Vector3 ))); - vmathV3Normalize( &tmpV3_25, &a_Vector3 ); - vmathV3Prints( &tmpV3_25, "Vector3 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &e_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV3Normalize( &b_Vector3, &b_Vector3 ); - vmathV3Normalize( &c_Vector3, &c_Vector3 ); - vmathV3Normalize( &d_Vector3, &d_Vector3 ); - vmathV3Normalize( &e_Vector3, &e_Vector3 ); - vmathV3Lerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); - vmathV3Prints( &a_Vector3, "Vector3 lerp" ); - vmathV3Slerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); - vmathV3Prints( &a_Vector3, "Vector3 slerp" ); -} - -void -Vector4_methods_test() -{ - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3, tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3; - VmathVector3 tmpV3_4; - VmathVector4 tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15, tmpV4_16, tmpV4_17, tmpV4_18, tmpV4_19, tmpV4_20, tmpV4_21; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3MakeFromScalar( &c_Vector3, 0.0f ); - vmathV3MakeFromScalar( &d_Vector3, 0.0f ); - vmathV3MakeFromScalar( &e_Vector3, 0.0f ); - vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4MakeFromScalar( &c_Vector4, 0.0f ); - vmathV4MakeFromScalar( &d_Vector4, 0.0f ); - vmathV4MakeFromScalar( &e_Vector4, 0.0f ); - vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3MakeFromScalar( &c_Point3, 0.0f ); - vmathP3MakeFromScalar( &d_Point3, 0.0f ); - vmathP3MakeFromScalar( &e_Point3, 0.0f ); - vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQMakeFromScalar( &c_Quat, 0.0f ); - vmathQMakeFromScalar( &d_Quat, 0.0f ); - vmathQMakeFromScalar( &e_Quat, 0.0f ); - vmathQPrints( &c_Quat, "set Quat elements to zero" ); - vmathQPrints( &d_Quat, "set Quat elements to zero" ); - vmathQPrints( &e_Quat, "set Quat elements to zero" ); - vmathV4MakeFromV3Scalar( &a_Vector4, &a_Vector3, randfloat() ); - vmathV4Prints( &a_Vector4, "set Vector4 with Vector3, float" ); - vmathV4MakeFromV3( &a_Vector4, &a_Vector3 ); - vmathV4Prints( &a_Vector4, "set Vector4 with Vector3" ); - vmathV4MakeFromP3( &a_Vector4, &a_Point3 ); - vmathV4Prints( &a_Vector4, "set Vector4 with Point3" ); - vmathV4MakeFromQ( &a_Vector4, &a_Quat ); - vmathV4Prints( &a_Vector4, "construct Vector4 with Quat" ); - vmathV4MakeFromScalar( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "set Vector4 with float" ); - vmathV4MakeFromScalar( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "set Vector4 with float" ); - vmathV4MakeFromElems( &aos_Vector4_0, 0.0f, 1.0f, 2.0f, 3.0f ); - vmathV4MakeFromElems( &aos_Vector4_1, 4.0f, 5.0f, 6.0f, 7.0f ); - vmathV4MakeFromElems( &aos_Vector4_2, 8.0f, 9.0f, 10.0f, 11.0f ); - vmathV4MakeFromElems( &aos_Vector4_3, 12.0f, 13.0f, 14.0f, 15.0f ); - vmathV4Prints( &aos_Vector4_3, "aos type 0" ); - vmathV4Prints( &aos_Vector4_2, "aos type 1" ); - vmathV4Prints( &aos_Vector4_1, "aos type 2" ); - vmathV4Prints( &aos_Vector4_0, "aos type 3" ); - vmathV4Select( &tmpV4_0, &a_Vector4, &b_Vector4, 0 ); - vmathV4Prints( &tmpV4_0, "select 0" ); - vmathV4Select( &tmpV4_1, &a_Vector4, &b_Vector4, 1 ); - vmathV4Prints( &tmpV4_1, "select 1" ); - vmathV4Select( &tmpV4_2, &a_Vector4, &b_Vector4, 0 ); - vmathV4Prints( &tmpV4_2, "select 2" ); - vmathV4Select( &tmpV4_3, &a_Vector4, &b_Vector4, (unsigned int)-1 ); - vmathV4Prints( &tmpV4_3, "select 3" ); - vmathV4Copy( &a_Vector4, &b_Vector4 ); - vmathV4Prints( &a_Vector4, "assign to Vector4 from Vector4" ); - vmathV4SetXYZ( &a_Vector4, &a_Vector3 ); - vmathV4Prints( &a_Vector4, "set Vector4 xyz" ); - vmathV4GetXYZ( &tmpV3_4, &a_Vector4 ); - vmathV3Prints( &tmpV3_4, "get Vector4 xyz" ); - vmathV4MakeFromScalar( &a_Vector4, 0.0f ); - vmathV4Prints( &a_Vector4, "set Vector4 elements to zero" ); - vmathV4MakeXAxis( &a_Vector4 ); - vmathV4Prints( &a_Vector4, "set to x axis" ); - vmathV4MakeYAxis( &a_Vector4 ); - vmathV4Prints( &a_Vector4, "set to y axis" ); - vmathV4MakeZAxis( &a_Vector4 ); - vmathV4Prints( &a_Vector4, "set to z axis" ); - vmathV4MakeWAxis( &a_Vector4 ); - vmathV4Prints( &a_Vector4, "set to w axis" ); - vmathV4SetElem( &a_Vector4, 0, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::set( 0, float )" ); - vmathV4SetElem( &a_Vector4, 0, randfloat() ); - vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) * randfloat() ) ); - vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) / randfloat() ) ); - vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) + randfloat() ) ); - vmathV4SetElem( &a_Vector4, 0, ( vmathV4GetElem( &a_Vector4, 0 ) - randfloat() ) ); - vmathV4Prints( &a_Vector4, "Vector4::operator [](0)" ); - vmathV4SetX( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::setX()" ); - vmathV4SetElem( &a_Vector4, 1, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::set( 1, float )" ); - vmathV4SetElem( &a_Vector4, 1, randfloat() ); - vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) * randfloat() ) ); - vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) / randfloat() ) ); - vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) + randfloat() ) ); - vmathV4SetElem( &a_Vector4, 1, ( vmathV4GetElem( &a_Vector4, 1 ) - randfloat() ) ); - vmathV4Prints( &a_Vector4, "Vector4::operator [](1)" ); - vmathV4SetY( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::setY()" ); - vmathV4SetElem( &a_Vector4, 2, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::set( 2, float )" ); - vmathV4SetElem( &a_Vector4, 2, randfloat() ); - vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) * randfloat() ) ); - vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) / randfloat() ) ); - vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) + randfloat() ) ); - vmathV4SetElem( &a_Vector4, 2, ( vmathV4GetElem( &a_Vector4, 2 ) - randfloat() ) ); - vmathV4Prints( &a_Vector4, "Vector4::operator [](2)" ); - vmathV4SetZ( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::setZ()" ); - vmathV4SetElem( &a_Vector4, 3, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::set( 3, float )" ); - vmathV4SetElem( &a_Vector4, 3, randfloat() ); - vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) * randfloat() ) ); - vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) / randfloat() ) ); - vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) + randfloat() ) ); - vmathV4SetElem( &a_Vector4, 3, ( vmathV4GetElem( &a_Vector4, 3 ) - randfloat() ) ); - vmathV4Prints( &a_Vector4, "Vector4::operator [](3)" ); - vmathV4SetW( &a_Vector4, randfloat() ); - vmathV4Prints( &a_Vector4, "Vector4::setW()" ); - printf("Vector4::get( 0 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 0 )) ); - printf("Vector4::operator []( 0 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 0 )) ); - printf("Vector4::getX(): %f\n", getfloat(vmathV4GetX( &a_Vector4 )) ); - printf("Vector4::get( 1 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 1 )) ); - printf("Vector4::operator []( 1 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 1 )) ); - printf("Vector4::getY(): %f\n", getfloat(vmathV4GetY( &a_Vector4 )) ); - printf("Vector4::get( 2 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 2 )) ); - printf("Vector4::operator []( 2 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 2 )) ); - printf("Vector4::getZ(): %f\n", getfloat(vmathV4GetZ( &a_Vector4 )) ); - printf("Vector4::get( 3 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 3 )) ); - printf("Vector4::operator []( 3 ): %f\n", getfloat(vmathV4GetElem( &a_Vector4, 3 )) ); - printf("Vector4::getW(): %f\n", getfloat(vmathV4GetW( &a_Vector4 )) ); - vmathV4Add( &tmpV4_4, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_4, "Vector4 + Vector4" ); - vmathV4Sub( &tmpV4_5, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_5, "Vector4 - Vector4" ); - vmathV4ScalarMul( &tmpV4_6, &a_Vector4, randfloat() ); - vmathV4Prints( &tmpV4_6, "Vector4 * float" ); - vmathV4ScalarDiv( &tmpV4_7, &a_Vector4, randfloat() ); - vmathV4Prints( &tmpV4_7, "Vector4 / float" ); - vmathV4ScalarMul( &tmpV4_8, &a_Vector4, randfloat() ); - vmathV4Prints( &tmpV4_8, "float * Vector4" ); - vmathV4Neg( &tmpV4_9, &a_Vector4 ); - vmathV4Prints( &tmpV4_9, "Vector4 negate" ); - vmathV4MulPerElem( &tmpV4_10, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_10, "mulPerElem( Vector4, Vector4 )" ); - vmathV4DivPerElem( &tmpV4_11, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_11, "divPerElem( Vector4, Vector4 )" ); - vmathV4RecipPerElem( &tmpV4_12, &a_Vector4 ); - vmathV4Prints( &tmpV4_12, "Vector4 recip" ); - vmathV4AbsPerElem( &tmpV4_13, &a_Vector4 ); - vmathV4SqrtPerElem( &tmpV4_14, &tmpV4_13 ); - vmathV4Prints( &tmpV4_14, "Vector4 sqrt" ); - vmathV4AbsPerElem( &tmpV4_15, &a_Vector4 ); - vmathV4RsqrtPerElem( &tmpV4_16, &tmpV4_15 ); - vmathV4Prints( &tmpV4_16, "Vector4 rsqrt" ); - vmathV4AbsPerElem( &tmpV4_17, &a_Vector4 ); - vmathV4Prints( &tmpV4_17, "Vector4 abs" ); - vmathV4CopySignPerElem( &tmpV4_18, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_18, "Vector4 copySign" ); - vmathV4MaxPerElem( &tmpV4_19, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_19, "Vector4 maximum Vector4" ); - vmathV4MinPerElem( &tmpV4_20, &a_Vector4, &b_Vector4 ); - vmathV4Prints( &tmpV4_20, "Vector4 minimum Vector4" ); - printf("Vector4 maximum of elements: %f\n", getfloat(vmathV4MaxElem( &a_Vector4 ))); - printf("Vector4 minimum of elements: %f\n", getfloat(vmathV4MinElem( &a_Vector4 ))); - printf("Vector4 sum of elements: %f\n", getfloat(vmathV4Sum( &a_Vector4 ))); - printf("Vector4 dot Vector4: %f\n", getfloat(vmathV4Dot( &a_Vector4, &b_Vector4 ))); - printf("Vector4 lengthSqr: %f\n", getfloat(vmathV4LengthSqr( &a_Vector4 ))); - printf("Vector4 length: %f\n", getfloat(vmathV4Length( &a_Vector4 ))); - vmathV4Normalize( &tmpV4_21, &a_Vector4 ); - vmathV4Prints( &tmpV4_21, "Vector4 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &e_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Normalize( &b_Vector4, &b_Vector4 ); - vmathV4Normalize( &c_Vector4, &c_Vector4 ); - vmathV4Normalize( &d_Vector4, &d_Vector4 ); - vmathV4Normalize( &e_Vector4, &e_Vector4 ); - vmathV4Lerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); - vmathV4Prints( &a_Vector4, "Vector4 lerp" ); - vmathV4Slerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); - vmathV4Prints( &a_Vector4, "Vector4 slerp" ); -} - -void -Point3_methods_test() -{ - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - VmathPoint3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, tmpP3_0, tmpP3_1, tmpP3_2, tmpP3_3; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - VmathVector3 tmpV3_4; - VmathPoint3 tmpP3_4, tmpP3_5, tmpP3_6, tmpP3_7, tmpP3_8, tmpP3_9, tmpP3_10, tmpP3_11, tmpP3_12, tmpP3_13, tmpP3_14, tmpP3_15, tmpP3_16; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - float xyz4[12] __attribute__ ((aligned(16))); -#ifndef _VECTORMATH_SCALAR_TEST - vec_float4 quad; -#endif - xyz4[0] = randfloat(); - xyz4[1] = randfloat(); - xyz4[2] = randfloat(); - xyz4[3] = randfloat(); - xyz4[4] = randfloat(); - xyz4[5] = randfloat(); - xyz4[6] = randfloat(); - xyz4[7] = randfloat(); - xyz4[8] = randfloat(); - xyz4[9] = randfloat(); - xyz4[10] = randfloat(); - xyz4[11] = randfloat(); - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3MakeFromScalar( &c_Vector3, 0.0f ); - vmathV3MakeFromScalar( &d_Vector3, 0.0f ); - vmathV3MakeFromScalar( &e_Vector3, 0.0f ); - vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4MakeFromScalar( &c_Vector4, 0.0f ); - vmathV4MakeFromScalar( &d_Vector4, 0.0f ); - vmathV4MakeFromScalar( &e_Vector4, 0.0f ); - vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3MakeFromScalar( &c_Point3, 0.0f ); - vmathP3MakeFromScalar( &d_Point3, 0.0f ); - vmathP3MakeFromScalar( &e_Point3, 0.0f ); - vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQMakeFromScalar( &c_Quat, 0.0f ); - vmathQMakeFromScalar( &d_Quat, 0.0f ); - vmathQMakeFromScalar( &e_Quat, 0.0f ); - vmathQPrints( &c_Quat, "set Quat elements to zero" ); - vmathQPrints( &d_Quat, "set Quat elements to zero" ); - vmathQPrints( &e_Quat, "set Quat elements to zero" ); - vmathP3MakeFromV3( &a_Point3, &a_Vector3 ); - vmathP3Prints( &a_Point3, "construct Point3 with Vector3" ); - vmathP3MakeFromScalar( &a_Point3, randfloat() ); - vmathP3Prints( &a_Point3, "set Point3 with float" ); - vmathP3MakeFromScalar( &a_Point3, randfloat() ); - vmathP3Prints( &a_Point3, "set Point3 with float" ); - vmathP3MakeFromElems( &aos_Point3_0, 0.0f, 1.0f, 2.0f ); - vmathP3MakeFromElems( &aos_Point3_1, 3.0f, 4.0f, 5.0f ); - vmathP3MakeFromElems( &aos_Point3_2, 6.0f, 7.0f, 8.0f ); - vmathP3MakeFromElems( &aos_Point3_3, 9.0f, 10.0f, 11.0f ); - vmathP3Prints( &aos_Point3_3, "aos type 0" ); - vmathP3Prints( &aos_Point3_2, "aos type 1" ); - vmathP3Prints( &aos_Point3_1, "aos type 2" ); - vmathP3Prints( &aos_Point3_0, "aos type 3" ); - vmathP3Select( &tmpP3_0, &a_Point3, &b_Point3, 0 ); - vmathP3Prints( &tmpP3_0, "select 0" ); - vmathP3Select( &tmpP3_1, &a_Point3, &b_Point3, 1 ); - vmathP3Prints( &tmpP3_1, "select 1" ); - vmathP3Select( &tmpP3_2, &a_Point3, &b_Point3, 0 ); - vmathP3Prints( &tmpP3_2, "select 2" ); - vmathP3Select( &tmpP3_3, &a_Point3, &b_Point3, (unsigned int)-1 ); - vmathP3Prints( &tmpP3_3, "select 3" ); - vmathP3MakeFromElems( &a_Point3, xyz4[0], xyz4[1], xyz4[2] ); - vmathP3Prints( &a_Point3, "load XYZ array" ); - xyz4[0] = -xyz4[0]; - xyz4[1] = -xyz4[1]; - xyz4[2] = -xyz4[2]; - xyz4[3] = -xyz4[3]; - xyz4[4] = -xyz4[4]; - xyz4[5] = -xyz4[5]; - xyz4[6] = -xyz4[6]; - xyz4[7] = -xyz4[7]; - xyz4[8] = -xyz4[8]; - xyz4[9] = -xyz4[9]; - xyz4[10] = -xyz4[10]; - xyz4[11] = -xyz4[11]; - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); -#ifndef _VECTORMATH_SCALAR_TEST - vmathP3LoadXYZArray( &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3, (const vec_float4 *)xyz4 ); - xyz4[0] = 0; - xyz4[1] = 1; - xyz4[2] = 2; - xyz4[3] = 3; - xyz4[4] = 4; - xyz4[5] = 5; - xyz4[6] = 6; - xyz4[7] = 7; - xyz4[8] = 8; - xyz4[9] = 9; - xyz4[10] = 10; - xyz4[11] = 11; - vmathP3StoreXYZArray( &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3, (vec_float4 *)xyz4 ); -#endif - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); -#ifdef _VECTORMATH_SCALAR_TEST - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); -#else - quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; - a_Point3.vec128 = quad; - quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; - vmathP3StoreXYZ( &a_Point3, &quad ); - printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); -#endif - vmathP3Copy( &a_Point3, &b_Point3 ); - vmathP3Prints( &a_Point3, "assign to Point3 from Point3" ); - vmathP3MakeFromScalar( &a_Point3, 0.0f ); - vmathP3Prints( &a_Point3, "set Point3 elements to zero" ); - vmathP3SetElem( &a_Point3, 0, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::set( 0, float )" ); - vmathP3SetElem( &a_Point3, 0, randfloat() ); - vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) * randfloat() ) ); - vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) / randfloat() ) ); - vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) + randfloat() ) ); - vmathP3SetElem( &a_Point3, 0, ( vmathP3GetElem( &a_Point3, 0 ) - randfloat() ) ); - vmathP3Prints( &a_Point3, "Point3::operator [](0)" ); - vmathP3SetX( &a_Point3, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::setX()" ); - vmathP3SetElem( &a_Point3, 1, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::set( 1, float )" ); - vmathP3SetElem( &a_Point3, 1, randfloat() ); - vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) * randfloat() ) ); - vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) / randfloat() ) ); - vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) + randfloat() ) ); - vmathP3SetElem( &a_Point3, 1, ( vmathP3GetElem( &a_Point3, 1 ) - randfloat() ) ); - vmathP3Prints( &a_Point3, "Point3::operator [](1)" ); - vmathP3SetY( &a_Point3, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::setY()" ); - vmathP3SetElem( &a_Point3, 2, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::set( 2, float )" ); - vmathP3SetElem( &a_Point3, 2, randfloat() ); - vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) * randfloat() ) ); - vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) / randfloat() ) ); - vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) + randfloat() ) ); - vmathP3SetElem( &a_Point3, 2, ( vmathP3GetElem( &a_Point3, 2 ) - randfloat() ) ); - vmathP3Prints( &a_Point3, "Point3::operator [](2)" ); - vmathP3SetZ( &a_Point3, randfloat() ); - vmathP3Prints( &a_Point3, "Point3::setZ()" ); - printf("Point3::get( 0 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 0 )) ); - printf("Point3::operator []( 0 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 0 )) ); - printf("Point3::getX(): %f\n", getfloat(vmathP3GetX( &a_Point3 )) ); - printf("Point3::get( 1 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 1 )) ); - printf("Point3::operator []( 1 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 1 )) ); - printf("Point3::getY(): %f\n", getfloat(vmathP3GetY( &a_Point3 )) ); - printf("Point3::get( 2 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 2 )) ); - printf("Point3::operator []( 2 ): %f\n", getfloat(vmathP3GetElem( &a_Point3, 2 )) ); - printf("Point3::getZ(): %f\n", getfloat(vmathP3GetZ( &a_Point3 )) ); - vmathP3Sub( &tmpV3_4, &a_Point3, &b_Point3 ); - vmathV3Prints( &tmpV3_4, "Point3 - Point3" ); - vmathP3AddV3( &tmpP3_4, &a_Point3, &b_Vector3 ); - vmathP3Prints( &tmpP3_4, "Point3 + Vector3" ); - vmathP3SubV3( &tmpP3_5, &a_Point3, &b_Vector3 ); - vmathP3Prints( &tmpP3_5, "Point3 - Vector3" ); - vmathP3MulPerElem( &tmpP3_6, &a_Point3, &b_Point3 ); - vmathP3Prints( &tmpP3_6, "mulPerElem( Point3, Point3 )" ); - vmathP3DivPerElem( &tmpP3_7, &a_Point3, &b_Point3 ); - vmathP3Prints( &tmpP3_7, "divPerElem( Point3, Point3 )" ); - vmathP3RecipPerElem( &tmpP3_8, &a_Point3 ); - vmathP3Prints( &tmpP3_8, "Point3 recip" ); - vmathP3AbsPerElem( &tmpP3_9, &a_Point3 ); - vmathP3SqrtPerElem( &tmpP3_10, &tmpP3_9 ); - vmathP3Prints( &tmpP3_10, "Point3 sqrt" ); - vmathP3AbsPerElem( &tmpP3_11, &a_Point3 ); - vmathP3RsqrtPerElem( &tmpP3_12, &tmpP3_11 ); - vmathP3Prints( &tmpP3_12, "Point3 rsqrt" ); - vmathP3AbsPerElem( &tmpP3_13, &a_Point3 ); - vmathP3Prints( &tmpP3_13, "Point3 abs" ); - vmathP3CopySignPerElem( &tmpP3_14, &a_Point3, &b_Point3 ); - vmathP3Prints( &tmpP3_14, "Point3 copySign" ); - vmathP3MaxPerElem( &tmpP3_15, &a_Point3, &b_Point3 ); - vmathP3Prints( &tmpP3_15, "Point3 maximum Point3" ); - vmathP3MinPerElem( &tmpP3_16, &a_Point3, &b_Point3 ); - vmathP3Prints( &tmpP3_16, "Point3 minimum Point3" ); - printf("Point3 maximum of elements: %f\n", getfloat(vmathP3MaxElem( &a_Point3 ))); - printf("Point3 minimum of elements: %f\n", getfloat(vmathP3MinElem( &a_Point3 ))); - printf("Point3 sum of elements: %f\n", getfloat(vmathP3Sum( &a_Point3 ))); - printf("Point projection: %f\n", getfloat(vmathP3Projection( &a_Point3, &b_Vector3 ))); - printf("Point distSqrFromOrigin: %f\n", getfloat(vmathP3DistSqrFromOrigin( &a_Point3 )) ); - printf("Point distFromOrigin: %f\n", getfloat(vmathP3DistFromOrigin( &a_Point3 )) ); - printf("Point distSqr: %f\n", getfloat(vmathP3DistSqr( &a_Point3, &b_Point3 )) ); - printf("Point dist: %f\n", getfloat(vmathP3Dist( &a_Point3, &b_Point3 )) ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &e_Point3, rndflt1, rndflt2, rndflt3 ); - vmathP3Lerp( &a_Point3, randfloat(), &b_Point3, &c_Point3 ); - vmathP3Prints( &a_Point3, "Point3 lerp" ); -} - -void -Quat_methods_test() -{ - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - VmathQuat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3, tmpQ_0, tmpQ_1, tmpQ_2, tmpQ_3; - VmathVector3 tmpV3_4; - VmathQuat tmpQ_4, tmpQ_5, tmpQ_6, tmpQ_7, tmpQ_8, tmpQ_9, tmpQ_10, tmpQ_11; - VmathVector3 tmpV3_5; - VmathQuat tmpQ_12; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3MakeFromScalar( &c_Vector3, 0.0f ); - vmathV3MakeFromScalar( &d_Vector3, 0.0f ); - vmathV3MakeFromScalar( &e_Vector3, 0.0f ); - vmathV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4MakeFromScalar( &c_Vector4, 0.0f ); - vmathV4MakeFromScalar( &d_Vector4, 0.0f ); - vmathV4MakeFromScalar( &e_Vector4, 0.0f ); - vmathV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3MakeFromScalar( &c_Point3, 0.0f ); - vmathP3MakeFromScalar( &d_Point3, 0.0f ); - vmathP3MakeFromScalar( &e_Point3, 0.0f ); - vmathP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQMakeFromScalar( &c_Quat, 0.0f ); - vmathQMakeFromScalar( &d_Quat, 0.0f ); - vmathQMakeFromScalar( &e_Quat, 0.0f ); - vmathQPrints( &c_Quat, "set Quat elements to zero" ); - vmathQPrints( &d_Quat, "set Quat elements to zero" ); - vmathQPrints( &e_Quat, "set Quat elements to zero" ); - vmathQMakeFromV3Scalar( &a_Quat, &a_Vector3, randfloat() ); - vmathQPrints( &a_Quat, "set Quat with Vector3, float" ); - vmathQMakeFromV4( &a_Quat, &a_Vector4 ); - vmathQPrints( &a_Quat, "construct Quat with Vector4" ); - vmathQMakeFromScalar( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "set Quat with float" ); - vmathQMakeFromScalar( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "set Quat with float" ); - vmathQMakeFromElems( &aos_Quat_0, 0.0f, 1.0f, 2.0f, 3.0f ); - vmathQMakeFromElems( &aos_Quat_1, 4.0f, 5.0f, 6.0f, 7.0f ); - vmathQMakeFromElems( &aos_Quat_2, 8.0f, 9.0f, 10.0f, 11.0f ); - vmathQMakeFromElems( &aos_Quat_3, 12.0f, 13.0f, 14.0f, 15.0f ); - vmathQPrints( &aos_Quat_3, "aos type 0" ); - vmathQPrints( &aos_Quat_2, "aos type 1" ); - vmathQPrints( &aos_Quat_1, "aos type 2" ); - vmathQPrints( &aos_Quat_0, "aos type 3" ); - vmathQSelect( &tmpQ_0, &a_Quat, &b_Quat, 0 ); - vmathQPrints( &tmpQ_0, "select 0" ); - vmathQSelect( &tmpQ_1, &a_Quat, &b_Quat, 1 ); - vmathQPrints( &tmpQ_1, "select 1" ); - vmathQSelect( &tmpQ_2, &a_Quat, &b_Quat, 0 ); - vmathQPrints( &tmpQ_2, "select 2" ); - vmathQSelect( &tmpQ_3, &a_Quat, &b_Quat, (unsigned int)-1 ); - vmathQPrints( &tmpQ_3, "select 3" ); - vmathQCopy( &a_Quat, &b_Quat ); - vmathQPrints( &a_Quat, "assign to Quat from Quat" ); - vmathQSetXYZ( &a_Quat, &a_Vector3 ); - vmathQPrints( &a_Quat, "set Quat xyz" ); - vmathQGetXYZ( &tmpV3_4, &a_Quat ); - vmathV3Prints( &tmpV3_4, "get Quat xyz" ); - vmathQMakeFromScalar( &a_Quat, 0.0f ); - vmathQPrints( &a_Quat, "set Quat elements to zero" ); - vmathQSetElem( &a_Quat, 0, randfloat() ); - vmathQPrints( &a_Quat, "Quat::set( 0, float )" ); - vmathQSetElem( &a_Quat, 0, randfloat() ); - vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) * randfloat() ) ); - vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) / randfloat() ) ); - vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) + randfloat() ) ); - vmathQSetElem( &a_Quat, 0, ( vmathQGetElem( &a_Quat, 0 ) - randfloat() ) ); - vmathQPrints( &a_Quat, "Quat::operator [](0)" ); - vmathQSetX( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat::setX()" ); - vmathQSetElem( &a_Quat, 1, randfloat() ); - vmathQPrints( &a_Quat, "Quat::set( 1, float )" ); - vmathQSetElem( &a_Quat, 1, randfloat() ); - vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) * randfloat() ) ); - vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) / randfloat() ) ); - vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) + randfloat() ) ); - vmathQSetElem( &a_Quat, 1, ( vmathQGetElem( &a_Quat, 1 ) - randfloat() ) ); - vmathQPrints( &a_Quat, "Quat::operator [](1)" ); - vmathQSetY( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat::setY()" ); - vmathQSetElem( &a_Quat, 2, randfloat() ); - vmathQPrints( &a_Quat, "Quat::set( 2, float )" ); - vmathQSetElem( &a_Quat, 2, randfloat() ); - vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) * randfloat() ) ); - vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) / randfloat() ) ); - vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) + randfloat() ) ); - vmathQSetElem( &a_Quat, 2, ( vmathQGetElem( &a_Quat, 2 ) - randfloat() ) ); - vmathQPrints( &a_Quat, "Quat::operator [](2)" ); - vmathQSetZ( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat::setZ()" ); - vmathQSetElem( &a_Quat, 3, randfloat() ); - vmathQPrints( &a_Quat, "Quat::set( 3, float )" ); - vmathQSetElem( &a_Quat, 3, randfloat() ); - vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) * randfloat() ) ); - vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) / randfloat() ) ); - vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) + randfloat() ) ); - vmathQSetElem( &a_Quat, 3, ( vmathQGetElem( &a_Quat, 3 ) - randfloat() ) ); - vmathQPrints( &a_Quat, "Quat::operator [](3)" ); - vmathQSetW( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat::setW()" ); - printf("Quat::get( 0 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 0 )) ); - printf("Quat::operator []( 0 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 0 )) ); - printf("Quat::getX(): %f\n", getfloat(vmathQGetX( &a_Quat )) ); - printf("Quat::get( 1 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 1 )) ); - printf("Quat::operator []( 1 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 1 )) ); - printf("Quat::getY(): %f\n", getfloat(vmathQGetY( &a_Quat )) ); - printf("Quat::get( 2 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 2 )) ); - printf("Quat::operator []( 2 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 2 )) ); - printf("Quat::getZ(): %f\n", getfloat(vmathQGetZ( &a_Quat )) ); - printf("Quat::get( 3 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 3 )) ); - printf("Quat::operator []( 3 ): %f\n", getfloat(vmathQGetElem( &a_Quat, 3 )) ); - printf("Quat::getW(): %f\n", getfloat(vmathQGetW( &a_Quat )) ); - vmathQAdd( &tmpQ_4, &a_Quat, &b_Quat ); - vmathQPrints( &tmpQ_4, "Quat + Quat" ); - vmathQSub( &tmpQ_5, &a_Quat, &b_Quat ); - vmathQPrints( &tmpQ_5, "Quat - Quat" ); - vmathQMul( &tmpQ_6, &a_Quat, &b_Quat ); - vmathQPrints( &tmpQ_6, "Quat * Quat" ); - vmathQScalarMul( &tmpQ_7, &a_Quat, randfloat() ); - vmathQPrints( &tmpQ_7, "Quat * float" ); - vmathQScalarDiv( &tmpQ_8, &a_Quat, randfloat() ); - vmathQPrints( &tmpQ_8, "Quat / float" ); - vmathQScalarMul( &tmpQ_9, &a_Quat, randfloat() ); - vmathQPrints( &tmpQ_9, "float * Quat" ); - vmathQNeg( &tmpQ_10, &a_Quat ); - vmathQPrints( &tmpQ_10, "Quat negate" ); - printf("Quat dot Quat: %f\n", getfloat(vmathQDot( &a_Quat, &b_Quat ))); - printf("Quat lengthSqr: %f\n", getfloat(vmathQNorm( &a_Quat ))); - printf("Quat length: %f\n", getfloat(vmathQLength( &a_Quat ))); - vmathQNormalize( &tmpQ_11, &a_Quat ); - vmathQPrints( &tmpQ_11, "Quat normalized" ); - vmathQMakeIdentity( &a_Quat ); - vmathQPrints( &a_Quat, "set to identity" ); - vmathQMakeRotationArc( &a_Quat, &a_Vector3, &b_Vector3 ); - vmathQPrints( &a_Quat, "Quat rotation between vectors" ); - vmathQMakeRotationAxis( &a_Quat, randfloat(), &a_Vector3 ); - vmathQPrints( &a_Quat, "Quat rotation axis angle" ); - vmathQMakeRotationX( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat rotationX" ); - vmathQMakeRotationY( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat rotationY" ); - vmathQMakeRotationZ( &a_Quat, randfloat() ); - vmathQPrints( &a_Quat, "Quat rotationZ" ); - vmathQRotate( &tmpV3_5, &a_Quat, &a_Vector3 ); - vmathV3Prints( &tmpV3_5, "Quat rotate Vector3" ); - vmathQConj( &tmpQ_12, &a_Quat ); - vmathQPrints( &tmpQ_12, "Quat conj" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &e_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQNormalize( &b_Quat, &b_Quat ); - vmathQNormalize( &c_Quat, &c_Quat ); - vmathQNormalize( &d_Quat, &d_Quat ); - vmathQNormalize( &e_Quat, &e_Quat ); - vmathQLerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); - vmathQPrints( &a_Quat, "Quat lerp" ); - vmathQSlerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); - vmathQPrints( &a_Quat, "Quat slerp" ); - vmathQSquad( &a_Quat, randfloat(), &b_Quat, &c_Quat, &d_Quat, &e_Quat ); - vmathQPrints( &a_Quat, "Quat squad" ); -} - -int main() -{ - printf("\n __begin__ \n"); - for ( iteration = 0; iteration < 2; iteration++ ) { - Vector3_methods_test(); - Vector4_methods_test(); - Point3_methods_test(); - Quat_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test1_aos_cpp.cpp b/Extras/vectormathlibrary/tests/test1_aos_cpp.cpp deleted file mode 100644 index 2a960787d..000000000 --- a/Extras/vectormathlibrary/tests/test1_aos_cpp.cpp +++ /dev/null @@ -1,1102 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Aos; - -void -Vector3_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Vector4 tmpV4; - Vector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; - Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - float xyz4[12] __attribute__ ((aligned(16))); -#ifndef _VECTORMATH_SCALAR_TEST - vec_float4 quad; -#endif - xyz4[0] = randfloat(); - xyz4[1] = randfloat(); - xyz4[2] = randfloat(); - xyz4[3] = randfloat(); - xyz4[4] = randfloat(); - xyz4[5] = randfloat(); - xyz4[6] = randfloat(); - xyz4[7] = randfloat(); - xyz4[8] = randfloat(); - xyz4[9] = randfloat(); - xyz4[10] = randfloat(); - xyz4[11] = randfloat(); - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( 0.0f ); - d_Vector3 = Vector3( 0.0f ); - e_Vector3 = Vector3( 0.0f ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( 0.0f ); - d_Vector4 = Vector4( 0.0f ); - e_Vector4 = Vector4( 0.0f ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( 0.0f ); - d_Point3 = Point3( 0.0f ); - e_Point3 = Point3( 0.0f ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( 0.0f ); - d_Quat = Quat( 0.0f ); - e_Quat = Quat( 0.0f ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Vector3 = Vector3( a_Point3 ); - print( a_Vector3, "construct Vector3 with Point3" ); - a_Vector3 = Vector3( randfloat() ); - print( a_Vector3, "set Vector3 with float" ); - a_Vector3 = Vector3( scalar_float(randfloat()) ); - print( a_Vector3, "set Vector3 with float" ); - aos_Vector3_0 = Vector3( 0.0f, 1.0f, 2.0f ); - aos_Vector3_1 = Vector3( 3.0f, 4.0f, 5.0f ); - aos_Vector3_2 = Vector3( 6.0f, 7.0f, 8.0f ); - aos_Vector3_3 = Vector3( 9.0f, 10.0f, 11.0f ); - print( aos_Vector3_3, "aos type 0" ); - print( aos_Vector3_2, "aos type 1" ); - print( aos_Vector3_1, "aos type 2" ); - print( aos_Vector3_0, "aos type 3" ); - print( select( a_Vector3, b_Vector3, 0 ), "select 0" ); - print( select( a_Vector3, b_Vector3, 1 ), "select 1" ); - print( select( a_Vector3, b_Vector3, 0 ), "select 2" ); - print( select( a_Vector3, b_Vector3, (unsigned int)-1 ), "select 3" ); - a_Vector3 = Vector3( xyz4[0], xyz4[1], xyz4[2] ); - print( a_Vector3, "load XYZ array" ); - xyz4[0] = -xyz4[0]; - xyz4[1] = -xyz4[1]; - xyz4[2] = -xyz4[2]; - xyz4[3] = -xyz4[3]; - xyz4[4] = -xyz4[4]; - xyz4[5] = -xyz4[5]; - xyz4[6] = -xyz4[6]; - xyz4[7] = -xyz4[7]; - xyz4[8] = -xyz4[8]; - xyz4[9] = -xyz4[9]; - xyz4[10] = -xyz4[10]; - xyz4[11] = -xyz4[11]; - aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - print( aos_Vector4_0, "xyzx" ); - print( aos_Vector4_1, "yzxy" ); - print( aos_Vector4_2, "zxyz" ); -#ifndef _VECTORMATH_SCALAR_TEST - loadXYZArray( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, (const vec_float4 *)xyz4 ); - xyz4[0] = 0; - xyz4[1] = 1; - xyz4[2] = 2; - xyz4[3] = 3; - xyz4[4] = 4; - xyz4[5] = 5; - xyz4[6] = 6; - xyz4[7] = 7; - xyz4[8] = 8; - xyz4[9] = 9; - xyz4[10] = 10; - xyz4[11] = 11; - storeXYZArray( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3, (vec_float4 *)xyz4 ); -#endif - aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - print( aos_Vector4_0, "xyzx" ); - print( aos_Vector4_1, "yzxy" ); - print( aos_Vector4_2, "zxyz" ); -#ifdef _VECTORMATH_SCALAR_TEST - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); -#else - quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; - a_Vector3 = Vector3( quad ); - quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; - storeXYZ( a_Vector3, &quad ); - printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); -#endif - a_Vector3 = b_Vector3; - print( a_Vector3, "assign to Vector3 from Vector3" ); - a_Vector3 = Vector3( 0.0f ); - print( a_Vector3, "set Vector3 elements to zero" ); - a_Vector3 = Vector3::xAxis( ); - print( a_Vector3, "set to x axis" ); - a_Vector3 = Vector3::yAxis( ); - print( a_Vector3, "set to y axis" ); - a_Vector3 = Vector3::zAxis( ); - print( a_Vector3, "set to z axis" ); - if (iteration % 2) { - a_Vector3.setElem( 0, randfloat() ); - } else { - a_Vector3.setElem( 0, scalar_float(randfloat()) ); - } - print( a_Vector3, "Vector3::set( 0, float )" ); - a_Vector3[0] = randfloat(); - a_Vector3[0] *= randfloat(); - a_Vector3[0] /= randfloat(); - a_Vector3[0] += randfloat(); - a_Vector3[0] -= randfloat(); - print( a_Vector3, "Vector3::operator [](0)" ); - a_Vector3.setX( randfloat() ); - print( a_Vector3, "Vector3::setX()" ); - if (iteration % 2) { - a_Vector3.setElem( 1, randfloat() ); - } else { - a_Vector3.setElem( 1, scalar_float(randfloat()) ); - } - print( a_Vector3, "Vector3::set( 1, float )" ); - a_Vector3[1] = randfloat(); - a_Vector3[1] *= randfloat(); - a_Vector3[1] /= randfloat(); - a_Vector3[1] += randfloat(); - a_Vector3[1] -= randfloat(); - print( a_Vector3, "Vector3::operator [](1)" ); - a_Vector3.setY( randfloat() ); - print( a_Vector3, "Vector3::setY()" ); - if (iteration % 2) { - a_Vector3.setElem( 2, randfloat() ); - } else { - a_Vector3.setElem( 2, scalar_float(randfloat()) ); - } - print( a_Vector3, "Vector3::set( 2, float )" ); - a_Vector3[2] = randfloat(); - a_Vector3[2] *= randfloat(); - a_Vector3[2] /= randfloat(); - a_Vector3[2] += randfloat(); - a_Vector3[2] -= randfloat(); - print( a_Vector3, "Vector3::operator [](2)" ); - a_Vector3.setZ( randfloat() ); - print( a_Vector3, "Vector3::setZ()" ); - printf("Vector3::get( 0 ): %f\n", getfloat(a_Vector3.getElem( 0 )) ); - printf("Vector3::operator []( 0 ): %f\n", getfloat((float)a_Vector3[0]) ); - printf("Vector3::getX(): %f\n", getfloat(a_Vector3.getX( )) ); - printf("Vector3::get( 1 ): %f\n", getfloat(a_Vector3.getElem( 1 )) ); - printf("Vector3::operator []( 1 ): %f\n", getfloat((float)a_Vector3[1]) ); - printf("Vector3::getY(): %f\n", getfloat(a_Vector3.getY( )) ); - printf("Vector3::get( 2 ): %f\n", getfloat(a_Vector3.getElem( 2 )) ); - printf("Vector3::operator []( 2 ): %f\n", getfloat((float)a_Vector3[2]) ); - printf("Vector3::getZ(): %f\n", getfloat(a_Vector3.getZ( )) ); - print( ( a_Vector3 + b_Vector3 ), "Vector3 + Vector3" ); - print( ( a_Vector3 - b_Vector3 ), "Vector3 - Vector3" ); - print( ( a_Vector3 + b_Point3 ), "Vector3 + Point3" ); - print( ( a_Vector3 * randfloat() ), "Vector3 * float" ); - print( ( a_Vector3 / randfloat() ), "Vector3 / float" ); - print( ( randfloat() * a_Vector3 ), "float * Vector3" ); - print( ( -a_Vector3 ), "Vector3 negate" ); - print( mulPerElem( a_Vector3, b_Vector3 ), "mulPerElem( Vector3, Vector3 )" ); - print( divPerElem( a_Vector3, b_Vector3 ), "divPerElem( Vector3, Vector3 )" ); - print( recipPerElem( a_Vector3 ), "Vector3 recip" ); - print( sqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 rsqrt" ); - print( absPerElem( a_Vector3 ), "Vector3 abs" ); - print( copySignPerElem( a_Vector3, b_Vector3 ), "Vector3 copySign" ); - print( maxPerElem( a_Vector3, b_Vector3 ), "Vector3 maximum Vector3" ); - print( minPerElem( a_Vector3, b_Vector3 ), "Vector3 minimum Vector3" ); - printf("Vector3 maximum of elements: %f\n", getfloat(maxElem( a_Vector3 ))); - printf("Vector3 minimum of elements: %f\n", getfloat(minElem( a_Vector3 ))); - printf("Vector3 sum of elements: %f\n", getfloat(sum( a_Vector3 ))); - printf("Vector3 dot Vector3: %f\n", getfloat(dot( a_Vector3, b_Vector3 ))); - printf("Vector3 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector3 ))); - printf("Vector3 length: %f\n", getfloat(length( a_Vector3 ))); - print( normalize( a_Vector3 ), "Vector3 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - e_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - b_Vector3 = normalize( b_Vector3 ); - c_Vector3 = normalize( c_Vector3 ); - d_Vector3 = normalize( d_Vector3 ); - e_Vector3 = normalize( e_Vector3 ); - a_Vector3 = lerp( randfloat(), b_Vector3, c_Vector3 ); - print( a_Vector3, "Vector3 lerp" ); - a_Vector3 = slerp( randfloat(), b_Vector3, c_Vector3 ); - print( a_Vector3, "Vector3 slerp" ); -} - -void -Vector4_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Vector4 tmpV4, aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( 0.0f ); - d_Vector3 = Vector3( 0.0f ); - e_Vector3 = Vector3( 0.0f ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( 0.0f ); - d_Vector4 = Vector4( 0.0f ); - e_Vector4 = Vector4( 0.0f ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( 0.0f ); - d_Point3 = Point3( 0.0f ); - e_Point3 = Point3( 0.0f ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( 0.0f ); - d_Quat = Quat( 0.0f ); - e_Quat = Quat( 0.0f ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Vector4 = Vector4( a_Vector3, randfloat() ); - print( a_Vector4, "set Vector4 with Vector3, float" ); - a_Vector4 = Vector4( a_Vector3 ); - print( a_Vector4, "set Vector4 with Vector3" ); - a_Vector4 = Vector4( a_Point3 ); - print( a_Vector4, "set Vector4 with Point3" ); - a_Vector4 = Vector4( a_Quat ); - print( a_Vector4, "construct Vector4 with Quat" ); - a_Vector4 = Vector4( randfloat() ); - print( a_Vector4, "set Vector4 with float" ); - a_Vector4 = Vector4( scalar_float(randfloat()) ); - print( a_Vector4, "set Vector4 with float" ); - aos_Vector4_0 = Vector4( 0.0f, 1.0f, 2.0f, 3.0f ); - aos_Vector4_1 = Vector4( 4.0f, 5.0f, 6.0f, 7.0f ); - aos_Vector4_2 = Vector4( 8.0f, 9.0f, 10.0f, 11.0f ); - aos_Vector4_3 = Vector4( 12.0f, 13.0f, 14.0f, 15.0f ); - print( aos_Vector4_3, "aos type 0" ); - print( aos_Vector4_2, "aos type 1" ); - print( aos_Vector4_1, "aos type 2" ); - print( aos_Vector4_0, "aos type 3" ); - print( select( a_Vector4, b_Vector4, 0 ), "select 0" ); - print( select( a_Vector4, b_Vector4, 1 ), "select 1" ); - print( select( a_Vector4, b_Vector4, 0 ), "select 2" ); - print( select( a_Vector4, b_Vector4, (unsigned int)-1 ), "select 3" ); - a_Vector4 = b_Vector4; - print( a_Vector4, "assign to Vector4 from Vector4" ); - a_Vector4.setXYZ( a_Vector3 ); - print( a_Vector4, "set Vector4 xyz" ); - print( a_Vector4.getXYZ( ), "get Vector4 xyz" ); - a_Vector4 = Vector4( 0.0f ); - print( a_Vector4, "set Vector4 elements to zero" ); - a_Vector4 = Vector4::xAxis( ); - print( a_Vector4, "set to x axis" ); - a_Vector4 = Vector4::yAxis( ); - print( a_Vector4, "set to y axis" ); - a_Vector4 = Vector4::zAxis( ); - print( a_Vector4, "set to z axis" ); - a_Vector4 = Vector4::wAxis( ); - print( a_Vector4, "set to w axis" ); - if (iteration % 2) { - a_Vector4.setElem( 0, randfloat() ); - } else { - a_Vector4.setElem( 0, scalar_float(randfloat()) ); - } - print( a_Vector4, "Vector4::set( 0, float )" ); - a_Vector4[0] = randfloat(); - a_Vector4[0] *= randfloat(); - a_Vector4[0] /= randfloat(); - a_Vector4[0] += randfloat(); - a_Vector4[0] -= randfloat(); - print( a_Vector4, "Vector4::operator [](0)" ); - a_Vector4.setX( randfloat() ); - print( a_Vector4, "Vector4::setX()" ); - if (iteration % 2) { - a_Vector4.setElem( 1, randfloat() ); - } else { - a_Vector4.setElem( 1, scalar_float(randfloat()) ); - } - print( a_Vector4, "Vector4::set( 1, float )" ); - a_Vector4[1] = randfloat(); - a_Vector4[1] *= randfloat(); - a_Vector4[1] /= randfloat(); - a_Vector4[1] += randfloat(); - a_Vector4[1] -= randfloat(); - print( a_Vector4, "Vector4::operator [](1)" ); - a_Vector4.setY( randfloat() ); - print( a_Vector4, "Vector4::setY()" ); - if (iteration % 2) { - a_Vector4.setElem( 2, randfloat() ); - } else { - a_Vector4.setElem( 2, scalar_float(randfloat()) ); - } - print( a_Vector4, "Vector4::set( 2, float )" ); - a_Vector4[2] = randfloat(); - a_Vector4[2] *= randfloat(); - a_Vector4[2] /= randfloat(); - a_Vector4[2] += randfloat(); - a_Vector4[2] -= randfloat(); - print( a_Vector4, "Vector4::operator [](2)" ); - a_Vector4.setZ( randfloat() ); - print( a_Vector4, "Vector4::setZ()" ); - if (iteration % 2) { - a_Vector4.setElem( 3, randfloat() ); - } else { - a_Vector4.setElem( 3, scalar_float(randfloat()) ); - } - print( a_Vector4, "Vector4::set( 3, float )" ); - a_Vector4[3] = randfloat(); - a_Vector4[3] *= randfloat(); - a_Vector4[3] /= randfloat(); - a_Vector4[3] += randfloat(); - a_Vector4[3] -= randfloat(); - print( a_Vector4, "Vector4::operator [](3)" ); - a_Vector4.setW( randfloat() ); - print( a_Vector4, "Vector4::setW()" ); - printf("Vector4::get( 0 ): %f\n", getfloat(a_Vector4.getElem( 0 )) ); - printf("Vector4::operator []( 0 ): %f\n", getfloat((float)a_Vector4[0]) ); - printf("Vector4::getX(): %f\n", getfloat(a_Vector4.getX( )) ); - printf("Vector4::get( 1 ): %f\n", getfloat(a_Vector4.getElem( 1 )) ); - printf("Vector4::operator []( 1 ): %f\n", getfloat((float)a_Vector4[1]) ); - printf("Vector4::getY(): %f\n", getfloat(a_Vector4.getY( )) ); - printf("Vector4::get( 2 ): %f\n", getfloat(a_Vector4.getElem( 2 )) ); - printf("Vector4::operator []( 2 ): %f\n", getfloat((float)a_Vector4[2]) ); - printf("Vector4::getZ(): %f\n", getfloat(a_Vector4.getZ( )) ); - printf("Vector4::get( 3 ): %f\n", getfloat(a_Vector4.getElem( 3 )) ); - printf("Vector4::operator []( 3 ): %f\n", getfloat((float)a_Vector4[3]) ); - printf("Vector4::getW(): %f\n", getfloat(a_Vector4.getW( )) ); - print( ( a_Vector4 + b_Vector4 ), "Vector4 + Vector4" ); - print( ( a_Vector4 - b_Vector4 ), "Vector4 - Vector4" ); - print( ( a_Vector4 * randfloat() ), "Vector4 * float" ); - print( ( a_Vector4 / randfloat() ), "Vector4 / float" ); - print( ( randfloat() * a_Vector4 ), "float * Vector4" ); - print( ( -a_Vector4 ), "Vector4 negate" ); - print( mulPerElem( a_Vector4, b_Vector4 ), "mulPerElem( Vector4, Vector4 )" ); - print( divPerElem( a_Vector4, b_Vector4 ), "divPerElem( Vector4, Vector4 )" ); - print( recipPerElem( a_Vector4 ), "Vector4 recip" ); - print( sqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 rsqrt" ); - print( absPerElem( a_Vector4 ), "Vector4 abs" ); - print( copySignPerElem( a_Vector4, b_Vector4 ), "Vector4 copySign" ); - print( maxPerElem( a_Vector4, b_Vector4 ), "Vector4 maximum Vector4" ); - print( minPerElem( a_Vector4, b_Vector4 ), "Vector4 minimum Vector4" ); - printf("Vector4 maximum of elements: %f\n", getfloat(maxElem( a_Vector4 ))); - printf("Vector4 minimum of elements: %f\n", getfloat(minElem( a_Vector4 ))); - printf("Vector4 sum of elements: %f\n", getfloat(sum( a_Vector4 ))); - printf("Vector4 dot Vector4: %f\n", getfloat(dot( a_Vector4, b_Vector4 ))); - printf("Vector4 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector4 ))); - printf("Vector4 length: %f\n", getfloat(length( a_Vector4 ))); - print( normalize( a_Vector4 ), "Vector4 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - e_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - b_Vector4 = normalize( b_Vector4 ); - c_Vector4 = normalize( c_Vector4 ); - d_Vector4 = normalize( d_Vector4 ); - e_Vector4 = normalize( e_Vector4 ); - a_Vector4 = lerp( randfloat(), b_Vector4, c_Vector4 ); - print( a_Vector4, "Vector4 lerp" ); - a_Vector4 = slerp( randfloat(), b_Vector4, c_Vector4 ); - print( a_Vector4, "Vector4 slerp" ); -} - -void -Point3_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Vector4 tmpV4; - Point3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; - Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - float xyz4[12] __attribute__ ((aligned(16))); -#ifndef _VECTORMATH_SCALAR_TEST - vec_float4 quad; -#endif - xyz4[0] = randfloat(); - xyz4[1] = randfloat(); - xyz4[2] = randfloat(); - xyz4[3] = randfloat(); - xyz4[4] = randfloat(); - xyz4[5] = randfloat(); - xyz4[6] = randfloat(); - xyz4[7] = randfloat(); - xyz4[8] = randfloat(); - xyz4[9] = randfloat(); - xyz4[10] = randfloat(); - xyz4[11] = randfloat(); - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( 0.0f ); - d_Vector3 = Vector3( 0.0f ); - e_Vector3 = Vector3( 0.0f ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( 0.0f ); - d_Vector4 = Vector4( 0.0f ); - e_Vector4 = Vector4( 0.0f ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( 0.0f ); - d_Point3 = Point3( 0.0f ); - e_Point3 = Point3( 0.0f ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( 0.0f ); - d_Quat = Quat( 0.0f ); - e_Quat = Quat( 0.0f ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Point3 = Point3( a_Vector3 ); - print( a_Point3, "construct Point3 with Vector3" ); - a_Point3 = Point3( randfloat() ); - print( a_Point3, "set Point3 with float" ); - a_Point3 = Point3( scalar_float(randfloat()) ); - print( a_Point3, "set Point3 with float" ); - aos_Point3_0 = Point3( 0.0f, 1.0f, 2.0f ); - aos_Point3_1 = Point3( 3.0f, 4.0f, 5.0f ); - aos_Point3_2 = Point3( 6.0f, 7.0f, 8.0f ); - aos_Point3_3 = Point3( 9.0f, 10.0f, 11.0f ); - print( aos_Point3_3, "aos type 0" ); - print( aos_Point3_2, "aos type 1" ); - print( aos_Point3_1, "aos type 2" ); - print( aos_Point3_0, "aos type 3" ); - print( select( a_Point3, b_Point3, 0 ), "select 0" ); - print( select( a_Point3, b_Point3, 1 ), "select 1" ); - print( select( a_Point3, b_Point3, 0 ), "select 2" ); - print( select( a_Point3, b_Point3, (unsigned int)-1 ), "select 3" ); - a_Point3 = Point3( xyz4[0], xyz4[1], xyz4[2] ); - print( a_Point3, "load XYZ array" ); - xyz4[0] = -xyz4[0]; - xyz4[1] = -xyz4[1]; - xyz4[2] = -xyz4[2]; - xyz4[3] = -xyz4[3]; - xyz4[4] = -xyz4[4]; - xyz4[5] = -xyz4[5]; - xyz4[6] = -xyz4[6]; - xyz4[7] = -xyz4[7]; - xyz4[8] = -xyz4[8]; - xyz4[9] = -xyz4[9]; - xyz4[10] = -xyz4[10]; - xyz4[11] = -xyz4[11]; - aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - print( aos_Vector4_0, "xyzx" ); - print( aos_Vector4_1, "yzxy" ); - print( aos_Vector4_2, "zxyz" ); -#ifndef _VECTORMATH_SCALAR_TEST - loadXYZArray( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, (const vec_float4 *)xyz4 ); - xyz4[0] = 0; - xyz4[1] = 1; - xyz4[2] = 2; - xyz4[3] = 3; - xyz4[4] = 4; - xyz4[5] = 5; - xyz4[6] = 6; - xyz4[7] = 7; - xyz4[8] = 8; - xyz4[9] = 9; - xyz4[10] = 10; - xyz4[11] = 11; - storeXYZArray( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3, (vec_float4 *)xyz4 ); -#endif - aos_Vector4_0 = Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - print( aos_Vector4_0, "xyzx" ); - print( aos_Vector4_1, "yzxy" ); - print( aos_Vector4_2, "zxyz" ); -#ifdef _VECTORMATH_SCALAR_TEST - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); -#else - quad = (vec_float4){-1.0f, -2.0f, -3.0f, -4.0f}; - a_Point3 = Point3( quad ); - quad = (vec_float4){0.1f, 0.2f, 0.3f, 0.4f}; - storeXYZ( a_Point3, &quad ); - printf("storeXYZ:%f %f %f %f\n", ((float *)&quad)[0], ((float *)&quad)[1], ((float *)&quad)[2], ((float *)&quad)[3]); -#endif - a_Point3 = b_Point3; - print( a_Point3, "assign to Point3 from Point3" ); - a_Point3 = Point3( 0.0f ); - print( a_Point3, "set Point3 elements to zero" ); - if (iteration % 2) { - a_Point3.setElem( 0, randfloat() ); - } else { - a_Point3.setElem( 0, scalar_float(randfloat()) ); - } - print( a_Point3, "Point3::set( 0, float )" ); - a_Point3[0] = randfloat(); - a_Point3[0] *= randfloat(); - a_Point3[0] /= randfloat(); - a_Point3[0] += randfloat(); - a_Point3[0] -= randfloat(); - print( a_Point3, "Point3::operator [](0)" ); - a_Point3.setX( randfloat() ); - print( a_Point3, "Point3::setX()" ); - if (iteration % 2) { - a_Point3.setElem( 1, randfloat() ); - } else { - a_Point3.setElem( 1, scalar_float(randfloat()) ); - } - print( a_Point3, "Point3::set( 1, float )" ); - a_Point3[1] = randfloat(); - a_Point3[1] *= randfloat(); - a_Point3[1] /= randfloat(); - a_Point3[1] += randfloat(); - a_Point3[1] -= randfloat(); - print( a_Point3, "Point3::operator [](1)" ); - a_Point3.setY( randfloat() ); - print( a_Point3, "Point3::setY()" ); - if (iteration % 2) { - a_Point3.setElem( 2, randfloat() ); - } else { - a_Point3.setElem( 2, scalar_float(randfloat()) ); - } - print( a_Point3, "Point3::set( 2, float )" ); - a_Point3[2] = randfloat(); - a_Point3[2] *= randfloat(); - a_Point3[2] /= randfloat(); - a_Point3[2] += randfloat(); - a_Point3[2] -= randfloat(); - print( a_Point3, "Point3::operator [](2)" ); - a_Point3.setZ( randfloat() ); - print( a_Point3, "Point3::setZ()" ); - printf("Point3::get( 0 ): %f\n", getfloat(a_Point3.getElem( 0 )) ); - printf("Point3::operator []( 0 ): %f\n", getfloat((float)a_Point3[0]) ); - printf("Point3::getX(): %f\n", getfloat(a_Point3.getX( )) ); - printf("Point3::get( 1 ): %f\n", getfloat(a_Point3.getElem( 1 )) ); - printf("Point3::operator []( 1 ): %f\n", getfloat((float)a_Point3[1]) ); - printf("Point3::getY(): %f\n", getfloat(a_Point3.getY( )) ); - printf("Point3::get( 2 ): %f\n", getfloat(a_Point3.getElem( 2 )) ); - printf("Point3::operator []( 2 ): %f\n", getfloat((float)a_Point3[2]) ); - printf("Point3::getZ(): %f\n", getfloat(a_Point3.getZ( )) ); - print( ( a_Point3 - b_Point3 ), "Point3 - Point3" ); - print( ( a_Point3 + b_Vector3 ), "Point3 + Vector3" ); - print( ( a_Point3 - b_Vector3 ), "Point3 - Vector3" ); - print( mulPerElem( a_Point3, b_Point3 ), "mulPerElem( Point3, Point3 )" ); - print( divPerElem( a_Point3, b_Point3 ), "divPerElem( Point3, Point3 )" ); - print( recipPerElem( a_Point3 ), "Point3 recip" ); - print( sqrtPerElem( absPerElem( a_Point3 ) ), "Point3 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Point3 ) ), "Point3 rsqrt" ); - print( absPerElem( a_Point3 ), "Point3 abs" ); - print( copySignPerElem( a_Point3, b_Point3 ), "Point3 copySign" ); - print( maxPerElem( a_Point3, b_Point3 ), "Point3 maximum Point3" ); - print( minPerElem( a_Point3, b_Point3 ), "Point3 minimum Point3" ); - printf("Point3 maximum of elements: %f\n", getfloat(maxElem( a_Point3 ))); - printf("Point3 minimum of elements: %f\n", getfloat(minElem( a_Point3 ))); - printf("Point3 sum of elements: %f\n", getfloat(sum( a_Point3 ))); - printf("Point projection: %f\n", getfloat(projection( a_Point3, b_Vector3 ))); - printf("Point distSqrFromOrigin: %f\n", getfloat(distSqrFromOrigin( a_Point3 )) ); - printf("Point distFromOrigin: %f\n", getfloat(distFromOrigin( a_Point3 )) ); - printf("Point distSqr: %f\n", getfloat(distSqr( a_Point3, b_Point3 )) ); - printf("Point dist: %f\n", getfloat(dist( a_Point3, b_Point3 )) ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - e_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - a_Point3 = lerp( randfloat(), b_Point3, c_Point3 ); - print( a_Point3, "Point3 lerp" ); -} - -void -Quat_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Vector4 tmpV4; - Quat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; - float rndflt1, rndflt2, rndflt3, rndflt4, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( 0.0f ); - d_Vector3 = Vector3( 0.0f ); - e_Vector3 = Vector3( 0.0f ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( 0.0f ); - d_Vector4 = Vector4( 0.0f ); - e_Vector4 = Vector4( 0.0f ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3) ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( 0.0f ); - d_Point3 = Point3( 0.0f ); - e_Point3 = Point3( 0.0f ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( scalar_float(rndflt1), scalar_float(rndflt2), scalar_float(rndflt3), scalar_float(rndflt4) ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( 0.0f ); - d_Quat = Quat( 0.0f ); - e_Quat = Quat( 0.0f ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Quat = Quat( a_Vector3, randfloat() ); - print( a_Quat, "set Quat with Vector3, float" ); - a_Quat = Quat( a_Vector4 ); - print( a_Quat, "construct Quat with Vector4" ); - a_Quat = Quat( randfloat() ); - print( a_Quat, "set Quat with float" ); - a_Quat = Quat( scalar_float(randfloat()) ); - print( a_Quat, "set Quat with float" ); - aos_Quat_0 = Quat( 0.0f, 1.0f, 2.0f, 3.0f ); - aos_Quat_1 = Quat( 4.0f, 5.0f, 6.0f, 7.0f ); - aos_Quat_2 = Quat( 8.0f, 9.0f, 10.0f, 11.0f ); - aos_Quat_3 = Quat( 12.0f, 13.0f, 14.0f, 15.0f ); - print( aos_Quat_3, "aos type 0" ); - print( aos_Quat_2, "aos type 1" ); - print( aos_Quat_1, "aos type 2" ); - print( aos_Quat_0, "aos type 3" ); - print( select( a_Quat, b_Quat, 0 ), "select 0" ); - print( select( a_Quat, b_Quat, 1 ), "select 1" ); - print( select( a_Quat, b_Quat, 0 ), "select 2" ); - print( select( a_Quat, b_Quat, (unsigned int)-1 ), "select 3" ); - a_Quat = b_Quat; - print( a_Quat, "assign to Quat from Quat" ); - a_Quat.setXYZ( a_Vector3 ); - print( a_Quat, "set Quat xyz" ); - print( a_Quat.getXYZ( ), "get Quat xyz" ); - a_Quat = Quat( 0.0f ); - print( a_Quat, "set Quat elements to zero" ); - if (iteration % 2) { - a_Quat.setElem( 0, randfloat() ); - } else { - a_Quat.setElem( 0, scalar_float(randfloat()) ); - } - print( a_Quat, "Quat::set( 0, float )" ); - a_Quat[0] = randfloat(); - a_Quat[0] *= randfloat(); - a_Quat[0] /= randfloat(); - a_Quat[0] += randfloat(); - a_Quat[0] -= randfloat(); - print( a_Quat, "Quat::operator [](0)" ); - a_Quat.setX( randfloat() ); - print( a_Quat, "Quat::setX()" ); - if (iteration % 2) { - a_Quat.setElem( 1, randfloat() ); - } else { - a_Quat.setElem( 1, scalar_float(randfloat()) ); - } - print( a_Quat, "Quat::set( 1, float )" ); - a_Quat[1] = randfloat(); - a_Quat[1] *= randfloat(); - a_Quat[1] /= randfloat(); - a_Quat[1] += randfloat(); - a_Quat[1] -= randfloat(); - print( a_Quat, "Quat::operator [](1)" ); - a_Quat.setY( randfloat() ); - print( a_Quat, "Quat::setY()" ); - if (iteration % 2) { - a_Quat.setElem( 2, randfloat() ); - } else { - a_Quat.setElem( 2, scalar_float(randfloat()) ); - } - print( a_Quat, "Quat::set( 2, float )" ); - a_Quat[2] = randfloat(); - a_Quat[2] *= randfloat(); - a_Quat[2] /= randfloat(); - a_Quat[2] += randfloat(); - a_Quat[2] -= randfloat(); - print( a_Quat, "Quat::operator [](2)" ); - a_Quat.setZ( randfloat() ); - print( a_Quat, "Quat::setZ()" ); - if (iteration % 2) { - a_Quat.setElem( 3, randfloat() ); - } else { - a_Quat.setElem( 3, scalar_float(randfloat()) ); - } - print( a_Quat, "Quat::set( 3, float )" ); - a_Quat[3] = randfloat(); - a_Quat[3] *= randfloat(); - a_Quat[3] /= randfloat(); - a_Quat[3] += randfloat(); - a_Quat[3] -= randfloat(); - print( a_Quat, "Quat::operator [](3)" ); - a_Quat.setW( randfloat() ); - print( a_Quat, "Quat::setW()" ); - printf("Quat::get( 0 ): %f\n", getfloat(a_Quat.getElem( 0 )) ); - printf("Quat::operator []( 0 ): %f\n", getfloat((float)a_Quat[0]) ); - printf("Quat::getX(): %f\n", getfloat(a_Quat.getX( )) ); - printf("Quat::get( 1 ): %f\n", getfloat(a_Quat.getElem( 1 )) ); - printf("Quat::operator []( 1 ): %f\n", getfloat((float)a_Quat[1]) ); - printf("Quat::getY(): %f\n", getfloat(a_Quat.getY( )) ); - printf("Quat::get( 2 ): %f\n", getfloat(a_Quat.getElem( 2 )) ); - printf("Quat::operator []( 2 ): %f\n", getfloat((float)a_Quat[2]) ); - printf("Quat::getZ(): %f\n", getfloat(a_Quat.getZ( )) ); - printf("Quat::get( 3 ): %f\n", getfloat(a_Quat.getElem( 3 )) ); - printf("Quat::operator []( 3 ): %f\n", getfloat((float)a_Quat[3]) ); - printf("Quat::getW(): %f\n", getfloat(a_Quat.getW( )) ); - print( ( a_Quat + b_Quat ), "Quat + Quat" ); - print( ( a_Quat - b_Quat ), "Quat - Quat" ); - print( ( a_Quat * b_Quat ), "Quat * Quat" ); - print( ( a_Quat * randfloat() ), "Quat * float" ); - print( ( a_Quat / randfloat() ), "Quat / float" ); - print( ( randfloat() * a_Quat ), "float * Quat" ); - print( ( -a_Quat ), "Quat negate" ); - printf("Quat dot Quat: %f\n", getfloat(dot( a_Quat, b_Quat ))); - printf("Quat lengthSqr: %f\n", getfloat(norm( a_Quat ))); - printf("Quat length: %f\n", getfloat(length( a_Quat ))); - print( normalize( a_Quat ), "Quat normalized" ); - a_Quat = Quat::identity( ); - print( a_Quat, "set to identity" ); - a_Quat = Quat::rotation( a_Vector3, b_Vector3 ); - print( a_Quat, "Quat rotation between vectors" ); - a_Quat = Quat::rotation( randfloat(), a_Vector3 ); - print( a_Quat, "Quat rotation axis angle" ); - a_Quat = Quat::rotationX( randfloat() ); - print( a_Quat, "Quat rotationX" ); - a_Quat = Quat::rotationY( randfloat() ); - print( a_Quat, "Quat rotationY" ); - a_Quat = Quat::rotationZ( randfloat() ); - print( a_Quat, "Quat rotationZ" ); - print( rotate( a_Quat, a_Vector3 ), "Quat rotate Vector3" ); - print( conj( a_Quat ), "Quat conj" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - e_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - b_Quat = normalize( b_Quat ); - c_Quat = normalize( c_Quat ); - d_Quat = normalize( d_Quat ); - e_Quat = normalize( e_Quat ); - a_Quat = lerp( randfloat(), b_Quat, c_Quat ); - print( a_Quat, "Quat lerp" ); - a_Quat = slerp( randfloat(), b_Quat, c_Quat ); - print( a_Quat, "Quat slerp" ); - a_Quat = squad( randfloat(), b_Quat, c_Quat, d_Quat, e_Quat ); - print( a_Quat, "Quat squad" ); -} - -int main() -{ - printf("\n __begin__ \n"); - for ( iteration = 0; iteration < 2; iteration++ ) { - Vector3_methods_test(); - Vector4_methods_test(); - Point3_methods_test(); - Quat_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test1_reference.txt b/Extras/vectormathlibrary/tests/test1_reference.txt deleted file mode 100644 index 69af2d5b6..000000000 --- a/Extras/vectormathlibrary/tests/test1_reference.txt +++ /dev/null @@ -1,680 +0,0 @@ -set Vector3 with floats: ( 0.465039 -0.479556 -0.211412 ) -set Vector3 with floats: ( 0.553580 0.690070 0.151576 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( 0.431077 -0.833992 -0.088350 -0.780106 ) -set Vector4 with floats: ( 0.090456 -0.218627 0.137171 0.918133 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( 0.735438 -0.673621 -0.448982 ) -set Point3 with floats: ( -0.479278 0.848189 -0.128155 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( 0.578922 -0.744766 -0.835589 0.881284 ) -set Quat with floats: ( -0.948850 -0.691578 -0.235635 -0.690527 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -construct Vector3 with Point3: ( 0.735438 -0.673621 -0.448982 ) -set Vector3 with float: ( 0.058667 0.058667 0.058667 ) -set Vector3 with float: ( 0.753697 0.753697 0.753697 ) -aos type 0: ( 9.000000 10.000000 11.000000 ) -aos type 1: ( 6.000000 7.000000 8.000000 ) -aos type 2: ( 3.000000 4.000000 5.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 ) -select 0: ( 0.753697 0.753697 0.753697 ) -select 1: ( 0.553580 0.690070 0.151576 ) -select 2: ( 0.753697 0.753697 0.753697 ) -select 3: ( 0.553580 0.690070 0.151576 ) -load XYZ array: ( -0.658344 0.499804 -0.807257 ) -xyzx: ( 0.658344 -0.499804 0.807257 -0.740930 ) -yzxy: ( -0.154607 -0.571599 -0.384388 0.262467 ) -zxyz: ( -0.747808 -0.490190 0.107908 0.292544 ) -xyzx: ( 0.658344 -0.499804 0.807257 -0.740930 ) -yzxy: ( -0.154607 -0.571599 -0.384388 0.262467 ) -zxyz: ( -0.747808 -0.490190 0.107908 0.292544 ) -storeXYZ:-1.0 -2.0 -3.0 0.4 -assign to Vector3 from Vector3: ( 0.553580 0.690070 0.151576 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set to x axis: ( 1.000000 0.000000 0.000000 ) -set to y axis: ( 0.000000 1.000000 0.000000 ) -set to z axis: ( 0.000000 0.000000 1.000000 ) -Vector3::set( 0, float ): ( -0.138777 0.000000 1.000000 ) -Vector3::operator [](0): ( -1.001420 0.000000 1.000000 ) -Vector3::setX(): ( 0.410391 0.000000 1.000000 ) -Vector3::set( 1, float ): ( 0.410391 -0.562721 1.000000 ) -Vector3::operator [](1): ( 0.410391 0.544473 1.000000 ) -Vector3::setY(): ( 0.410391 0.374881 1.000000 ) -Vector3::set( 2, float ): ( 0.410391 0.374881 -0.127818 ) -Vector3::operator [](2): ( 0.410391 0.374881 -0.212598 ) -Vector3::setZ(): ( 0.410391 0.374881 -0.723410 ) -Vector3::get( 0 ): 0.410391 -Vector3::operator []( 0 ): 0.410391 -Vector3::getX(): 0.410391 -Vector3::get( 1 ): 0.374881 -Vector3::operator []( 1 ): 0.374881 -Vector3::getY(): 0.374881 -Vector3::get( 2 ): -0.723410 -Vector3::operator []( 2 ): -0.723410 -Vector3::getZ(): -0.723410 -Vector3 + Vector3: ( 0.963971 1.064952 -0.571834 ) -Vector3 - Vector3: ( -0.143189 -0.315189 -0.874987 ) -Vector3 + Point3: ( -0.068887 1.223071 -0.851565 ) -Vector3 * float: ( 0.378185 0.345462 -0.666639 ) -Vector3 / float: ( -0.577000 -0.527074 1.017097 ) -float * Vector3: ( -0.043762 -0.039975 0.077140 ) -Vector3 negate: ( -0.410391 -0.374881 0.723410 ) -mulPerElem( Vector3, Vector3 ): ( 0.227184 0.258694 -0.109652 ) -divPerElem( Vector3, Vector3 ): ( 0.741340 0.543251 -4.772578 ) -Vector3 recip: ( 2.436700 2.667511 -1.382342 ) -Vector3 sqrt: ( 0.640618 0.612276 0.850535 ) -Vector3 rsqrt: ( 1.560993 1.633252 1.175730 ) -Vector3 abs: ( 0.410391 0.374881 0.723410 ) -Vector3 copySign: ( 0.410391 0.374881 0.723410 ) -Vector3 maximum Vector3: ( 0.553580 0.690070 0.151576 ) -Vector3 minimum Vector3: ( 0.410391 0.374881 -0.723410 ) -Vector3 maximum of elements: 0.410391 -Vector3 minimum of elements: -0.723410 -Vector3 sum of elements: 0.061862 -Vector3 dot Vector3: 0.376227 -Vector3 lengthSqr: 0.832279 -Vector3 length: 0.912293 -Vector3 normalized: ( 0.449846 0.410922 -0.792958 ) -Vector3 lerp: ( -0.504755 2.242539 -1.172064 ) -Vector3 slerp: ( -0.308956 -0.503372 0.806947 ) -set Vector3 with floats: ( 0.932526 0.571087 0.610330 ) -set Vector3 with floats: ( 0.142507 -0.434829 0.925102 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( 0.158954 -0.126283 -0.249128 0.846815 ) -set Vector4 with floats: ( -0.942601 0.537720 0.446214 0.181939 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( -0.148223 0.284286 0.493525 ) -set Point3 with floats: ( -0.861963 -0.893410 0.548627 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( 0.407007 -0.757467 -0.393126 -0.850984 ) -set Quat with floats: ( 0.375720 -0.270088 0.458888 -0.610828 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 with Vector3, float: ( 0.932526 0.571087 0.610330 -0.690816 ) -set Vector4 with Vector3: ( 0.932526 0.571087 0.610330 0.000000 ) -set Vector4 with Point3: ( -0.148223 0.284286 0.493525 1.000000 ) -construct Vector4 with Quat: ( 0.407007 -0.757467 -0.393126 -0.850984 ) -set Vector4 with float: ( -0.676415 -0.676415 -0.676415 -0.676415 ) -set Vector4 with float: ( 0.664466 0.664466 0.664466 0.664466 ) -aos type 0: ( 12.000000 13.000000 14.000000 15.000000 ) -aos type 1: ( 8.000000 9.000000 10.000000 11.000000 ) -aos type 2: ( 4.000000 5.000000 6.000000 7.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 3.000000 ) -select 0: ( 0.664466 0.664466 0.664466 0.664466 ) -select 1: ( -0.942601 0.537720 0.446214 0.181939 ) -select 2: ( 0.664466 0.664466 0.664466 0.664466 ) -select 3: ( -0.942601 0.537720 0.446214 0.181939 ) -assign to Vector4 from Vector4: ( -0.942601 0.537720 0.446214 0.181939 ) -set Vector4 xyz: ( 0.932526 0.571087 0.610330 0.181939 ) -get Vector4 xyz: ( 0.932526 0.571087 0.610330 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set to x axis: ( 1.000000 0.000000 0.000000 0.000000 ) -set to y axis: ( 0.000000 1.000000 0.000000 0.000000 ) -set to z axis: ( 0.000000 0.000000 1.000000 0.000000 ) -set to w axis: ( 0.000000 0.000000 0.000000 1.000000 ) -Vector4::set( 0, float ): ( 0.101874 0.000000 0.000000 1.000000 ) -Vector4::operator [](0): ( -0.879952 0.000000 0.000000 1.000000 ) -Vector4::setX(): ( -0.997261 0.000000 0.000000 1.000000 ) -Vector4::set( 1, float ): ( -0.997261 0.172409 0.000000 1.000000 ) -Vector4::operator [](1): ( -0.997261 0.150201 0.000000 1.000000 ) -Vector4::setY(): ( -0.997261 -0.000013 0.000000 1.000000 ) -Vector4::set( 2, float ): ( -0.997261 -0.000013 0.689543 1.000000 ) -Vector4::operator [](2): ( -0.997261 -0.000013 -0.384253 1.000000 ) -Vector4::setZ(): ( -0.997261 -0.000013 -0.801022 1.000000 ) -Vector4::set( 3, float ): ( -0.997261 -0.000013 -0.801022 0.656335 ) -Vector4::operator [](3): ( -0.997261 -0.000013 -0.801022 16.472569 ) -Vector4::setW(): ( -0.997261 -0.000013 -0.801022 0.133022 ) -Vector4::get( 0 ): -0.997261 -Vector4::operator []( 0 ): -0.997261 -Vector4::getX(): -0.997261 -Vector4::get( 1 ): -0.000013 -Vector4::operator []( 1 ): -0.000013 -Vector4::getY(): -0.000013 -Vector4::get( 2 ): -0.801022 -Vector4::operator []( 2 ): -0.801022 -Vector4::getZ(): -0.801022 -Vector4::get( 3 ): 0.133022 -Vector4::operator []( 3 ): 0.133022 -Vector4::getW(): 0.133022 -Vector4 + Vector4: ( -1.939863 0.537707 -0.354808 0.314960 ) -Vector4 - Vector4: ( -0.054660 -0.537733 -1.247235 -0.048917 ) -Vector4 * float: ( 0.052076 0.000001 0.041829 -0.006946 ) -Vector4 / float: ( 6.048177 0.000081 4.858026 -0.806748 ) -float * Vector4: ( -0.299867 -0.000004 -0.240859 0.039998 ) -Vector4 negate: ( 0.997261 0.000013 0.801022 -0.133022 ) -mulPerElem( Vector4, Vector4 ): ( 0.940020 -0.000007 -0.357427 0.024202 ) -divPerElem( Vector4, Vector4 ): ( 1.057989 -0.000025 -1.795154 0.731134 ) -Vector4 recip: ( -1.002746 -75309.887339 -1.248405 7.517576 ) -Vector4 sqrt: ( 0.998630 0.003644 0.894998 0.364721 ) -Vector4 rsqrt: ( 1.001372 274.426483 1.117321 2.741820 ) -Vector4 abs: ( 0.997261 0.000013 0.801022 0.133022 ) -Vector4 copySign: ( -0.997261 0.000013 0.801022 0.133022 ) -Vector4 maximum Vector4: ( -0.942601 0.537720 0.446214 0.181939 ) -Vector4 minimum Vector4: ( -0.997261 -0.000013 -0.801022 0.133022 ) -Vector4 maximum of elements: 0.133022 -Vector4 minimum of elements: -0.997261 -Vector4 sum of elements: -1.665275 -Vector4 dot Vector4: 0.606788 -Vector4 lengthSqr: 1.653861 -Vector4 length: 1.286025 -Vector4 normalized: ( -0.775460 -0.000010 -0.622866 0.103436 ) -Vector4 lerp: ( -0.226675 0.250339 0.113208 0.735255 ) -Vector4 slerp: ( 0.351058 0.199306 -0.276993 0.871958 ) -set Vector3 with floats: ( 0.137637 -0.111879 -0.929543 ) -set Vector3 with floats: ( -0.336303 -0.146740 0.165140 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( -0.823874 0.349776 0.174872 -0.528584 ) -set Vector4 with floats: ( 0.489292 0.916708 0.728511 -0.851140 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( 0.079620 -0.234370 -0.996308 ) -set Point3 with floats: ( 0.433229 -0.892684 -0.957911 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( 0.517122 0.257921 0.862028 0.095881 ) -set Quat with floats: ( -0.171933 -0.214078 -0.604841 -0.383831 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -construct Point3 with Vector3: ( 0.137637 -0.111879 -0.929543 ) -set Point3 with float: ( -0.581500 -0.581500 -0.581500 ) -set Point3 with float: ( 0.222183 0.222183 0.222183 ) -aos type 0: ( 9.000000 10.000000 11.000000 ) -aos type 1: ( 6.000000 7.000000 8.000000 ) -aos type 2: ( 3.000000 4.000000 5.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 ) -select 0: ( 0.222183 0.222183 0.222183 ) -select 1: ( 0.433229 -0.892684 -0.957911 ) -select 2: ( 0.222183 0.222183 0.222183 ) -select 3: ( 0.433229 -0.892684 -0.957911 ) -load XYZ array: ( -0.160082 0.962714 0.737794 ) -xyzx: ( 0.160082 -0.962714 -0.737794 0.071926 ) -yzxy: ( 0.506313 -0.689277 -0.686485 -0.473013 ) -zxyz: ( 0.735610 0.046390 -0.568674 0.004815 ) -xyzx: ( 0.160082 -0.962714 -0.737794 0.071926 ) -yzxy: ( 0.506313 -0.689277 -0.686485 -0.473013 ) -zxyz: ( 0.735610 0.046390 -0.568674 0.004815 ) -storeXYZ:-1.0 -2.0 -3.0 0.4 -assign to Point3 from Point3: ( 0.433229 -0.892684 -0.957911 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -Point3::set( 0, float ): ( -0.256120 0.000000 0.000000 ) -Point3::operator [](0): ( -0.979920 0.000000 0.000000 ) -Point3::setX(): ( -0.046627 0.000000 0.000000 ) -Point3::set( 1, float ): ( -0.046627 -0.716491 0.000000 ) -Point3::operator [](1): ( -0.046627 1.719236 0.000000 ) -Point3::setY(): ( -0.046627 0.508814 0.000000 ) -Point3::set( 2, float ): ( -0.046627 0.508814 -0.238839 ) -Point3::operator [](2): ( -0.046627 0.508814 0.061402 ) -Point3::setZ(): ( -0.046627 0.508814 -0.157280 ) -Point3::get( 0 ): -0.046627 -Point3::operator []( 0 ): -0.046627 -Point3::getX(): -0.046627 -Point3::get( 1 ): 0.508814 -Point3::operator []( 1 ): 0.508814 -Point3::getY(): 0.508814 -Point3::get( 2 ): -0.157280 -Point3::operator []( 2 ): -0.157280 -Point3::getZ(): -0.157280 -Point3 - Point3: ( -0.479856 1.401498 0.800631 ) -Point3 + Vector3: ( -0.382931 0.362074 0.007860 ) -Point3 - Vector3: ( 0.289676 0.655554 -0.322420 ) -mulPerElem( Point3, Point3 ): ( -0.020200 -0.454210 0.150660 ) -divPerElem( Point3, Point3 ): ( -0.107627 -0.569982 0.164191 ) -Point3 recip: ( -21.446777 1.965355 -6.358085 ) -Point3 sqrt: ( 0.215933 0.713312 0.396586 ) -Point3 rsqrt: ( 4.631066 1.401911 2.521524 ) -Point3 abs: ( 0.046627 0.508814 0.157280 ) -Point3 copySign: ( 0.046627 -0.508814 -0.157280 ) -Point3 maximum Point3: ( 0.433229 0.508814 -0.157280 ) -Point3 minimum Point3: ( -0.046627 -0.892684 -0.957911 ) -Point3 maximum of elements: 0.508814 -Point3 minimum of elements: -0.157280 -Point3 sum of elements: 0.304907 -Point projection: -0.084956 -Point distSqrFromOrigin: 0.285803 -Point distFromOrigin: 0.534605 -Point distSqr: 2.835468 -Point dist: 1.683885 -Point3 lerp: ( 0.508235 -0.017312 0.360111 ) -set Vector3 with floats: ( 0.219317 -0.118359 0.413442 ) -set Vector3 with floats: ( -0.567698 0.531358 -0.387226 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( 0.572490 -0.820417 0.797191 0.867178 ) -set Vector4 with floats: ( 0.934764 0.237092 -0.866162 -0.773939 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( 0.261311 -0.851570 0.114814 ) -set Point3 with floats: ( -0.531592 0.223925 0.869105 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( 0.143405 0.148518 -0.071136 -0.758292 ) -set Quat with floats: ( -0.527633 0.997215 0.114440 0.727558 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat with Vector3, float: ( 0.219317 -0.118359 0.413442 -0.425760 ) -construct Quat with Vector4: ( 0.572490 -0.820417 0.797191 0.867178 ) -set Quat with float: ( 0.459888 0.459888 0.459888 0.459888 ) -set Quat with float: ( 0.642516 0.642516 0.642516 0.642516 ) -aos type 0: ( 12.000000 13.000000 14.000000 15.000000 ) -aos type 1: ( 8.000000 9.000000 10.000000 11.000000 ) -aos type 2: ( 4.000000 5.000000 6.000000 7.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 3.000000 ) -select 0: ( 0.642516 0.642516 0.642516 0.642516 ) -select 1: ( -0.527633 0.997215 0.114440 0.727558 ) -select 2: ( 0.642516 0.642516 0.642516 0.642516 ) -select 3: ( -0.527633 0.997215 0.114440 0.727558 ) -assign to Quat from Quat: ( -0.527633 0.997215 0.114440 0.727558 ) -set Quat xyz: ( 0.219317 -0.118359 0.413442 0.727558 ) -get Quat xyz: ( 0.219317 -0.118359 0.413442 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -Quat::set( 0, float ): ( -0.022534 0.000000 0.000000 0.000000 ) -Quat::operator [](0): ( 0.419714 0.000000 0.000000 0.000000 ) -Quat::setX(): ( 0.765986 0.000000 0.000000 0.000000 ) -Quat::set( 1, float ): ( 0.765986 -0.137795 0.000000 0.000000 ) -Quat::operator [](1): ( 0.765986 0.890273 0.000000 0.000000 ) -Quat::setY(): ( 0.765986 -0.553800 0.000000 0.000000 ) -Quat::set( 2, float ): ( 0.765986 -0.553800 -0.014688 0.000000 ) -Quat::operator [](2): ( 0.765986 -0.553800 -0.802660 0.000000 ) -Quat::setZ(): ( 0.765986 -0.553800 0.499529 0.000000 ) -Quat::set( 3, float ): ( 0.765986 -0.553800 0.499529 0.385180 ) -Quat::operator [](3): ( 0.765986 -0.553800 0.499529 -0.150467 ) -Quat::setW(): ( 0.765986 -0.553800 0.499529 0.067637 ) -Quat::get( 0 ): 0.765986 -Quat::operator []( 0 ): 0.765986 -Quat::getX(): 0.765986 -Quat::get( 1 ): -0.553800 -Quat::operator []( 1 ): -0.553800 -Quat::getY(): -0.553800 -Quat::get( 2 ): 0.499529 -Quat::operator []( 2 ): 0.499529 -Quat::getZ(): 0.499529 -Quat::get( 3 ): 0.067637 -Quat::operator []( 3 ): 0.067637 -Quat::getW(): 0.067637 -Quat + Quat: ( 0.238353 0.443416 0.613969 0.795196 ) -Quat - Quat: ( 1.293620 -1.551015 0.385089 -0.659921 ) -Quat * Quat: ( -0.039902 -0.686700 0.842827 0.948461 ) -Quat * float: ( 0.611545 -0.442140 0.398812 0.054000 ) -Quat / float: ( 2.464705 -1.781954 1.607327 0.217635 ) -float * Quat: ( 0.659770 -0.477006 0.430261 0.058258 ) -Quat negate: ( -0.765986 0.553800 -0.499529 -0.067637 ) -Quat dot Quat: -0.850041 -Quat lengthSqr: 1.147533 -Quat length: 1.071229 -Quat normalized: ( 0.715053 -0.516976 0.466313 0.063140 ) -set to identity: ( 0.000000 0.000000 0.000000 1.000000 ) -Quat rotation between vectors: ( -0.152187 -0.131117 0.043194 0.571186 ) -Quat rotation axis angle: ( -0.103250 0.055721 -0.194639 0.882252 ) -Quat rotationX: ( -0.321727 0.000000 0.000000 0.946833 ) -Quat rotationY: ( 0.000000 0.142892 0.000000 0.989738 ) -Quat rotationZ: ( 0.000000 0.000000 0.262912 0.964820 ) -Quat rotate Vector3: ( 0.249044 0.009268 0.413442 ) -Quat conj: ( -0.000000 -0.000000 -0.262912 0.964820 ) -Quat lerp: ( -0.053419 0.446373 0.392075 0.581368 ) -Quat slerp: ( -0.630711 0.472429 0.365730 0.495233 ) -Quat squad: ( 0.119307 -0.523957 -0.534187 -0.652594 ) -set Vector3 with floats: ( 0.531906 0.271995 -0.862601 ) -set Vector3 with floats: ( -0.738694 0.514248 -0.039363 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( 0.429390 -0.769469 0.281336 -0.203301 ) -set Vector4 with floats: ( 0.412586 0.567926 0.410131 -0.462918 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( 0.560953 -0.731715 -0.446158 ) -set Point3 with floats: ( -0.837491 -0.573480 -0.607820 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( 0.238415 0.213445 0.098612 0.135072 ) -set Quat with floats: ( -0.749274 -0.855977 0.765675 -0.693447 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -construct Vector3 with Point3: ( 0.560953 -0.731715 -0.446158 ) -set Vector3 with float: ( 0.131554 0.131554 0.131554 ) -set Vector3 with float: ( -0.366757 -0.366757 -0.366757 ) -aos type 0: ( 9.000000 10.000000 11.000000 ) -aos type 1: ( 6.000000 7.000000 8.000000 ) -aos type 2: ( 3.000000 4.000000 5.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 ) -select 0: ( -0.366757 -0.366757 -0.366757 ) -select 1: ( -0.738694 0.514248 -0.039363 ) -select 2: ( -0.366757 -0.366757 -0.366757 ) -select 3: ( -0.738694 0.514248 -0.039363 ) -load XYZ array: ( -0.913636 0.675222 0.144053 ) -xyzx: ( 0.913636 -0.675222 -0.144053 0.632329 ) -yzxy: ( 0.947120 0.049367 -0.126333 0.664206 ) -zxyz: ( -0.220879 -0.284219 0.387216 -0.913568 ) -xyzx: ( 0.913636 -0.675222 -0.144053 0.632329 ) -yzxy: ( 0.947120 0.049367 -0.126333 0.664206 ) -zxyz: ( -0.220879 -0.284219 0.387216 -0.913568 ) -storeXYZ:-1.0 -2.0 -3.0 0.4 -assign to Vector3 from Vector3: ( -0.738694 0.514248 -0.039363 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set to x axis: ( 1.000000 0.000000 0.000000 ) -set to y axis: ( 0.000000 1.000000 0.000000 ) -set to z axis: ( 0.000000 0.000000 1.000000 ) -Vector3::set( 0, float ): ( -0.330409 0.000000 1.000000 ) -Vector3::operator [](0): ( -1.321680 0.000000 1.000000 ) -Vector3::setX(): ( -0.870739 0.000000 1.000000 ) -Vector3::set( 1, float ): ( -0.870739 0.415605 1.000000 ) -Vector3::operator [](1): ( -0.870739 -0.855146 1.000000 ) -Vector3::setY(): ( -0.870739 0.876855 1.000000 ) -Vector3::set( 2, float ): ( -0.870739 0.876855 0.982846 ) -Vector3::operator [](2): ( -0.870739 0.876855 -0.725814 ) -Vector3::setZ(): ( -0.870739 0.876855 -0.123567 ) -Vector3::get( 0 ): -0.870739 -Vector3::operator []( 0 ): -0.870739 -Vector3::getX(): -0.870739 -Vector3::get( 1 ): 0.876855 -Vector3::operator []( 1 ): 0.876855 -Vector3::getY(): 0.876855 -Vector3::get( 2 ): -0.123567 -Vector3::operator []( 2 ): -0.123567 -Vector3::getZ(): -0.123567 -Vector3 + Vector3: ( -1.609433 1.391104 -0.162930 ) -Vector3 - Vector3: ( -0.132046 0.362607 -0.084203 ) -Vector3 + Point3: ( -1.708231 0.303375 -0.731387 ) -Vector3 * float: ( -0.354427 0.356917 -0.050297 ) -Vector3 / float: ( -6.166518 6.209829 -0.875092 ) -float * Vector3: ( 0.690557 -0.695407 0.097997 ) -Vector3 negate: ( 0.870739 -0.876855 0.123567 ) -mulPerElem( Vector3, Vector3 ): ( 0.643210 0.450921 0.004864 ) -divPerElem( Vector3, Vector3 ): ( 1.178756 1.705119 3.139138 ) -Vector3 recip: ( -1.148449 1.140439 -8.092791 ) -Vector3 sqrt: ( 0.933134 0.936405 0.351521 ) -Vector3 rsqrt: ( 1.071657 1.067914 2.844783 ) -Vector3 abs: ( 0.870739 0.876855 0.123567 ) -Vector3 copySign: ( -0.870739 0.876855 -0.123567 ) -Vector3 maximum Vector3: ( -0.738694 0.876855 -0.039363 ) -Vector3 minimum Vector3: ( -0.870739 0.514248 -0.123567 ) -Vector3 maximum of elements: 0.876855 -Vector3 minimum of elements: -0.870739 -Vector3 sum of elements: -0.117451 -Vector3 dot Vector3: 1.098995 -Vector3 lengthSqr: 1.542330 -Vector3 length: 1.241906 -Vector3 normalized: ( -0.701131 0.706056 -0.099498 ) -Vector3 lerp: ( -0.118997 -0.338092 0.499550 ) -Vector3 slerp: ( -0.899759 -0.236062 -0.367027 ) -set Vector3 with floats: ( 0.060414 -0.867395 -0.702364 ) -set Vector3 with floats: ( -0.182602 -0.832807 0.278191 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( -0.967562 -0.520296 0.160191 -0.677990 ) -set Vector4 with floats: ( -0.470750 -0.846580 -0.705751 -0.825368 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( -0.712890 -0.064487 0.444065 ) -set Point3 with floats: ( -0.045226 0.116544 -0.007285 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( -0.838230 -0.410767 -0.409299 -0.336683 ) -set Quat with floats: ( -0.830700 -0.801729 -0.595153 -0.784672 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 with Vector3, float: ( 0.060414 -0.867395 -0.702364 -0.653655 ) -set Vector4 with Vector3: ( 0.060414 -0.867395 -0.702364 0.000000 ) -set Vector4 with Point3: ( -0.712890 -0.064487 0.444065 1.000000 ) -construct Vector4 with Quat: ( -0.838230 -0.410767 -0.409299 -0.336683 ) -set Vector4 with float: ( 0.670791 0.670791 0.670791 0.670791 ) -set Vector4 with float: ( 0.653571 0.653571 0.653571 0.653571 ) -aos type 0: ( 12.000000 13.000000 14.000000 15.000000 ) -aos type 1: ( 8.000000 9.000000 10.000000 11.000000 ) -aos type 2: ( 4.000000 5.000000 6.000000 7.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 3.000000 ) -select 0: ( 0.653571 0.653571 0.653571 0.653571 ) -select 1: ( -0.470750 -0.846580 -0.705751 -0.825368 ) -select 2: ( 0.653571 0.653571 0.653571 0.653571 ) -select 3: ( -0.470750 -0.846580 -0.705751 -0.825368 ) -assign to Vector4 from Vector4: ( -0.470750 -0.846580 -0.705751 -0.825368 ) -set Vector4 xyz: ( 0.060414 -0.867395 -0.702364 -0.825368 ) -get Vector4 xyz: ( 0.060414 -0.867395 -0.702364 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set to x axis: ( 1.000000 0.000000 0.000000 0.000000 ) -set to y axis: ( 0.000000 1.000000 0.000000 0.000000 ) -set to z axis: ( 0.000000 0.000000 1.000000 0.000000 ) -set to w axis: ( 0.000000 0.000000 0.000000 1.000000 ) -Vector4::set( 0, float ): ( 0.850716 0.000000 0.000000 1.000000 ) -Vector4::operator [](0): ( -0.528836 0.000000 0.000000 1.000000 ) -Vector4::setX(): ( 0.965901 0.000000 0.000000 1.000000 ) -Vector4::set( 1, float ): ( 0.965901 -0.072675 0.000000 1.000000 ) -Vector4::operator [](1): ( 0.965901 0.450700 0.000000 1.000000 ) -Vector4::setY(): ( 0.965901 -0.825793 0.000000 1.000000 ) -Vector4::set( 2, float ): ( 0.965901 -0.825793 0.597719 1.000000 ) -Vector4::operator [](2): ( 0.965901 -0.825793 0.279622 1.000000 ) -Vector4::setZ(): ( 0.965901 -0.825793 -0.884427 1.000000 ) -Vector4::set( 3, float ): ( 0.965901 -0.825793 -0.884427 -0.756791 ) -Vector4::operator [](3): ( 0.965901 -0.825793 -0.884427 -0.685697 ) -Vector4::setW(): ( 0.965901 -0.825793 -0.884427 -0.684626 ) -Vector4::get( 0 ): 0.965901 -Vector4::operator []( 0 ): 0.965901 -Vector4::getX(): 0.965901 -Vector4::get( 1 ): -0.825793 -Vector4::operator []( 1 ): -0.825793 -Vector4::getY(): -0.825793 -Vector4::get( 2 ): -0.884427 -Vector4::operator []( 2 ): -0.884427 -Vector4::getZ(): -0.884427 -Vector4::get( 3 ): -0.684626 -Vector4::operator []( 3 ): -0.684626 -Vector4::getW(): -0.684626 -Vector4 + Vector4: ( 0.495151 -1.672373 -1.590178 -1.509993 ) -Vector4 - Vector4: ( 1.436652 0.020787 -0.178676 0.140742 ) -Vector4 * float: ( -0.960151 0.820877 0.879161 0.680550 ) -Vector4 / float: ( 1.206825 -1.031770 -1.105029 -0.855391 ) -float * Vector4: ( -0.546353 0.467102 0.500267 0.387252 ) -Vector4 negate: ( -0.965901 0.825793 0.884427 0.684626 ) -mulPerElem( Vector4, Vector4 ): ( -0.454698 0.699100 0.624185 0.565068 ) -divPerElem( Vector4, Vector4 ): ( -2.051834 0.975446 1.253172 0.829480 ) -Vector4 recip: ( 1.035302 -1.210957 -1.130676 -1.460652 ) -Vector4 sqrt: ( 0.982803 0.908731 0.940440 0.827421 ) -Vector4 rsqrt: ( 1.017498 1.100435 1.063332 1.208575 ) -Vector4 abs: ( 0.965901 0.825793 0.884427 0.684626 ) -Vector4 copySign: ( -0.965901 -0.825793 -0.884427 -0.684626 ) -Vector4 maximum Vector4: ( 0.965901 -0.825793 -0.705751 -0.684626 ) -Vector4 minimum Vector4: ( -0.470750 -0.846580 -0.884427 -0.825368 ) -Vector4 maximum of elements: 0.965901 -Vector4 minimum of elements: -0.884427 -Vector4 sum of elements: -1.428944 -Vector4 dot Vector4: 1.433654 -Vector4 lengthSqr: 2.865822 -Vector4 length: 1.692874 -Vector4 normalized: ( 0.570569 -0.487805 -0.522441 -0.404416 ) -Vector4 lerp: ( -0.436271 0.676982 0.475175 0.275280 ) -Vector4 slerp: ( -0.493672 0.661673 0.416222 0.381100 ) -set Vector3 with floats: ( -0.287826 0.942655 -0.634432 ) -set Vector3 with floats: ( -0.140438 0.570869 -0.764965 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( 0.067523 -0.514589 0.233091 0.554488 ) -set Vector4 with floats: ( -0.633529 -0.019374 0.869259 -0.369818 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( -0.280690 -0.797209 -0.255233 ) -set Point3 with floats: ( 0.780605 0.789803 0.974262 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( -0.785980 -0.701386 0.871088 0.566743 ) -set Quat with floats: ( 0.752273 -0.476301 -0.747342 0.077386 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -construct Point3 with Vector3: ( -0.287826 0.942655 -0.634432 ) -set Point3 with float: ( -0.305600 -0.305600 -0.305600 ) -set Point3 with float: ( -0.229194 -0.229194 -0.229194 ) -aos type 0: ( 9.000000 10.000000 11.000000 ) -aos type 1: ( 6.000000 7.000000 8.000000 ) -aos type 2: ( 3.000000 4.000000 5.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 ) -select 0: ( -0.229194 -0.229194 -0.229194 ) -select 1: ( 0.780605 0.789803 0.974262 ) -select 2: ( -0.229194 -0.229194 -0.229194 ) -select 3: ( 0.780605 0.789803 0.974262 ) -load XYZ array: ( 0.376026 -0.935045 -0.189804 ) -xyzx: ( -0.376026 0.935045 0.189804 -0.007649 ) -yzxy: ( 0.440298 -0.994796 0.271484 0.259070 ) -zxyz: ( -0.902149 0.836501 -0.229093 -0.586393 ) -xyzx: ( -0.376026 0.935045 0.189804 -0.007649 ) -yzxy: ( 0.440298 -0.994796 0.271484 0.259070 ) -zxyz: ( -0.902149 0.836501 -0.229093 -0.586393 ) -storeXYZ:-1.0 -2.0 -3.0 0.4 -assign to Point3 from Point3: ( 0.780605 0.789803 0.974262 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -Point3::set( 0, float ): ( -0.260009 0.000000 0.000000 ) -Point3::operator [](0): ( 0.017680 0.000000 0.000000 ) -Point3::setX(): ( 0.912886 0.000000 0.000000 ) -Point3::set( 1, float ): ( 0.912886 -0.402380 0.000000 ) -Point3::operator [](1): ( 0.912886 1.043836 0.000000 ) -Point3::setY(): ( 0.912886 0.321576 0.000000 ) -Point3::set( 2, float ): ( 0.912886 0.321576 0.724026 ) -Point3::operator [](2): ( 0.912886 0.321576 -0.074816 ) -Point3::setZ(): ( 0.912886 0.321576 0.137730 ) -Point3::get( 0 ): 0.912886 -Point3::operator []( 0 ): 0.912886 -Point3::getX(): 0.912886 -Point3::get( 1 ): 0.321576 -Point3::operator []( 1 ): 0.321576 -Point3::getY(): 0.321576 -Point3::get( 2 ): 0.137730 -Point3::operator []( 2 ): 0.137730 -Point3::getZ(): 0.137730 -Point3 - Point3: ( 0.132280 -0.468228 -0.836532 ) -Point3 + Vector3: ( 0.772448 0.892445 -0.627235 ) -Point3 - Vector3: ( 1.053323 -0.249293 0.902695 ) -mulPerElem( Point3, Point3 ): ( 0.712603 0.253982 0.134185 ) -divPerElem( Point3, Point3 ): ( 1.169459 0.407159 0.141368 ) -Point3 recip: ( 1.095427 3.109689 7.260596 ) -Point3 sqrt: ( 0.955451 0.567076 0.371120 ) -Point3 rsqrt: ( 1.046627 1.763431 2.694549 ) -Point3 abs: ( 0.912886 0.321576 0.137730 ) -Point3 copySign: ( 0.912886 0.321576 0.137730 ) -Point3 maximum Point3: ( 0.912886 0.789803 0.974262 ) -Point3 minimum Point3: ( 0.780605 0.321576 0.137730 ) -Point3 maximum of elements: 0.912886 -Point3 minimum of elements: 0.137730 -Point3 sum of elements: 1.372191 -Point projection: -0.049984 -Point distSqrFromOrigin: 0.955741 -Point distFromOrigin: 0.977620 -Point distSqr: 0.936521 -Point dist: 0.967740 -Point3 lerp: ( -0.148533 -0.240318 0.263234 ) -set Vector3 with floats: ( -0.950919 -0.196258 -0.599808 ) -set Vector3 with floats: ( -0.794413 -0.927636 -0.187478 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Vector4 with floats: ( -0.113038 0.366120 -0.483786 0.622670 ) -set Vector4 with floats: ( -0.801806 0.295383 0.022005 -0.000678 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Vector4 elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Point3 with floats: ( -0.689334 0.266538 -0.785099 ) -set Point3 with floats: ( -0.572665 0.772760 0.971896 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Point3 elements to zero: ( 0.000000 0.000000 0.000000 ) -set Quat with floats: ( -0.961363 0.723449 -0.758442 -0.733158 ) -set Quat with floats: ( 0.139667 -0.738147 0.727224 0.089921 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -set Quat with Vector3, float: ( -0.950919 -0.196258 -0.599808 -0.113118 ) -construct Quat with Vector4: ( -0.113038 0.366120 -0.483786 0.622670 ) -set Quat with float: ( -0.364554 -0.364554 -0.364554 -0.364554 ) -set Quat with float: ( -0.137645 -0.137645 -0.137645 -0.137645 ) -aos type 0: ( 12.000000 13.000000 14.000000 15.000000 ) -aos type 1: ( 8.000000 9.000000 10.000000 11.000000 ) -aos type 2: ( 4.000000 5.000000 6.000000 7.000000 ) -aos type 3: ( 0.000000 1.000000 2.000000 3.000000 ) -select 0: ( -0.137645 -0.137645 -0.137645 -0.137645 ) -select 1: ( 0.139667 -0.738147 0.727224 0.089921 ) -select 2: ( -0.137645 -0.137645 -0.137645 -0.137645 ) -select 3: ( 0.139667 -0.738147 0.727224 0.089921 ) -assign to Quat from Quat: ( 0.139667 -0.738147 0.727224 0.089921 ) -set Quat xyz: ( -0.950919 -0.196258 -0.599808 0.089921 ) -get Quat xyz: ( -0.950919 -0.196258 -0.599808 ) -set Quat elements to zero: ( 0.000000 0.000000 0.000000 0.000000 ) -Quat::set( 0, float ): ( 0.933847 0.000000 0.000000 0.000000 ) -Quat::operator [](0): ( 2.026584 0.000000 0.000000 0.000000 ) -Quat::setX(): ( -0.069558 0.000000 0.000000 0.000000 ) -Quat::set( 1, float ): ( -0.069558 -0.216369 0.000000 0.000000 ) -Quat::operator [](1): ( -0.069558 -0.152646 0.000000 0.000000 ) -Quat::setY(): ( -0.069558 -0.022250 0.000000 0.000000 ) -Quat::set( 2, float ): ( -0.069558 -0.022250 0.035410 0.000000 ) -Quat::operator [](2): ( -0.069558 -0.022250 1.428823 0.000000 ) -Quat::setZ(): ( -0.069558 -0.022250 0.804061 0.000000 ) -Quat::set( 3, float ): ( -0.069558 -0.022250 0.804061 0.161693 ) -Quat::operator [](3): ( -0.069558 -0.022250 0.804061 -0.332169 ) -Quat::setW(): ( -0.069558 -0.022250 0.804061 -0.586017 ) -Quat::get( 0 ): -0.069558 -Quat::operator []( 0 ): -0.069558 -Quat::getX(): -0.069558 -Quat::get( 1 ): -0.022250 -Quat::operator []( 1 ): -0.022250 -Quat::getY(): -0.022250 -Quat::get( 2 ): 0.804061 -Quat::operator []( 2 ): 0.804061 -Quat::getZ(): 0.804061 -Quat::get( 3 ): -0.586017 -Quat::operator []( 3 ): -0.586017 -Quat::getW(): -0.586017 -Quat + Quat: ( 0.070108 -0.760397 1.531285 -0.496095 ) -Quat - Quat: ( -0.209225 0.715896 0.076837 -0.675938 ) -Quat * Quat: ( 0.489232 0.593451 -0.299411 -0.644137 ) -Quat * float: ( -0.031036 -0.009928 0.358759 -0.261471 ) -Quat / float: ( -0.103711 -0.033175 1.198842 -0.873742 ) -float * Quat: ( 0.021745 0.006956 -0.251360 0.183196 ) -Quat negate: ( 0.069558 0.022250 -0.804061 0.586017 ) -Quat dot Quat: 0.538746 -Quat lengthSqr: 0.995263 -Quat length: 0.997629 -Quat normalized: ( -0.069724 -0.022303 0.805972 -0.587410 ) -set to identity: ( 0.000000 0.000000 0.000000 1.000000 ) -Quat rotation between vectors: ( -0.256621 0.147283 0.358649 1.012405 ) -Quat rotation axis angle: ( 0.163854 0.033817 0.103354 0.985043 ) -Quat rotationX: ( -0.160489 0.000000 0.000000 0.987038 ) -Quat rotationY: ( 0.000000 0.030795 0.000000 0.999526 ) -Quat rotationZ: ( 0.000000 0.000000 0.054406 0.998519 ) -Quat rotate Vector3: ( -0.923966 -0.298415 -0.599808 ) -Quat conj: ( -0.000000 -0.000000 -0.054406 0.998519 ) -Quat lerp: ( -0.860671 -0.101017 0.008389 -0.459099 ) -Quat slerp: ( -0.935192 0.097684 -0.079386 -0.331015 ) -Quat squad: ( -0.208138 -0.281808 0.458751 -0.816585 ) - - __end__ diff --git a/Extras/vectormathlibrary/tests/test1_soa_c.c b/Extras/vectormathlibrary/tests/test1_soa_c.c deleted file mode 100644 index 985488f1c..000000000 --- a/Extras/vectormathlibrary/tests/test1_soa_c.c +++ /dev/null @@ -1,1006 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -void -Vector3_methods_test() -{ - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; - VmathSoaVector3 soa_Vector3; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3; - VmathSoaPoint3 tmpP3_0; - VmathSoaVector3 tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - float xyz4[12] __attribute__ ((aligned(16))); - xyz4[0] = getfloat(randfloat()); - xyz4[1] = getfloat(randfloat()); - xyz4[2] = getfloat(randfloat()); - xyz4[3] = getfloat(randfloat()); - xyz4[4] = getfloat(randfloat()); - xyz4[5] = getfloat(randfloat()); - xyz4[6] = getfloat(randfloat()); - xyz4[7] = getfloat(randfloat()); - xyz4[8] = getfloat(randfloat()); - xyz4[9] = getfloat(randfloat()); - xyz4[10] = getfloat(randfloat()); - xyz4[11] = getfloat(randfloat()); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); - vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); - vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); - vmathSoaV3MakeFromP3( &a_Vector3, &a_Point3 ); - vmathSoaV3Prints( &a_Vector3, "construct Vector3 with Point3" ); - vmathSoaV3MakeFromScalar( &a_Vector3, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with float" ); - vmathSoaV3MakeFromScalar( &a_Vector3, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with float" ); - vmathV3MakeFromElems( &aos_Vector3_0, 0.0f, 1.0f, 2.0f ); - vmathV3MakeFromElems( &aos_Vector3_1, 3.0f, 4.0f, 5.0f ); - vmathV3MakeFromElems( &aos_Vector3_2, 6.0f, 7.0f, 8.0f ); - vmathV3MakeFromElems( &aos_Vector3_3, 9.0f, 10.0f, 11.0f ); - vmathSoaV3MakeFrom4Aos( &soa_Vector3, &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3 ); - vmathSoaV3Get4Aos( &soa_Vector3, &aos_Vector3_3, &aos_Vector3_2, &aos_Vector3_1, &aos_Vector3_0 ); - vmathV3Prints( &aos_Vector3_0, "aos type 0" ); - vmathV3Prints( &aos_Vector3_1, "aos type 1" ); - vmathV3Prints( &aos_Vector3_2, "aos type 2" ); - vmathV3Prints( &aos_Vector3_3, "aos type 3" ); - vmathSoaV3Select( &a_Vector3, &a_Vector3, &b_Vector3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - vmathSoaV3Get4Aos( &a_Vector3, &aos_Vector3_0, &aos_Vector3_1, &aos_Vector3_2, &aos_Vector3_3 ); - vmathV3Prints( &aos_Vector3_0, "select 0" ); - vmathV3Prints( &aos_Vector3_1, "select 1" ); - vmathV3Prints( &aos_Vector3_2, "select 2" ); - vmathV3Prints( &aos_Vector3_3, "select 3" ); - vmathSoaV3LoadXYZArray( &a_Vector3, (const vec_float4 *)xyz4 ); - vmathSoaV3Prints( &a_Vector3, "load XYZ array" ); - vmathSoaV3Copy( &tmpV3_0, &a_Vector3 ); - vmathSoaV3Neg( &tmpV3_1, &tmpV3_0 ); - vmathSoaV3Copy( &a_Vector3, &tmpV3_1 ); - vmathSoaV3StoreXYZArray( &a_Vector3, (vec_float4 *)xyz4 ); - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); - vmathSoaV3Copy( &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "assign to Vector3 from Vector3" ); - vmathSoaV3MakeFromScalar( &a_Vector3, (vec_float4){0.0f} ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3MakeXAxis( &a_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "set to x axis" ); - vmathSoaV3MakeYAxis( &a_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "set to y axis" ); - vmathSoaV3MakeZAxis( &a_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "set to z axis" ); - vmathSoaV3SetElem( &a_Vector3, 0, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::set( 0, float )" ); - vmathSoaV3SetElem( &a_Vector3, 0, randfloat() ); - vmathSoaV3SetElem( &a_Vector3, 0, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 0, divf4( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 0, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 0, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 0 ), randfloat() ) ); - vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](0)" ); - vmathSoaV3SetX( &a_Vector3, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::setX()" ); - vmathSoaV3SetElem( &a_Vector3, 1, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::set( 1, float )" ); - vmathSoaV3SetElem( &a_Vector3, 1, randfloat() ); - vmathSoaV3SetElem( &a_Vector3, 1, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 1, divf4( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 1, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 1, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 1 ), randfloat() ) ); - vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](1)" ); - vmathSoaV3SetY( &a_Vector3, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::setY()" ); - vmathSoaV3SetElem( &a_Vector3, 2, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::set( 2, float )" ); - vmathSoaV3SetElem( &a_Vector3, 2, randfloat() ); - vmathSoaV3SetElem( &a_Vector3, 2, vec_mul_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 2, divf4( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 2, vec_add_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); - vmathSoaV3SetElem( &a_Vector3, 2, vec_sub_float( vmathSoaV3GetElem( &a_Vector3, 2 ), randfloat() ) ); - vmathSoaV3Prints( &a_Vector3, "Vector3::operator [](2)" ); - vmathSoaV3SetZ( &a_Vector3, randfloat() ); - vmathSoaV3Prints( &a_Vector3, "Vector3::setZ()" ); - printf("Vector3::get( 0 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 0 )) ); - printf("Vector3::operator []( 0 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 0 )) ); - printf("Vector3::getX(): %f\n", getfloat(vmathSoaV3GetX( &a_Vector3 )) ); - printf("Vector3::get( 1 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 1 )) ); - printf("Vector3::operator []( 1 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 1 )) ); - printf("Vector3::getY(): %f\n", getfloat(vmathSoaV3GetY( &a_Vector3 )) ); - printf("Vector3::get( 2 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 2 )) ); - printf("Vector3::operator []( 2 ): %f\n", getfloat(vmathSoaV3GetElem( &a_Vector3, 2 )) ); - printf("Vector3::getZ(): %f\n", getfloat(vmathSoaV3GetZ( &a_Vector3 )) ); - vmathSoaV3Add( &tmpV3_2, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_2, "Vector3 + Vector3" ); - vmathSoaV3Sub( &tmpV3_3, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_3, "Vector3 - Vector3" ); - vmathSoaV3AddP3( &tmpP3_0, &a_Vector3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_0, "Vector3 + Point3" ); - vmathSoaV3ScalarMul( &tmpV3_4, &a_Vector3, randfloat() ); - vmathSoaV3Prints( &tmpV3_4, "Vector3 * float" ); - vmathSoaV3ScalarDiv( &tmpV3_5, &a_Vector3, randfloat() ); - vmathSoaV3Prints( &tmpV3_5, "Vector3 / float" ); - vmathSoaV3ScalarMul( &tmpV3_6, &a_Vector3, randfloat() ); - vmathSoaV3Prints( &tmpV3_6, "float * Vector3" ); - vmathSoaV3Neg( &tmpV3_7, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_7, "Vector3 negate" ); - vmathSoaV3MulPerElem( &tmpV3_8, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_8, "mulPerElem( Vector3, Vector3 )" ); - vmathSoaV3DivPerElem( &tmpV3_9, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_9, "divPerElem( Vector3, Vector3 )" ); - vmathSoaV3RecipPerElem( &tmpV3_10, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_10, "Vector3 recip" ); - vmathSoaV3AbsPerElem( &tmpV3_11, &a_Vector3 ); - vmathSoaV3SqrtPerElem( &tmpV3_12, &tmpV3_11 ); - vmathSoaV3Prints( &tmpV3_12, "Vector3 sqrt" ); - vmathSoaV3AbsPerElem( &tmpV3_13, &a_Vector3 ); - vmathSoaV3RsqrtPerElem( &tmpV3_14, &tmpV3_13 ); - vmathSoaV3Prints( &tmpV3_14, "Vector3 rsqrt" ); - vmathSoaV3AbsPerElem( &tmpV3_15, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_15, "Vector3 abs" ); - vmathSoaV3CopySignPerElem( &tmpV3_16, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_16, "Vector3 copySign" ); - vmathSoaV3MaxPerElem( &tmpV3_17, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_17, "Vector3 maximum Vector3" ); - vmathSoaV3MinPerElem( &tmpV3_18, &a_Vector3, &b_Vector3 ); - vmathSoaV3Prints( &tmpV3_18, "Vector3 minimum Vector3" ); - printf("Vector3 maximum of elements: %f\n", getfloat(vmathSoaV3MaxElem( &a_Vector3 ))); - printf("Vector3 minimum of elements: %f\n", getfloat(vmathSoaV3MinElem( &a_Vector3 ))); - printf("Vector3 sum of elements: %f\n", getfloat(vmathSoaV3Sum( &a_Vector3 ))); - printf("Vector3 dot Vector3: %f\n", getfloat(vmathSoaV3Dot( &a_Vector3, &b_Vector3 ))); - printf("Vector3 lengthSqr: %f\n", getfloat(vmathSoaV3LengthSqr( &a_Vector3 ))); - printf("Vector3 length: %f\n", getfloat(vmathSoaV3Length( &a_Vector3 ))); - vmathSoaV3Normalize( &tmpV3_19, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_19, "Vector3 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &e_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Normalize( &b_Vector3, &b_Vector3 ); - vmathSoaV3Normalize( &c_Vector3, &c_Vector3 ); - vmathSoaV3Normalize( &d_Vector3, &d_Vector3 ); - vmathSoaV3Normalize( &e_Vector3, &e_Vector3 ); - vmathSoaV3Lerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "Vector3 lerp" ); - vmathSoaV3Slerp( &a_Vector3, randfloat(), &b_Vector3, &c_Vector3 ); - vmathSoaV3Prints( &a_Vector3, "Vector3 slerp" ); -} - -void -Vector4_methods_test() -{ - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; - VmathSoaVector4 soa_Vector4; - VmathSoaVector3 tmpV3_0; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15, tmpV4_16, tmpV4_17; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); - vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); - vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); - vmathSoaV4MakeFromV3Scalar( &a_Vector4, &a_Vector3, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with Vector3, float" ); - vmathSoaV4MakeFromV3( &a_Vector4, &a_Vector3 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with Vector3" ); - vmathSoaV4MakeFromP3( &a_Vector4, &a_Point3 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with Point3" ); - vmathSoaV4MakeFromQ( &a_Vector4, &a_Quat ); - vmathSoaV4Prints( &a_Vector4, "construct Vector4 with Quat" ); - vmathSoaV4MakeFromScalar( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with float" ); - vmathSoaV4MakeFromScalar( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with float" ); - vmathV4MakeFromElems( &aos_Vector4_0, 0.0f, 1.0f, 2.0f, 3.0f ); - vmathV4MakeFromElems( &aos_Vector4_1, 4.0f, 5.0f, 6.0f, 7.0f ); - vmathV4MakeFromElems( &aos_Vector4_2, 8.0f, 9.0f, 10.0f, 11.0f ); - vmathV4MakeFromElems( &aos_Vector4_3, 12.0f, 13.0f, 14.0f, 15.0f ); - vmathSoaV4MakeFrom4Aos( &soa_Vector4, &aos_Vector4_0, &aos_Vector4_1, &aos_Vector4_2, &aos_Vector4_3 ); - vmathSoaV4Get4Aos( &soa_Vector4, &aos_Vector4_3, &aos_Vector4_2, &aos_Vector4_1, &aos_Vector4_0 ); - vmathV4Prints( &aos_Vector4_0, "aos type 0" ); - vmathV4Prints( &aos_Vector4_1, "aos type 1" ); - vmathV4Prints( &aos_Vector4_2, "aos type 2" ); - vmathV4Prints( &aos_Vector4_3, "aos type 3" ); - vmathSoaV4Select( &a_Vector4, &a_Vector4, &b_Vector4, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - vmathSoaV4Get4Aos( &a_Vector4, &aos_Vector4_0, &aos_Vector4_1, &aos_Vector4_2, &aos_Vector4_3 ); - vmathV4Prints( &aos_Vector4_0, "select 0" ); - vmathV4Prints( &aos_Vector4_1, "select 1" ); - vmathV4Prints( &aos_Vector4_2, "select 2" ); - vmathV4Prints( &aos_Vector4_3, "select 3" ); - vmathSoaV4Copy( &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "assign to Vector4 from Vector4" ); - vmathSoaV4SetXYZ( &a_Vector4, &a_Vector3 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 xyz" ); - vmathSoaV4GetXYZ( &tmpV3_0, &a_Vector4 ); - vmathSoaV3Prints( &tmpV3_0, "get Vector4 xyz" ); - vmathSoaV4MakeFromScalar( &a_Vector4, (vec_float4){0.0f} ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4MakeXAxis( &a_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "set to x axis" ); - vmathSoaV4MakeYAxis( &a_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "set to y axis" ); - vmathSoaV4MakeZAxis( &a_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "set to z axis" ); - vmathSoaV4MakeWAxis( &a_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "set to w axis" ); - vmathSoaV4SetElem( &a_Vector4, 0, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::set( 0, float )" ); - vmathSoaV4SetElem( &a_Vector4, 0, randfloat() ); - vmathSoaV4SetElem( &a_Vector4, 0, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 0, divf4( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 0, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 0, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 0 ), randfloat() ) ); - vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](0)" ); - vmathSoaV4SetX( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::setX()" ); - vmathSoaV4SetElem( &a_Vector4, 1, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::set( 1, float )" ); - vmathSoaV4SetElem( &a_Vector4, 1, randfloat() ); - vmathSoaV4SetElem( &a_Vector4, 1, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 1, divf4( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 1, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 1, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 1 ), randfloat() ) ); - vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](1)" ); - vmathSoaV4SetY( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::setY()" ); - vmathSoaV4SetElem( &a_Vector4, 2, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::set( 2, float )" ); - vmathSoaV4SetElem( &a_Vector4, 2, randfloat() ); - vmathSoaV4SetElem( &a_Vector4, 2, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 2, divf4( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 2, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 2, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 2 ), randfloat() ) ); - vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](2)" ); - vmathSoaV4SetZ( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::setZ()" ); - vmathSoaV4SetElem( &a_Vector4, 3, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::set( 3, float )" ); - vmathSoaV4SetElem( &a_Vector4, 3, randfloat() ); - vmathSoaV4SetElem( &a_Vector4, 3, vec_mul_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 3, divf4( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 3, vec_add_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); - vmathSoaV4SetElem( &a_Vector4, 3, vec_sub_float( vmathSoaV4GetElem( &a_Vector4, 3 ), randfloat() ) ); - vmathSoaV4Prints( &a_Vector4, "Vector4::operator [](3)" ); - vmathSoaV4SetW( &a_Vector4, randfloat() ); - vmathSoaV4Prints( &a_Vector4, "Vector4::setW()" ); - printf("Vector4::get( 0 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 0 )) ); - printf("Vector4::operator []( 0 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 0 )) ); - printf("Vector4::getX(): %f\n", getfloat(vmathSoaV4GetX( &a_Vector4 )) ); - printf("Vector4::get( 1 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 1 )) ); - printf("Vector4::operator []( 1 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 1 )) ); - printf("Vector4::getY(): %f\n", getfloat(vmathSoaV4GetY( &a_Vector4 )) ); - printf("Vector4::get( 2 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 2 )) ); - printf("Vector4::operator []( 2 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 2 )) ); - printf("Vector4::getZ(): %f\n", getfloat(vmathSoaV4GetZ( &a_Vector4 )) ); - printf("Vector4::get( 3 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 3 )) ); - printf("Vector4::operator []( 3 ): %f\n", getfloat(vmathSoaV4GetElem( &a_Vector4, 3 )) ); - printf("Vector4::getW(): %f\n", getfloat(vmathSoaV4GetW( &a_Vector4 )) ); - vmathSoaV4Add( &tmpV4_0, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_0, "Vector4 + Vector4" ); - vmathSoaV4Sub( &tmpV4_1, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_1, "Vector4 - Vector4" ); - vmathSoaV4ScalarMul( &tmpV4_2, &a_Vector4, randfloat() ); - vmathSoaV4Prints( &tmpV4_2, "Vector4 * float" ); - vmathSoaV4ScalarDiv( &tmpV4_3, &a_Vector4, randfloat() ); - vmathSoaV4Prints( &tmpV4_3, "Vector4 / float" ); - vmathSoaV4ScalarMul( &tmpV4_4, &a_Vector4, randfloat() ); - vmathSoaV4Prints( &tmpV4_4, "float * Vector4" ); - vmathSoaV4Neg( &tmpV4_5, &a_Vector4 ); - vmathSoaV4Prints( &tmpV4_5, "Vector4 negate" ); - vmathSoaV4MulPerElem( &tmpV4_6, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_6, "mulPerElem( Vector4, Vector4 )" ); - vmathSoaV4DivPerElem( &tmpV4_7, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_7, "divPerElem( Vector4, Vector4 )" ); - vmathSoaV4RecipPerElem( &tmpV4_8, &a_Vector4 ); - vmathSoaV4Prints( &tmpV4_8, "Vector4 recip" ); - vmathSoaV4AbsPerElem( &tmpV4_9, &a_Vector4 ); - vmathSoaV4SqrtPerElem( &tmpV4_10, &tmpV4_9 ); - vmathSoaV4Prints( &tmpV4_10, "Vector4 sqrt" ); - vmathSoaV4AbsPerElem( &tmpV4_11, &a_Vector4 ); - vmathSoaV4RsqrtPerElem( &tmpV4_12, &tmpV4_11 ); - vmathSoaV4Prints( &tmpV4_12, "Vector4 rsqrt" ); - vmathSoaV4AbsPerElem( &tmpV4_13, &a_Vector4 ); - vmathSoaV4Prints( &tmpV4_13, "Vector4 abs" ); - vmathSoaV4CopySignPerElem( &tmpV4_14, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_14, "Vector4 copySign" ); - vmathSoaV4MaxPerElem( &tmpV4_15, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_15, "Vector4 maximum Vector4" ); - vmathSoaV4MinPerElem( &tmpV4_16, &a_Vector4, &b_Vector4 ); - vmathSoaV4Prints( &tmpV4_16, "Vector4 minimum Vector4" ); - printf("Vector4 maximum of elements: %f\n", getfloat(vmathSoaV4MaxElem( &a_Vector4 ))); - printf("Vector4 minimum of elements: %f\n", getfloat(vmathSoaV4MinElem( &a_Vector4 ))); - printf("Vector4 sum of elements: %f\n", getfloat(vmathSoaV4Sum( &a_Vector4 ))); - printf("Vector4 dot Vector4: %f\n", getfloat(vmathSoaV4Dot( &a_Vector4, &b_Vector4 ))); - printf("Vector4 lengthSqr: %f\n", getfloat(vmathSoaV4LengthSqr( &a_Vector4 ))); - printf("Vector4 length: %f\n", getfloat(vmathSoaV4Length( &a_Vector4 ))); - vmathSoaV4Normalize( &tmpV4_17, &a_Vector4 ); - vmathSoaV4Prints( &tmpV4_17, "Vector4 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &e_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Normalize( &b_Vector4, &b_Vector4 ); - vmathSoaV4Normalize( &c_Vector4, &c_Vector4 ); - vmathSoaV4Normalize( &d_Vector4, &d_Vector4 ); - vmathSoaV4Normalize( &e_Vector4, &e_Vector4 ); - vmathSoaV4Lerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "Vector4 lerp" ); - vmathSoaV4Slerp( &a_Vector4, randfloat(), &b_Vector4, &c_Vector4 ); - vmathSoaV4Prints( &a_Vector4, "Vector4 slerp" ); -} - -void -Point3_methods_test() -{ - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathPoint3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; - VmathSoaPoint3 soa_Point3; - VmathVector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2; - VmathSoaPoint3 tmpP3_0, tmpP3_1, tmpP3_2, tmpP3_3, tmpP3_4, tmpP3_5, tmpP3_6, tmpP3_7, tmpP3_8, tmpP3_9, tmpP3_10, tmpP3_11, tmpP3_12; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - float xyz4[12] __attribute__ ((aligned(16))); - xyz4[0] = getfloat(randfloat()); - xyz4[1] = getfloat(randfloat()); - xyz4[2] = getfloat(randfloat()); - xyz4[3] = getfloat(randfloat()); - xyz4[4] = getfloat(randfloat()); - xyz4[5] = getfloat(randfloat()); - xyz4[6] = getfloat(randfloat()); - xyz4[7] = getfloat(randfloat()); - xyz4[8] = getfloat(randfloat()); - xyz4[9] = getfloat(randfloat()); - xyz4[10] = getfloat(randfloat()); - xyz4[11] = getfloat(randfloat()); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); - vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); - vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); - vmathSoaP3MakeFromV3( &a_Point3, &a_Vector3 ); - vmathSoaP3Prints( &a_Point3, "construct Point3 with Vector3" ); - vmathSoaP3MakeFromScalar( &a_Point3, randfloat() ); - vmathSoaP3Prints( &a_Point3, "set Point3 with float" ); - vmathSoaP3MakeFromScalar( &a_Point3, randfloat() ); - vmathSoaP3Prints( &a_Point3, "set Point3 with float" ); - vmathP3MakeFromElems( &aos_Point3_0, 0.0f, 1.0f, 2.0f ); - vmathP3MakeFromElems( &aos_Point3_1, 3.0f, 4.0f, 5.0f ); - vmathP3MakeFromElems( &aos_Point3_2, 6.0f, 7.0f, 8.0f ); - vmathP3MakeFromElems( &aos_Point3_3, 9.0f, 10.0f, 11.0f ); - vmathSoaP3MakeFrom4Aos( &soa_Point3, &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3 ); - vmathSoaP3Get4Aos( &soa_Point3, &aos_Point3_3, &aos_Point3_2, &aos_Point3_1, &aos_Point3_0 ); - vmathP3Prints( &aos_Point3_0, "aos type 0" ); - vmathP3Prints( &aos_Point3_1, "aos type 1" ); - vmathP3Prints( &aos_Point3_2, "aos type 2" ); - vmathP3Prints( &aos_Point3_3, "aos type 3" ); - vmathSoaP3Select( &a_Point3, &a_Point3, &b_Point3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - vmathSoaP3Get4Aos( &a_Point3, &aos_Point3_0, &aos_Point3_1, &aos_Point3_2, &aos_Point3_3 ); - vmathP3Prints( &aos_Point3_0, "select 0" ); - vmathP3Prints( &aos_Point3_1, "select 1" ); - vmathP3Prints( &aos_Point3_2, "select 2" ); - vmathP3Prints( &aos_Point3_3, "select 3" ); - vmathSoaP3LoadXYZArray( &a_Point3, (const vec_float4 *)xyz4 ); - vmathSoaP3Prints( &a_Point3, "load XYZ array" ); - vmathSoaV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathSoaV3Neg( &tmpV3_1, &tmpV3_0 ); - vmathSoaP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathSoaP3StoreXYZArray( &a_Point3, (vec_float4 *)xyz4 ); - vmathV4MakeFromElems( &aos_Vector4_0, xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - vmathV4MakeFromElems( &aos_Vector4_1, xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - vmathV4MakeFromElems( &aos_Vector4_2, xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); - vmathV4Prints( &aos_Vector4_0, "xyzx" ); - vmathV4Prints( &aos_Vector4_1, "yzxy" ); - vmathV4Prints( &aos_Vector4_2, "zxyz" ); - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); - vmathSoaP3Copy( &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &a_Point3, "assign to Point3 from Point3" ); - vmathSoaP3MakeFromScalar( &a_Point3, (vec_float4){0.0f} ); - vmathSoaP3Prints( &a_Point3, "set Point3 elements to zero" ); - vmathSoaP3SetElem( &a_Point3, 0, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::set( 0, float )" ); - vmathSoaP3SetElem( &a_Point3, 0, randfloat() ); - vmathSoaP3SetElem( &a_Point3, 0, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 0, divf4( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 0, vec_add_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 0, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 0 ), randfloat() ) ); - vmathSoaP3Prints( &a_Point3, "Point3::operator [](0)" ); - vmathSoaP3SetX( &a_Point3, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::setX()" ); - vmathSoaP3SetElem( &a_Point3, 1, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::set( 1, float )" ); - vmathSoaP3SetElem( &a_Point3, 1, randfloat() ); - vmathSoaP3SetElem( &a_Point3, 1, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 1, divf4( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 1, vec_add_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 1, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 1 ), randfloat() ) ); - vmathSoaP3Prints( &a_Point3, "Point3::operator [](1)" ); - vmathSoaP3SetY( &a_Point3, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::setY()" ); - vmathSoaP3SetElem( &a_Point3, 2, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::set( 2, float )" ); - vmathSoaP3SetElem( &a_Point3, 2, randfloat() ); - vmathSoaP3SetElem( &a_Point3, 2, vec_mul_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 2, divf4( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 2, vec_add_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); - vmathSoaP3SetElem( &a_Point3, 2, vec_sub_float( vmathSoaP3GetElem( &a_Point3, 2 ), randfloat() ) ); - vmathSoaP3Prints( &a_Point3, "Point3::operator [](2)" ); - vmathSoaP3SetZ( &a_Point3, randfloat() ); - vmathSoaP3Prints( &a_Point3, "Point3::setZ()" ); - printf("Point3::get( 0 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 0 )) ); - printf("Point3::operator []( 0 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 0 )) ); - printf("Point3::getX(): %f\n", getfloat(vmathSoaP3GetX( &a_Point3 )) ); - printf("Point3::get( 1 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 1 )) ); - printf("Point3::operator []( 1 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 1 )) ); - printf("Point3::getY(): %f\n", getfloat(vmathSoaP3GetY( &a_Point3 )) ); - printf("Point3::get( 2 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 2 )) ); - printf("Point3::operator []( 2 ): %f\n", getfloat(vmathSoaP3GetElem( &a_Point3, 2 )) ); - printf("Point3::getZ(): %f\n", getfloat(vmathSoaP3GetZ( &a_Point3 )) ); - vmathSoaP3Sub( &tmpV3_2, &a_Point3, &b_Point3 ); - vmathSoaV3Prints( &tmpV3_2, "Point3 - Point3" ); - vmathSoaP3AddV3( &tmpP3_0, &a_Point3, &b_Vector3 ); - vmathSoaP3Prints( &tmpP3_0, "Point3 + Vector3" ); - vmathSoaP3SubV3( &tmpP3_1, &a_Point3, &b_Vector3 ); - vmathSoaP3Prints( &tmpP3_1, "Point3 - Vector3" ); - vmathSoaP3MulPerElem( &tmpP3_2, &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_2, "mulPerElem( Point3, Point3 )" ); - vmathSoaP3DivPerElem( &tmpP3_3, &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_3, "divPerElem( Point3, Point3 )" ); - vmathSoaP3RecipPerElem( &tmpP3_4, &a_Point3 ); - vmathSoaP3Prints( &tmpP3_4, "Point3 recip" ); - vmathSoaP3AbsPerElem( &tmpP3_5, &a_Point3 ); - vmathSoaP3SqrtPerElem( &tmpP3_6, &tmpP3_5 ); - vmathSoaP3Prints( &tmpP3_6, "Point3 sqrt" ); - vmathSoaP3AbsPerElem( &tmpP3_7, &a_Point3 ); - vmathSoaP3RsqrtPerElem( &tmpP3_8, &tmpP3_7 ); - vmathSoaP3Prints( &tmpP3_8, "Point3 rsqrt" ); - vmathSoaP3AbsPerElem( &tmpP3_9, &a_Point3 ); - vmathSoaP3Prints( &tmpP3_9, "Point3 abs" ); - vmathSoaP3CopySignPerElem( &tmpP3_10, &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_10, "Point3 copySign" ); - vmathSoaP3MaxPerElem( &tmpP3_11, &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_11, "Point3 maximum Point3" ); - vmathSoaP3MinPerElem( &tmpP3_12, &a_Point3, &b_Point3 ); - vmathSoaP3Prints( &tmpP3_12, "Point3 minimum Point3" ); - printf("Point3 maximum of elements: %f\n", getfloat(vmathSoaP3MaxElem( &a_Point3 ))); - printf("Point3 minimum of elements: %f\n", getfloat(vmathSoaP3MinElem( &a_Point3 ))); - printf("Point3 sum of elements: %f\n", getfloat(vmathSoaP3Sum( &a_Point3 ))); - printf("Point projection: %f\n", getfloat(vmathSoaP3Projection( &a_Point3, &b_Vector3 ))); - printf("Point distSqrFromOrigin: %f\n", getfloat(vmathSoaP3DistSqrFromOrigin( &a_Point3 )) ); - printf("Point distFromOrigin: %f\n", getfloat(vmathSoaP3DistFromOrigin( &a_Point3 )) ); - printf("Point distSqr: %f\n", getfloat(vmathSoaP3DistSqr( &a_Point3, &b_Point3 )) ); - printf("Point dist: %f\n", getfloat(vmathSoaP3Dist( &a_Point3, &b_Point3 )) ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &e_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Lerp( &a_Point3, randfloat(), &b_Point3, &c_Point3 ); - vmathSoaP3Prints( &a_Point3, "Point3 lerp" ); -} - -void -Quat_methods_test() -{ - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - VmathQuat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; - VmathSoaQuat soa_Quat; - VmathSoaVector3 tmpV3_0; - VmathSoaQuat tmpQ_0, tmpQ_1, tmpQ_2, tmpQ_3, tmpQ_4, tmpQ_5, tmpQ_6, tmpQ_7; - VmathSoaVector3 tmpV3_1; - VmathSoaQuat tmpQ_8; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3MakeFromScalar( &c_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &d_Vector3, (vec_float4){0.0f} ); - vmathSoaV3MakeFromScalar( &e_Vector3, (vec_float4){0.0f} ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 elements to zero" ); - vmathSoaV3Prints( &e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4MakeFromScalar( &c_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &d_Vector4, (vec_float4){0.0f} ); - vmathSoaV4MakeFromScalar( &e_Vector4, (vec_float4){0.0f} ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 elements to zero" ); - vmathSoaV4Prints( &e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3MakeFromScalar( &c_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &d_Point3, (vec_float4){0.0f} ); - vmathSoaP3MakeFromScalar( &e_Point3, (vec_float4){0.0f} ); - vmathSoaP3Prints( &c_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &d_Point3, "set Point3 elements to zero" ); - vmathSoaP3Prints( &e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQMakeFromScalar( &c_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &d_Quat, (vec_float4){0.0f} ); - vmathSoaQMakeFromScalar( &e_Quat, (vec_float4){0.0f} ); - vmathSoaQPrints( &c_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &d_Quat, "set Quat elements to zero" ); - vmathSoaQPrints( &e_Quat, "set Quat elements to zero" ); - vmathSoaQMakeFromV3Scalar( &a_Quat, &a_Vector3, randfloat() ); - vmathSoaQPrints( &a_Quat, "set Quat with Vector3, float" ); - vmathSoaQMakeFromV4( &a_Quat, &a_Vector4 ); - vmathSoaQPrints( &a_Quat, "construct Quat with Vector4" ); - vmathSoaQMakeFromScalar( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "set Quat with float" ); - vmathSoaQMakeFromScalar( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "set Quat with float" ); - vmathQMakeFromElems( &aos_Quat_0, 0.0f, 1.0f, 2.0f, 3.0f ); - vmathQMakeFromElems( &aos_Quat_1, 4.0f, 5.0f, 6.0f, 7.0f ); - vmathQMakeFromElems( &aos_Quat_2, 8.0f, 9.0f, 10.0f, 11.0f ); - vmathQMakeFromElems( &aos_Quat_3, 12.0f, 13.0f, 14.0f, 15.0f ); - vmathSoaQMakeFrom4Aos( &soa_Quat, &aos_Quat_0, &aos_Quat_1, &aos_Quat_2, &aos_Quat_3 ); - vmathSoaQGet4Aos( &soa_Quat, &aos_Quat_3, &aos_Quat_2, &aos_Quat_1, &aos_Quat_0 ); - vmathQPrints( &aos_Quat_0, "aos type 0" ); - vmathQPrints( &aos_Quat_1, "aos type 1" ); - vmathQPrints( &aos_Quat_2, "aos type 2" ); - vmathQPrints( &aos_Quat_3, "aos type 3" ); - vmathSoaQSelect( &a_Quat, &a_Quat, &b_Quat, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - vmathSoaQGet4Aos( &a_Quat, &aos_Quat_0, &aos_Quat_1, &aos_Quat_2, &aos_Quat_3 ); - vmathQPrints( &aos_Quat_0, "select 0" ); - vmathQPrints( &aos_Quat_1, "select 1" ); - vmathQPrints( &aos_Quat_2, "select 2" ); - vmathQPrints( &aos_Quat_3, "select 3" ); - vmathSoaQCopy( &a_Quat, &b_Quat ); - vmathSoaQPrints( &a_Quat, "assign to Quat from Quat" ); - vmathSoaQSetXYZ( &a_Quat, &a_Vector3 ); - vmathSoaQPrints( &a_Quat, "set Quat xyz" ); - vmathSoaQGetXYZ( &tmpV3_0, &a_Quat ); - vmathSoaV3Prints( &tmpV3_0, "get Quat xyz" ); - vmathSoaQMakeFromScalar( &a_Quat, (vec_float4){0.0f} ); - vmathSoaQPrints( &a_Quat, "set Quat elements to zero" ); - vmathSoaQSetElem( &a_Quat, 0, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::set( 0, float )" ); - vmathSoaQSetElem( &a_Quat, 0, randfloat() ); - vmathSoaQSetElem( &a_Quat, 0, vec_mul_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 0, divf4( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 0, vec_add_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 0, vec_sub_float( vmathSoaQGetElem( &a_Quat, 0 ), randfloat() ) ); - vmathSoaQPrints( &a_Quat, "Quat::operator [](0)" ); - vmathSoaQSetX( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::setX()" ); - vmathSoaQSetElem( &a_Quat, 1, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::set( 1, float )" ); - vmathSoaQSetElem( &a_Quat, 1, randfloat() ); - vmathSoaQSetElem( &a_Quat, 1, vec_mul_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 1, divf4( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 1, vec_add_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 1, vec_sub_float( vmathSoaQGetElem( &a_Quat, 1 ), randfloat() ) ); - vmathSoaQPrints( &a_Quat, "Quat::operator [](1)" ); - vmathSoaQSetY( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::setY()" ); - vmathSoaQSetElem( &a_Quat, 2, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::set( 2, float )" ); - vmathSoaQSetElem( &a_Quat, 2, randfloat() ); - vmathSoaQSetElem( &a_Quat, 2, vec_mul_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 2, divf4( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 2, vec_add_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 2, vec_sub_float( vmathSoaQGetElem( &a_Quat, 2 ), randfloat() ) ); - vmathSoaQPrints( &a_Quat, "Quat::operator [](2)" ); - vmathSoaQSetZ( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::setZ()" ); - vmathSoaQSetElem( &a_Quat, 3, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::set( 3, float )" ); - vmathSoaQSetElem( &a_Quat, 3, randfloat() ); - vmathSoaQSetElem( &a_Quat, 3, vec_mul_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 3, divf4( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 3, vec_add_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); - vmathSoaQSetElem( &a_Quat, 3, vec_sub_float( vmathSoaQGetElem( &a_Quat, 3 ), randfloat() ) ); - vmathSoaQPrints( &a_Quat, "Quat::operator [](3)" ); - vmathSoaQSetW( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat::setW()" ); - printf("Quat::get( 0 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 0 )) ); - printf("Quat::operator []( 0 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 0 )) ); - printf("Quat::getX(): %f\n", getfloat(vmathSoaQGetX( &a_Quat )) ); - printf("Quat::get( 1 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 1 )) ); - printf("Quat::operator []( 1 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 1 )) ); - printf("Quat::getY(): %f\n", getfloat(vmathSoaQGetY( &a_Quat )) ); - printf("Quat::get( 2 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 2 )) ); - printf("Quat::operator []( 2 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 2 )) ); - printf("Quat::getZ(): %f\n", getfloat(vmathSoaQGetZ( &a_Quat )) ); - printf("Quat::get( 3 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 3 )) ); - printf("Quat::operator []( 3 ): %f\n", getfloat(vmathSoaQGetElem( &a_Quat, 3 )) ); - printf("Quat::getW(): %f\n", getfloat(vmathSoaQGetW( &a_Quat )) ); - vmathSoaQAdd( &tmpQ_0, &a_Quat, &b_Quat ); - vmathSoaQPrints( &tmpQ_0, "Quat + Quat" ); - vmathSoaQSub( &tmpQ_1, &a_Quat, &b_Quat ); - vmathSoaQPrints( &tmpQ_1, "Quat - Quat" ); - vmathSoaQMul( &tmpQ_2, &a_Quat, &b_Quat ); - vmathSoaQPrints( &tmpQ_2, "Quat * Quat" ); - vmathSoaQScalarMul( &tmpQ_3, &a_Quat, randfloat() ); - vmathSoaQPrints( &tmpQ_3, "Quat * float" ); - vmathSoaQScalarDiv( &tmpQ_4, &a_Quat, randfloat() ); - vmathSoaQPrints( &tmpQ_4, "Quat / float" ); - vmathSoaQScalarMul( &tmpQ_5, &a_Quat, randfloat() ); - vmathSoaQPrints( &tmpQ_5, "float * Quat" ); - vmathSoaQNeg( &tmpQ_6, &a_Quat ); - vmathSoaQPrints( &tmpQ_6, "Quat negate" ); - printf("Quat dot Quat: %f\n", getfloat(vmathSoaQDot( &a_Quat, &b_Quat ))); - printf("Quat lengthSqr: %f\n", getfloat(vmathSoaQNorm( &a_Quat ))); - printf("Quat length: %f\n", getfloat(vmathSoaQLength( &a_Quat ))); - vmathSoaQNormalize( &tmpQ_7, &a_Quat ); - vmathSoaQPrints( &tmpQ_7, "Quat normalized" ); - vmathSoaQMakeIdentity( &a_Quat ); - vmathSoaQPrints( &a_Quat, "set to identity" ); - vmathSoaQMakeRotationArc( &a_Quat, &a_Vector3, &b_Vector3 ); - vmathSoaQPrints( &a_Quat, "Quat rotation between vectors" ); - vmathSoaQMakeRotationAxis( &a_Quat, randfloat(), &a_Vector3 ); - vmathSoaQPrints( &a_Quat, "Quat rotation axis angle" ); - vmathSoaQMakeRotationX( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat rotationX" ); - vmathSoaQMakeRotationY( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat rotationY" ); - vmathSoaQMakeRotationZ( &a_Quat, randfloat() ); - vmathSoaQPrints( &a_Quat, "Quat rotationZ" ); - vmathSoaQRotate( &tmpV3_1, &a_Quat, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_1, "Quat rotate Vector3" ); - vmathSoaQConj( &tmpQ_8, &a_Quat ); - vmathSoaQPrints( &tmpQ_8, "Quat conj" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &e_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQNormalize( &b_Quat, &b_Quat ); - vmathSoaQNormalize( &c_Quat, &c_Quat ); - vmathSoaQNormalize( &d_Quat, &d_Quat ); - vmathSoaQNormalize( &e_Quat, &e_Quat ); - vmathSoaQLerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); - vmathSoaQPrints( &a_Quat, "Quat lerp" ); - vmathSoaQSlerp( &a_Quat, randfloat(), &b_Quat, &c_Quat ); - vmathSoaQPrints( &a_Quat, "Quat slerp" ); - vmathSoaQSquad( &a_Quat, randfloat(), &b_Quat, &c_Quat, &d_Quat, &e_Quat ); - vmathSoaQPrints( &a_Quat, "Quat squad" ); -} - -int main() -{ - printf("\n __begin__ \n"); - for ( iteration = 0; iteration < 2; iteration++ ) { - Vector3_methods_test(); - Vector4_methods_test(); - Point3_methods_test(); - Quat_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test1_soa_cpp.cpp b/Extras/vectormathlibrary/tests/test1_soa_cpp.cpp deleted file mode 100644 index daaeec45c..000000000 --- a/Extras/vectormathlibrary/tests/test1_soa_cpp.cpp +++ /dev/null @@ -1,931 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Soa; - -void -Vector3_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Aos::Vector3 aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3; - Vector3 soa_Vector3; - Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - float xyz4[12] __attribute__ ((aligned(16))); - xyz4[0] = getfloat(randfloat()); - xyz4[1] = getfloat(randfloat()); - xyz4[2] = getfloat(randfloat()); - xyz4[3] = getfloat(randfloat()); - xyz4[4] = getfloat(randfloat()); - xyz4[5] = getfloat(randfloat()); - xyz4[6] = getfloat(randfloat()); - xyz4[7] = getfloat(randfloat()); - xyz4[8] = getfloat(randfloat()); - xyz4[9] = getfloat(randfloat()); - xyz4[10] = getfloat(randfloat()); - xyz4[11] = getfloat(randfloat()); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( (vec_float4){0.0f} ); - d_Vector3 = Vector3( (vec_float4){0.0f} ); - e_Vector3 = Vector3( (vec_float4){0.0f} ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( (vec_float4){0.0f} ); - d_Vector4 = Vector4( (vec_float4){0.0f} ); - e_Vector4 = Vector4( (vec_float4){0.0f} ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( (vec_float4){0.0f} ); - d_Point3 = Point3( (vec_float4){0.0f} ); - e_Point3 = Point3( (vec_float4){0.0f} ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( (vec_float4){0.0f} ); - d_Quat = Quat( (vec_float4){0.0f} ); - e_Quat = Quat( (vec_float4){0.0f} ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Vector3 = Vector3( a_Point3 ); - print( a_Vector3, "construct Vector3 with Point3" ); - a_Vector3 = Vector3( randfloat() ); - print( a_Vector3, "set Vector3 with float" ); - a_Vector3 = Vector3( randfloat() ); - print( a_Vector3, "set Vector3 with float" ); - aos_Vector3_0 = Aos::Vector3( 0.0f, 1.0f, 2.0f ); - aos_Vector3_1 = Aos::Vector3( 3.0f, 4.0f, 5.0f ); - aos_Vector3_2 = Aos::Vector3( 6.0f, 7.0f, 8.0f ); - aos_Vector3_3 = Aos::Vector3( 9.0f, 10.0f, 11.0f ); - soa_Vector3 = Vector3( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 ); - soa_Vector3.get4Aos( aos_Vector3_3, aos_Vector3_2, aos_Vector3_1, aos_Vector3_0 ); - Aos::print( aos_Vector3_0, "aos type 0" ); - Aos::print( aos_Vector3_1, "aos type 1" ); - Aos::print( aos_Vector3_2, "aos type 2" ); - Aos::print( aos_Vector3_3, "aos type 3" ); - a_Vector3 = select( a_Vector3, b_Vector3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - a_Vector3.get4Aos( aos_Vector3_0, aos_Vector3_1, aos_Vector3_2, aos_Vector3_3 ); - Aos::print( aos_Vector3_0, "select 0" ); - Aos::print( aos_Vector3_1, "select 1" ); - Aos::print( aos_Vector3_2, "select 2" ); - Aos::print( aos_Vector3_3, "select 3" ); - loadXYZArray( a_Vector3, (const vec_float4 *)xyz4 ); - print( a_Vector3, "load XYZ array" ); - a_Vector3 = Vector3( ( -Vector3( a_Vector3 ) ) ); - storeXYZArray( a_Vector3, (vec_float4 *)xyz4 ); - aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - Aos::print( aos_Vector4_0, "xyzx" ); - Aos::print( aos_Vector4_1, "yzxy" ); - Aos::print( aos_Vector4_2, "zxyz" ); - Aos::print( aos_Vector4_0, "xyzx" ); - Aos::print( aos_Vector4_1, "yzxy" ); - Aos::print( aos_Vector4_2, "zxyz" ); - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); - a_Vector3 = b_Vector3; - print( a_Vector3, "assign to Vector3 from Vector3" ); - a_Vector3 = Vector3( (vec_float4){0.0f} ); - print( a_Vector3, "set Vector3 elements to zero" ); - a_Vector3 = Vector3::xAxis( ); - print( a_Vector3, "set to x axis" ); - a_Vector3 = Vector3::yAxis( ); - print( a_Vector3, "set to y axis" ); - a_Vector3 = Vector3::zAxis( ); - print( a_Vector3, "set to z axis" ); - a_Vector3.setElem( 0, randfloat() ); - print( a_Vector3, "Vector3::set( 0, float )" ); - a_Vector3[0] = randfloat(); - a_Vector3[0] = vec_mul_float( a_Vector3[0], randfloat() ); - a_Vector3[0] = divf4( a_Vector3[0], randfloat() ); - a_Vector3[0] = vec_add_float( a_Vector3[0], randfloat() ); - a_Vector3[0] = vec_sub_float( a_Vector3[0], randfloat() ); - print( a_Vector3, "Vector3::operator [](0)" ); - a_Vector3.setX( randfloat() ); - print( a_Vector3, "Vector3::setX()" ); - a_Vector3.setElem( 1, randfloat() ); - print( a_Vector3, "Vector3::set( 1, float )" ); - a_Vector3[1] = randfloat(); - a_Vector3[1] = vec_mul_float( a_Vector3[1], randfloat() ); - a_Vector3[1] = divf4( a_Vector3[1], randfloat() ); - a_Vector3[1] = vec_add_float( a_Vector3[1], randfloat() ); - a_Vector3[1] = vec_sub_float( a_Vector3[1], randfloat() ); - print( a_Vector3, "Vector3::operator [](1)" ); - a_Vector3.setY( randfloat() ); - print( a_Vector3, "Vector3::setY()" ); - a_Vector3.setElem( 2, randfloat() ); - print( a_Vector3, "Vector3::set( 2, float )" ); - a_Vector3[2] = randfloat(); - a_Vector3[2] = vec_mul_float( a_Vector3[2], randfloat() ); - a_Vector3[2] = divf4( a_Vector3[2], randfloat() ); - a_Vector3[2] = vec_add_float( a_Vector3[2], randfloat() ); - a_Vector3[2] = vec_sub_float( a_Vector3[2], randfloat() ); - print( a_Vector3, "Vector3::operator [](2)" ); - a_Vector3.setZ( randfloat() ); - print( a_Vector3, "Vector3::setZ()" ); - printf("Vector3::get( 0 ): %f\n", getfloat(a_Vector3.getElem( 0 )) ); - printf("Vector3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector3[0]) ); - printf("Vector3::getX(): %f\n", getfloat(a_Vector3.getX( )) ); - printf("Vector3::get( 1 ): %f\n", getfloat(a_Vector3.getElem( 1 )) ); - printf("Vector3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector3[1]) ); - printf("Vector3::getY(): %f\n", getfloat(a_Vector3.getY( )) ); - printf("Vector3::get( 2 ): %f\n", getfloat(a_Vector3.getElem( 2 )) ); - printf("Vector3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector3[2]) ); - printf("Vector3::getZ(): %f\n", getfloat(a_Vector3.getZ( )) ); - print( ( a_Vector3 + b_Vector3 ), "Vector3 + Vector3" ); - print( ( a_Vector3 - b_Vector3 ), "Vector3 - Vector3" ); - print( ( a_Vector3 + b_Point3 ), "Vector3 + Point3" ); - print( ( a_Vector3 * randfloat() ), "Vector3 * float" ); - print( ( a_Vector3 / randfloat() ), "Vector3 / float" ); - print( ( randfloat() * a_Vector3 ), "float * Vector3" ); - print( ( -a_Vector3 ), "Vector3 negate" ); - print( mulPerElem( a_Vector3, b_Vector3 ), "mulPerElem( Vector3, Vector3 )" ); - print( divPerElem( a_Vector3, b_Vector3 ), "divPerElem( Vector3, Vector3 )" ); - print( recipPerElem( a_Vector3 ), "Vector3 recip" ); - print( sqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Vector3 ) ), "Vector3 rsqrt" ); - print( absPerElem( a_Vector3 ), "Vector3 abs" ); - print( copySignPerElem( a_Vector3, b_Vector3 ), "Vector3 copySign" ); - print( maxPerElem( a_Vector3, b_Vector3 ), "Vector3 maximum Vector3" ); - print( minPerElem( a_Vector3, b_Vector3 ), "Vector3 minimum Vector3" ); - printf("Vector3 maximum of elements: %f\n", getfloat(maxElem( a_Vector3 ))); - printf("Vector3 minimum of elements: %f\n", getfloat(minElem( a_Vector3 ))); - printf("Vector3 sum of elements: %f\n", getfloat(sum( a_Vector3 ))); - printf("Vector3 dot Vector3: %f\n", getfloat(dot( a_Vector3, b_Vector3 ))); - printf("Vector3 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector3 ))); - printf("Vector3 length: %f\n", getfloat(length( a_Vector3 ))); - print( normalize( a_Vector3 ), "Vector3 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - e_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - b_Vector3 = normalize( b_Vector3 ); - c_Vector3 = normalize( c_Vector3 ); - d_Vector3 = normalize( d_Vector3 ); - e_Vector3 = normalize( e_Vector3 ); - a_Vector3 = lerp( randfloat(), b_Vector3, c_Vector3 ); - print( a_Vector3, "Vector3 lerp" ); - a_Vector3 = slerp( randfloat(), b_Vector3, c_Vector3 ); - print( a_Vector3, "Vector3 slerp" ); -} - -void -Vector4_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3; - Vector4 soa_Vector4; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( (vec_float4){0.0f} ); - d_Vector3 = Vector3( (vec_float4){0.0f} ); - e_Vector3 = Vector3( (vec_float4){0.0f} ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( (vec_float4){0.0f} ); - d_Vector4 = Vector4( (vec_float4){0.0f} ); - e_Vector4 = Vector4( (vec_float4){0.0f} ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( (vec_float4){0.0f} ); - d_Point3 = Point3( (vec_float4){0.0f} ); - e_Point3 = Point3( (vec_float4){0.0f} ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( (vec_float4){0.0f} ); - d_Quat = Quat( (vec_float4){0.0f} ); - e_Quat = Quat( (vec_float4){0.0f} ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Vector4 = Vector4( a_Vector3, randfloat() ); - print( a_Vector4, "set Vector4 with Vector3, float" ); - a_Vector4 = Vector4( a_Vector3 ); - print( a_Vector4, "set Vector4 with Vector3" ); - a_Vector4 = Vector4( a_Point3 ); - print( a_Vector4, "set Vector4 with Point3" ); - a_Vector4 = Vector4( a_Quat ); - print( a_Vector4, "construct Vector4 with Quat" ); - a_Vector4 = Vector4( randfloat() ); - print( a_Vector4, "set Vector4 with float" ); - a_Vector4 = Vector4( randfloat() ); - print( a_Vector4, "set Vector4 with float" ); - aos_Vector4_0 = Aos::Vector4( 0.0f, 1.0f, 2.0f, 3.0f ); - aos_Vector4_1 = Aos::Vector4( 4.0f, 5.0f, 6.0f, 7.0f ); - aos_Vector4_2 = Aos::Vector4( 8.0f, 9.0f, 10.0f, 11.0f ); - aos_Vector4_3 = Aos::Vector4( 12.0f, 13.0f, 14.0f, 15.0f ); - soa_Vector4 = Vector4( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 ); - soa_Vector4.get4Aos( aos_Vector4_3, aos_Vector4_2, aos_Vector4_1, aos_Vector4_0 ); - Aos::print( aos_Vector4_0, "aos type 0" ); - Aos::print( aos_Vector4_1, "aos type 1" ); - Aos::print( aos_Vector4_2, "aos type 2" ); - Aos::print( aos_Vector4_3, "aos type 3" ); - a_Vector4 = select( a_Vector4, b_Vector4, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - a_Vector4.get4Aos( aos_Vector4_0, aos_Vector4_1, aos_Vector4_2, aos_Vector4_3 ); - Aos::print( aos_Vector4_0, "select 0" ); - Aos::print( aos_Vector4_1, "select 1" ); - Aos::print( aos_Vector4_2, "select 2" ); - Aos::print( aos_Vector4_3, "select 3" ); - a_Vector4 = b_Vector4; - print( a_Vector4, "assign to Vector4 from Vector4" ); - a_Vector4.setXYZ( a_Vector3 ); - print( a_Vector4, "set Vector4 xyz" ); - print( a_Vector4.getXYZ( ), "get Vector4 xyz" ); - a_Vector4 = Vector4( (vec_float4){0.0f} ); - print( a_Vector4, "set Vector4 elements to zero" ); - a_Vector4 = Vector4::xAxis( ); - print( a_Vector4, "set to x axis" ); - a_Vector4 = Vector4::yAxis( ); - print( a_Vector4, "set to y axis" ); - a_Vector4 = Vector4::zAxis( ); - print( a_Vector4, "set to z axis" ); - a_Vector4 = Vector4::wAxis( ); - print( a_Vector4, "set to w axis" ); - a_Vector4.setElem( 0, randfloat() ); - print( a_Vector4, "Vector4::set( 0, float )" ); - a_Vector4[0] = randfloat(); - a_Vector4[0] = vec_mul_float( a_Vector4[0], randfloat() ); - a_Vector4[0] = divf4( a_Vector4[0], randfloat() ); - a_Vector4[0] = vec_add_float( a_Vector4[0], randfloat() ); - a_Vector4[0] = vec_sub_float( a_Vector4[0], randfloat() ); - print( a_Vector4, "Vector4::operator [](0)" ); - a_Vector4.setX( randfloat() ); - print( a_Vector4, "Vector4::setX()" ); - a_Vector4.setElem( 1, randfloat() ); - print( a_Vector4, "Vector4::set( 1, float )" ); - a_Vector4[1] = randfloat(); - a_Vector4[1] = vec_mul_float( a_Vector4[1], randfloat() ); - a_Vector4[1] = divf4( a_Vector4[1], randfloat() ); - a_Vector4[1] = vec_add_float( a_Vector4[1], randfloat() ); - a_Vector4[1] = vec_sub_float( a_Vector4[1], randfloat() ); - print( a_Vector4, "Vector4::operator [](1)" ); - a_Vector4.setY( randfloat() ); - print( a_Vector4, "Vector4::setY()" ); - a_Vector4.setElem( 2, randfloat() ); - print( a_Vector4, "Vector4::set( 2, float )" ); - a_Vector4[2] = randfloat(); - a_Vector4[2] = vec_mul_float( a_Vector4[2], randfloat() ); - a_Vector4[2] = divf4( a_Vector4[2], randfloat() ); - a_Vector4[2] = vec_add_float( a_Vector4[2], randfloat() ); - a_Vector4[2] = vec_sub_float( a_Vector4[2], randfloat() ); - print( a_Vector4, "Vector4::operator [](2)" ); - a_Vector4.setZ( randfloat() ); - print( a_Vector4, "Vector4::setZ()" ); - a_Vector4.setElem( 3, randfloat() ); - print( a_Vector4, "Vector4::set( 3, float )" ); - a_Vector4[3] = randfloat(); - a_Vector4[3] = vec_mul_float( a_Vector4[3], randfloat() ); - a_Vector4[3] = divf4( a_Vector4[3], randfloat() ); - a_Vector4[3] = vec_add_float( a_Vector4[3], randfloat() ); - a_Vector4[3] = vec_sub_float( a_Vector4[3], randfloat() ); - print( a_Vector4, "Vector4::operator [](3)" ); - a_Vector4.setW( randfloat() ); - print( a_Vector4, "Vector4::setW()" ); - printf("Vector4::get( 0 ): %f\n", getfloat(a_Vector4.getElem( 0 )) ); - printf("Vector4::operator []( 0 ): %f\n", getfloat((vec_float4)a_Vector4[0]) ); - printf("Vector4::getX(): %f\n", getfloat(a_Vector4.getX( )) ); - printf("Vector4::get( 1 ): %f\n", getfloat(a_Vector4.getElem( 1 )) ); - printf("Vector4::operator []( 1 ): %f\n", getfloat((vec_float4)a_Vector4[1]) ); - printf("Vector4::getY(): %f\n", getfloat(a_Vector4.getY( )) ); - printf("Vector4::get( 2 ): %f\n", getfloat(a_Vector4.getElem( 2 )) ); - printf("Vector4::operator []( 2 ): %f\n", getfloat((vec_float4)a_Vector4[2]) ); - printf("Vector4::getZ(): %f\n", getfloat(a_Vector4.getZ( )) ); - printf("Vector4::get( 3 ): %f\n", getfloat(a_Vector4.getElem( 3 )) ); - printf("Vector4::operator []( 3 ): %f\n", getfloat((vec_float4)a_Vector4[3]) ); - printf("Vector4::getW(): %f\n", getfloat(a_Vector4.getW( )) ); - print( ( a_Vector4 + b_Vector4 ), "Vector4 + Vector4" ); - print( ( a_Vector4 - b_Vector4 ), "Vector4 - Vector4" ); - print( ( a_Vector4 * randfloat() ), "Vector4 * float" ); - print( ( a_Vector4 / randfloat() ), "Vector4 / float" ); - print( ( randfloat() * a_Vector4 ), "float * Vector4" ); - print( ( -a_Vector4 ), "Vector4 negate" ); - print( mulPerElem( a_Vector4, b_Vector4 ), "mulPerElem( Vector4, Vector4 )" ); - print( divPerElem( a_Vector4, b_Vector4 ), "divPerElem( Vector4, Vector4 )" ); - print( recipPerElem( a_Vector4 ), "Vector4 recip" ); - print( sqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Vector4 ) ), "Vector4 rsqrt" ); - print( absPerElem( a_Vector4 ), "Vector4 abs" ); - print( copySignPerElem( a_Vector4, b_Vector4 ), "Vector4 copySign" ); - print( maxPerElem( a_Vector4, b_Vector4 ), "Vector4 maximum Vector4" ); - print( minPerElem( a_Vector4, b_Vector4 ), "Vector4 minimum Vector4" ); - printf("Vector4 maximum of elements: %f\n", getfloat(maxElem( a_Vector4 ))); - printf("Vector4 minimum of elements: %f\n", getfloat(minElem( a_Vector4 ))); - printf("Vector4 sum of elements: %f\n", getfloat(sum( a_Vector4 ))); - printf("Vector4 dot Vector4: %f\n", getfloat(dot( a_Vector4, b_Vector4 ))); - printf("Vector4 lengthSqr: %f\n", getfloat(lengthSqr( a_Vector4 ))); - printf("Vector4 length: %f\n", getfloat(length( a_Vector4 ))); - print( normalize( a_Vector4 ), "Vector4 normalized" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - e_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - b_Vector4 = normalize( b_Vector4 ); - c_Vector4 = normalize( c_Vector4 ); - d_Vector4 = normalize( d_Vector4 ); - e_Vector4 = normalize( e_Vector4 ); - a_Vector4 = lerp( randfloat(), b_Vector4, c_Vector4 ); - print( a_Vector4, "Vector4 lerp" ); - a_Vector4 = slerp( randfloat(), b_Vector4, c_Vector4 ); - print( a_Vector4, "Vector4 slerp" ); -} - -void -Point3_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Aos::Point3 aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3; - Point3 soa_Point3; - Aos::Vector4 aos_Vector4_0, aos_Vector4_1, aos_Vector4_2; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - float xyz4[12] __attribute__ ((aligned(16))); - xyz4[0] = getfloat(randfloat()); - xyz4[1] = getfloat(randfloat()); - xyz4[2] = getfloat(randfloat()); - xyz4[3] = getfloat(randfloat()); - xyz4[4] = getfloat(randfloat()); - xyz4[5] = getfloat(randfloat()); - xyz4[6] = getfloat(randfloat()); - xyz4[7] = getfloat(randfloat()); - xyz4[8] = getfloat(randfloat()); - xyz4[9] = getfloat(randfloat()); - xyz4[10] = getfloat(randfloat()); - xyz4[11] = getfloat(randfloat()); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( (vec_float4){0.0f} ); - d_Vector3 = Vector3( (vec_float4){0.0f} ); - e_Vector3 = Vector3( (vec_float4){0.0f} ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( (vec_float4){0.0f} ); - d_Vector4 = Vector4( (vec_float4){0.0f} ); - e_Vector4 = Vector4( (vec_float4){0.0f} ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( (vec_float4){0.0f} ); - d_Point3 = Point3( (vec_float4){0.0f} ); - e_Point3 = Point3( (vec_float4){0.0f} ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( (vec_float4){0.0f} ); - d_Quat = Quat( (vec_float4){0.0f} ); - e_Quat = Quat( (vec_float4){0.0f} ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Point3 = Point3( a_Vector3 ); - print( a_Point3, "construct Point3 with Vector3" ); - a_Point3 = Point3( randfloat() ); - print( a_Point3, "set Point3 with float" ); - a_Point3 = Point3( randfloat() ); - print( a_Point3, "set Point3 with float" ); - aos_Point3_0 = Aos::Point3( 0.0f, 1.0f, 2.0f ); - aos_Point3_1 = Aos::Point3( 3.0f, 4.0f, 5.0f ); - aos_Point3_2 = Aos::Point3( 6.0f, 7.0f, 8.0f ); - aos_Point3_3 = Aos::Point3( 9.0f, 10.0f, 11.0f ); - soa_Point3 = Point3( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 ); - soa_Point3.get4Aos( aos_Point3_3, aos_Point3_2, aos_Point3_1, aos_Point3_0 ); - Aos::print( aos_Point3_0, "aos type 0" ); - Aos::print( aos_Point3_1, "aos type 1" ); - Aos::print( aos_Point3_2, "aos type 2" ); - Aos::print( aos_Point3_3, "aos type 3" ); - a_Point3 = select( a_Point3, b_Point3, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - a_Point3.get4Aos( aos_Point3_0, aos_Point3_1, aos_Point3_2, aos_Point3_3 ); - Aos::print( aos_Point3_0, "select 0" ); - Aos::print( aos_Point3_1, "select 1" ); - Aos::print( aos_Point3_2, "select 2" ); - Aos::print( aos_Point3_3, "select 3" ); - loadXYZArray( a_Point3, (const vec_float4 *)xyz4 ); - print( a_Point3, "load XYZ array" ); - a_Point3 = Point3( ( -Vector3( a_Point3 ) ) ); - storeXYZArray( a_Point3, (vec_float4 *)xyz4 ); - aos_Vector4_0 = Aos::Vector4( xyz4[0], xyz4[1], xyz4[2], xyz4[3] ); - aos_Vector4_1 = Aos::Vector4( xyz4[4], xyz4[5], xyz4[6], xyz4[7] ); - aos_Vector4_2 = Aos::Vector4( xyz4[8], xyz4[9], xyz4[10], xyz4[11] ); - Aos::print( aos_Vector4_0, "xyzx" ); - Aos::print( aos_Vector4_1, "yzxy" ); - Aos::print( aos_Vector4_2, "zxyz" ); - Aos::print( aos_Vector4_0, "xyzx" ); - Aos::print( aos_Vector4_1, "yzxy" ); - Aos::print( aos_Vector4_2, "zxyz" ); - printf("storeXYZ:-1.0 -2.0 -3.0 0.4\n"); - a_Point3 = b_Point3; - print( a_Point3, "assign to Point3 from Point3" ); - a_Point3 = Point3( (vec_float4){0.0f} ); - print( a_Point3, "set Point3 elements to zero" ); - a_Point3.setElem( 0, randfloat() ); - print( a_Point3, "Point3::set( 0, float )" ); - a_Point3[0] = randfloat(); - a_Point3[0] = vec_mul_float( a_Point3[0], randfloat() ); - a_Point3[0] = divf4( a_Point3[0], randfloat() ); - a_Point3[0] = vec_add_float( a_Point3[0], randfloat() ); - a_Point3[0] = vec_sub_float( a_Point3[0], randfloat() ); - print( a_Point3, "Point3::operator [](0)" ); - a_Point3.setX( randfloat() ); - print( a_Point3, "Point3::setX()" ); - a_Point3.setElem( 1, randfloat() ); - print( a_Point3, "Point3::set( 1, float )" ); - a_Point3[1] = randfloat(); - a_Point3[1] = vec_mul_float( a_Point3[1], randfloat() ); - a_Point3[1] = divf4( a_Point3[1], randfloat() ); - a_Point3[1] = vec_add_float( a_Point3[1], randfloat() ); - a_Point3[1] = vec_sub_float( a_Point3[1], randfloat() ); - print( a_Point3, "Point3::operator [](1)" ); - a_Point3.setY( randfloat() ); - print( a_Point3, "Point3::setY()" ); - a_Point3.setElem( 2, randfloat() ); - print( a_Point3, "Point3::set( 2, float )" ); - a_Point3[2] = randfloat(); - a_Point3[2] = vec_mul_float( a_Point3[2], randfloat() ); - a_Point3[2] = divf4( a_Point3[2], randfloat() ); - a_Point3[2] = vec_add_float( a_Point3[2], randfloat() ); - a_Point3[2] = vec_sub_float( a_Point3[2], randfloat() ); - print( a_Point3, "Point3::operator [](2)" ); - a_Point3.setZ( randfloat() ); - print( a_Point3, "Point3::setZ()" ); - printf("Point3::get( 0 ): %f\n", getfloat(a_Point3.getElem( 0 )) ); - printf("Point3::operator []( 0 ): %f\n", getfloat((vec_float4)a_Point3[0]) ); - printf("Point3::getX(): %f\n", getfloat(a_Point3.getX( )) ); - printf("Point3::get( 1 ): %f\n", getfloat(a_Point3.getElem( 1 )) ); - printf("Point3::operator []( 1 ): %f\n", getfloat((vec_float4)a_Point3[1]) ); - printf("Point3::getY(): %f\n", getfloat(a_Point3.getY( )) ); - printf("Point3::get( 2 ): %f\n", getfloat(a_Point3.getElem( 2 )) ); - printf("Point3::operator []( 2 ): %f\n", getfloat((vec_float4)a_Point3[2]) ); - printf("Point3::getZ(): %f\n", getfloat(a_Point3.getZ( )) ); - print( ( a_Point3 - b_Point3 ), "Point3 - Point3" ); - print( ( a_Point3 + b_Vector3 ), "Point3 + Vector3" ); - print( ( a_Point3 - b_Vector3 ), "Point3 - Vector3" ); - print( mulPerElem( a_Point3, b_Point3 ), "mulPerElem( Point3, Point3 )" ); - print( divPerElem( a_Point3, b_Point3 ), "divPerElem( Point3, Point3 )" ); - print( recipPerElem( a_Point3 ), "Point3 recip" ); - print( sqrtPerElem( absPerElem( a_Point3 ) ), "Point3 sqrt" ); - print( rsqrtPerElem( absPerElem( a_Point3 ) ), "Point3 rsqrt" ); - print( absPerElem( a_Point3 ), "Point3 abs" ); - print( copySignPerElem( a_Point3, b_Point3 ), "Point3 copySign" ); - print( maxPerElem( a_Point3, b_Point3 ), "Point3 maximum Point3" ); - print( minPerElem( a_Point3, b_Point3 ), "Point3 minimum Point3" ); - printf("Point3 maximum of elements: %f\n", getfloat(maxElem( a_Point3 ))); - printf("Point3 minimum of elements: %f\n", getfloat(minElem( a_Point3 ))); - printf("Point3 sum of elements: %f\n", getfloat(sum( a_Point3 ))); - printf("Point projection: %f\n", getfloat(projection( a_Point3, b_Vector3 ))); - printf("Point distSqrFromOrigin: %f\n", getfloat(distSqrFromOrigin( a_Point3 )) ); - printf("Point distFromOrigin: %f\n", getfloat(distFromOrigin( a_Point3 )) ); - printf("Point distSqr: %f\n", getfloat(distSqr( a_Point3, b_Point3 )) ); - printf("Point dist: %f\n", getfloat(dist( a_Point3, b_Point3 )) ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - e_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - a_Point3 = lerp( randfloat(), b_Point3, c_Point3 ); - print( a_Point3, "Point3 lerp" ); -} - -void -Quat_methods_test() -{ - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3, e_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4, e_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3, e_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat, e_Quat; - Aos::Quat aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3; - Quat soa_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - c_Vector3 = Vector3( (vec_float4){0.0f} ); - d_Vector3 = Vector3( (vec_float4){0.0f} ); - e_Vector3 = Vector3( (vec_float4){0.0f} ); - print( c_Vector3, "set Vector3 elements to zero" ); - print( d_Vector3, "set Vector3 elements to zero" ); - print( e_Vector3, "set Vector3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - c_Vector4 = Vector4( (vec_float4){0.0f} ); - d_Vector4 = Vector4( (vec_float4){0.0f} ); - e_Vector4 = Vector4( (vec_float4){0.0f} ); - print( c_Vector4, "set Vector4 elements to zero" ); - print( d_Vector4, "set Vector4 elements to zero" ); - print( e_Vector4, "set Vector4 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - b_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - c_Point3 = Point3( (vec_float4){0.0f} ); - d_Point3 = Point3( (vec_float4){0.0f} ); - e_Point3 = Point3( (vec_float4){0.0f} ); - print( c_Point3, "set Point3 elements to zero" ); - print( d_Point3, "set Point3 elements to zero" ); - print( e_Point3, "set Point3 elements to zero" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - c_Quat = Quat( (vec_float4){0.0f} ); - d_Quat = Quat( (vec_float4){0.0f} ); - e_Quat = Quat( (vec_float4){0.0f} ); - print( c_Quat, "set Quat elements to zero" ); - print( d_Quat, "set Quat elements to zero" ); - print( e_Quat, "set Quat elements to zero" ); - a_Quat = Quat( a_Vector3, randfloat() ); - print( a_Quat, "set Quat with Vector3, float" ); - a_Quat = Quat( a_Vector4 ); - print( a_Quat, "construct Quat with Vector4" ); - a_Quat = Quat( randfloat() ); - print( a_Quat, "set Quat with float" ); - a_Quat = Quat( randfloat() ); - print( a_Quat, "set Quat with float" ); - aos_Quat_0 = Aos::Quat( 0.0f, 1.0f, 2.0f, 3.0f ); - aos_Quat_1 = Aos::Quat( 4.0f, 5.0f, 6.0f, 7.0f ); - aos_Quat_2 = Aos::Quat( 8.0f, 9.0f, 10.0f, 11.0f ); - aos_Quat_3 = Aos::Quat( 12.0f, 13.0f, 14.0f, 15.0f ); - soa_Quat = Quat( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 ); - soa_Quat.get4Aos( aos_Quat_3, aos_Quat_2, aos_Quat_1, aos_Quat_0 ); - Aos::print( aos_Quat_0, "aos type 0" ); - Aos::print( aos_Quat_1, "aos type 1" ); - Aos::print( aos_Quat_2, "aos type 2" ); - Aos::print( aos_Quat_3, "aos type 3" ); - a_Quat = select( a_Quat, b_Quat, ((vec_uint4){0,0xffffffff,0,0xffffffff}) ); - a_Quat.get4Aos( aos_Quat_0, aos_Quat_1, aos_Quat_2, aos_Quat_3 ); - Aos::print( aos_Quat_0, "select 0" ); - Aos::print( aos_Quat_1, "select 1" ); - Aos::print( aos_Quat_2, "select 2" ); - Aos::print( aos_Quat_3, "select 3" ); - a_Quat = b_Quat; - print( a_Quat, "assign to Quat from Quat" ); - a_Quat.setXYZ( a_Vector3 ); - print( a_Quat, "set Quat xyz" ); - print( a_Quat.getXYZ( ), "get Quat xyz" ); - a_Quat = Quat( (vec_float4){0.0f} ); - print( a_Quat, "set Quat elements to zero" ); - a_Quat.setElem( 0, randfloat() ); - print( a_Quat, "Quat::set( 0, float )" ); - a_Quat[0] = randfloat(); - a_Quat[0] = vec_mul_float( a_Quat[0], randfloat() ); - a_Quat[0] = divf4( a_Quat[0], randfloat() ); - a_Quat[0] = vec_add_float( a_Quat[0], randfloat() ); - a_Quat[0] = vec_sub_float( a_Quat[0], randfloat() ); - print( a_Quat, "Quat::operator [](0)" ); - a_Quat.setX( randfloat() ); - print( a_Quat, "Quat::setX()" ); - a_Quat.setElem( 1, randfloat() ); - print( a_Quat, "Quat::set( 1, float )" ); - a_Quat[1] = randfloat(); - a_Quat[1] = vec_mul_float( a_Quat[1], randfloat() ); - a_Quat[1] = divf4( a_Quat[1], randfloat() ); - a_Quat[1] = vec_add_float( a_Quat[1], randfloat() ); - a_Quat[1] = vec_sub_float( a_Quat[1], randfloat() ); - print( a_Quat, "Quat::operator [](1)" ); - a_Quat.setY( randfloat() ); - print( a_Quat, "Quat::setY()" ); - a_Quat.setElem( 2, randfloat() ); - print( a_Quat, "Quat::set( 2, float )" ); - a_Quat[2] = randfloat(); - a_Quat[2] = vec_mul_float( a_Quat[2], randfloat() ); - a_Quat[2] = divf4( a_Quat[2], randfloat() ); - a_Quat[2] = vec_add_float( a_Quat[2], randfloat() ); - a_Quat[2] = vec_sub_float( a_Quat[2], randfloat() ); - print( a_Quat, "Quat::operator [](2)" ); - a_Quat.setZ( randfloat() ); - print( a_Quat, "Quat::setZ()" ); - a_Quat.setElem( 3, randfloat() ); - print( a_Quat, "Quat::set( 3, float )" ); - a_Quat[3] = randfloat(); - a_Quat[3] = vec_mul_float( a_Quat[3], randfloat() ); - a_Quat[3] = divf4( a_Quat[3], randfloat() ); - a_Quat[3] = vec_add_float( a_Quat[3], randfloat() ); - a_Quat[3] = vec_sub_float( a_Quat[3], randfloat() ); - print( a_Quat, "Quat::operator [](3)" ); - a_Quat.setW( randfloat() ); - print( a_Quat, "Quat::setW()" ); - printf("Quat::get( 0 ): %f\n", getfloat(a_Quat.getElem( 0 )) ); - printf("Quat::operator []( 0 ): %f\n", getfloat((vec_float4)a_Quat[0]) ); - printf("Quat::getX(): %f\n", getfloat(a_Quat.getX( )) ); - printf("Quat::get( 1 ): %f\n", getfloat(a_Quat.getElem( 1 )) ); - printf("Quat::operator []( 1 ): %f\n", getfloat((vec_float4)a_Quat[1]) ); - printf("Quat::getY(): %f\n", getfloat(a_Quat.getY( )) ); - printf("Quat::get( 2 ): %f\n", getfloat(a_Quat.getElem( 2 )) ); - printf("Quat::operator []( 2 ): %f\n", getfloat((vec_float4)a_Quat[2]) ); - printf("Quat::getZ(): %f\n", getfloat(a_Quat.getZ( )) ); - printf("Quat::get( 3 ): %f\n", getfloat(a_Quat.getElem( 3 )) ); - printf("Quat::operator []( 3 ): %f\n", getfloat((vec_float4)a_Quat[3]) ); - printf("Quat::getW(): %f\n", getfloat(a_Quat.getW( )) ); - print( ( a_Quat + b_Quat ), "Quat + Quat" ); - print( ( a_Quat - b_Quat ), "Quat - Quat" ); - print( ( a_Quat * b_Quat ), "Quat * Quat" ); - print( ( a_Quat * randfloat() ), "Quat * float" ); - print( ( a_Quat / randfloat() ), "Quat / float" ); - print( ( randfloat() * a_Quat ), "float * Quat" ); - print( ( -a_Quat ), "Quat negate" ); - printf("Quat dot Quat: %f\n", getfloat(dot( a_Quat, b_Quat ))); - printf("Quat lengthSqr: %f\n", getfloat(norm( a_Quat ))); - printf("Quat length: %f\n", getfloat(length( a_Quat ))); - print( normalize( a_Quat ), "Quat normalized" ); - a_Quat = Quat::identity( ); - print( a_Quat, "set to identity" ); - a_Quat = Quat::rotation( a_Vector3, b_Vector3 ); - print( a_Quat, "Quat rotation between vectors" ); - a_Quat = Quat::rotation( randfloat(), a_Vector3 ); - print( a_Quat, "Quat rotation axis angle" ); - a_Quat = Quat::rotationX( randfloat() ); - print( a_Quat, "Quat rotationX" ); - a_Quat = Quat::rotationY( randfloat() ); - print( a_Quat, "Quat rotationY" ); - a_Quat = Quat::rotationZ( randfloat() ); - print( a_Quat, "Quat rotationZ" ); - print( rotate( a_Quat, a_Vector3 ), "Quat rotate Vector3" ); - print( conj( a_Quat ), "Quat conj" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - b_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - e_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - b_Quat = normalize( b_Quat ); - c_Quat = normalize( c_Quat ); - d_Quat = normalize( d_Quat ); - e_Quat = normalize( e_Quat ); - a_Quat = lerp( randfloat(), b_Quat, c_Quat ); - print( a_Quat, "Quat lerp" ); - a_Quat = slerp( randfloat(), b_Quat, c_Quat ); - print( a_Quat, "Quat slerp" ); - a_Quat = squad( randfloat(), b_Quat, c_Quat, d_Quat, e_Quat ); - print( a_Quat, "Quat squad" ); -} - -int main() -{ - printf("\n __begin__ \n"); - for ( iteration = 0; iteration < 2; iteration++ ) { - Vector3_methods_test(); - Vector4_methods_test(); - Point3_methods_test(); - Quat_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test2_aos_c.c b/Extras/vectormathlibrary/tests/test2_aos_c.c deleted file mode 100644 index 27acec0a1..000000000 --- a/Extras/vectormathlibrary/tests/test2_aos_c.c +++ /dev/null @@ -1,852 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; - VmathQuat tmpQ_0; - VmathVector3 tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17, tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathQNormalize( &tmpQ_0, &a_Quat ); - vmathM3MakeFromQ( &a_Matrix3, &tmpQ_0 ); - vmathM3Prints( &a_Matrix3, "construct Matrix3 with Quat" ); - vmathQMakeFromM3( &a_Quat, &a_Matrix3 ); - vmathQPrints( &a_Quat, "construct Quat with Matrix3" ); - vmathM3Copy( &a_Matrix3, &b_Matrix3 ); - vmathM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" ); - vmathM3MakeFromScalar( &a_Matrix3, randfloat() ); - vmathM3Prints( &a_Matrix3, "set Matrix3 with float" ); - vmathM3MakeFromScalar( &a_Matrix3, randfloat() ); - vmathM3Prints( &a_Matrix3, "set Matrix3 with float" ); - vmathM3MakeFromScalar( &a_Matrix3, 0.0f ); - vmathM3Prints( &a_Matrix3, "set elements to zero" ); - vmathM3MakeIdentity( &a_Matrix3 ); - vmathM3Prints( &a_Matrix3, "set to identity" ); - vmathM3MakeRotationX( &a_Matrix3, randfloat() ); - vmathM3Prints( &a_Matrix3, "set to rotationX" ); - vmathM3MakeRotationY( &a_Matrix3, randfloat() ); - vmathM3Prints( &a_Matrix3, "set to rotationY" ); - vmathM3MakeRotationZ( &a_Matrix3, randfloat() ); - vmathM3Prints( &a_Matrix3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); - vmathM3MakeRotationZYX( &a_Matrix3, &tmpV3_8 ); - vmathM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" ); - vmathV3Normalize( &tmpV3_9, &a_Vector3 ); - vmathM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_9 ); - vmathM3Prints( &a_Matrix3, "set to rotation from axis angle" ); - vmathM3SetCol0( &a_Matrix3, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" ); - vmathM3SetCol1( &a_Matrix3, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" ); - vmathM3SetCol2( &a_Matrix3, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" ); - vmathM3GetCol0( &tmpV3_10, &a_Matrix3 ); - vmathV3Prints( &tmpV3_10, "Matrix3 get col 0" ); - vmathM3GetCol1( &tmpV3_11, &a_Matrix3 ); - vmathV3Prints( &tmpV3_11, "Matrix3 get col 1" ); - vmathM3GetCol2( &tmpV3_12, &a_Matrix3 ); - vmathV3Prints( &tmpV3_12, "Matrix3 get col 2" ); - vmathM3SetCol( &a_Matrix3, 0, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 0" ); - vmathM3SetCol( &a_Matrix3, 1, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 1" ); - vmathM3SetCol( &a_Matrix3, 2, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set col 2" ); - vmathM3GetCol( &tmpV3_13, &a_Matrix3, 0 ); - vmathV3Prints( &tmpV3_13, "Matrix3 get col 0" ); - vmathM3GetCol( &tmpV3_14, &a_Matrix3, 1 ); - vmathV3Prints( &tmpV3_14, "Matrix3 get col 1" ); - vmathM3GetCol( &tmpV3_15, &a_Matrix3, 2 ); - vmathV3Prints( &tmpV3_15, "Matrix3 get col 2" ); - vmathM3SetRow( &a_Matrix3, 0, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set row 0" ); - vmathM3SetRow( &a_Matrix3, 1, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set row 1" ); - vmathM3SetRow( &a_Matrix3, 2, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "Matrix3 set row 2" ); - vmathM3GetRow( &tmpV3_16, &a_Matrix3, 0 ); - vmathV3Prints( &tmpV3_16, "Matrix3 get row 0" ); - vmathM3GetRow( &tmpV3_17, &a_Matrix3, 1 ); - vmathV3Prints( &tmpV3_17, "Matrix3 get row 1" ); - vmathM3GetRow( &tmpV3_18, &a_Matrix3, 2 ); - vmathV3Prints( &tmpV3_18, "Matrix3 get row 2" ); - vmathM3SetCol( &a_Matrix3, 0, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "set " ); - vmathM3SetCol( &a_Matrix3, 1, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "set " ); - vmathM3SetCol( &a_Matrix3, 2, &a_Vector3 ); - vmathM3Prints( &a_Matrix3, "set " ); - vmathM3GetCol( &tmpV3_19, &a_Matrix3, 0 ); - vmathV3Prints( &tmpV3_19, "get " ); - vmathM3GetCol( &tmpV3_20, &a_Matrix3, 1 ); - vmathV3Prints( &tmpV3_20, "get " ); - vmathM3GetCol( &tmpV3_21, &a_Matrix3, 2 ); - vmathV3Prints( &tmpV3_21, "get " ); - vmathM3SetElem( &a_Matrix3, 0, 0, randfloat() ); - vmathM3SetElem( &a_Matrix3, 0, 1, randfloat() ); - vmathM3SetElem( &a_Matrix3, 0, 2, randfloat() ); - vmathM3SetElem( &a_Matrix3, 1, 0, randfloat() ); - vmathM3SetElem( &a_Matrix3, 1, 1, randfloat() ); - vmathM3SetElem( &a_Matrix3, 1, 2, randfloat() ); - vmathM3SetElem( &a_Matrix3, 2, 0, randfloat() ); - vmathM3SetElem( &a_Matrix3, 2, 1, randfloat() ); - vmathM3SetElem( &a_Matrix3, 2, 2, randfloat() ); - vmathM3Prints( &a_Matrix3, "Matrix3 set elements" ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 0 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 1 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 0, 2 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 0 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 1 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 1, 2 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 0 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 1 )) ); - printf("%f\n", getfloat(vmathM3GetElem( &a_Matrix3, 2, 2 )) ); -} - -void -Matrix4_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathM4MakeFromT3( &a_Matrix4, &a_Transform3 ); - vmathM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" ); - vmathM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 ); - vmathM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); - vmathM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 ); - vmathM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" ); - vmathM4Copy( &a_Matrix4, &b_Matrix4 ); - vmathM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" ); - vmathM4MakeFromScalar( &a_Matrix4, randfloat() ); - vmathM4Prints( &a_Matrix4, "set Matrix4 with float" ); - vmathM4MakeFromScalar( &a_Matrix4, randfloat() ); - vmathM4Prints( &a_Matrix4, "set Matrix4 with float" ); - vmathM4MakeFromScalar( &a_Matrix4, 0.0f ); - vmathM4Prints( &a_Matrix4, "set elements to zero" ); - vmathM4MakeIdentity( &a_Matrix4 ); - vmathM4Prints( &a_Matrix4, "set to identity" ); - vmathM4MakeRotationX( &a_Matrix4, randfloat() ); - vmathM4Prints( &a_Matrix4, "set to rotationX" ); - vmathM4MakeRotationY( &a_Matrix4, randfloat() ); - vmathM4Prints( &a_Matrix4, "set to rotationY" ); - vmathM4MakeRotationZ( &a_Matrix4, randfloat() ); - vmathM4Prints( &a_Matrix4, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); - vmathM4MakeRotationZYX( &a_Matrix4, &tmpV3_8 ); - vmathM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" ); - vmathV3Normalize( &tmpV3_9, &a_Vector3 ); - vmathM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_9 ); - vmathM4Prints( &a_Matrix4, "set to rotation from axis angle" ); - vmathM4MakeTranslation( &a_Matrix4, &a_Vector3 ); - vmathM4Prints( &a_Matrix4, "set to translation" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathM4Prints( &a_Matrix4, "set to perspective matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - vmathM4Prints( &a_Matrix4, "set to frustum matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - vmathM4Prints( &a_Matrix4, "set to orthographic matrix" ); - vmathM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 ); - vmathM4Prints( &a_Matrix4, "set to look-at matrix" ); - vmathM4SetCol0( &a_Matrix4, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" ); - vmathM4SetCol1( &a_Matrix4, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" ); - vmathM4SetCol2( &a_Matrix4, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" ); - vmathM4SetCol3( &a_Matrix4, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" ); - vmathM4GetCol0( &tmpV4_0, &a_Matrix4 ); - vmathV4Prints( &tmpV4_0, "Matrix4 get col 0" ); - vmathM4GetCol1( &tmpV4_1, &a_Matrix4 ); - vmathV4Prints( &tmpV4_1, "Matrix4 get col 1" ); - vmathM4GetCol2( &tmpV4_2, &a_Matrix4 ); - vmathV4Prints( &tmpV4_2, "Matrix4 get col 2" ); - vmathM4GetCol3( &tmpV4_3, &a_Matrix4 ); - vmathV4Prints( &tmpV4_3, "Matrix4 get col 3" ); - vmathM4SetCol( &a_Matrix4, 0, &b_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 0" ); - vmathM4SetCol( &a_Matrix4, 1, &b_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 1" ); - vmathM4SetCol( &a_Matrix4, 2, &b_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 2" ); - vmathM4SetCol( &a_Matrix4, 3, &b_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set col 3" ); - vmathM4GetCol( &tmpV4_4, &a_Matrix4, 0 ); - vmathV4Prints( &tmpV4_4, "Matrix4 get col 0" ); - vmathM4GetCol( &tmpV4_5, &a_Matrix4, 1 ); - vmathV4Prints( &tmpV4_5, "Matrix4 get col 1" ); - vmathM4GetCol( &tmpV4_6, &a_Matrix4, 2 ); - vmathV4Prints( &tmpV4_6, "Matrix4 get col 2" ); - vmathM4GetCol( &tmpV4_7, &a_Matrix4, 3 ); - vmathV4Prints( &tmpV4_7, "Matrix4 get col 3" ); - vmathM4SetRow( &a_Matrix4, 0, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set row 0" ); - vmathM4SetRow( &a_Matrix4, 1, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set row 1" ); - vmathM4SetRow( &a_Matrix4, 2, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set row 2" ); - vmathM4SetRow( &a_Matrix4, 3, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "Matrix4 set row 3" ); - vmathM4GetRow( &tmpV4_8, &a_Matrix4, 0 ); - vmathV4Prints( &tmpV4_8, "Matrix4 get row 0" ); - vmathM4GetRow( &tmpV4_9, &a_Matrix4, 1 ); - vmathV4Prints( &tmpV4_9, "Matrix4 get row 1" ); - vmathM4GetRow( &tmpV4_10, &a_Matrix4, 2 ); - vmathV4Prints( &tmpV4_10, "Matrix4 get row 2" ); - vmathM4GetRow( &tmpV4_11, &a_Matrix4, 3 ); - vmathV4Prints( &tmpV4_11, "Matrix4 get row 3" ); - vmathM4SetCol( &a_Matrix4, 0, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "set " ); - vmathM4SetCol( &a_Matrix4, 1, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "set " ); - vmathM4SetCol( &a_Matrix4, 2, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "set " ); - vmathM4SetCol( &a_Matrix4, 3, &a_Vector4 ); - vmathM4Prints( &a_Matrix4, "set " ); - vmathM4GetCol( &tmpV4_12, &a_Matrix4, 0 ); - vmathV4Prints( &tmpV4_12, "get " ); - vmathM4GetCol( &tmpV4_13, &a_Matrix4, 1 ); - vmathV4Prints( &tmpV4_13, "get " ); - vmathM4GetCol( &tmpV4_14, &a_Matrix4, 2 ); - vmathV4Prints( &tmpV4_14, "get " ); - vmathM4GetCol( &tmpV4_15, &a_Matrix4, 3 ); - vmathV4Prints( &tmpV4_15, "get " ); - vmathM4SetElem( &a_Matrix4, 0, 0, randfloat() ); - vmathM4SetElem( &a_Matrix4, 0, 1, randfloat() ); - vmathM4SetElem( &a_Matrix4, 0, 2, randfloat() ); - vmathM4SetElem( &a_Matrix4, 0, 3, randfloat() ); - vmathM4SetElem( &a_Matrix4, 1, 0, randfloat() ); - vmathM4SetElem( &a_Matrix4, 1, 1, randfloat() ); - vmathM4SetElem( &a_Matrix4, 1, 2, randfloat() ); - vmathM4SetElem( &a_Matrix4, 1, 3, randfloat() ); - vmathM4SetElem( &a_Matrix4, 2, 0, randfloat() ); - vmathM4SetElem( &a_Matrix4, 2, 1, randfloat() ); - vmathM4SetElem( &a_Matrix4, 2, 2, randfloat() ); - vmathM4SetElem( &a_Matrix4, 2, 3, randfloat() ); - vmathM4SetElem( &a_Matrix4, 3, 0, randfloat() ); - vmathM4SetElem( &a_Matrix4, 3, 1, randfloat() ); - vmathM4SetElem( &a_Matrix4, 3, 2, randfloat() ); - vmathM4SetElem( &a_Matrix4, 3, 3, randfloat() ); - vmathM4Prints( &a_Matrix4, "Matrix4 set elements" ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 0 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 1 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 2 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 0, 3 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 0 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 1 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 2 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 1, 3 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 0 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 1 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 2 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 2, 3 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 0 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 1 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 2 )) ); - printf("%f\n", getfloat(vmathM4GetElem( &a_Matrix4, 3, 3 )) ); -} - -void -Transform3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13, tmpV3_14, tmpV3_15, tmpV3_16, tmpV3_17; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; - VmathVector3 tmpV3_18, tmpV3_19, tmpV3_20, tmpV3_21; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); - vmathT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" ); - vmathT3Copy( &a_Transform3, &b_Transform3 ); - vmathT3Prints( &a_Transform3, "assign to Transform3 from Transform3" ); - vmathT3MakeFromScalar( &a_Transform3, randfloat() ); - vmathT3Prints( &a_Transform3, "set Transform3 with float" ); - vmathT3MakeFromScalar( &a_Transform3, randfloat() ); - vmathT3Prints( &a_Transform3, "set Transform3 with float" ); - vmathT3MakeFromScalar( &a_Transform3, 0.0f ); - vmathT3Prints( &a_Transform3, "set elements to zero" ); - vmathT3MakeIdentity( &a_Transform3 ); - vmathT3Prints( &a_Transform3, "set to identity" ); - vmathT3MakeRotationX( &a_Transform3, randfloat() ); - vmathT3Prints( &a_Transform3, "set to rotationX" ); - vmathT3MakeRotationY( &a_Transform3, randfloat() ); - vmathT3Prints( &a_Transform3, "set to rotationY" ); - vmathT3MakeRotationZ( &a_Transform3, randfloat() ); - vmathT3Prints( &a_Transform3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &tmpV3_8, rndflt3, rndflt2, rndflt1 ); - vmathT3MakeRotationZYX( &a_Transform3, &tmpV3_8 ); - vmathT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" ); - vmathV3Normalize( &tmpV3_9, &a_Vector3 ); - vmathT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_9 ); - vmathT3Prints( &a_Transform3, "set to rotation from axis angle" ); - vmathT3MakeTranslation( &a_Transform3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "set to translation" ); - vmathT3SetCol0( &a_Transform3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 0" ); - vmathT3SetCol1( &a_Transform3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 1" ); - vmathT3SetCol2( &a_Transform3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 2" ); - vmathT3SetCol3( &a_Transform3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 3" ); - vmathT3GetCol0( &tmpV3_10, &a_Transform3 ); - vmathV3Prints( &tmpV3_10, "Transform3 get col 0" ); - vmathT3GetCol1( &tmpV3_11, &a_Transform3 ); - vmathV3Prints( &tmpV3_11, "Transform3 get col 1" ); - vmathT3GetCol2( &tmpV3_12, &a_Transform3 ); - vmathV3Prints( &tmpV3_12, "Transform3 get col 2" ); - vmathT3GetCol3( &tmpV3_13, &a_Transform3 ); - vmathV3Prints( &tmpV3_13, "Transform3 get col 3" ); - vmathT3SetCol( &a_Transform3, 0, &b_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 0" ); - vmathT3SetCol( &a_Transform3, 1, &b_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 1" ); - vmathT3SetCol( &a_Transform3, 2, &b_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 2" ); - vmathT3SetCol( &a_Transform3, 3, &b_Vector3 ); - vmathT3Prints( &a_Transform3, "Transform3 set col 3" ); - vmathT3GetCol( &tmpV3_14, &a_Transform3, 0 ); - vmathV3Prints( &tmpV3_14, "Transform3 get col 0" ); - vmathT3GetCol( &tmpV3_15, &a_Transform3, 1 ); - vmathV3Prints( &tmpV3_15, "Transform3 get col 1" ); - vmathT3GetCol( &tmpV3_16, &a_Transform3, 2 ); - vmathV3Prints( &tmpV3_16, "Transform3 get col 2" ); - vmathT3GetCol( &tmpV3_17, &a_Transform3, 3 ); - vmathV3Prints( &tmpV3_17, "Transform3 get col 3" ); - vmathT3SetRow( &a_Transform3, 0, &a_Vector4 ); - vmathT3Prints( &a_Transform3, "Transform3 set row 0" ); - vmathT3SetRow( &a_Transform3, 1, &a_Vector4 ); - vmathT3Prints( &a_Transform3, "Transform3 set row 1" ); - vmathT3SetRow( &a_Transform3, 2, &a_Vector4 ); - vmathT3Prints( &a_Transform3, "Transform3 set row 2" ); - vmathT3GetRow( &tmpV4_0, &a_Transform3, 0 ); - vmathV4Prints( &tmpV4_0, "Transform3 get row 0" ); - vmathT3GetRow( &tmpV4_1, &a_Transform3, 1 ); - vmathV4Prints( &tmpV4_1, "Transform3 get row 1" ); - vmathT3GetRow( &tmpV4_2, &a_Transform3, 2 ); - vmathV4Prints( &tmpV4_2, "Transform3 get row 2" ); - vmathT3SetCol( &a_Transform3, 0, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "set " ); - vmathT3SetCol( &a_Transform3, 1, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "set " ); - vmathT3SetCol( &a_Transform3, 2, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "set " ); - vmathT3SetCol( &a_Transform3, 3, &a_Vector3 ); - vmathT3Prints( &a_Transform3, "set " ); - vmathT3GetCol( &tmpV3_18, &a_Transform3, 0 ); - vmathV3Prints( &tmpV3_18, "get " ); - vmathT3GetCol( &tmpV3_19, &a_Transform3, 1 ); - vmathV3Prints( &tmpV3_19, "get " ); - vmathT3GetCol( &tmpV3_20, &a_Transform3, 2 ); - vmathV3Prints( &tmpV3_20, "get " ); - vmathT3GetCol( &tmpV3_21, &a_Transform3, 3 ); - vmathV3Prints( &tmpV3_21, "get " ); - vmathT3SetElem( &a_Transform3, 0, 0, randfloat() ); - vmathT3SetElem( &a_Transform3, 0, 1, randfloat() ); - vmathT3SetElem( &a_Transform3, 0, 2, randfloat() ); - vmathT3SetElem( &a_Transform3, 1, 0, randfloat() ); - vmathT3SetElem( &a_Transform3, 1, 1, randfloat() ); - vmathT3SetElem( &a_Transform3, 1, 2, randfloat() ); - vmathT3SetElem( &a_Transform3, 2, 0, randfloat() ); - vmathT3SetElem( &a_Transform3, 2, 1, randfloat() ); - vmathT3SetElem( &a_Transform3, 2, 2, randfloat() ); - vmathT3SetElem( &a_Transform3, 3, 0, randfloat() ); - vmathT3SetElem( &a_Transform3, 3, 1, randfloat() ); - vmathT3SetElem( &a_Transform3, 3, 2, randfloat() ); - vmathT3Prints( &a_Transform3, "Transform3 set elements" ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 0 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 1 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 0, 2 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 0 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 1 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 1, 2 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 0 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 1 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 2, 2 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 0 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 1 )) ); - printf("%f\n", getfloat(vmathT3GetElem( &a_Transform3, 3, 2 )) ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test2_aos_cpp.cpp b/Extras/vectormathlibrary/tests/test2_aos_cpp.cpp deleted file mode 100644 index 6b8884a1b..000000000 --- a/Extras/vectormathlibrary/tests/test2_aos_cpp.cpp +++ /dev/null @@ -1,784 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Aos; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Matrix3 = Matrix3( normalize( a_Quat ) ); - print( a_Matrix3, "construct Matrix3 with Quat" ); - a_Quat = Quat( a_Matrix3 ); - print( a_Quat, "construct Quat with Matrix3" ); - a_Matrix3 = b_Matrix3; - print( a_Matrix3, "assign to Matrix3 from Matrix3" ); - a_Matrix3 = Matrix3( randfloat() ); - print( a_Matrix3, "set Matrix3 with float" ); - a_Matrix3 = Matrix3( scalar_float(randfloat()) ); - print( a_Matrix3, "set Matrix3 with float" ); - a_Matrix3 = Matrix3( 0.0f ); - print( a_Matrix3, "set elements to zero" ); - a_Matrix3 = Matrix3::identity( ); - print( a_Matrix3, "set to identity" ); - a_Matrix3 = Matrix3::rotationX( randfloat() ); - print( a_Matrix3, "set to rotationX" ); - a_Matrix3 = Matrix3::rotationY( randfloat() ); - print( a_Matrix3, "set to rotationY" ); - a_Matrix3 = Matrix3::rotationZ( randfloat() ); - print( a_Matrix3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Matrix3, "set to rotation from Z,Y,X angles" ); - a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Matrix3, "set to rotation from axis angle" ); - a_Matrix3.setCol0( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 0" ); - a_Matrix3.setCol1( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 1" ); - a_Matrix3.setCol2( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 2" ); - print( a_Matrix3.getCol0( ), "Matrix3 get col 0" ); - print( a_Matrix3.getCol1( ), "Matrix3 get col 1" ); - print( a_Matrix3.getCol2( ), "Matrix3 get col 2" ); - a_Matrix3.setCol( 0, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 0" ); - a_Matrix3.setCol( 1, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 1" ); - a_Matrix3.setCol( 2, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 2" ); - print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" ); - print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" ); - print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" ); - a_Matrix3.setRow( 0, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 0" ); - a_Matrix3.setRow( 1, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 1" ); - a_Matrix3.setRow( 2, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 2" ); - print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" ); - print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" ); - print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" ); - a_Matrix3[0] = a_Vector3; - print( a_Matrix3, "set Matrix3[0]" ); - a_Matrix3[1] = a_Vector3; - print( a_Matrix3, "set Matrix3[1]" ); - a_Matrix3[2] = a_Vector3; - print( a_Matrix3, "set Matrix3[2]" ); - a_Matrix3[0] = a_Vector3; - print( a_Matrix3[0], "get Matrix3[0]" ); - a_Matrix3[1] = a_Vector3; - print( a_Matrix3[1], "get Matrix3[1]" ); - a_Matrix3[2] = a_Vector3; - print( a_Matrix3[2], "get Matrix3[2]" ); - a_Matrix3.setElem( 0, 0, randfloat() ); - a_Matrix3.setElem( 0, 1, randfloat() ); - a_Matrix3.setElem( 0, 2, randfloat() ); - a_Matrix3.setElem( 1, 0, randfloat() ); - a_Matrix3.setElem( 1, 1, randfloat() ); - a_Matrix3.setElem( 1, 2, randfloat() ); - a_Matrix3.setElem( 2, 0, randfloat() ); - a_Matrix3.setElem( 2, 1, randfloat() ); - a_Matrix3.setElem( 2, 2, randfloat() ); - print( a_Matrix3, "Matrix3 set elements" ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Matrix4 = Matrix4( a_Transform3 ); - print( a_Matrix4, "construct Matrix4 with Transform3" ); - a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 ); - print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); - a_Matrix4 = Matrix4( a_Quat, a_Vector3 ); - print( a_Matrix4, "construct Matrix4 with Quat and Vector3" ); - a_Matrix4 = b_Matrix4; - print( a_Matrix4, "assign to Matrix4 from Matrix4" ); - a_Matrix4 = Matrix4( randfloat() ); - print( a_Matrix4, "set Matrix4 with float" ); - a_Matrix4 = Matrix4( scalar_float(randfloat()) ); - print( a_Matrix4, "set Matrix4 with float" ); - a_Matrix4 = Matrix4( 0.0f ); - print( a_Matrix4, "set elements to zero" ); - a_Matrix4 = Matrix4::identity( ); - print( a_Matrix4, "set to identity" ); - a_Matrix4 = Matrix4::rotationX( randfloat() ); - print( a_Matrix4, "set to rotationX" ); - a_Matrix4 = Matrix4::rotationY( randfloat() ); - print( a_Matrix4, "set to rotationY" ); - a_Matrix4 = Matrix4::rotationZ( randfloat() ); - print( a_Matrix4, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Matrix4, "set to rotation from Z,Y,X angles" ); - a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Matrix4, "set to rotation from axis angle" ); - a_Matrix4 = Matrix4::translation( a_Vector3 ); - print( a_Matrix4, "set to translation" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Matrix4, "set to perspective matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - print( a_Matrix4, "set to frustum matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - print( a_Matrix4, "set to orthographic matrix" ); - a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 ); - print( a_Matrix4, "set to look-at matrix" ); - a_Matrix4.setCol0( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 0" ); - a_Matrix4.setCol1( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 1" ); - a_Matrix4.setCol2( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 2" ); - a_Matrix4.setCol3( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 3" ); - print( a_Matrix4.getCol0( ), "Matrix4 get col 0" ); - print( a_Matrix4.getCol1( ), "Matrix4 get col 1" ); - print( a_Matrix4.getCol2( ), "Matrix4 get col 2" ); - print( a_Matrix4.getCol3( ), "Matrix4 get col 3" ); - a_Matrix4.setCol( 0, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 0" ); - a_Matrix4.setCol( 1, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 1" ); - a_Matrix4.setCol( 2, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 2" ); - a_Matrix4.setCol( 3, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 3" ); - print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" ); - print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" ); - print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" ); - print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" ); - a_Matrix4.setRow( 0, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 0" ); - a_Matrix4.setRow( 1, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 1" ); - a_Matrix4.setRow( 2, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 2" ); - a_Matrix4.setRow( 3, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 3" ); - print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" ); - print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" ); - print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" ); - print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" ); - a_Matrix4[0] = a_Vector4; - print( a_Matrix4, "set Matrix4[0]" ); - a_Matrix4[1] = a_Vector4; - print( a_Matrix4, "set Matrix4[1]" ); - a_Matrix4[2] = a_Vector4; - print( a_Matrix4, "set Matrix4[2]" ); - a_Matrix4[3] = a_Vector4; - print( a_Matrix4, "set Matrix4[3]" ); - a_Matrix4[0] = a_Vector4; - print( a_Matrix4[0], "get Matrix4[0]" ); - a_Matrix4[1] = a_Vector4; - print( a_Matrix4[1], "get Matrix4[1]" ); - a_Matrix4[2] = a_Vector4; - print( a_Matrix4[2], "get Matrix4[2]" ); - a_Matrix4[3] = a_Vector4; - print( a_Matrix4[3], "get Matrix4[3]" ); - a_Matrix4.setElem( 0, 0, randfloat() ); - a_Matrix4.setElem( 0, 1, randfloat() ); - a_Matrix4.setElem( 0, 2, randfloat() ); - a_Matrix4.setElem( 0, 3, randfloat() ); - a_Matrix4.setElem( 1, 0, randfloat() ); - a_Matrix4.setElem( 1, 1, randfloat() ); - a_Matrix4.setElem( 1, 2, randfloat() ); - a_Matrix4.setElem( 1, 3, randfloat() ); - a_Matrix4.setElem( 2, 0, randfloat() ); - a_Matrix4.setElem( 2, 1, randfloat() ); - a_Matrix4.setElem( 2, 2, randfloat() ); - a_Matrix4.setElem( 2, 3, randfloat() ); - a_Matrix4.setElem( 3, 0, randfloat() ); - a_Matrix4.setElem( 3, 1, randfloat() ); - a_Matrix4.setElem( 3, 2, randfloat() ); - a_Matrix4.setElem( 3, 3, randfloat() ); - print( a_Matrix4, "Matrix4 set elements" ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Transform3 = Transform3( a_Matrix3, a_Vector3 ); - print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); - a_Transform3 = Transform3( a_Quat, a_Vector3 ); - print( a_Transform3, "construct Transform3 with Quat and Vector3" ); - a_Transform3 = b_Transform3; - print( a_Transform3, "assign to Transform3 from Transform3" ); - a_Transform3 = Transform3( randfloat() ); - print( a_Transform3, "set Transform3 with float" ); - a_Transform3 = Transform3( scalar_float(randfloat()) ); - print( a_Transform3, "set Transform3 with float" ); - a_Transform3 = Transform3( 0.0f ); - print( a_Transform3, "set elements to zero" ); - a_Transform3 = Transform3::identity( ); - print( a_Transform3, "set to identity" ); - a_Transform3 = Transform3::rotationX( randfloat() ); - print( a_Transform3, "set to rotationX" ); - a_Transform3 = Transform3::rotationY( randfloat() ); - print( a_Transform3, "set to rotationY" ); - a_Transform3 = Transform3::rotationZ( randfloat() ); - print( a_Transform3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Transform3, "set to rotation from Z,Y,X angles" ); - a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Transform3, "set to rotation from axis angle" ); - a_Transform3 = Transform3::translation( a_Vector3 ); - print( a_Transform3, "set to translation" ); - a_Transform3.setCol0( a_Vector3 ); - print( a_Transform3, "Transform3 set col 0" ); - a_Transform3.setCol1( a_Vector3 ); - print( a_Transform3, "Transform3 set col 1" ); - a_Transform3.setCol2( a_Vector3 ); - print( a_Transform3, "Transform3 set col 2" ); - a_Transform3.setCol3( a_Vector3 ); - print( a_Transform3, "Transform3 set col 3" ); - print( a_Transform3.getCol0( ), "Transform3 get col 0" ); - print( a_Transform3.getCol1( ), "Transform3 get col 1" ); - print( a_Transform3.getCol2( ), "Transform3 get col 2" ); - print( a_Transform3.getCol3( ), "Transform3 get col 3" ); - a_Transform3.setCol( 0, b_Vector3 ); - print( a_Transform3, "Transform3 set col 0" ); - a_Transform3.setCol( 1, b_Vector3 ); - print( a_Transform3, "Transform3 set col 1" ); - a_Transform3.setCol( 2, b_Vector3 ); - print( a_Transform3, "Transform3 set col 2" ); - a_Transform3.setCol( 3, b_Vector3 ); - print( a_Transform3, "Transform3 set col 3" ); - print( a_Transform3.getCol( 0 ), "Transform3 get col 0" ); - print( a_Transform3.getCol( 1 ), "Transform3 get col 1" ); - print( a_Transform3.getCol( 2 ), "Transform3 get col 2" ); - print( a_Transform3.getCol( 3 ), "Transform3 get col 3" ); - a_Transform3.setRow( 0, a_Vector4 ); - print( a_Transform3, "Transform3 set row 0" ); - a_Transform3.setRow( 1, a_Vector4 ); - print( a_Transform3, "Transform3 set row 1" ); - a_Transform3.setRow( 2, a_Vector4 ); - print( a_Transform3, "Transform3 set row 2" ); - print( a_Transform3.getRow( 0 ), "Transform3 get row 0" ); - print( a_Transform3.getRow( 1 ), "Transform3 get row 1" ); - print( a_Transform3.getRow( 2 ), "Transform3 get row 2" ); - a_Transform3[0] = a_Vector3; - print( a_Transform3, "set Transform3[0]" ); - a_Transform3[1] = a_Vector3; - print( a_Transform3, "set Transform3[1]" ); - a_Transform3[2] = a_Vector3; - print( a_Transform3, "set Transform3[2]" ); - a_Transform3[3] = a_Vector3; - print( a_Transform3, "set Transform3[3]" ); - a_Transform3[0] = a_Vector3; - print( a_Transform3[0], "get Transform3[0]" ); - a_Transform3[1] = a_Vector3; - print( a_Transform3[1], "get Transform3[1]" ); - a_Transform3[2] = a_Vector3; - print( a_Transform3[2], "get Transform3[2]" ); - a_Transform3[3] = a_Vector3; - print( a_Transform3[3], "get Transform3[3]" ); - a_Transform3.setElem( 0, 0, randfloat() ); - a_Transform3.setElem( 0, 1, randfloat() ); - a_Transform3.setElem( 0, 2, randfloat() ); - a_Transform3.setElem( 1, 0, randfloat() ); - a_Transform3.setElem( 1, 1, randfloat() ); - a_Transform3.setElem( 1, 2, randfloat() ); - a_Transform3.setElem( 2, 0, randfloat() ); - a_Transform3.setElem( 2, 1, randfloat() ); - a_Transform3.setElem( 2, 2, randfloat() ); - a_Transform3.setElem( 3, 0, randfloat() ); - a_Transform3.setElem( 3, 1, randfloat() ); - a_Transform3.setElem( 3, 2, randfloat() ); - print( a_Transform3, "Transform3 set elements" ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test2_reference.txt b/Extras/vectormathlibrary/tests/test2_reference.txt deleted file mode 100644 index 6f885a212..000000000 --- a/Extras/vectormathlibrary/tests/test2_reference.txt +++ /dev/null @@ -1,1190 +0,0 @@ -set Vector3 with floats: ( -0.658344 0.499804 -0.807257 ) -set Vector3 with floats: ( 0.740930 0.154607 0.571599 ) -set Vector3 with floats: ( 0.384388 -0.262467 0.747808 ) -set Vector3 with floats: ( 0.490190 -0.107908 -0.292544 ) -set Vector4 with floats: ( 0.465039 -0.479556 -0.211412 0.553580 ) -set Vector4 with floats: ( 0.690070 0.151576 0.431077 -0.833992 ) -set Vector4 with floats: ( -0.088350 -0.780106 0.090456 -0.218627 ) -set Vector4 with floats: ( 0.137171 0.918133 0.735438 -0.673621 ) -set Point3 with floats: ( -0.448982 -0.479278 0.848189 ) -set Point3 with floats: ( -0.128155 0.578922 -0.744766 ) -set Point3 with floats: ( -0.835589 0.881284 -0.948850 ) -set Point3 with floats: ( -0.691578 -0.235635 -0.690527 ) -set Quat with floats: ( 0.058667 0.753697 -0.138777 -0.472188 ) -set Quat with floats: ( -0.372811 0.540183 -0.785218 0.542085 ) -set Quat with floats: ( 0.410391 -0.562721 0.523588 -0.176574 ) -set Quat with floats: ( 0.297654 0.859913 0.004837 0.374881 ) -set Matrix3 columns: -( -0.658344 0.740930 0.384388 ) -( 0.499804 0.154607 -0.262467 ) -( -0.807257 0.571599 0.747808 ) -set Matrix3 columns: -( 0.490190 -0.658344 0.740930 ) -( -0.107908 0.499804 0.154607 ) -( -0.292544 -0.807257 0.571599 ) -set Matrix4 columns: -( 0.465039 0.690070 -0.088350 0.137171 ) -( -0.479556 0.151576 -0.780106 0.918133 ) -( -0.211412 0.431077 0.090456 0.735438 ) -( 0.553580 -0.833992 -0.218627 -0.673621 ) -set Matrix4 columns: -( 0.137171 0.465039 0.690070 -0.088350 ) -( 0.918133 -0.479556 0.151576 -0.780106 ) -( 0.735438 -0.211412 0.431077 0.090456 ) -( -0.673621 0.553580 -0.833992 -0.218627 ) -set Transform3 columns: -( -0.658344 0.740930 0.384388 0.490190 ) -( 0.499804 0.154607 -0.262467 -0.107908 ) -( -0.807257 0.571599 0.747808 -0.292544 ) -set Transform3 columns: -( 0.490190 -0.658344 0.740930 0.384388 ) -( -0.107908 0.499804 0.154607 -0.262467 ) -( -0.292544 -0.807257 0.571599 0.747808 ) -construct Matrix3 with Quat: -( -0.443537 -0.052381 -0.894724 ) -( 0.269738 0.944205 -0.188994 ) -( 0.854702 -0.325167 -0.404660 ) -construct Quat with Matrix3: ( -0.065036 -0.835524 0.153844 0.523452 ) -assign to Matrix3 from Matrix3: -( 0.490190 -0.658344 0.740930 ) -( -0.107908 0.499804 0.154607 ) -( -0.292544 -0.807257 0.571599 ) -set Matrix3 with float: -( -0.127818 -0.127818 -0.127818 ) -( -0.127818 -0.127818 -0.127818 ) -( -0.127818 -0.127818 -0.127818 ) -set Matrix3 with float: -( 0.216602 0.216602 0.216602 ) -( 0.216602 0.216602 0.216602 ) -( 0.216602 0.216602 0.216602 ) -set elements to zero: -( 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 1.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 ) -( 0.000000 0.988300 -0.152520 ) -( 0.000000 0.152520 0.988300 ) -set to rotationY: -( 0.965029 0.000000 0.262144 ) -( 0.000000 1.000000 0.000000 ) -( -0.262144 0.000000 0.965029 ) -set to rotationZ: -( 0.997326 0.073083 0.000000 ) -( -0.073083 0.997326 0.000000 ) -( 0.000000 0.000000 1.000000 ) -set to rotation from Z,Y,X angles: -( 0.723488 -0.666973 -0.178077 ) -( 0.195944 0.445752 -0.873448 ) -( 0.661945 0.597036 0.453186 ) -set to rotation from axis angle: -( 0.836267 -0.515861 -0.185860 ) -( 0.396334 0.802918 -0.445244 ) -( 0.378915 0.298680 0.875907 ) -Matrix3 set col 0: -( -0.658344 -0.515861 -0.185860 ) -( 0.499804 0.802918 -0.445244 ) -( -0.807257 0.298680 0.875907 ) -Matrix3 set col 1: -( -0.658344 -0.658344 -0.185860 ) -( 0.499804 0.499804 -0.445244 ) -( -0.807257 -0.807257 0.875907 ) -Matrix3 set col 2: -( -0.658344 -0.658344 -0.658344 ) -( 0.499804 0.499804 0.499804 ) -( -0.807257 -0.807257 -0.807257 ) -Matrix3 get col 0: ( -0.658344 0.499804 -0.807257 ) -Matrix3 get col 1: ( -0.658344 0.499804 -0.807257 ) -Matrix3 get col 2: ( -0.658344 0.499804 -0.807257 ) -Matrix3 set col 0: -( 0.740930 -0.658344 -0.658344 ) -( 0.154607 0.499804 0.499804 ) -( 0.571599 -0.807257 -0.807257 ) -Matrix3 set col 1: -( 0.740930 0.740930 -0.658344 ) -( 0.154607 0.154607 0.499804 ) -( 0.571599 0.571599 -0.807257 ) -Matrix3 set col 2: -( 0.740930 0.740930 0.740930 ) -( 0.154607 0.154607 0.154607 ) -( 0.571599 0.571599 0.571599 ) -Matrix3 get col 0: ( 0.740930 0.154607 0.571599 ) -Matrix3 get col 1: ( 0.740930 0.154607 0.571599 ) -Matrix3 get col 2: ( 0.740930 0.154607 0.571599 ) -Matrix3 set row 0: -( -0.658344 0.499804 -0.807257 ) -( 0.154607 0.154607 0.154607 ) -( 0.571599 0.571599 0.571599 ) -Matrix3 set row 1: -( -0.658344 0.499804 -0.807257 ) -( -0.658344 0.499804 -0.807257 ) -( 0.571599 0.571599 0.571599 ) -Matrix3 set row 2: -( -0.658344 0.499804 -0.807257 ) -( -0.658344 0.499804 -0.807257 ) -( -0.658344 0.499804 -0.807257 ) -Matrix3 get row 0: ( -0.658344 0.499804 -0.807257 ) -Matrix3 get row 1: ( -0.658344 0.499804 -0.807257 ) -Matrix3 get row 2: ( -0.658344 0.499804 -0.807257 ) -set Matrix3[0]: -( -0.658344 0.499804 -0.807257 ) -( 0.499804 0.499804 -0.807257 ) -( -0.807257 0.499804 -0.807257 ) -set Matrix3[1]: -( -0.658344 -0.658344 -0.807257 ) -( 0.499804 0.499804 -0.807257 ) -( -0.807257 -0.807257 -0.807257 ) -set Matrix3[2]: -( -0.658344 -0.658344 -0.658344 ) -( 0.499804 0.499804 0.499804 ) -( -0.807257 -0.807257 -0.807257 ) -get Matrix3[0]: ( -0.658344 0.499804 -0.807257 ) -get Matrix3[1]: ( -0.658344 0.499804 -0.807257 ) -get Matrix3[2]: ( -0.658344 0.499804 -0.807257 ) -Matrix3 set elements: -( -0.106634 -0.283632 0.910171 ) -( -0.350831 -0.203584 0.969234 ) -( 0.905168 -0.797437 0.151940 ) --0.106634 --0.350831 -0.905168 --0.283632 --0.203584 --0.797437 -0.910171 -0.969234 -0.151940 -set Vector3 with floats: ( 0.731827 -0.700248 0.818301 ) -set Vector3 with floats: ( 0.302505 -0.872278 0.909999 ) -set Vector3 with floats: ( 0.932526 0.571087 0.610330 ) -set Vector3 with floats: ( 0.142507 -0.434829 0.925102 ) -set Vector4 with floats: ( 0.158954 -0.126283 -0.249128 0.846815 ) -set Vector4 with floats: ( -0.942601 0.537720 0.446214 0.181939 ) -set Vector4 with floats: ( -0.148223 0.284286 0.493525 -0.861963 ) -set Vector4 with floats: ( -0.893410 0.548627 0.407007 -0.757467 ) -set Point3 with floats: ( -0.393126 -0.850984 0.375720 ) -set Point3 with floats: ( -0.270088 0.458888 -0.610828 ) -set Point3 with floats: ( -0.690816 -0.676415 0.664466 ) -set Point3 with floats: ( 0.101874 -0.365714 0.055473 ) -set Quat with floats: ( -0.133556 -0.572643 0.459209 -0.997261 ) -set Quat with floats: ( 0.172409 -0.045124 0.879716 0.524317 ) -set Quat with floats: ( -0.744532 -0.970444 -0.000013 0.689543 ) -set Quat with floats: ( 0.704297 -0.817983 0.715505 0.577868 ) -set Matrix3 columns: -( 0.731827 0.302505 0.932526 ) -( -0.700248 -0.872278 0.571087 ) -( 0.818301 0.909999 0.610330 ) -set Matrix3 columns: -( 0.142507 0.731827 0.302505 ) -( -0.434829 -0.700248 -0.872278 ) -( 0.925102 0.818301 0.909999 ) -set Matrix4 columns: -( 0.158954 -0.942601 -0.148223 -0.893410 ) -( -0.126283 0.537720 0.284286 0.548627 ) -( -0.249128 0.446214 0.493525 0.407007 ) -( 0.846815 0.181939 -0.861963 -0.757467 ) -set Matrix4 columns: -( -0.893410 0.158954 -0.942601 -0.148223 ) -( 0.548627 -0.126283 0.537720 0.284286 ) -( 0.407007 -0.249128 0.446214 0.493525 ) -( -0.757467 0.846815 0.181939 -0.861963 ) -set Transform3 columns: -( 0.731827 0.302505 0.932526 0.142507 ) -( -0.700248 -0.872278 0.571087 -0.434829 ) -( 0.818301 0.909999 0.610330 0.925102 ) -set Transform3 columns: -( 0.142507 0.731827 0.302505 0.932526 ) -( -0.434829 -0.700248 -0.872278 0.571087 ) -( 0.925102 0.818301 0.909999 0.610330 ) -construct Matrix4 with Transform3: -( 0.731827 0.302505 0.932526 0.142507 ) -( -0.700248 -0.872278 0.571087 -0.434829 ) -( 0.818301 0.909999 0.610330 0.925102 ) -( 0.000000 0.000000 0.000000 1.000000 ) -construct Matrix4 with Matrix3 and Vector3: -( 0.731827 0.302505 0.932526 0.731827 ) -( -0.700248 -0.872278 0.571087 -0.700248 ) -( 0.818301 0.909999 0.610330 0.818301 ) -( 0.000000 0.000000 0.000000 1.000000 ) -construct Matrix4 with Quat and Vector3: -( -0.077586 1.068863 1.019489 0.731827 ) -( -0.762943 0.542579 -0.792307 -0.700248 ) -( -1.264810 -0.259545 0.308485 0.818301 ) -( 0.000000 0.000000 0.000000 1.000000 ) -assign to Matrix4 from Matrix4: -( -0.893410 0.158954 -0.942601 -0.148223 ) -( 0.548627 -0.126283 0.537720 0.284286 ) -( 0.407007 -0.249128 0.446214 0.493525 ) -( -0.757467 0.846815 0.181939 -0.861963 ) -set Matrix4 with float: -( 0.156952 0.156952 0.156952 0.156952 ) -( 0.156952 0.156952 0.156952 0.156952 ) -( 0.156952 0.156952 0.156952 0.156952 ) -( 0.156952 0.156952 0.156952 0.156952 ) -set Matrix4 with float: -( -0.801022 -0.801022 -0.801022 -0.801022 ) -( -0.801022 -0.801022 -0.801022 -0.801022 ) -( -0.801022 -0.801022 -0.801022 -0.801022 ) -( -0.801022 -0.801022 -0.801022 -0.801022 ) -set elements to zero: -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.792234 -0.610218 0.000000 ) -( 0.000000 0.610218 0.792234 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationY: -( 0.880257 0.000000 0.474498 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( -0.474498 0.000000 0.880257 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationZ: -( 0.684599 -0.728920 0.000000 0.000000 ) -( 0.728920 0.684599 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotation from Z,Y,X angles: -( 0.718303 0.540188 0.438449 0.000000 ) -( 0.017447 0.616016 -0.787541 0.000000 ) -( -0.695512 0.573343 0.433061 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotation from axis angle: -( 0.993956 -0.086019 -0.068204 0.000000 ) -( 0.080679 0.993721 -0.077527 0.000000 ) -( 0.074445 0.071556 0.994655 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to translation: -( 1.000000 0.000000 0.000000 0.731827 ) -( 0.000000 1.000000 0.000000 -0.700248 ) -( 0.000000 0.000000 1.000000 0.818301 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to perspective matrix: -( 232.227814 0.000000 0.000000 0.000000 ) -( 0.000000 -38.291180 0.000000 0.000000 ) -( 0.000000 0.000000 -2.308166 -0.994733 ) -( 0.000000 0.000000 -1.000000 0.000000 ) -set to frustum matrix: -( -1.076418 0.000000 0.527081 0.000000 ) -( 0.000000 -0.465615 -0.188684 0.000000 ) -( 0.000000 0.000000 -66.946648 -26.580370 ) -( 0.000000 0.000000 -1.000000 0.000000 ) -set to orthographic matrix: -( -2.962014 0.000000 0.000000 1.880296 ) -( 0.000000 5.281968 0.000000 -2.636149 ) -( 0.000000 0.000000 -3.467666 -2.260634 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to look-at matrix: -( 0.275461 -0.594716 -0.755271 -0.114033 ) -( 0.958396 0.108747 0.263914 0.370155 ) -( -0.074821 -0.796547 0.599929 -0.932668 ) -( 0.000000 0.000000 0.000000 1.000000 ) -Matrix4 set col 0: -( 0.158954 -0.594716 -0.755271 -0.114033 ) -( -0.126283 0.108747 0.263914 0.370155 ) -( -0.249128 -0.796547 0.599929 -0.932668 ) -( 0.846815 0.000000 0.000000 1.000000 ) -Matrix4 set col 1: -( 0.158954 0.158954 -0.755271 -0.114033 ) -( -0.126283 -0.126283 0.263914 0.370155 ) -( -0.249128 -0.249128 0.599929 -0.932668 ) -( 0.846815 0.846815 0.000000 1.000000 ) -Matrix4 set col 2: -( 0.158954 0.158954 0.158954 -0.114033 ) -( -0.126283 -0.126283 -0.126283 0.370155 ) -( -0.249128 -0.249128 -0.249128 -0.932668 ) -( 0.846815 0.846815 0.846815 1.000000 ) -Matrix4 set col 3: -( 0.158954 0.158954 0.158954 0.158954 ) -( -0.126283 -0.126283 -0.126283 -0.126283 ) -( -0.249128 -0.249128 -0.249128 -0.249128 ) -( 0.846815 0.846815 0.846815 0.846815 ) -Matrix4 get col 0: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get col 1: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get col 2: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get col 3: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 set col 0: -( -0.942601 0.158954 0.158954 0.158954 ) -( 0.537720 -0.126283 -0.126283 -0.126283 ) -( 0.446214 -0.249128 -0.249128 -0.249128 ) -( 0.181939 0.846815 0.846815 0.846815 ) -Matrix4 set col 1: -( -0.942601 -0.942601 0.158954 0.158954 ) -( 0.537720 0.537720 -0.126283 -0.126283 ) -( 0.446214 0.446214 -0.249128 -0.249128 ) -( 0.181939 0.181939 0.846815 0.846815 ) -Matrix4 set col 2: -( -0.942601 -0.942601 -0.942601 0.158954 ) -( 0.537720 0.537720 0.537720 -0.126283 ) -( 0.446214 0.446214 0.446214 -0.249128 ) -( 0.181939 0.181939 0.181939 0.846815 ) -Matrix4 set col 3: -( -0.942601 -0.942601 -0.942601 -0.942601 ) -( 0.537720 0.537720 0.537720 0.537720 ) -( 0.446214 0.446214 0.446214 0.446214 ) -( 0.181939 0.181939 0.181939 0.181939 ) -Matrix4 get col 0: ( -0.942601 0.537720 0.446214 0.181939 ) -Matrix4 get col 1: ( -0.942601 0.537720 0.446214 0.181939 ) -Matrix4 get col 2: ( -0.942601 0.537720 0.446214 0.181939 ) -Matrix4 get col 3: ( -0.942601 0.537720 0.446214 0.181939 ) -Matrix4 set row 0: -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.537720 0.537720 0.537720 0.537720 ) -( 0.446214 0.446214 0.446214 0.446214 ) -( 0.181939 0.181939 0.181939 0.181939 ) -Matrix4 set row 1: -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.446214 0.446214 0.446214 0.446214 ) -( 0.181939 0.181939 0.181939 0.181939 ) -Matrix4 set row 2: -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.181939 0.181939 0.181939 0.181939 ) -Matrix4 set row 3: -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get row 0: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get row 1: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get row 2: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 get row 3: ( 0.158954 -0.126283 -0.249128 0.846815 ) -set Matrix4[0]: -( 0.158954 -0.126283 -0.249128 0.846815 ) -( -0.126283 -0.126283 -0.249128 0.846815 ) -( -0.249128 -0.126283 -0.249128 0.846815 ) -( 0.846815 -0.126283 -0.249128 0.846815 ) -set Matrix4[1]: -( 0.158954 0.158954 -0.249128 0.846815 ) -( -0.126283 -0.126283 -0.249128 0.846815 ) -( -0.249128 -0.249128 -0.249128 0.846815 ) -( 0.846815 0.846815 -0.249128 0.846815 ) -set Matrix4[2]: -( 0.158954 0.158954 0.158954 0.846815 ) -( -0.126283 -0.126283 -0.126283 0.846815 ) -( -0.249128 -0.249128 -0.249128 0.846815 ) -( 0.846815 0.846815 0.846815 0.846815 ) -set Matrix4[3]: -( 0.158954 0.158954 0.158954 0.158954 ) -( -0.126283 -0.126283 -0.126283 -0.126283 ) -( -0.249128 -0.249128 -0.249128 -0.249128 ) -( 0.846815 0.846815 0.846815 0.846815 ) -get Matrix4[0]: ( 0.158954 -0.126283 -0.249128 0.846815 ) -get Matrix4[1]: ( 0.158954 -0.126283 -0.249128 0.846815 ) -get Matrix4[2]: ( 0.158954 -0.126283 -0.249128 0.846815 ) -get Matrix4[3]: ( 0.158954 -0.126283 -0.249128 0.846815 ) -Matrix4 set elements: -( -0.336683 0.205513 -0.071926 0.473013 ) -( 0.600164 -0.160082 -0.506313 -0.735610 ) -( -0.681272 0.962714 0.689277 -0.046390 ) -( 0.726558 0.737794 0.686485 0.568674 ) --0.336683 -0.600164 --0.681272 -0.726558 -0.205513 --0.160082 -0.962714 -0.737794 --0.071926 --0.506313 -0.689277 -0.686485 -0.473013 --0.735610 --0.046390 -0.568674 -set Vector3 with floats: ( -0.004815 0.137637 -0.111879 ) -set Vector3 with floats: ( -0.929543 -0.336303 -0.146740 ) -set Vector3 with floats: ( 0.165140 -0.823874 0.349776 ) -set Vector3 with floats: ( 0.174872 -0.528584 0.489292 ) -set Vector4 with floats: ( 0.916708 0.728511 -0.851140 0.079620 ) -set Vector4 with floats: ( -0.234370 -0.996308 0.433229 -0.892684 ) -set Vector4 with floats: ( -0.957911 0.517122 0.257921 0.862028 ) -set Vector4 with floats: ( 0.095881 -0.171933 -0.214078 -0.604841 ) -set Point3 with floats: ( -0.383831 -0.581500 0.222183 ) -set Point3 with floats: ( -0.256120 -0.678699 -0.079553 ) -set Point3 with floats: ( 0.605960 -0.633147 0.435875 ) -set Point3 with floats: ( -0.046627 -0.716491 0.267317 ) -set Quat with floats: ( -0.514874 -0.751700 0.742959 -0.793180 ) -set Quat with floats: ( 0.508814 -0.238839 0.113471 -0.843523 ) -set Quat with floats: ( -0.245250 0.250368 0.579243 -0.157280 ) -set Quat with floats: ( 0.648487 0.103833 0.456401 -0.022372 ) -set Matrix3 columns: -( -0.004815 -0.929543 0.165140 ) -( 0.137637 -0.336303 -0.823874 ) -( -0.111879 -0.146740 0.349776 ) -set Matrix3 columns: -( 0.174872 -0.004815 -0.929543 ) -( -0.528584 0.137637 -0.336303 ) -( 0.489292 -0.111879 -0.146740 ) -set Matrix4 columns: -( 0.916708 -0.234370 -0.957911 0.095881 ) -( 0.728511 -0.996308 0.517122 -0.171933 ) -( -0.851140 0.433229 0.257921 -0.214078 ) -( 0.079620 -0.892684 0.862028 -0.604841 ) -set Matrix4 columns: -( 0.095881 0.916708 -0.234370 -0.957911 ) -( -0.171933 0.728511 -0.996308 0.517122 ) -( -0.214078 -0.851140 0.433229 0.257921 ) -( -0.604841 0.079620 -0.892684 0.862028 ) -set Transform3 columns: -( -0.004815 -0.929543 0.165140 0.174872 ) -( 0.137637 -0.336303 -0.823874 -0.528584 ) -( -0.111879 -0.146740 0.349776 0.489292 ) -set Transform3 columns: -( 0.174872 -0.004815 -0.929543 0.165140 ) -( -0.528584 0.137637 -0.336303 -0.823874 ) -( 0.489292 -0.111879 -0.146740 0.349776 ) -construct Transform3 with Matrix3 and Vector3: -( -0.004815 -0.929543 0.165140 -0.004815 ) -( 0.137637 -0.336303 -0.823874 0.137637 ) -( -0.111879 -0.146740 0.349776 -0.111879 ) -construct Transform3 with Quat and Vector3: -( -1.234080 1.952660 0.427405 -0.004815 ) -( -0.404539 -0.634166 -1.933738 0.137637 ) -( -1.957525 -0.300189 -0.660294 -0.111879 ) -assign to Transform3 from Transform3: -( 0.174872 -0.004815 -0.929543 0.165140 ) -( -0.528584 0.137637 -0.336303 -0.823874 ) -( 0.489292 -0.111879 -0.146740 0.349776 ) -set Transform3 with float: -( -0.475631 -0.475631 -0.475631 -0.475631 ) -( -0.475631 -0.475631 -0.475631 -0.475631 ) -( -0.475631 -0.475631 -0.475631 -0.475631 ) -set Transform3 with float: -( -0.004178 -0.004178 -0.004178 -0.004178 ) -( -0.004178 -0.004178 -0.004178 -0.004178 ) -( -0.004178 -0.004178 -0.004178 -0.004178 ) -set elements to zero: -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.999782 0.020864 0.000000 ) -( 0.000000 -0.020864 0.999782 0.000000 ) -set to rotationY: -( 0.999856 0.000000 -0.016996 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.016996 0.000000 0.999856 0.000000 ) -set to rotationZ: -( 0.765394 -0.643562 0.000000 0.000000 ) -( 0.643562 0.765394 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -set to rotation from Z,Y,X angles: -( 0.643764 -0.756736 -0.113659 0.000000 ) -( 0.715027 0.647771 -0.262922 0.000000 ) -( 0.272588 0.087991 0.958099 0.000000 ) -set to rotation from axis angle: -( 0.978242 0.130404 0.161363 0.000000 ) -( -0.131321 0.991327 -0.005018 0.000000 ) -( -0.160618 -0.016281 0.986882 0.000000 ) -set to translation: -( 1.000000 0.000000 0.000000 -0.004815 ) -( 0.000000 1.000000 0.000000 0.137637 ) -( 0.000000 0.000000 1.000000 -0.111879 ) -Transform3 set col 0: -( -0.004815 0.000000 0.000000 -0.004815 ) -( 0.137637 1.000000 0.000000 0.137637 ) -( -0.111879 0.000000 1.000000 -0.111879 ) -Transform3 set col 1: -( -0.004815 -0.004815 0.000000 -0.004815 ) -( 0.137637 0.137637 0.000000 0.137637 ) -( -0.111879 -0.111879 1.000000 -0.111879 ) -Transform3 set col 2: -( -0.004815 -0.004815 -0.004815 -0.004815 ) -( 0.137637 0.137637 0.137637 0.137637 ) -( -0.111879 -0.111879 -0.111879 -0.111879 ) -Transform3 set col 3: -( -0.004815 -0.004815 -0.004815 -0.004815 ) -( 0.137637 0.137637 0.137637 0.137637 ) -( -0.111879 -0.111879 -0.111879 -0.111879 ) -Transform3 get col 0: ( -0.004815 0.137637 -0.111879 ) -Transform3 get col 1: ( -0.004815 0.137637 -0.111879 ) -Transform3 get col 2: ( -0.004815 0.137637 -0.111879 ) -Transform3 get col 3: ( -0.004815 0.137637 -0.111879 ) -Transform3 set col 0: -( -0.929543 -0.004815 -0.004815 -0.004815 ) -( -0.336303 0.137637 0.137637 0.137637 ) -( -0.146740 -0.111879 -0.111879 -0.111879 ) -Transform3 set col 1: -( -0.929543 -0.929543 -0.004815 -0.004815 ) -( -0.336303 -0.336303 0.137637 0.137637 ) -( -0.146740 -0.146740 -0.111879 -0.111879 ) -Transform3 set col 2: -( -0.929543 -0.929543 -0.929543 -0.004815 ) -( -0.336303 -0.336303 -0.336303 0.137637 ) -( -0.146740 -0.146740 -0.146740 -0.111879 ) -Transform3 set col 3: -( -0.929543 -0.929543 -0.929543 -0.929543 ) -( -0.336303 -0.336303 -0.336303 -0.336303 ) -( -0.146740 -0.146740 -0.146740 -0.146740 ) -Transform3 get col 0: ( -0.929543 -0.336303 -0.146740 ) -Transform3 get col 1: ( -0.929543 -0.336303 -0.146740 ) -Transform3 get col 2: ( -0.929543 -0.336303 -0.146740 ) -Transform3 get col 3: ( -0.929543 -0.336303 -0.146740 ) -Transform3 set row 0: -( 0.916708 0.728511 -0.851140 0.079620 ) -( -0.336303 -0.336303 -0.336303 -0.336303 ) -( -0.146740 -0.146740 -0.146740 -0.146740 ) -Transform3 set row 1: -( 0.916708 0.728511 -0.851140 0.079620 ) -( 0.916708 0.728511 -0.851140 0.079620 ) -( -0.146740 -0.146740 -0.146740 -0.146740 ) -Transform3 set row 2: -( 0.916708 0.728511 -0.851140 0.079620 ) -( 0.916708 0.728511 -0.851140 0.079620 ) -( 0.916708 0.728511 -0.851140 0.079620 ) -Transform3 get row 0: ( 0.916708 0.728511 -0.851140 0.079620 ) -Transform3 get row 1: ( 0.916708 0.728511 -0.851140 0.079620 ) -Transform3 get row 2: ( 0.916708 0.728511 -0.851140 0.079620 ) -set Transform3[0]: -( -0.004815 0.728511 -0.851140 0.079620 ) -( 0.137637 0.728511 -0.851140 0.079620 ) -( -0.111879 0.728511 -0.851140 0.079620 ) -set Transform3[1]: -( -0.004815 -0.004815 -0.851140 0.079620 ) -( 0.137637 0.137637 -0.851140 0.079620 ) -( -0.111879 -0.111879 -0.851140 0.079620 ) -set Transform3[2]: -( -0.004815 -0.004815 -0.004815 0.079620 ) -( 0.137637 0.137637 0.137637 0.079620 ) -( -0.111879 -0.111879 -0.111879 0.079620 ) -set Transform3[3]: -( -0.004815 -0.004815 -0.004815 -0.004815 ) -( 0.137637 0.137637 0.137637 0.137637 ) -( -0.111879 -0.111879 -0.111879 -0.111879 ) -get Transform3[0]: ( -0.004815 0.137637 -0.111879 ) -get Transform3[1]: ( -0.004815 0.137637 -0.111879 ) -get Transform3[2]: ( -0.004815 0.137637 -0.111879 ) -get Transform3[3]: ( -0.004815 0.137637 -0.111879 ) -Transform3 set elements: -( 0.219317 -0.567698 0.572490 0.867178 ) -( -0.118359 0.531358 -0.820417 0.934764 ) -( 0.413442 -0.387226 0.797191 0.237092 ) -0.219317 --0.118359 -0.413442 --0.567698 -0.531358 --0.387226 -0.572490 --0.820417 -0.797191 -0.867178 -0.934764 -0.237092 -set Vector3 with floats: ( -0.866162 -0.773939 0.261311 ) -set Vector3 with floats: ( -0.851570 0.114814 -0.531592 ) -set Vector3 with floats: ( 0.223925 0.869105 0.143405 ) -set Vector3 with floats: ( 0.148518 -0.071136 -0.758292 ) -set Vector4 with floats: ( -0.527633 0.997215 0.114440 0.727558 ) -set Vector4 with floats: ( -0.425760 0.459888 0.642516 -0.022534 ) -set Vector4 with floats: ( 0.186095 -0.775679 -0.683401 0.398134 ) -set Vector4 with floats: ( 0.189642 0.765986 -0.137795 -0.579844 ) -set Point3 with floats: ( -0.635647 0.374970 -0.563750 ) -set Point3 with floats: ( -0.471075 -0.553800 -0.014688 ) -set Point3 with floats: ( -0.464365 -0.107890 -0.527503 ) -set Point3 with floats: ( -0.406423 0.301261 0.499529 ) -set Quat with floats: ( 0.385180 -0.150218 0.519112 -0.203209 ) -set Quat with floats: ( -0.252017 0.282194 0.067637 0.798376 ) -set Quat with floats: ( 0.310782 0.861334 -0.980345 -0.655106 ) -set Quat with floats: ( 0.286765 0.532078 0.352671 0.540977 ) -set Matrix3 columns: -( -0.866162 -0.851570 0.223925 ) -( -0.773939 0.114814 0.869105 ) -( 0.261311 -0.531592 0.143405 ) -set Matrix3 columns: -( 0.148518 -0.866162 -0.851570 ) -( -0.071136 -0.773939 0.114814 ) -( -0.758292 0.261311 -0.531592 ) -set Matrix4 columns: -( -0.527633 -0.425760 0.186095 0.189642 ) -( 0.997215 0.459888 -0.775679 0.765986 ) -( 0.114440 0.642516 -0.683401 -0.137795 ) -( 0.727558 -0.022534 0.398134 -0.579844 ) -set Matrix4 columns: -( 0.189642 -0.527633 -0.425760 0.186095 ) -( 0.765986 0.997215 0.459888 -0.775679 ) -( -0.137795 0.114440 0.642516 -0.683401 ) -( -0.579844 0.727558 -0.022534 0.398134 ) -set Transform3 columns: -( -0.866162 -0.851570 0.223925 0.148518 ) -( -0.773939 0.114814 0.869105 -0.071136 ) -( 0.261311 -0.531592 0.143405 -0.758292 ) -set Transform3 columns: -( 0.148518 -0.866162 -0.851570 0.223925 ) -( -0.071136 -0.773939 0.114814 0.869105 ) -( -0.758292 0.261311 -0.531592 0.143405 ) -construct Matrix3 with Quat: -( -0.212551 0.197745 0.956932 ) -( -0.678219 -0.734858 0.001211 ) -( 0.703449 -0.648753 0.290309 ) -construct Quat with Matrix3: ( 0.554977 -0.216439 0.747950 -0.292789 ) -assign to Matrix3 from Matrix3: -( 0.148518 -0.866162 -0.851570 ) -( -0.071136 -0.773939 0.114814 ) -( -0.758292 0.261311 -0.531592 ) -set Matrix3 with float: -( 0.510961 0.510961 0.510961 ) -( 0.510961 0.510961 0.510961 ) -( 0.510961 0.510961 0.510961 ) -set Matrix3 with float: -( 0.791871 0.791871 0.791871 ) -( 0.791871 0.791871 0.791871 ) -( 0.791871 0.791871 0.791871 ) -set elements to zero: -( 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 1.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 ) -( 0.000000 0.844921 0.534891 ) -( 0.000000 -0.534891 0.844921 ) -set to rotationY: -( 0.962913 0.000000 0.269813 ) -( 0.000000 1.000000 0.000000 ) -( -0.269813 0.000000 0.962913 ) -set to rotationZ: -( 0.981168 -0.193156 0.000000 ) -( 0.193156 0.981168 0.000000 ) -( 0.000000 0.000000 1.000000 ) -set to rotation from Z,Y,X angles: -( 0.935176 0.037174 -0.352226 ) -( 0.233454 0.683174 0.691934 ) -( 0.266354 -0.729309 0.630210 ) -set to rotation from axis angle: -( 0.943492 0.161034 0.289639 ) -( -0.047495 0.930683 -0.362731 ) -( -0.327974 0.328477 0.885740 ) -Matrix3 set col 0: -( -0.866162 0.161034 0.289639 ) -( -0.773939 0.930683 -0.362731 ) -( 0.261311 0.328477 0.885740 ) -Matrix3 set col 1: -( -0.866162 -0.866162 0.289639 ) -( -0.773939 -0.773939 -0.362731 ) -( 0.261311 0.261311 0.885740 ) -Matrix3 set col 2: -( -0.866162 -0.866162 -0.866162 ) -( -0.773939 -0.773939 -0.773939 ) -( 0.261311 0.261311 0.261311 ) -Matrix3 get col 0: ( -0.866162 -0.773939 0.261311 ) -Matrix3 get col 1: ( -0.866162 -0.773939 0.261311 ) -Matrix3 get col 2: ( -0.866162 -0.773939 0.261311 ) -Matrix3 set col 0: -( -0.851570 -0.866162 -0.866162 ) -( 0.114814 -0.773939 -0.773939 ) -( -0.531592 0.261311 0.261311 ) -Matrix3 set col 1: -( -0.851570 -0.851570 -0.866162 ) -( 0.114814 0.114814 -0.773939 ) -( -0.531592 -0.531592 0.261311 ) -Matrix3 set col 2: -( -0.851570 -0.851570 -0.851570 ) -( 0.114814 0.114814 0.114814 ) -( -0.531592 -0.531592 -0.531592 ) -Matrix3 get col 0: ( -0.851570 0.114814 -0.531592 ) -Matrix3 get col 1: ( -0.851570 0.114814 -0.531592 ) -Matrix3 get col 2: ( -0.851570 0.114814 -0.531592 ) -Matrix3 set row 0: -( -0.866162 -0.773939 0.261311 ) -( 0.114814 0.114814 0.114814 ) -( -0.531592 -0.531592 -0.531592 ) -Matrix3 set row 1: -( -0.866162 -0.773939 0.261311 ) -( -0.866162 -0.773939 0.261311 ) -( -0.531592 -0.531592 -0.531592 ) -Matrix3 set row 2: -( -0.866162 -0.773939 0.261311 ) -( -0.866162 -0.773939 0.261311 ) -( -0.866162 -0.773939 0.261311 ) -Matrix3 get row 0: ( -0.866162 -0.773939 0.261311 ) -Matrix3 get row 1: ( -0.866162 -0.773939 0.261311 ) -Matrix3 get row 2: ( -0.866162 -0.773939 0.261311 ) -set Matrix3[0]: -( -0.866162 -0.773939 0.261311 ) -( -0.773939 -0.773939 0.261311 ) -( 0.261311 -0.773939 0.261311 ) -set Matrix3[1]: -( -0.866162 -0.866162 0.261311 ) -( -0.773939 -0.773939 0.261311 ) -( 0.261311 0.261311 0.261311 ) -set Matrix3[2]: -( -0.866162 -0.866162 -0.866162 ) -( -0.773939 -0.773939 -0.773939 ) -( 0.261311 0.261311 0.261311 ) -get Matrix3[0]: ( -0.866162 -0.773939 0.261311 ) -get Matrix3[1]: ( -0.866162 -0.773939 0.261311 ) -get Matrix3[2]: ( -0.866162 -0.773939 0.261311 ) -Matrix3 set elements: -( -0.277798 -0.420178 0.795389 ) -( -0.032740 -0.522577 0.342900 ) -( 0.007412 0.324972 -0.913636 ) --0.277798 --0.032740 -0.007412 --0.420178 --0.522577 -0.324972 -0.795389 -0.342900 --0.913636 -set Vector3 with floats: ( 0.675222 0.144053 -0.632329 ) -set Vector3 with floats: ( -0.947120 -0.049367 0.126333 ) -set Vector3 with floats: ( -0.664206 0.220879 0.284219 ) -set Vector3 with floats: ( -0.387216 0.913568 0.531906 ) -set Vector4 with floats: ( 0.271995 -0.862601 -0.738694 0.514248 ) -set Vector4 with floats: ( -0.039363 0.429390 -0.769469 0.281336 ) -set Vector4 with floats: ( -0.203301 0.412586 0.567926 0.410131 ) -set Vector4 with floats: ( -0.462918 0.560953 -0.731715 -0.446158 ) -set Point3 with floats: ( -0.837491 -0.573480 -0.607820 ) -set Point3 with floats: ( 0.238415 0.213445 0.098612 ) -set Point3 with floats: ( 0.135072 -0.749274 -0.855977 ) -set Point3 with floats: ( 0.765675 -0.693447 0.131554 ) -set Quat with floats: ( -0.366757 -0.330409 -0.588816 0.352533 ) -set Quat with floats: ( -0.920523 -0.915255 0.631924 -0.870739 ) -set Quat with floats: ( 0.415605 -0.180974 0.775698 0.879357 ) -set Quat with floats: ( -0.993958 -0.298452 0.876855 0.982846 ) -set Matrix3 columns: -( 0.675222 -0.947120 -0.664206 ) -( 0.144053 -0.049367 0.220879 ) -( -0.632329 0.126333 0.284219 ) -set Matrix3 columns: -( -0.387216 0.675222 -0.947120 ) -( 0.913568 0.144053 -0.049367 ) -( 0.531906 -0.632329 0.126333 ) -set Matrix4 columns: -( 0.271995 -0.039363 -0.203301 -0.462918 ) -( -0.862601 0.429390 0.412586 0.560953 ) -( -0.738694 -0.769469 0.567926 -0.731715 ) -( 0.514248 0.281336 0.410131 -0.446158 ) -set Matrix4 columns: -( -0.462918 0.271995 -0.039363 -0.203301 ) -( 0.560953 -0.862601 0.429390 0.412586 ) -( -0.731715 -0.738694 -0.769469 0.567926 ) -( -0.446158 0.514248 0.281336 0.410131 ) -set Transform3 columns: -( 0.675222 -0.947120 -0.664206 -0.387216 ) -( 0.144053 -0.049367 0.220879 0.913568 ) -( -0.632329 0.126333 0.284219 0.531906 ) -set Transform3 columns: -( -0.387216 0.675222 -0.947120 -0.664206 ) -( 0.913568 0.144053 -0.049367 0.220879 ) -( 0.531906 -0.632329 0.126333 0.284219 ) -construct Matrix4 with Transform3: -( 0.675222 -0.947120 -0.664206 -0.387216 ) -( 0.144053 -0.049367 0.220879 0.913568 ) -( -0.632329 0.126333 0.284219 0.531906 ) -( 0.000000 0.000000 0.000000 1.000000 ) -construct Matrix4 with Matrix3 and Vector3: -( 0.675222 -0.947120 -0.664206 0.675222 ) -( 0.144053 -0.049367 0.220879 0.144053 ) -( -0.632329 0.126333 0.284219 -0.632329 ) -( 0.000000 0.000000 0.000000 1.000000 ) -construct Matrix4 with Quat and Vector3: -( 0.088252 0.657513 0.198944 0.675222 ) -( -0.172794 0.037572 0.647688 0.144053 ) -( 0.664864 0.130513 0.512639 -0.632329 ) -( 0.000000 0.000000 0.000000 1.000000 ) -assign to Matrix4 from Matrix4: -( -0.462918 0.271995 -0.039363 -0.203301 ) -( 0.560953 -0.862601 0.429390 0.412586 ) -( -0.731715 -0.738694 -0.769469 0.567926 ) -( -0.446158 0.514248 0.281336 0.410131 ) -set Matrix4 with float: -( -0.282564 -0.282564 -0.282564 -0.282564 ) -( -0.282564 -0.282564 -0.282564 -0.282564 ) -( -0.282564 -0.282564 -0.282564 -0.282564 ) -( -0.282564 -0.282564 -0.282564 -0.282564 ) -set Matrix4 with float: -( 0.953469 0.953469 0.953469 0.953469 ) -( 0.953469 0.953469 0.953469 0.953469 ) -( 0.953469 0.953469 0.953469 0.953469 ) -( 0.953469 0.953469 0.953469 0.953469 ) -set elements to zero: -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.583868 0.811849 0.000000 ) -( 0.000000 -0.811849 0.583868 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationY: -( 0.949918 0.000000 -0.312499 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.312499 0.000000 0.949918 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotationZ: -( 0.769721 -0.638380 0.000000 0.000000 ) -( 0.638380 0.769721 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotation from Z,Y,X angles: -( 0.911294 0.177317 0.371620 0.000000 ) -( -0.113182 0.975631 -0.187972 0.000000 ) -( -0.395894 0.129237 0.909156 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to rotation from axis angle: -( 0.856844 -0.448125 -0.254956 0.000000 ) -( 0.514339 0.708724 0.482872 0.000000 ) -( -0.035694 -0.544879 0.837754 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to translation: -( 1.000000 0.000000 0.000000 0.675222 ) -( 0.000000 1.000000 0.000000 0.144053 ) -( 0.000000 0.000000 1.000000 -0.632329 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to perspective matrix: -( 5.824870 0.000000 0.000000 0.000000 ) -( 0.000000 -3.026335 0.000000 0.000000 ) -( 0.000000 0.000000 -2.224833 -1.188350 ) -( 0.000000 0.000000 -1.000000 0.000000 ) -set to frustum matrix: -( -0.477514 0.000000 1.070274 0.000000 ) -( 0.000000 -24.527069 -7.801479 0.000000 ) -( 0.000000 0.000000 -0.473057 0.272420 ) -( 0.000000 0.000000 -1.000000 0.000000 ) -set to orthographic matrix: -( 32.423248 0.000000 0.000000 23.964319 ) -( 0.000000 -2.278212 0.000000 -0.092664 ) -( 0.000000 0.000000 2.155617 -0.869770 ) -( 0.000000 0.000000 0.000000 1.000000 ) -set to look-at matrix: -( -0.441820 0.853126 -0.277437 -0.049401 ) -( 0.544212 0.009028 -0.838899 -0.048950 ) -( -0.713182 -0.521627 -0.468270 -1.181050 ) -( 0.000000 0.000000 0.000000 1.000000 ) -Matrix4 set col 0: -( 0.271995 0.853126 -0.277437 -0.049401 ) -( -0.862601 0.009028 -0.838899 -0.048950 ) -( -0.738694 -0.521627 -0.468270 -1.181050 ) -( 0.514248 0.000000 0.000000 1.000000 ) -Matrix4 set col 1: -( 0.271995 0.271995 -0.277437 -0.049401 ) -( -0.862601 -0.862601 -0.838899 -0.048950 ) -( -0.738694 -0.738694 -0.468270 -1.181050 ) -( 0.514248 0.514248 0.000000 1.000000 ) -Matrix4 set col 2: -( 0.271995 0.271995 0.271995 -0.049401 ) -( -0.862601 -0.862601 -0.862601 -0.048950 ) -( -0.738694 -0.738694 -0.738694 -1.181050 ) -( 0.514248 0.514248 0.514248 1.000000 ) -Matrix4 set col 3: -( 0.271995 0.271995 0.271995 0.271995 ) -( -0.862601 -0.862601 -0.862601 -0.862601 ) -( -0.738694 -0.738694 -0.738694 -0.738694 ) -( 0.514248 0.514248 0.514248 0.514248 ) -Matrix4 get col 0: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get col 1: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get col 2: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get col 3: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 set col 0: -( -0.039363 0.271995 0.271995 0.271995 ) -( 0.429390 -0.862601 -0.862601 -0.862601 ) -( -0.769469 -0.738694 -0.738694 -0.738694 ) -( 0.281336 0.514248 0.514248 0.514248 ) -Matrix4 set col 1: -( -0.039363 -0.039363 0.271995 0.271995 ) -( 0.429390 0.429390 -0.862601 -0.862601 ) -( -0.769469 -0.769469 -0.738694 -0.738694 ) -( 0.281336 0.281336 0.514248 0.514248 ) -Matrix4 set col 2: -( -0.039363 -0.039363 -0.039363 0.271995 ) -( 0.429390 0.429390 0.429390 -0.862601 ) -( -0.769469 -0.769469 -0.769469 -0.738694 ) -( 0.281336 0.281336 0.281336 0.514248 ) -Matrix4 set col 3: -( -0.039363 -0.039363 -0.039363 -0.039363 ) -( 0.429390 0.429390 0.429390 0.429390 ) -( -0.769469 -0.769469 -0.769469 -0.769469 ) -( 0.281336 0.281336 0.281336 0.281336 ) -Matrix4 get col 0: ( -0.039363 0.429390 -0.769469 0.281336 ) -Matrix4 get col 1: ( -0.039363 0.429390 -0.769469 0.281336 ) -Matrix4 get col 2: ( -0.039363 0.429390 -0.769469 0.281336 ) -Matrix4 get col 3: ( -0.039363 0.429390 -0.769469 0.281336 ) -Matrix4 set row 0: -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.429390 0.429390 0.429390 0.429390 ) -( -0.769469 -0.769469 -0.769469 -0.769469 ) -( 0.281336 0.281336 0.281336 0.281336 ) -Matrix4 set row 1: -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -( -0.769469 -0.769469 -0.769469 -0.769469 ) -( 0.281336 0.281336 0.281336 0.281336 ) -Matrix4 set row 2: -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.281336 0.281336 0.281336 0.281336 ) -Matrix4 set row 3: -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get row 0: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get row 1: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get row 2: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 get row 3: ( 0.271995 -0.862601 -0.738694 0.514248 ) -set Matrix4[0]: -( 0.271995 -0.862601 -0.738694 0.514248 ) -( -0.862601 -0.862601 -0.738694 0.514248 ) -( -0.738694 -0.862601 -0.738694 0.514248 ) -( 0.514248 -0.862601 -0.738694 0.514248 ) -set Matrix4[1]: -( 0.271995 0.271995 -0.738694 0.514248 ) -( -0.862601 -0.862601 -0.738694 0.514248 ) -( -0.738694 -0.738694 -0.738694 0.514248 ) -( 0.514248 0.514248 -0.738694 0.514248 ) -set Matrix4[2]: -( 0.271995 0.271995 0.271995 0.514248 ) -( -0.862601 -0.862601 -0.862601 0.514248 ) -( -0.738694 -0.738694 -0.738694 0.514248 ) -( 0.514248 0.514248 0.514248 0.514248 ) -set Matrix4[3]: -( 0.271995 0.271995 0.271995 0.271995 ) -( -0.862601 -0.862601 -0.862601 -0.862601 ) -( -0.738694 -0.738694 -0.738694 -0.738694 ) -( 0.514248 0.514248 0.514248 0.514248 ) -get Matrix4[0]: ( 0.271995 -0.862601 -0.738694 0.514248 ) -get Matrix4[1]: ( 0.271995 -0.862601 -0.738694 0.514248 ) -get Matrix4[2]: ( 0.271995 -0.862601 -0.738694 0.514248 ) -get Matrix4[3]: ( 0.271995 -0.862601 -0.738694 0.514248 ) -Matrix4 set elements: -( -0.702364 -0.967562 -0.470750 -0.712890 ) -( -0.182602 -0.520296 -0.846580 -0.064487 ) -( -0.832807 0.160191 -0.705751 0.444065 ) -( 0.278191 -0.677990 -0.825368 -0.045226 ) --0.702364 --0.182602 --0.832807 -0.278191 --0.967562 --0.520296 -0.160191 --0.677990 --0.470750 --0.846580 --0.705751 --0.825368 --0.712890 --0.064487 -0.444065 --0.045226 -set Vector3 with floats: ( 0.116544 -0.007285 -0.838230 ) -set Vector3 with floats: ( -0.410767 -0.409299 -0.336683 ) -set Vector3 with floats: ( -0.830700 -0.801729 -0.595153 ) -set Vector3 with floats: ( -0.784672 -0.653655 0.670791 ) -set Vector4 with floats: ( 0.653571 0.850716 0.071433 -0.057715 ) -set Vector4 with floats: ( 0.401895 0.016861 0.535438 0.965901 ) -set Vector4 with floats: ( -0.072675 0.341689 0.781662 0.707322 ) -set Vector4 with floats: ( 0.505889 0.432790 -0.825793 0.597719 ) -set Point3 with floats: ( -0.250905 -0.085712 -0.272847 ) -set Point3 with floats: ( 0.552644 0.194203 -0.884427 ) -set Point3 with floats: ( -0.756791 0.121107 0.312483 ) -set Point3 with floats: ( -0.873317 0.045081 0.687444 ) -set Quat with floats: ( -0.684626 -0.994047 0.800366 -0.565640 ) -set Quat with floats: ( -0.625626 0.932585 0.636928 0.420250 ) -set Quat with floats: ( 0.175863 0.362158 0.547496 -0.534423 ) -set Quat with floats: ( -0.563030 -0.254488 0.647778 -0.674240 ) -set Matrix3 columns: -( 0.116544 -0.410767 -0.830700 ) -( -0.007285 -0.409299 -0.801729 ) -( -0.838230 -0.336683 -0.595153 ) -set Matrix3 columns: -( -0.784672 0.116544 -0.410767 ) -( -0.653655 -0.007285 -0.409299 ) -( 0.670791 -0.838230 -0.336683 ) -set Matrix4 columns: -( 0.653571 0.401895 -0.072675 0.505889 ) -( 0.850716 0.016861 0.341689 0.432790 ) -( 0.071433 0.535438 0.781662 -0.825793 ) -( -0.057715 0.965901 0.707322 0.597719 ) -set Matrix4 columns: -( 0.505889 0.653571 0.401895 -0.072675 ) -( 0.432790 0.850716 0.016861 0.341689 ) -( -0.825793 0.071433 0.535438 0.781662 ) -( 0.597719 -0.057715 0.965901 0.707322 ) -set Transform3 columns: -( 0.116544 -0.410767 -0.830700 -0.784672 ) -( -0.007285 -0.409299 -0.801729 -0.653655 ) -( -0.838230 -0.336683 -0.595153 0.670791 ) -set Transform3 columns: -( -0.784672 0.116544 -0.410767 -0.830700 ) -( -0.653655 -0.007285 -0.409299 -0.801729 ) -( 0.670791 -0.838230 -0.336683 -0.595153 ) -construct Transform3 with Matrix3 and Vector3: -( 0.116544 -0.410767 -0.830700 0.116544 ) -( -0.007285 -0.409299 -0.801729 -0.007285 ) -( -0.838230 -0.336683 -0.595153 -0.838230 ) -construct Transform3 with Quat and Vector3: -( -2.257427 2.266537 0.028644 0.116544 ) -( 0.455662 -1.218594 -2.365705 -0.007285 ) -( -2.220447 -0.816698 -1.913682 -0.838230 ) -assign to Transform3 from Transform3: -( -0.784672 0.116544 -0.410767 -0.830700 ) -( -0.653655 -0.007285 -0.409299 -0.801729 ) -( 0.670791 -0.838230 -0.336683 -0.595153 ) -set Transform3 with float: -( 0.224345 0.224345 0.224345 0.224345 ) -( 0.224345 0.224345 0.224345 0.224345 ) -( 0.224345 0.224345 0.224345 0.224345 ) -set Transform3 with float: -( -0.754563 -0.754563 -0.754563 -0.754563 ) -( -0.754563 -0.754563 -0.754563 -0.754563 ) -( -0.754563 -0.754563 -0.754563 -0.754563 ) -set elements to zero: -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.000000 0.000000 0.000000 ) -set to identity: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -set to rotationX: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 0.991715 0.128461 0.000000 ) -( 0.000000 -0.128461 0.991715 0.000000 ) -set to rotationY: -( 0.542120 0.000000 -0.840301 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( 0.840301 0.000000 0.542120 0.000000 ) -set to rotationZ: -( 0.999319 -0.036908 0.000000 0.000000 ) -( 0.036908 0.999319 0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 0.000000 ) -set to rotation from Z,Y,X angles: -( 0.927336 -0.248591 0.279733 0.000000 ) -( -0.072059 0.614889 0.785314 0.000000 ) -( -0.367227 -0.748408 0.552296 0.000000 ) -set to rotation from axis angle: -( 0.982382 -0.186883 -0.000825 0.000000 ) -( 0.186841 0.982043 0.026134 0.000000 ) -( -0.004073 -0.025827 0.999658 0.000000 ) -set to translation: -( 1.000000 0.000000 0.000000 0.116544 ) -( 0.000000 1.000000 0.000000 -0.007285 ) -( 0.000000 0.000000 1.000000 -0.838230 ) -Transform3 set col 0: -( 0.116544 0.000000 0.000000 0.116544 ) -( -0.007285 1.000000 0.000000 -0.007285 ) -( -0.838230 0.000000 1.000000 -0.838230 ) -Transform3 set col 1: -( 0.116544 0.116544 0.000000 0.116544 ) -( -0.007285 -0.007285 0.000000 -0.007285 ) -( -0.838230 -0.838230 1.000000 -0.838230 ) -Transform3 set col 2: -( 0.116544 0.116544 0.116544 0.116544 ) -( -0.007285 -0.007285 -0.007285 -0.007285 ) -( -0.838230 -0.838230 -0.838230 -0.838230 ) -Transform3 set col 3: -( 0.116544 0.116544 0.116544 0.116544 ) -( -0.007285 -0.007285 -0.007285 -0.007285 ) -( -0.838230 -0.838230 -0.838230 -0.838230 ) -Transform3 get col 0: ( 0.116544 -0.007285 -0.838230 ) -Transform3 get col 1: ( 0.116544 -0.007285 -0.838230 ) -Transform3 get col 2: ( 0.116544 -0.007285 -0.838230 ) -Transform3 get col 3: ( 0.116544 -0.007285 -0.838230 ) -Transform3 set col 0: -( -0.410767 0.116544 0.116544 0.116544 ) -( -0.409299 -0.007285 -0.007285 -0.007285 ) -( -0.336683 -0.838230 -0.838230 -0.838230 ) -Transform3 set col 1: -( -0.410767 -0.410767 0.116544 0.116544 ) -( -0.409299 -0.409299 -0.007285 -0.007285 ) -( -0.336683 -0.336683 -0.838230 -0.838230 ) -Transform3 set col 2: -( -0.410767 -0.410767 -0.410767 0.116544 ) -( -0.409299 -0.409299 -0.409299 -0.007285 ) -( -0.336683 -0.336683 -0.336683 -0.838230 ) -Transform3 set col 3: -( -0.410767 -0.410767 -0.410767 -0.410767 ) -( -0.409299 -0.409299 -0.409299 -0.409299 ) -( -0.336683 -0.336683 -0.336683 -0.336683 ) -Transform3 get col 0: ( -0.410767 -0.409299 -0.336683 ) -Transform3 get col 1: ( -0.410767 -0.409299 -0.336683 ) -Transform3 get col 2: ( -0.410767 -0.409299 -0.336683 ) -Transform3 get col 3: ( -0.410767 -0.409299 -0.336683 ) -Transform3 set row 0: -( 0.653571 0.850716 0.071433 -0.057715 ) -( -0.409299 -0.409299 -0.409299 -0.409299 ) -( -0.336683 -0.336683 -0.336683 -0.336683 ) -Transform3 set row 1: -( 0.653571 0.850716 0.071433 -0.057715 ) -( 0.653571 0.850716 0.071433 -0.057715 ) -( -0.336683 -0.336683 -0.336683 -0.336683 ) -Transform3 set row 2: -( 0.653571 0.850716 0.071433 -0.057715 ) -( 0.653571 0.850716 0.071433 -0.057715 ) -( 0.653571 0.850716 0.071433 -0.057715 ) -Transform3 get row 0: ( 0.653571 0.850716 0.071433 -0.057715 ) -Transform3 get row 1: ( 0.653571 0.850716 0.071433 -0.057715 ) -Transform3 get row 2: ( 0.653571 0.850716 0.071433 -0.057715 ) -set Transform3[0]: -( 0.116544 0.850716 0.071433 -0.057715 ) -( -0.007285 0.850716 0.071433 -0.057715 ) -( -0.838230 0.850716 0.071433 -0.057715 ) -set Transform3[1]: -( 0.116544 0.116544 0.071433 -0.057715 ) -( -0.007285 -0.007285 0.071433 -0.057715 ) -( -0.838230 -0.838230 0.071433 -0.057715 ) -set Transform3[2]: -( 0.116544 0.116544 0.116544 -0.057715 ) -( -0.007285 -0.007285 -0.007285 -0.057715 ) -( -0.838230 -0.838230 -0.838230 -0.057715 ) -set Transform3[3]: -( 0.116544 0.116544 0.116544 0.116544 ) -( -0.007285 -0.007285 -0.007285 -0.007285 ) -( -0.838230 -0.838230 -0.838230 -0.838230 ) -get Transform3[0]: ( 0.116544 -0.007285 -0.838230 ) -get Transform3[1]: ( 0.116544 -0.007285 -0.838230 ) -get Transform3[2]: ( 0.116544 -0.007285 -0.838230 ) -get Transform3[3]: ( 0.116544 -0.007285 -0.838230 ) -Transform3 set elements: -( 0.007649 -0.271484 -0.836501 -0.287826 ) -( -0.440298 -0.259070 0.229093 0.942655 ) -( 0.994796 0.902149 0.586393 -0.634432 ) -0.007649 --0.440298 -0.994796 --0.271484 --0.259070 -0.902149 --0.836501 -0.229093 -0.586393 --0.287826 -0.942655 --0.634432 - - __end__ diff --git a/Extras/vectormathlibrary/tests/test2_soa_c.c b/Extras/vectormathlibrary/tests/test2_soa_c.c deleted file mode 100644 index 6c64bf187..000000000 --- a/Extras/vectormathlibrary/tests/test2_soa_c.c +++ /dev/null @@ -1,760 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9, tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaQNormalize( &tmpQ_0, &a_Quat ); - vmathSoaM3MakeFromQ( &a_Matrix3, &tmpQ_0 ); - vmathSoaM3Prints( &a_Matrix3, "construct Matrix3 with Quat" ); - vmathSoaQMakeFromM3( &a_Quat, &a_Matrix3 ); - vmathSoaQPrints( &a_Quat, "construct Quat with Matrix3" ); - vmathSoaM3Copy( &a_Matrix3, &b_Matrix3 ); - vmathSoaM3Prints( &a_Matrix3, "assign to Matrix3 from Matrix3" ); - vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" ); - vmathSoaM3MakeFromScalar( &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 with float" ); - vmathSoaM3MakeFromScalar( &a_Matrix3, (vec_float4){0.0f} ); - vmathSoaM3Prints( &a_Matrix3, "set elements to zero" ); - vmathSoaM3MakeIdentity( &a_Matrix3 ); - vmathSoaM3Prints( &a_Matrix3, "set to identity" ); - vmathSoaM3MakeRotationX( &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "set to rotationX" ); - vmathSoaM3MakeRotationY( &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "set to rotationY" ); - vmathSoaM3MakeRotationZ( &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); - vmathSoaM3MakeRotationZYX( &a_Matrix3, &tmpV3_0 ); - vmathSoaM3Prints( &a_Matrix3, "set to rotation from Z,Y,X angles" ); - vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); - vmathSoaM3MakeRotationAxis( &a_Matrix3, randfloat(), &tmpV3_1 ); - vmathSoaM3Prints( &a_Matrix3, "set to rotation from axis angle" ); - vmathSoaM3SetCol0( &a_Matrix3, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" ); - vmathSoaM3SetCol1( &a_Matrix3, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" ); - vmathSoaM3SetCol2( &a_Matrix3, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" ); - vmathSoaM3GetCol0( &tmpV3_2, &a_Matrix3 ); - vmathSoaV3Prints( &tmpV3_2, "Matrix3 get col 0" ); - vmathSoaM3GetCol1( &tmpV3_3, &a_Matrix3 ); - vmathSoaV3Prints( &tmpV3_3, "Matrix3 get col 1" ); - vmathSoaM3GetCol2( &tmpV3_4, &a_Matrix3 ); - vmathSoaV3Prints( &tmpV3_4, "Matrix3 get col 2" ); - vmathSoaM3SetCol( &a_Matrix3, 0, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 0" ); - vmathSoaM3SetCol( &a_Matrix3, 1, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 1" ); - vmathSoaM3SetCol( &a_Matrix3, 2, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set col 2" ); - vmathSoaM3GetCol( &tmpV3_5, &a_Matrix3, 0 ); - vmathSoaV3Prints( &tmpV3_5, "Matrix3 get col 0" ); - vmathSoaM3GetCol( &tmpV3_6, &a_Matrix3, 1 ); - vmathSoaV3Prints( &tmpV3_6, "Matrix3 get col 1" ); - vmathSoaM3GetCol( &tmpV3_7, &a_Matrix3, 2 ); - vmathSoaV3Prints( &tmpV3_7, "Matrix3 get col 2" ); - vmathSoaM3SetRow( &a_Matrix3, 0, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 0" ); - vmathSoaM3SetRow( &a_Matrix3, 1, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 1" ); - vmathSoaM3SetRow( &a_Matrix3, 2, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set row 2" ); - vmathSoaM3GetRow( &tmpV3_8, &a_Matrix3, 0 ); - vmathSoaV3Prints( &tmpV3_8, "Matrix3 get row 0" ); - vmathSoaM3GetRow( &tmpV3_9, &a_Matrix3, 1 ); - vmathSoaV3Prints( &tmpV3_9, "Matrix3 get row 1" ); - vmathSoaM3GetRow( &tmpV3_10, &a_Matrix3, 2 ); - vmathSoaV3Prints( &tmpV3_10, "Matrix3 get row 2" ); - vmathSoaM3SetCol( &a_Matrix3, 0, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set " ); - vmathSoaM3SetCol( &a_Matrix3, 1, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set " ); - vmathSoaM3SetCol( &a_Matrix3, 2, &a_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set " ); - vmathSoaM3GetCol( &tmpV3_11, &a_Matrix3, 0 ); - vmathSoaV3Prints( &tmpV3_11, "get " ); - vmathSoaM3GetCol( &tmpV3_12, &a_Matrix3, 1 ); - vmathSoaV3Prints( &tmpV3_12, "get " ); - vmathSoaM3GetCol( &tmpV3_13, &a_Matrix3, 2 ); - vmathSoaV3Prints( &tmpV3_13, "get " ); - vmathSoaM3SetElem( &a_Matrix3, 0, 0, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 0, 1, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 0, 2, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 1, 0, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 1, 1, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 1, 2, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 2, 0, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 2, 1, randfloat() ); - vmathSoaM3SetElem( &a_Matrix3, 2, 2, randfloat() ); - vmathSoaM3Prints( &a_Matrix3, "Matrix3 set elements" ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 0 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 1 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 0, 2 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 0 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 1 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 1, 2 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 0 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 1 )) ); - printf("%f\n", getfloat(vmathSoaM3GetElem( &a_Matrix3, 2, 2 )) ); -} - -void -Matrix4_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector3 tmpV3_0, tmpV3_1; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2, tmpV4_3, tmpV4_4, tmpV4_5, tmpV4_6, tmpV4_7, tmpV4_8, tmpV4_9, tmpV4_10, tmpV4_11, tmpV4_12, tmpV4_13, tmpV4_14, tmpV4_15; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaM4MakeFromT3( &a_Matrix4, &a_Transform3 ); - vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Transform3" ); - vmathSoaM4MakeFromM3V3( &a_Matrix4, &a_Matrix3, &a_Vector3 ); - vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); - vmathSoaM4MakeFromQV3( &a_Matrix4, &a_Quat, &a_Vector3 ); - vmathSoaM4Prints( &a_Matrix4, "construct Matrix4 with Quat and Vector3" ); - vmathSoaM4Copy( &a_Matrix4, &b_Matrix4 ); - vmathSoaM4Prints( &a_Matrix4, "assign to Matrix4 from Matrix4" ); - vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" ); - vmathSoaM4MakeFromScalar( &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 with float" ); - vmathSoaM4MakeFromScalar( &a_Matrix4, (vec_float4){0.0f} ); - vmathSoaM4Prints( &a_Matrix4, "set elements to zero" ); - vmathSoaM4MakeIdentity( &a_Matrix4 ); - vmathSoaM4Prints( &a_Matrix4, "set to identity" ); - vmathSoaM4MakeRotationX( &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "set to rotationX" ); - vmathSoaM4MakeRotationY( &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "set to rotationY" ); - vmathSoaM4MakeRotationZ( &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); - vmathSoaM4MakeRotationZYX( &a_Matrix4, &tmpV3_0 ); - vmathSoaM4Prints( &a_Matrix4, "set to rotation from Z,Y,X angles" ); - vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); - vmathSoaM4MakeRotationAxis( &a_Matrix4, randfloat(), &tmpV3_1 ); - vmathSoaM4Prints( &a_Matrix4, "set to rotation from axis angle" ); - vmathSoaM4MakeTranslation( &a_Matrix4, &a_Vector3 ); - vmathSoaM4Prints( &a_Matrix4, "set to translation" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaM4MakePerspective( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaM4Prints( &a_Matrix4, "set to perspective matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaM4MakeFrustum( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - vmathSoaM4Prints( &a_Matrix4, "set to frustum matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaM4MakeOrthographic( &a_Matrix4, rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - vmathSoaM4Prints( &a_Matrix4, "set to orthographic matrix" ); - vmathSoaM4MakeLookAt( &a_Matrix4, &a_Point3, &b_Point3, &a_Vector3 ); - vmathSoaM4Prints( &a_Matrix4, "set to look-at matrix" ); - vmathSoaM4SetCol0( &a_Matrix4, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" ); - vmathSoaM4SetCol1( &a_Matrix4, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" ); - vmathSoaM4SetCol2( &a_Matrix4, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" ); - vmathSoaM4SetCol3( &a_Matrix4, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" ); - vmathSoaM4GetCol0( &tmpV4_0, &a_Matrix4 ); - vmathSoaV4Prints( &tmpV4_0, "Matrix4 get col 0" ); - vmathSoaM4GetCol1( &tmpV4_1, &a_Matrix4 ); - vmathSoaV4Prints( &tmpV4_1, "Matrix4 get col 1" ); - vmathSoaM4GetCol2( &tmpV4_2, &a_Matrix4 ); - vmathSoaV4Prints( &tmpV4_2, "Matrix4 get col 2" ); - vmathSoaM4GetCol3( &tmpV4_3, &a_Matrix4 ); - vmathSoaV4Prints( &tmpV4_3, "Matrix4 get col 3" ); - vmathSoaM4SetCol( &a_Matrix4, 0, &b_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 0" ); - vmathSoaM4SetCol( &a_Matrix4, 1, &b_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 1" ); - vmathSoaM4SetCol( &a_Matrix4, 2, &b_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 2" ); - vmathSoaM4SetCol( &a_Matrix4, 3, &b_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set col 3" ); - vmathSoaM4GetCol( &tmpV4_4, &a_Matrix4, 0 ); - vmathSoaV4Prints( &tmpV4_4, "Matrix4 get col 0" ); - vmathSoaM4GetCol( &tmpV4_5, &a_Matrix4, 1 ); - vmathSoaV4Prints( &tmpV4_5, "Matrix4 get col 1" ); - vmathSoaM4GetCol( &tmpV4_6, &a_Matrix4, 2 ); - vmathSoaV4Prints( &tmpV4_6, "Matrix4 get col 2" ); - vmathSoaM4GetCol( &tmpV4_7, &a_Matrix4, 3 ); - vmathSoaV4Prints( &tmpV4_7, "Matrix4 get col 3" ); - vmathSoaM4SetRow( &a_Matrix4, 0, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 0" ); - vmathSoaM4SetRow( &a_Matrix4, 1, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 1" ); - vmathSoaM4SetRow( &a_Matrix4, 2, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 2" ); - vmathSoaM4SetRow( &a_Matrix4, 3, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set row 3" ); - vmathSoaM4GetRow( &tmpV4_8, &a_Matrix4, 0 ); - vmathSoaV4Prints( &tmpV4_8, "Matrix4 get row 0" ); - vmathSoaM4GetRow( &tmpV4_9, &a_Matrix4, 1 ); - vmathSoaV4Prints( &tmpV4_9, "Matrix4 get row 1" ); - vmathSoaM4GetRow( &tmpV4_10, &a_Matrix4, 2 ); - vmathSoaV4Prints( &tmpV4_10, "Matrix4 get row 2" ); - vmathSoaM4GetRow( &tmpV4_11, &a_Matrix4, 3 ); - vmathSoaV4Prints( &tmpV4_11, "Matrix4 get row 3" ); - vmathSoaM4SetCol( &a_Matrix4, 0, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set " ); - vmathSoaM4SetCol( &a_Matrix4, 1, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set " ); - vmathSoaM4SetCol( &a_Matrix4, 2, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set " ); - vmathSoaM4SetCol( &a_Matrix4, 3, &a_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set " ); - vmathSoaM4GetCol( &tmpV4_12, &a_Matrix4, 0 ); - vmathSoaV4Prints( &tmpV4_12, "get " ); - vmathSoaM4GetCol( &tmpV4_13, &a_Matrix4, 1 ); - vmathSoaV4Prints( &tmpV4_13, "get " ); - vmathSoaM4GetCol( &tmpV4_14, &a_Matrix4, 2 ); - vmathSoaV4Prints( &tmpV4_14, "get " ); - vmathSoaM4GetCol( &tmpV4_15, &a_Matrix4, 3 ); - vmathSoaV4Prints( &tmpV4_15, "get " ); - vmathSoaM4SetElem( &a_Matrix4, 0, 0, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 0, 1, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 0, 2, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 0, 3, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 1, 0, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 1, 1, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 1, 2, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 1, 3, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 2, 0, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 2, 1, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 2, 2, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 2, 3, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 3, 0, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 3, 1, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 3, 2, randfloat() ); - vmathSoaM4SetElem( &a_Matrix4, 3, 3, randfloat() ); - vmathSoaM4Prints( &a_Matrix4, "Matrix4 set elements" ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 0 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 1 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 2 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 0, 3 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 0 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 1 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 2 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 1, 3 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 0 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 1 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 2 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 2, 3 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 0 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 1 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 2 )) ); - printf("%f\n", getfloat(vmathSoaM4GetElem( &a_Matrix4, 3, 3 )) ); -} - -void -Transform3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8, tmpV3_9; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2; - VmathSoaVector3 tmpV3_10, tmpV3_11, tmpV3_12, tmpV3_13; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaT3MakeFromM3V3( &a_Transform3, &a_Matrix3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); - vmathSoaT3MakeFromQV3( &a_Transform3, &a_Quat, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "construct Transform3 with Quat and Vector3" ); - vmathSoaT3Copy( &a_Transform3, &b_Transform3 ); - vmathSoaT3Prints( &a_Transform3, "assign to Transform3 from Transform3" ); - vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" ); - vmathSoaT3MakeFromScalar( &a_Transform3, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 with float" ); - vmathSoaT3MakeFromScalar( &a_Transform3, (vec_float4){0.0f} ); - vmathSoaT3Prints( &a_Transform3, "set elements to zero" ); - vmathSoaT3MakeIdentity( &a_Transform3 ); - vmathSoaT3Prints( &a_Transform3, "set to identity" ); - vmathSoaT3MakeRotationX( &a_Transform3, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "set to rotationX" ); - vmathSoaT3MakeRotationY( &a_Transform3, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "set to rotationY" ); - vmathSoaT3MakeRotationZ( &a_Transform3, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &tmpV3_0, rndflt3, rndflt2, rndflt1 ); - vmathSoaT3MakeRotationZYX( &a_Transform3, &tmpV3_0 ); - vmathSoaT3Prints( &a_Transform3, "set to rotation from Z,Y,X angles" ); - vmathSoaV3Normalize( &tmpV3_1, &a_Vector3 ); - vmathSoaT3MakeRotationAxis( &a_Transform3, randfloat(), &tmpV3_1 ); - vmathSoaT3Prints( &a_Transform3, "set to rotation from axis angle" ); - vmathSoaT3MakeTranslation( &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set to translation" ); - vmathSoaT3SetCol0( &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" ); - vmathSoaT3SetCol1( &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" ); - vmathSoaT3SetCol2( &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" ); - vmathSoaT3SetCol3( &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" ); - vmathSoaT3GetCol0( &tmpV3_2, &a_Transform3 ); - vmathSoaV3Prints( &tmpV3_2, "Transform3 get col 0" ); - vmathSoaT3GetCol1( &tmpV3_3, &a_Transform3 ); - vmathSoaV3Prints( &tmpV3_3, "Transform3 get col 1" ); - vmathSoaT3GetCol2( &tmpV3_4, &a_Transform3 ); - vmathSoaV3Prints( &tmpV3_4, "Transform3 get col 2" ); - vmathSoaT3GetCol3( &tmpV3_5, &a_Transform3 ); - vmathSoaV3Prints( &tmpV3_5, "Transform3 get col 3" ); - vmathSoaT3SetCol( &a_Transform3, 0, &b_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 0" ); - vmathSoaT3SetCol( &a_Transform3, 1, &b_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 1" ); - vmathSoaT3SetCol( &a_Transform3, 2, &b_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 2" ); - vmathSoaT3SetCol( &a_Transform3, 3, &b_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set col 3" ); - vmathSoaT3GetCol( &tmpV3_6, &a_Transform3, 0 ); - vmathSoaV3Prints( &tmpV3_6, "Transform3 get col 0" ); - vmathSoaT3GetCol( &tmpV3_7, &a_Transform3, 1 ); - vmathSoaV3Prints( &tmpV3_7, "Transform3 get col 1" ); - vmathSoaT3GetCol( &tmpV3_8, &a_Transform3, 2 ); - vmathSoaV3Prints( &tmpV3_8, "Transform3 get col 2" ); - vmathSoaT3GetCol( &tmpV3_9, &a_Transform3, 3 ); - vmathSoaV3Prints( &tmpV3_9, "Transform3 get col 3" ); - vmathSoaT3SetRow( &a_Transform3, 0, &a_Vector4 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set row 0" ); - vmathSoaT3SetRow( &a_Transform3, 1, &a_Vector4 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set row 1" ); - vmathSoaT3SetRow( &a_Transform3, 2, &a_Vector4 ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set row 2" ); - vmathSoaT3GetRow( &tmpV4_0, &a_Transform3, 0 ); - vmathSoaV4Prints( &tmpV4_0, "Transform3 get row 0" ); - vmathSoaT3GetRow( &tmpV4_1, &a_Transform3, 1 ); - vmathSoaV4Prints( &tmpV4_1, "Transform3 get row 1" ); - vmathSoaT3GetRow( &tmpV4_2, &a_Transform3, 2 ); - vmathSoaV4Prints( &tmpV4_2, "Transform3 get row 2" ); - vmathSoaT3SetCol( &a_Transform3, 0, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set " ); - vmathSoaT3SetCol( &a_Transform3, 1, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set " ); - vmathSoaT3SetCol( &a_Transform3, 2, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set " ); - vmathSoaT3SetCol( &a_Transform3, 3, &a_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set " ); - vmathSoaT3GetCol( &tmpV3_10, &a_Transform3, 0 ); - vmathSoaV3Prints( &tmpV3_10, "get " ); - vmathSoaT3GetCol( &tmpV3_11, &a_Transform3, 1 ); - vmathSoaV3Prints( &tmpV3_11, "get " ); - vmathSoaT3GetCol( &tmpV3_12, &a_Transform3, 2 ); - vmathSoaV3Prints( &tmpV3_12, "get " ); - vmathSoaT3GetCol( &tmpV3_13, &a_Transform3, 3 ); - vmathSoaV3Prints( &tmpV3_13, "get " ); - vmathSoaT3SetElem( &a_Transform3, 0, 0, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 0, 1, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 0, 2, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 1, 0, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 1, 1, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 1, 2, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 2, 0, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 2, 1, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 2, 2, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 3, 0, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 3, 1, randfloat() ); - vmathSoaT3SetElem( &a_Transform3, 3, 2, randfloat() ); - vmathSoaT3Prints( &a_Transform3, "Transform3 set elements" ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 0 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 1 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 0, 2 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 0 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 1 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 1, 2 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 0 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 1 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 2, 2 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 0 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 1 )) ); - printf("%f\n", getfloat(vmathSoaT3GetElem( &a_Transform3, 3, 2 )) ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test2_soa_cpp.cpp b/Extras/vectormathlibrary/tests/test2_soa_cpp.cpp deleted file mode 100644 index 6ec58159b..000000000 --- a/Extras/vectormathlibrary/tests/test2_soa_cpp.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Soa; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Matrix3 = Matrix3( normalize( a_Quat ) ); - print( a_Matrix3, "construct Matrix3 with Quat" ); - a_Quat = Quat( a_Matrix3 ); - print( a_Quat, "construct Quat with Matrix3" ); - a_Matrix3 = b_Matrix3; - print( a_Matrix3, "assign to Matrix3 from Matrix3" ); - a_Matrix3 = Matrix3( randfloat() ); - print( a_Matrix3, "set Matrix3 with float" ); - a_Matrix3 = Matrix3( randfloat() ); - print( a_Matrix3, "set Matrix3 with float" ); - a_Matrix3 = Matrix3( (vec_float4){0.0f} ); - print( a_Matrix3, "set elements to zero" ); - a_Matrix3 = Matrix3::identity( ); - print( a_Matrix3, "set to identity" ); - a_Matrix3 = Matrix3::rotationX( randfloat() ); - print( a_Matrix3, "set to rotationX" ); - a_Matrix3 = Matrix3::rotationY( randfloat() ); - print( a_Matrix3, "set to rotationY" ); - a_Matrix3 = Matrix3::rotationZ( randfloat() ); - print( a_Matrix3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Matrix3 = Matrix3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Matrix3, "set to rotation from Z,Y,X angles" ); - a_Matrix3 = Matrix3::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Matrix3, "set to rotation from axis angle" ); - a_Matrix3.setCol0( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 0" ); - a_Matrix3.setCol1( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 1" ); - a_Matrix3.setCol2( a_Vector3 ); - print( a_Matrix3, "Matrix3 set col 2" ); - print( a_Matrix3.getCol0( ), "Matrix3 get col 0" ); - print( a_Matrix3.getCol1( ), "Matrix3 get col 1" ); - print( a_Matrix3.getCol2( ), "Matrix3 get col 2" ); - a_Matrix3.setCol( 0, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 0" ); - a_Matrix3.setCol( 1, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 1" ); - a_Matrix3.setCol( 2, b_Vector3 ); - print( a_Matrix3, "Matrix3 set col 2" ); - print( a_Matrix3.getCol( 0 ), "Matrix3 get col 0" ); - print( a_Matrix3.getCol( 1 ), "Matrix3 get col 1" ); - print( a_Matrix3.getCol( 2 ), "Matrix3 get col 2" ); - a_Matrix3.setRow( 0, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 0" ); - a_Matrix3.setRow( 1, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 1" ); - a_Matrix3.setRow( 2, a_Vector3 ); - print( a_Matrix3, "Matrix3 set row 2" ); - print( a_Matrix3.getRow( 0 ), "Matrix3 get row 0" ); - print( a_Matrix3.getRow( 1 ), "Matrix3 get row 1" ); - print( a_Matrix3.getRow( 2 ), "Matrix3 get row 2" ); - a_Matrix3[0] = a_Vector3; - print( a_Matrix3, "set Matrix3[0]" ); - a_Matrix3[1] = a_Vector3; - print( a_Matrix3, "set Matrix3[1]" ); - a_Matrix3[2] = a_Vector3; - print( a_Matrix3, "set Matrix3[2]" ); - a_Matrix3[0] = a_Vector3; - print( a_Matrix3[0], "get Matrix3[0]" ); - a_Matrix3[1] = a_Vector3; - print( a_Matrix3[1], "get Matrix3[1]" ); - a_Matrix3[2] = a_Vector3; - print( a_Matrix3[2], "get Matrix3[2]" ); - a_Matrix3.setElem( 0, 0, randfloat() ); - a_Matrix3.setElem( 0, 1, randfloat() ); - a_Matrix3.setElem( 0, 2, randfloat() ); - a_Matrix3.setElem( 1, 0, randfloat() ); - a_Matrix3.setElem( 1, 1, randfloat() ); - a_Matrix3.setElem( 1, 2, randfloat() ); - a_Matrix3.setElem( 2, 0, randfloat() ); - a_Matrix3.setElem( 2, 1, randfloat() ); - a_Matrix3.setElem( 2, 2, randfloat() ); - print( a_Matrix3, "Matrix3 set elements" ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Matrix3.getElem( 2, 2 )) ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Matrix4 = Matrix4( a_Transform3 ); - print( a_Matrix4, "construct Matrix4 with Transform3" ); - a_Matrix4 = Matrix4( a_Matrix3, a_Vector3 ); - print( a_Matrix4, "construct Matrix4 with Matrix3 and Vector3" ); - a_Matrix4 = Matrix4( a_Quat, a_Vector3 ); - print( a_Matrix4, "construct Matrix4 with Quat and Vector3" ); - a_Matrix4 = b_Matrix4; - print( a_Matrix4, "assign to Matrix4 from Matrix4" ); - a_Matrix4 = Matrix4( randfloat() ); - print( a_Matrix4, "set Matrix4 with float" ); - a_Matrix4 = Matrix4( randfloat() ); - print( a_Matrix4, "set Matrix4 with float" ); - a_Matrix4 = Matrix4( (vec_float4){0.0f} ); - print( a_Matrix4, "set elements to zero" ); - a_Matrix4 = Matrix4::identity( ); - print( a_Matrix4, "set to identity" ); - a_Matrix4 = Matrix4::rotationX( randfloat() ); - print( a_Matrix4, "set to rotationX" ); - a_Matrix4 = Matrix4::rotationY( randfloat() ); - print( a_Matrix4, "set to rotationY" ); - a_Matrix4 = Matrix4::rotationZ( randfloat() ); - print( a_Matrix4, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Matrix4 = Matrix4::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Matrix4, "set to rotation from Z,Y,X angles" ); - a_Matrix4 = Matrix4::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Matrix4, "set to rotation from axis angle" ); - a_Matrix4 = Matrix4::translation( a_Vector3 ); - print( a_Matrix4, "set to translation" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Matrix4 = Matrix4::perspective( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Matrix4, "set to perspective matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - a_Matrix4 = Matrix4::frustum( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - print( a_Matrix4, "set to frustum matrix" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - a_Matrix4 = Matrix4::orthographic( rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6 ); - print( a_Matrix4, "set to orthographic matrix" ); - a_Matrix4 = Matrix4::lookAt( a_Point3, b_Point3, a_Vector3 ); - print( a_Matrix4, "set to look-at matrix" ); - a_Matrix4.setCol0( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 0" ); - a_Matrix4.setCol1( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 1" ); - a_Matrix4.setCol2( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 2" ); - a_Matrix4.setCol3( a_Vector4 ); - print( a_Matrix4, "Matrix4 set col 3" ); - print( a_Matrix4.getCol0( ), "Matrix4 get col 0" ); - print( a_Matrix4.getCol1( ), "Matrix4 get col 1" ); - print( a_Matrix4.getCol2( ), "Matrix4 get col 2" ); - print( a_Matrix4.getCol3( ), "Matrix4 get col 3" ); - a_Matrix4.setCol( 0, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 0" ); - a_Matrix4.setCol( 1, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 1" ); - a_Matrix4.setCol( 2, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 2" ); - a_Matrix4.setCol( 3, b_Vector4 ); - print( a_Matrix4, "Matrix4 set col 3" ); - print( a_Matrix4.getCol( 0 ), "Matrix4 get col 0" ); - print( a_Matrix4.getCol( 1 ), "Matrix4 get col 1" ); - print( a_Matrix4.getCol( 2 ), "Matrix4 get col 2" ); - print( a_Matrix4.getCol( 3 ), "Matrix4 get col 3" ); - a_Matrix4.setRow( 0, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 0" ); - a_Matrix4.setRow( 1, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 1" ); - a_Matrix4.setRow( 2, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 2" ); - a_Matrix4.setRow( 3, a_Vector4 ); - print( a_Matrix4, "Matrix4 set row 3" ); - print( a_Matrix4.getRow( 0 ), "Matrix4 get row 0" ); - print( a_Matrix4.getRow( 1 ), "Matrix4 get row 1" ); - print( a_Matrix4.getRow( 2 ), "Matrix4 get row 2" ); - print( a_Matrix4.getRow( 3 ), "Matrix4 get row 3" ); - a_Matrix4[0] = a_Vector4; - print( a_Matrix4, "set Matrix4[0]" ); - a_Matrix4[1] = a_Vector4; - print( a_Matrix4, "set Matrix4[1]" ); - a_Matrix4[2] = a_Vector4; - print( a_Matrix4, "set Matrix4[2]" ); - a_Matrix4[3] = a_Vector4; - print( a_Matrix4, "set Matrix4[3]" ); - a_Matrix4[0] = a_Vector4; - print( a_Matrix4[0], "get Matrix4[0]" ); - a_Matrix4[1] = a_Vector4; - print( a_Matrix4[1], "get Matrix4[1]" ); - a_Matrix4[2] = a_Vector4; - print( a_Matrix4[2], "get Matrix4[2]" ); - a_Matrix4[3] = a_Vector4; - print( a_Matrix4[3], "get Matrix4[3]" ); - a_Matrix4.setElem( 0, 0, randfloat() ); - a_Matrix4.setElem( 0, 1, randfloat() ); - a_Matrix4.setElem( 0, 2, randfloat() ); - a_Matrix4.setElem( 0, 3, randfloat() ); - a_Matrix4.setElem( 1, 0, randfloat() ); - a_Matrix4.setElem( 1, 1, randfloat() ); - a_Matrix4.setElem( 1, 2, randfloat() ); - a_Matrix4.setElem( 1, 3, randfloat() ); - a_Matrix4.setElem( 2, 0, randfloat() ); - a_Matrix4.setElem( 2, 1, randfloat() ); - a_Matrix4.setElem( 2, 2, randfloat() ); - a_Matrix4.setElem( 2, 3, randfloat() ); - a_Matrix4.setElem( 3, 0, randfloat() ); - a_Matrix4.setElem( 3, 1, randfloat() ); - a_Matrix4.setElem( 3, 2, randfloat() ); - a_Matrix4.setElem( 3, 3, randfloat() ); - print( a_Matrix4, "Matrix4 set elements" ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 0, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 1, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 2, 3 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 0 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 1 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 2 )) ); - printf("%f\n", getfloat(a_Matrix4.getElem( 3, 3 )) ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - a_Transform3 = Transform3( a_Matrix3, a_Vector3 ); - print( a_Transform3, "construct Transform3 with Matrix3 and Vector3" ); - a_Transform3 = Transform3( a_Quat, a_Vector3 ); - print( a_Transform3, "construct Transform3 with Quat and Vector3" ); - a_Transform3 = b_Transform3; - print( a_Transform3, "assign to Transform3 from Transform3" ); - a_Transform3 = Transform3( randfloat() ); - print( a_Transform3, "set Transform3 with float" ); - a_Transform3 = Transform3( randfloat() ); - print( a_Transform3, "set Transform3 with float" ); - a_Transform3 = Transform3( (vec_float4){0.0f} ); - print( a_Transform3, "set elements to zero" ); - a_Transform3 = Transform3::identity( ); - print( a_Transform3, "set to identity" ); - a_Transform3 = Transform3::rotationX( randfloat() ); - print( a_Transform3, "set to rotationX" ); - a_Transform3 = Transform3::rotationY( randfloat() ); - print( a_Transform3, "set to rotationY" ); - a_Transform3 = Transform3::rotationZ( randfloat() ); - print( a_Transform3, "set to rotationZ" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Transform3 = Transform3::rotationZYX( Vector3( rndflt3, rndflt2, rndflt1 ) ); - print( a_Transform3, "set to rotation from Z,Y,X angles" ); - a_Transform3 = Transform3::rotation( randfloat(), normalize( a_Vector3 ) ); - print( a_Transform3, "set to rotation from axis angle" ); - a_Transform3 = Transform3::translation( a_Vector3 ); - print( a_Transform3, "set to translation" ); - a_Transform3.setCol0( a_Vector3 ); - print( a_Transform3, "Transform3 set col 0" ); - a_Transform3.setCol1( a_Vector3 ); - print( a_Transform3, "Transform3 set col 1" ); - a_Transform3.setCol2( a_Vector3 ); - print( a_Transform3, "Transform3 set col 2" ); - a_Transform3.setCol3( a_Vector3 ); - print( a_Transform3, "Transform3 set col 3" ); - print( a_Transform3.getCol0( ), "Transform3 get col 0" ); - print( a_Transform3.getCol1( ), "Transform3 get col 1" ); - print( a_Transform3.getCol2( ), "Transform3 get col 2" ); - print( a_Transform3.getCol3( ), "Transform3 get col 3" ); - a_Transform3.setCol( 0, b_Vector3 ); - print( a_Transform3, "Transform3 set col 0" ); - a_Transform3.setCol( 1, b_Vector3 ); - print( a_Transform3, "Transform3 set col 1" ); - a_Transform3.setCol( 2, b_Vector3 ); - print( a_Transform3, "Transform3 set col 2" ); - a_Transform3.setCol( 3, b_Vector3 ); - print( a_Transform3, "Transform3 set col 3" ); - print( a_Transform3.getCol( 0 ), "Transform3 get col 0" ); - print( a_Transform3.getCol( 1 ), "Transform3 get col 1" ); - print( a_Transform3.getCol( 2 ), "Transform3 get col 2" ); - print( a_Transform3.getCol( 3 ), "Transform3 get col 3" ); - a_Transform3.setRow( 0, a_Vector4 ); - print( a_Transform3, "Transform3 set row 0" ); - a_Transform3.setRow( 1, a_Vector4 ); - print( a_Transform3, "Transform3 set row 1" ); - a_Transform3.setRow( 2, a_Vector4 ); - print( a_Transform3, "Transform3 set row 2" ); - print( a_Transform3.getRow( 0 ), "Transform3 get row 0" ); - print( a_Transform3.getRow( 1 ), "Transform3 get row 1" ); - print( a_Transform3.getRow( 2 ), "Transform3 get row 2" ); - a_Transform3[0] = a_Vector3; - print( a_Transform3, "set Transform3[0]" ); - a_Transform3[1] = a_Vector3; - print( a_Transform3, "set Transform3[1]" ); - a_Transform3[2] = a_Vector3; - print( a_Transform3, "set Transform3[2]" ); - a_Transform3[3] = a_Vector3; - print( a_Transform3, "set Transform3[3]" ); - a_Transform3[0] = a_Vector3; - print( a_Transform3[0], "get Transform3[0]" ); - a_Transform3[1] = a_Vector3; - print( a_Transform3[1], "get Transform3[1]" ); - a_Transform3[2] = a_Vector3; - print( a_Transform3[2], "get Transform3[2]" ); - a_Transform3[3] = a_Vector3; - print( a_Transform3[3], "get Transform3[3]" ); - a_Transform3.setElem( 0, 0, randfloat() ); - a_Transform3.setElem( 0, 1, randfloat() ); - a_Transform3.setElem( 0, 2, randfloat() ); - a_Transform3.setElem( 1, 0, randfloat() ); - a_Transform3.setElem( 1, 1, randfloat() ); - a_Transform3.setElem( 1, 2, randfloat() ); - a_Transform3.setElem( 2, 0, randfloat() ); - a_Transform3.setElem( 2, 1, randfloat() ); - a_Transform3.setElem( 2, 2, randfloat() ); - a_Transform3.setElem( 3, 0, randfloat() ); - a_Transform3.setElem( 3, 1, randfloat() ); - a_Transform3.setElem( 3, 2, randfloat() ); - print( a_Transform3, "Transform3 set elements" ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 0, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 1, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 2, 2 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 0 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 1 )) ); - printf("%f\n", getfloat(a_Transform3.getElem( 3, 2 )) ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test3_aos_c.c b/Extras/vectormathlibrary/tests/test3_aos_c.c deleted file mode 100644 index 22afb694f..000000000 --- a/Extras/vectormathlibrary/tests/test3_aos_c.c +++ /dev/null @@ -1,524 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 ); - vmathM3Prints( &tmpM3_0, "Matrix3 + Matrix3" ); - vmathM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 ); - vmathM3Prints( &tmpM3_1, "Matrix3 - Matrix3" ); - vmathM3Neg( &tmpM3_2, &a_Matrix3 ); - vmathM3Prints( &tmpM3_2, "-Matrix3" ); - vmathM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() ); - vmathM3Prints( &tmpM3_3, "Matrix3 * float" ); - vmathM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() ); - vmathM3Prints( &tmpM3_4, "float * Matrix3" ); - vmathM3MulV3( &tmpV3_8, &a_Matrix3, &a_Vector3 ); - vmathV3Prints( &tmpV3_8, "Matrix3 * Vector3" ); - vmathM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 ); - vmathM3Prints( &tmpM3_5, "Matrix3 * Matrix3" ); -} - -void -Matrix4_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; - VmathVector4 tmpV4_0, tmpV4_1, tmpV4_2; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 ); - vmathM4Prints( &tmpM4_0, "Matrix4 + Matrix4" ); - vmathM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 ); - vmathM4Prints( &tmpM4_1, "Matrix4 - Matrix4" ); - vmathM4Neg( &tmpM4_2, &a_Matrix4 ); - vmathM4Prints( &tmpM4_2, "-Matrix4" ); - vmathM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() ); - vmathM4Prints( &tmpM4_3, "Matrix4 * float" ); - vmathM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() ); - vmathM4Prints( &tmpM4_4, "float * Matrix4" ); - vmathM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 ); - vmathV4Prints( &tmpV4_0, "Matrix4 * Vector4" ); - vmathM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 ); - vmathV4Prints( &tmpV4_1, "Matrix4 * Vector3" ); - vmathM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 ); - vmathV4Prints( &tmpV4_2, "Matrix4 * Point3" ); - vmathM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 ); - vmathM4Prints( &tmpM4_5, "Matrix4 * Matrix4" ); - vmathM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 ); - vmathM4Prints( &tmpM4_6, "Matrix4 * Transform3" ); -} - -void -Transform3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3, tmpT3_0; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; - VmathPoint3 tmpP3_0; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathT3MulV3( &tmpV3_8, &a_Transform3, &a_Vector3 ); - vmathV3Prints( &tmpV3_8, "Transform3 * Vector3" ); - vmathT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 ); - vmathP3Prints( &tmpP3_0, "Transform3 * Point3" ); - vmathT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 ); - vmathT3Prints( &tmpT3_0, "Transform3 * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test3_aos_cpp.cpp b/Extras/vectormathlibrary/tests/test3_aos_cpp.cpp deleted file mode 100644 index 09427d421..000000000 --- a/Extras/vectormathlibrary/tests/test3_aos_cpp.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Aos; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" ); - print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" ); - print( ( -a_Matrix3 ), "-Matrix3" ); - print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" ); - print( ( randfloat() * a_Matrix3 ), "float * Matrix3" ); - print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" ); - print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" ); - print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" ); - print( ( -a_Matrix4 ), "-Matrix4" ); - print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" ); - print( ( randfloat() * a_Matrix4 ), "float * Matrix4" ); - print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" ); - print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" ); - print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" ); - print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" ); - print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" ); - print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" ); - print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test3_reference.txt b/Extras/vectormathlibrary/tests/test3_reference.txt deleted file mode 100644 index 834b0fe20..000000000 --- a/Extras/vectormathlibrary/tests/test3_reference.txt +++ /dev/null @@ -1,392 +0,0 @@ -set Vector3 with floats: ( -0.658344 0.499804 -0.807257 ) -set Vector3 with floats: ( 0.740930 0.154607 0.571599 ) -set Vector3 with floats: ( 0.384388 -0.262467 0.747808 ) -set Vector3 with floats: ( 0.490190 -0.107908 -0.292544 ) -set Vector4 with floats: ( 0.465039 -0.479556 -0.211412 0.553580 ) -set Vector4 with floats: ( 0.690070 0.151576 0.431077 -0.833992 ) -set Vector4 with floats: ( -0.088350 -0.780106 0.090456 -0.218627 ) -set Vector4 with floats: ( 0.137171 0.918133 0.735438 -0.673621 ) -set Point3 with floats: ( -0.448982 -0.479278 0.848189 ) -set Point3 with floats: ( -0.128155 0.578922 -0.744766 ) -set Point3 with floats: ( -0.835589 0.881284 -0.948850 ) -set Point3 with floats: ( -0.691578 -0.235635 -0.690527 ) -set Quat with floats: ( 0.058667 0.753697 -0.138777 -0.472188 ) -set Quat with floats: ( -0.372811 0.540183 -0.785218 0.542085 ) -set Quat with floats: ( 0.410391 -0.562721 0.523588 -0.176574 ) -set Quat with floats: ( 0.297654 0.859913 0.004837 0.374881 ) -set Matrix3 columns: -( -0.658344 0.740930 0.384388 ) -( 0.499804 0.154607 -0.262467 ) -( -0.807257 0.571599 0.747808 ) -set Matrix3 columns: -( 0.490190 -0.658344 0.740930 ) -( -0.107908 0.499804 0.154607 ) -( -0.292544 -0.807257 0.571599 ) -set Matrix4 columns: -( 0.465039 0.690070 -0.088350 0.137171 ) -( -0.479556 0.151576 -0.780106 0.918133 ) -( -0.211412 0.431077 0.090456 0.735438 ) -( 0.553580 -0.833992 -0.218627 -0.673621 ) -set Matrix4 columns: -( 0.137171 0.465039 0.690070 -0.088350 ) -( 0.918133 -0.479556 0.151576 -0.780106 ) -( 0.735438 -0.211412 0.431077 0.090456 ) -( -0.673621 0.553580 -0.833992 -0.218627 ) -set Transform3 columns: -( -0.658344 0.740930 0.384388 0.490190 ) -( 0.499804 0.154607 -0.262467 -0.107908 ) -( -0.807257 0.571599 0.747808 -0.292544 ) -set Transform3 columns: -( 0.490190 -0.658344 0.740930 0.384388 ) -( -0.107908 0.499804 0.154607 -0.262467 ) -( -0.292544 -0.807257 0.571599 0.747808 ) -Matrix3 + Matrix3: -( -0.168154 0.082587 1.125319 ) -( 0.391896 0.654411 -0.107860 ) -( -1.099800 -0.235658 1.319407 ) -Matrix3 - Matrix3: -( -1.148534 1.399274 -0.356542 ) -( 0.607712 -0.345197 -0.417075 ) -( -0.514713 1.378855 0.176210 ) --Matrix3: -( 0.658344 -0.740930 -0.384388 ) -( -0.499804 -0.154607 0.262467 ) -( 0.807257 -0.571599 -0.747808 ) -Matrix3 * float: -( 0.084148 -0.094704 -0.049132 ) -( -0.063884 -0.019762 0.033548 ) -( 0.103182 -0.073061 -0.095583 ) -float * Matrix3: -( -0.142598 0.160487 0.083259 ) -( 0.108258 0.033488 -0.056851 ) -( -0.174853 0.123809 0.161977 ) -Matrix3 * Vector3: ( 0.493437 -0.039891 0.213467 ) -Matrix3 * Matrix3: -( -0.515117 0.493437 -0.153518 ) -( 0.305099 -0.039891 0.244197 ) -( -0.676156 0.213467 -0.082302 ) -set Vector3 with floats: ( 0.153117 0.265243 -0.073149 ) -set Vector3 with floats: ( 0.264488 -0.723410 0.921523 ) -set Vector3 with floats: ( -0.711250 -0.106634 -0.350831 ) -set Vector3 with floats: ( 0.905168 -0.283632 -0.203584 ) -set Vector4 with floats: ( -0.797437 0.910171 0.969234 0.151940 ) -set Vector4 with floats: ( 0.731827 -0.700248 0.818301 0.302505 ) -set Vector4 with floats: ( -0.872278 0.909999 0.932526 0.571087 ) -set Vector4 with floats: ( 0.610330 0.142507 -0.434829 0.925102 ) -set Point3 with floats: ( 0.158954 -0.126283 -0.249128 ) -set Point3 with floats: ( 0.846815 -0.942601 0.537720 ) -set Point3 with floats: ( 0.446214 0.181939 -0.148223 ) -set Point3 with floats: ( 0.284286 0.493525 -0.861963 ) -set Quat with floats: ( -0.893410 0.548627 0.407007 -0.757467 ) -set Quat with floats: ( -0.393126 -0.850984 0.375720 -0.270088 ) -set Quat with floats: ( 0.458888 -0.610828 -0.690816 -0.676415 ) -set Quat with floats: ( 0.664466 0.101874 -0.365714 0.055473 ) -set Matrix3 columns: -( 0.153117 0.264488 -0.711250 ) -( 0.265243 -0.723410 -0.106634 ) -( -0.073149 0.921523 -0.350831 ) -set Matrix3 columns: -( 0.905168 0.153117 0.264488 ) -( -0.283632 0.265243 -0.723410 ) -( -0.203584 -0.073149 0.921523 ) -set Matrix4 columns: -( -0.797437 0.731827 -0.872278 0.610330 ) -( 0.910171 -0.700248 0.909999 0.142507 ) -( 0.969234 0.818301 0.932526 -0.434829 ) -( 0.151940 0.302505 0.571087 0.925102 ) -set Matrix4 columns: -( 0.610330 -0.797437 0.731827 -0.872278 ) -( 0.142507 0.910171 -0.700248 0.909999 ) -( -0.434829 0.969234 0.818301 0.932526 ) -( 0.925102 0.151940 0.302505 0.571087 ) -set Transform3 columns: -( 0.153117 0.264488 -0.711250 0.905168 ) -( 0.265243 -0.723410 -0.106634 -0.283632 ) -( -0.073149 0.921523 -0.350831 -0.203584 ) -set Transform3 columns: -( 0.905168 0.153117 0.264488 -0.711250 ) -( -0.283632 0.265243 -0.723410 -0.106634 ) -( -0.203584 -0.073149 0.921523 -0.350831 ) -Matrix4 + Matrix4: -( -0.187107 -0.065609 -0.140451 -0.261949 ) -( 1.052679 0.209923 0.209751 1.052506 ) -( 0.534405 1.787535 1.750826 0.497697 ) -( 1.077042 0.454445 0.873592 1.496189 ) -Matrix4 - Matrix4: -( -1.407767 1.529264 -1.604106 1.482608 ) -( 0.767664 -1.610420 1.610247 -0.767491 ) -( 1.404062 -0.150933 0.114225 -1.367354 ) -( -0.773162 0.150565 0.268582 0.354015 ) --Matrix4: -( 0.797437 -0.731827 0.872278 -0.610330 ) -( -0.910171 0.700248 -0.909999 -0.142507 ) -( -0.969234 -0.818301 -0.932526 0.434829 ) -( -0.151940 -0.302505 -0.571087 -0.925102 ) -Matrix4 * float: -( 0.106503 -0.097740 0.116498 -0.081513 ) -( -0.121559 0.093522 -0.121536 -0.019033 ) -( -0.129447 -0.109289 -0.124544 0.058074 ) -( -0.020293 -0.040401 -0.076272 -0.123553 ) -float * Matrix4: -( 0.456647 -0.419076 0.499504 -0.349501 ) -( -0.521203 0.400992 -0.521105 -0.081606 ) -( -0.555025 -0.468594 -0.534004 0.249002 ) -( -0.087007 -0.173227 -0.327029 -0.529753 ) -Matrix4 * Vector4: ( 0.549286 -0.459496 0.809659 0.848246 ) -Matrix4 * Vector3: ( 0.135817 -0.112939 0.297242 0.061728 ) -Matrix4 * Point3: ( 0.608465 0.148906 -0.616420 0.768779 ) -Matrix4 * Matrix4: -( 0.561500 0.549286 -1.625205 0.896678 ) -( 0.191855 -0.459496 1.944198 -0.501167 ) -( -0.099583 0.809659 0.767847 0.520490 ) -( 0.743332 0.848246 0.646534 1.203612 ) -Matrix4 * Transform3: -( -0.751803 0.135817 -1.544148 1.405491 ) -( 0.837210 -0.112939 1.585880 -0.749438 ) -( 0.455376 0.297242 0.523727 -1.538614 ) -( -0.064533 0.061728 0.347621 0.584422 ) -set Vector3 with floats: ( 0.459209 -0.997261 0.172409 ) -set Vector3 with floats: ( -0.045124 0.879716 0.524317 ) -set Vector3 with floats: ( -0.744532 -0.970444 -0.000013 ) -set Vector3 with floats: ( 0.689543 0.704297 -0.817983 ) -set Vector4 with floats: ( 0.715505 0.577868 0.156952 -0.801022 ) -set Vector4 with floats: ( 0.656335 0.494393 0.816743 0.024285 ) -set Vector4 with floats: ( 0.769132 0.923895 0.133022 -0.052219 ) -set Vector4 with floats: ( -0.164886 0.300690 0.760403 0.171869 ) -set Point3 with floats: ( -0.554976 0.998693 -0.681641 ) -set Point3 with floats: ( 0.391195 0.403059 0.972411 ) -set Point3 with floats: ( 0.297195 0.309761 0.688408 ) -set Point3 with floats: ( 0.363540 0.940297 -0.336683 ) -set Quat with floats: ( 0.600164 -0.681272 0.726558 0.205513 ) -set Quat with floats: ( -0.160082 0.962714 0.737794 -0.071926 ) -set Quat with floats: ( -0.506313 0.689277 0.686485 0.473013 ) -set Quat with floats: ( -0.735610 -0.046390 0.568674 -0.004815 ) -set Matrix3 columns: -( 0.459209 -0.045124 -0.744532 ) -( -0.997261 0.879716 -0.970444 ) -( 0.172409 0.524317 -0.000013 ) -set Matrix3 columns: -( 0.689543 0.459209 -0.045124 ) -( 0.704297 -0.997261 0.879716 ) -( -0.817983 0.172409 0.524317 ) -set Matrix4 columns: -( 0.715505 0.656335 0.769132 -0.164886 ) -( 0.577868 0.494393 0.923895 0.300690 ) -( 0.156952 0.816743 0.133022 0.760403 ) -( -0.801022 0.024285 -0.052219 0.171869 ) -set Matrix4 columns: -( -0.164886 0.715505 0.656335 0.769132 ) -( 0.300690 0.577868 0.494393 0.923895 ) -( 0.760403 0.156952 0.816743 0.133022 ) -( 0.171869 -0.801022 0.024285 -0.052219 ) -set Transform3 columns: -( 0.459209 -0.045124 -0.744532 0.689543 ) -( -0.997261 0.879716 -0.970444 0.704297 ) -( 0.172409 0.524317 -0.000013 -0.817983 ) -set Transform3 columns: -( 0.689543 0.459209 -0.045124 -0.744532 ) -( 0.704297 -0.997261 0.879716 -0.970444 ) -( -0.817983 0.172409 0.524317 -0.000013 ) -Transform3 * Vector3: ( 0.127510 -1.502572 -0.443712 ) -Transform3 * Point3: ( 0.897132 2.797814 -0.390025 ) -Transform3 * Transform3: -( 0.893878 0.127510 -0.450789 0.391447 ) -( 0.725733 -1.502572 0.310080 0.593088 ) -( 0.488169 -0.443712 0.453463 -1.455167 ) -set Vector3 with floats: ( 0.137637 -0.111879 -0.929543 ) -set Vector3 with floats: ( -0.336303 -0.146740 0.165140 ) -set Vector3 with floats: ( -0.823874 0.349776 0.174872 ) -set Vector3 with floats: ( -0.528584 0.489292 0.916708 ) -set Vector4 with floats: ( 0.728511 -0.851140 0.079620 -0.234370 ) -set Vector4 with floats: ( -0.996308 0.433229 -0.892684 -0.957911 ) -set Vector4 with floats: ( 0.517122 0.257921 0.862028 0.095881 ) -set Vector4 with floats: ( -0.171933 -0.214078 -0.604841 -0.383831 ) -set Point3 with floats: ( -0.581500 0.222183 -0.256120 ) -set Point3 with floats: ( -0.678699 -0.079553 0.605960 ) -set Point3 with floats: ( -0.633147 0.435875 -0.046627 ) -set Point3 with floats: ( -0.716491 0.267317 -0.514874 ) -set Quat with floats: ( -0.751700 0.742959 -0.793180 0.508814 ) -set Quat with floats: ( -0.238839 0.113471 -0.843523 -0.245250 ) -set Quat with floats: ( 0.250368 0.579243 -0.157280 0.648487 ) -set Quat with floats: ( 0.103833 0.456401 -0.022372 -0.475631 ) -set Matrix3 columns: -( 0.137637 -0.336303 -0.823874 ) -( -0.111879 -0.146740 0.349776 ) -( -0.929543 0.165140 0.174872 ) -set Matrix3 columns: -( -0.528584 0.137637 -0.336303 ) -( 0.489292 -0.111879 -0.146740 ) -( 0.916708 -0.929543 0.165140 ) -set Matrix4 columns: -( 0.728511 -0.996308 0.517122 -0.171933 ) -( -0.851140 0.433229 0.257921 -0.214078 ) -( 0.079620 -0.892684 0.862028 -0.604841 ) -( -0.234370 -0.957911 0.095881 -0.383831 ) -set Matrix4 columns: -( -0.171933 0.728511 -0.996308 0.517122 ) -( -0.214078 -0.851140 0.433229 0.257921 ) -( -0.604841 0.079620 -0.892684 0.862028 ) -( -0.383831 -0.234370 -0.957911 0.095881 ) -set Transform3 columns: -( 0.137637 -0.336303 -0.823874 -0.528584 ) -( -0.111879 -0.146740 0.349776 0.489292 ) -( -0.929543 0.165140 0.174872 0.916708 ) -set Transform3 columns: -( -0.528584 0.137637 -0.336303 -0.823874 ) -( 0.489292 -0.111879 -0.146740 0.349776 ) -( 0.916708 -0.929543 0.165140 0.174872 ) -Matrix3 + Matrix3: -( -0.390948 -0.198667 -1.160178 ) -( 0.377413 -0.258619 0.203036 ) -( -0.012835 -0.764402 0.340013 ) -Matrix3 - Matrix3: -( 0.666221 -0.473940 -0.487571 ) -( -0.601171 -0.034861 0.496517 ) -( -1.846250 1.094683 0.009732 ) --Matrix3: -( -0.137637 0.336303 0.823874 ) -( 0.111879 0.146740 -0.349776 ) -( 0.929543 -0.165140 -0.174872 ) -Matrix3 * float: -( -0.000575 0.001405 0.003442 ) -( 0.000467 0.000613 -0.001461 ) -( 0.003884 -0.000690 -0.000731 ) -float * Matrix3: -( -0.002872 0.007017 0.017190 ) -( 0.002334 0.003062 -0.007298 ) -( 0.019395 -0.003446 -0.003649 ) -Matrix3 * Vector3: ( 0.822395 -0.324114 -0.308966 ) -Matrix3 * Matrix3: -( -0.992555 0.822395 -0.132993 ) -( 0.307981 -0.324114 0.116920 ) -( 0.732450 -0.308966 0.317254 ) -set Vector3 with floats: ( -0.016997 0.699144 0.837796 ) -set Vector3 with floats: ( -0.276082 0.091582 0.209064 ) -set Vector3 with floats: ( 0.219317 -0.118359 0.413442 ) -set Vector3 with floats: ( -0.567698 0.531358 -0.387226 ) -set Vector4 with floats: ( 0.572490 -0.820417 0.797191 0.867178 ) -set Vector4 with floats: ( 0.934764 0.237092 -0.866162 -0.773939 ) -set Vector4 with floats: ( 0.261311 -0.851570 0.114814 -0.531592 ) -set Vector4 with floats: ( 0.223925 0.869105 0.143405 0.148518 ) -set Point3 with floats: ( -0.071136 -0.758292 -0.527633 ) -set Point3 with floats: ( 0.997215 0.114440 0.727558 ) -set Point3 with floats: ( -0.425760 0.459888 0.642516 ) -set Point3 with floats: ( -0.022534 0.186095 -0.775679 ) -set Quat with floats: ( -0.683401 0.398134 0.189642 0.765986 ) -set Quat with floats: ( -0.137795 -0.579844 -0.635647 0.374970 ) -set Quat with floats: ( -0.563750 -0.471075 -0.553800 -0.014688 ) -set Quat with floats: ( -0.464365 -0.107890 -0.527503 -0.406423 ) -set Matrix3 columns: -( -0.016997 -0.276082 0.219317 ) -( 0.699144 0.091582 -0.118359 ) -( 0.837796 0.209064 0.413442 ) -set Matrix3 columns: -( -0.567698 -0.016997 -0.276082 ) -( 0.531358 0.699144 0.091582 ) -( -0.387226 0.837796 0.209064 ) -set Matrix4 columns: -( 0.572490 0.934764 0.261311 0.223925 ) -( -0.820417 0.237092 -0.851570 0.869105 ) -( 0.797191 -0.866162 0.114814 0.143405 ) -( 0.867178 -0.773939 -0.531592 0.148518 ) -set Matrix4 columns: -( 0.223925 0.572490 0.934764 0.261311 ) -( 0.869105 -0.820417 0.237092 -0.851570 ) -( 0.143405 0.797191 -0.866162 0.114814 ) -( 0.148518 0.867178 -0.773939 -0.531592 ) -set Transform3 columns: -( -0.016997 -0.276082 0.219317 -0.567698 ) -( 0.699144 0.091582 -0.118359 0.531358 ) -( 0.837796 0.209064 0.413442 -0.387226 ) -set Transform3 columns: -( -0.567698 -0.016997 -0.276082 0.219317 ) -( 0.531358 0.699144 0.091582 -0.118359 ) -( -0.387226 0.837796 0.209064 0.413442 ) -Matrix4 + Matrix4: -( 0.796414 1.507254 1.196075 0.485235 ) -( 0.048687 -0.583325 -0.614477 0.017535 ) -( 0.940596 -0.068971 -0.751347 0.258219 ) -( 1.015695 0.093239 -1.305531 -0.383075 ) -Matrix4 - Matrix4: -( 0.348565 0.362275 -0.673454 -0.037386 ) -( -1.689522 1.057509 -1.088662 1.720674 ) -( 0.653787 -1.663353 0.980976 0.028590 ) -( 0.718660 -1.641117 0.242347 0.680110 ) --Matrix4: -( -0.572490 -0.934764 -0.261311 -0.223925 ) -( 0.820417 -0.237092 0.851570 -0.869105 ) -( -0.797191 0.866162 -0.114814 -0.143405 ) -( -0.867178 0.773939 0.531592 -0.148518 ) -Matrix4 * float: -( 0.172469 0.281608 0.078723 0.067460 ) -( -0.247160 0.071427 -0.256545 0.261827 ) -( 0.240163 -0.260941 0.034589 0.043202 ) -( 0.261247 -0.233158 -0.160148 0.044743 ) -float * Matrix4: -( 0.285975 0.466942 0.130532 0.111857 ) -( -0.409822 0.118434 -0.425383 0.434143 ) -( 0.398220 -0.432673 0.057353 0.071635 ) -( 0.433180 -0.386605 -0.265545 0.074189 ) -Matrix4 * Vector4: ( -0.036655 -0.589390 1.382884 0.836413 ) -Matrix4 * Vector3: ( 0.862729 -0.533736 -0.522930 -1.001200 ) -Matrix4 * Point3: ( -0.663500 1.196998 0.682919 0.954187 ) -Matrix4 * Matrix4: -( 1.011332 -0.036655 0.357127 -0.735454 ) -( 0.029304 -0.589390 -0.645721 -0.976066 ) -( -0.536511 1.382884 0.329392 0.882861 ) -( -0.532626 0.836413 0.972614 0.745680 ) -Matrix4 * Transform3: -( 0.070508 0.862729 -0.017816 0.346880 ) -( 0.921479 -0.533736 0.070183 0.309037 ) -( -0.957265 -0.522930 -0.275411 0.468230 ) -( -0.697687 -1.001200 -0.421428 0.210525 ) -set Vector3 with floats: ( 0.385180 -0.150218 0.519112 ) -set Vector3 with floats: ( -0.203209 -0.252017 0.282194 ) -set Vector3 with floats: ( 0.067637 0.798376 0.310782 ) -set Vector3 with floats: ( 0.861334 -0.980345 -0.655106 ) -set Vector4 with floats: ( 0.286765 0.532078 0.352671 0.540977 ) -set Vector4 with floats: ( 0.510961 0.791871 -0.564379 0.273199 ) -set Vector4 with floats: ( 0.194378 0.244636 -0.269608 -0.858162 ) -set Vector4 with floats: ( -0.495023 -0.277798 -0.032740 0.007412 ) -set Point3 with floats: ( -0.420178 -0.522577 0.324972 ) -set Point3 with floats: ( 0.795389 0.342900 -0.913636 ) -set Point3 with floats: ( 0.675222 0.144053 -0.632329 ) -set Point3 with floats: ( -0.947120 -0.049367 0.126333 ) -set Quat with floats: ( -0.664206 0.220879 0.284219 -0.387216 ) -set Quat with floats: ( 0.913568 0.531906 0.271995 -0.862601 ) -set Quat with floats: ( -0.738694 0.514248 -0.039363 0.429390 ) -set Quat with floats: ( -0.769469 0.281336 -0.203301 0.412586 ) -set Matrix3 columns: -( 0.385180 -0.203209 0.067637 ) -( -0.150218 -0.252017 0.798376 ) -( 0.519112 0.282194 0.310782 ) -set Matrix3 columns: -( 0.861334 0.385180 -0.203209 ) -( -0.980345 -0.150218 -0.252017 ) -( -0.655106 0.519112 0.282194 ) -set Matrix4 columns: -( 0.286765 0.510961 0.194378 -0.495023 ) -( 0.532078 0.791871 0.244636 -0.277798 ) -( 0.352671 -0.564379 -0.269608 -0.032740 ) -( 0.540977 0.273199 -0.858162 0.007412 ) -set Matrix4 columns: -( -0.495023 0.286765 0.510961 0.194378 ) -( -0.277798 0.532078 0.791871 0.244636 ) -( -0.032740 0.352671 -0.564379 -0.269608 ) -( 0.007412 0.540977 0.273199 -0.858162 ) -set Transform3 columns: -( 0.385180 -0.203209 0.067637 0.861334 ) -( -0.150218 -0.252017 0.798376 -0.980345 ) -( 0.519112 0.282194 0.310782 -0.655106 ) -set Transform3 columns: -( 0.861334 0.385180 -0.203209 0.067637 ) -( -0.980345 -0.150218 -0.252017 0.798376 ) -( -0.655106 0.519112 0.282194 0.310782 ) -Transform3 * Vector3: ( 0.214000 0.394443 0.318891 ) -Transform3 * Point3: ( 0.827662 -0.526078 -0.919697 ) -Transform3 * Transform3: -( 0.486673 0.214000 -0.007973 0.746170 ) -( -0.405345 0.394443 0.319335 -0.943589 ) -( -0.033113 0.318891 -0.088905 -0.298112 ) - - __end__ diff --git a/Extras/vectormathlibrary/tests/test3_soa_c.c b/Extras/vectormathlibrary/tests/test3_soa_c.c deleted file mode 100644 index 36cda98e2..000000000 --- a/Extras/vectormathlibrary/tests/test3_soa_c.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector3 tmpV3_0; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaM3Add( &tmpM3_0, &a_Matrix3, &b_Matrix3 ); - vmathSoaM3Prints( &tmpM3_0, "Matrix3 + Matrix3" ); - vmathSoaM3Sub( &tmpM3_1, &a_Matrix3, &b_Matrix3 ); - vmathSoaM3Prints( &tmpM3_1, "Matrix3 - Matrix3" ); - vmathSoaM3Neg( &tmpM3_2, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_2, "-Matrix3" ); - vmathSoaM3ScalarMul( &tmpM3_3, &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &tmpM3_3, "Matrix3 * float" ); - vmathSoaM3ScalarMul( &tmpM3_4, &a_Matrix3, randfloat() ); - vmathSoaM3Prints( &tmpM3_4, "float * Matrix3" ); - vmathSoaM3MulV3( &tmpV3_0, &a_Matrix3, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_0, "Matrix3 * Vector3" ); - vmathSoaM3Mul( &tmpM3_5, &a_Matrix3, &b_Matrix3 ); - vmathSoaM3Prints( &tmpM3_5, "Matrix3 * Matrix3" ); -} - -void -Matrix4_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector4 tmpV4_0, tmpV4_1, tmpV4_2; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaM4Add( &tmpM4_0, &a_Matrix4, &b_Matrix4 ); - vmathSoaM4Prints( &tmpM4_0, "Matrix4 + Matrix4" ); - vmathSoaM4Sub( &tmpM4_1, &a_Matrix4, &b_Matrix4 ); - vmathSoaM4Prints( &tmpM4_1, "Matrix4 - Matrix4" ); - vmathSoaM4Neg( &tmpM4_2, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_2, "-Matrix4" ); - vmathSoaM4ScalarMul( &tmpM4_3, &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &tmpM4_3, "Matrix4 * float" ); - vmathSoaM4ScalarMul( &tmpM4_4, &a_Matrix4, randfloat() ); - vmathSoaM4Prints( &tmpM4_4, "float * Matrix4" ); - vmathSoaM4MulV4( &tmpV4_0, &a_Matrix4, &a_Vector4 ); - vmathSoaV4Prints( &tmpV4_0, "Matrix4 * Vector4" ); - vmathSoaM4MulV3( &tmpV4_1, &a_Matrix4, &a_Vector3 ); - vmathSoaV4Prints( &tmpV4_1, "Matrix4 * Vector3" ); - vmathSoaM4MulP3( &tmpV4_2, &a_Matrix4, &a_Point3 ); - vmathSoaV4Prints( &tmpV4_2, "Matrix4 * Point3" ); - vmathSoaM4Mul( &tmpM4_5, &a_Matrix4, &b_Matrix4 ); - vmathSoaM4Prints( &tmpM4_5, "Matrix4 * Matrix4" ); - vmathSoaM4MulT3( &tmpM4_6, &a_Matrix4, &b_Transform3 ); - vmathSoaM4Prints( &tmpM4_6, "Matrix4 * Transform3" ); -} - -void -Transform3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector3 tmpV3_0; - VmathSoaPoint3 tmpP3_0; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaT3MulV3( &tmpV3_0, &a_Transform3, &a_Vector3 ); - vmathSoaV3Prints( &tmpV3_0, "Transform3 * Vector3" ); - vmathSoaT3MulP3( &tmpP3_0, &a_Transform3, &a_Point3 ); - vmathSoaP3Prints( &tmpP3_0, "Transform3 * Point3" ); - vmathSoaT3Mul( &tmpT3_0, &a_Transform3, &b_Transform3 ); - vmathSoaT3Prints( &tmpT3_0, "Transform3 * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test3_soa_cpp.cpp b/Extras/vectormathlibrary/tests/test3_soa_cpp.cpp deleted file mode 100644 index dafcad16c..000000000 --- a/Extras/vectormathlibrary/tests/test3_soa_cpp.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Soa; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Matrix3 + b_Matrix3 ), "Matrix3 + Matrix3" ); - print( ( a_Matrix3 - b_Matrix3 ), "Matrix3 - Matrix3" ); - print( ( -a_Matrix3 ), "-Matrix3" ); - print( ( a_Matrix3 * randfloat() ), "Matrix3 * float" ); - print( ( randfloat() * a_Matrix3 ), "float * Matrix3" ); - print( ( a_Matrix3 * a_Vector3 ), "Matrix3 * Vector3" ); - print( ( a_Matrix3 * b_Matrix3 ), "Matrix3 * Matrix3" ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Matrix4 + b_Matrix4 ), "Matrix4 + Matrix4" ); - print( ( a_Matrix4 - b_Matrix4 ), "Matrix4 - Matrix4" ); - print( ( -a_Matrix4 ), "-Matrix4" ); - print( ( a_Matrix4 * randfloat() ), "Matrix4 * float" ); - print( ( randfloat() * a_Matrix4 ), "float * Matrix4" ); - print( ( a_Matrix4 * a_Vector4 ), "Matrix4 * Vector4" ); - print( ( a_Matrix4 * a_Vector3 ), "Matrix4 * Vector3" ); - print( ( a_Matrix4 * a_Point3 ), "Matrix4 * Point3" ); - print( ( a_Matrix4 * b_Matrix4 ), "Matrix4 * Matrix4" ); - print( ( a_Matrix4 * b_Transform3 ), "Matrix4 * Transform3" ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( ( a_Transform3 * a_Vector3 ), "Transform3 * Vector3" ); - print( ( a_Transform3 * a_Point3 ), "Transform3 * Point3" ); - print( ( a_Transform3 * b_Transform3 ), "Transform3 * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test4_aos_c.c b/Extras/vectormathlibrary/tests/test4_aos_c.c deleted file mode 100644 index 94b47f8e5..000000000 --- a/Extras/vectormathlibrary/tests/test4_aos_c.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7, tmpV3_8; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 ); - vmathM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" ); - vmathM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 ); - vmathM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" ); - vmathM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 ); - vmathM3Prints( &tmpM3_2, "mulPerElem Matrix3" ); - vmathM3AbsPerElem( &tmpM3_3, &a_Matrix3 ); - vmathM3Prints( &tmpM3_3, "absPerElem Matrix3" ); - vmathM3Transpose( &tmpM3_4, &a_Matrix3 ); - vmathM3Prints( &tmpM3_4, "transpose Matrix3" ); - vmathM3Inverse( &tmpM3_5, &a_Matrix3 ); - vmathM3Prints( &tmpM3_5, "inverse Matrix3" ); - vmathM3Inverse( &tmpM3_6, &a_Matrix3 ); - vmathM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 ); - vmathM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" ); - printf("%f\n", getfloat(vmathM3Determinant( &a_Matrix3 )) ); - vmathV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &tmpM3_8, "outer Vector3" ); - vmathV3RowMul( &tmpV3_8, &a_Vector3, &a_Matrix3 ); - vmathV3Prints( &tmpV3_8, "rowMul Vector3" ); - vmathV3CrossMatrix( &tmpM3_9, &a_Vector3 ); - vmathM3Prints( &tmpM3_9, "crossMatrix" ); - vmathV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 ); - vmathM3Prints( &tmpM3_10, "crossMatrixMul" ); -} - -void -Matrix4_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3; - VmathMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7; - VmathMatrix3 tmpM3_0; - VmathMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; - VmathVector4 tmpV4_0; - VmathQuat tmpQ_0; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 ); - vmathM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" ); - vmathM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 ); - vmathM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" ); - vmathM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 ); - vmathM4Prints( &tmpM4_2, "mulPerElem Matrix4" ); - vmathM4AbsPerElem( &tmpM4_3, &a_Matrix4 ); - vmathM4Prints( &tmpM4_3, "absPerElem Matrix4" ); - vmathM4Transpose( &tmpM4_4, &a_Matrix4 ); - vmathM4Prints( &tmpM4_4, "transpose Matrix4" ); - vmathM4Inverse( &tmpM4_5, &a_Matrix4 ); - vmathM4Prints( &tmpM4_5, "inverse Matrix4" ); - vmathM4Inverse( &tmpM4_6, &a_Matrix4 ); - vmathM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 ); - vmathM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" ); - vmathV4MakeFromElems( &tmpV4_0, 0.0f, 0.0f, 0.0f, 1.0f ); - vmathM4SetRow( &a_Matrix4, 3, &tmpV4_0 ); - vmathQNormalize( &tmpQ_0, &a_Quat ); - vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); - vmathM4SetUpper3x3( &a_Matrix4, &tmpM3_0 ); - vmathM4AffineInverse( &tmpM4_8, &a_Matrix4 ); - vmathM4Prints( &tmpM4_8, "affineInverse Matrix4" ); - vmathM4AffineInverse( &tmpM4_9, &a_Matrix4 ); - vmathM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 ); - vmathM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" ); - vmathM4OrthoInverse( &tmpM4_11, &a_Matrix4 ); - vmathM4Prints( &tmpM4_11, "orthoInverse Matrix4" ); - vmathM4OrthoInverse( &tmpM4_12, &a_Matrix4 ); - vmathM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 ); - vmathM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" ); - printf("%f\n", getfloat(vmathM4Determinant( &a_Matrix4 )) ); - vmathV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 ); - vmathM4Prints( &tmpM4_14, "outer Vector4" ); -} - -void -Transform3_methods_test() -{ - VmathMatrix3 a_Matrix3, b_Matrix3; - VmathMatrix4 a_Matrix4, b_Matrix4; - VmathTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6; - VmathMatrix3 tmpM3_0; - VmathTransform3 tmpT3_7, tmpT3_8, tmpT3_9; - VmathVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathVector4 tmpV4; - VmathVector3 tmpV3_0, tmpV3_1, tmpV3_2, tmpV3_3, tmpV3_4, tmpV3_5, tmpV3_6, tmpV3_7; - VmathQuat tmpQ_0; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &a_Vector3, pad ); - vmathV4GetXYZ( &a_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &b_Vector3, pad ); - vmathV4GetXYZ( &b_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &c_Vector3, pad ); - vmathV4GetXYZ( &c_Vector3, &tmpV4 ); - vmathV4MakeFromV3Scalar( &tmpV4, &d_Vector3, pad ); - vmathV4GetXYZ( &d_Vector3, &tmpV4 ); - vmathV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathV3MakeFromP3( &tmpV3_0, &a_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_0, pad ); - vmathV4GetXYZ( &tmpV3_1, &tmpV4 ); - vmathP3MakeFromV3( &a_Point3, &tmpV3_1 ); - vmathV3MakeFromP3( &tmpV3_2, &b_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_2, pad ); - vmathV4GetXYZ( &tmpV3_3, &tmpV4 ); - vmathP3MakeFromV3( &b_Point3, &tmpV3_3 ); - vmathV3MakeFromP3( &tmpV3_4, &c_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_4, pad ); - vmathV4GetXYZ( &tmpV3_5, &tmpV4 ); - vmathP3MakeFromV3( &c_Point3, &tmpV3_5 ); - vmathV3MakeFromP3( &tmpV3_6, &d_Point3 ); - vmathV4MakeFromV3Scalar( &tmpV4, &tmpV3_6, pad ); - vmathV4GetXYZ( &tmpV3_7, &tmpV4 ); - vmathP3MakeFromV3( &d_Point3, &tmpV3_7 ); - vmathP3Prints( &a_Point3, "set Point3 with floats" ); - vmathP3Prints( &b_Point3, "set Point3 with floats" ); - vmathP3Prints( &c_Point3, "set Point3 with floats" ); - vmathP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathQPrints( &a_Quat, "set Quat with floats" ); - vmathQPrints( &b_Quat, "set Quat with floats" ); - vmathQPrints( &c_Quat, "set Quat with floats" ); - vmathQPrints( &d_Quat, "set Quat with floats" ); - vmathM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 ); - vmathT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" ); - vmathT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 ); - vmathT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" ); - vmathT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 ); - vmathT3Prints( &tmpT3_2, "mulPerElem Transform3" ); - vmathT3AbsPerElem( &tmpT3_3, &a_Transform3 ); - vmathT3Prints( &tmpT3_3, "absPerElem Transform3" ); - vmathT3Inverse( &tmpT3_4, &a_Transform3 ); - vmathT3Prints( &tmpT3_4, "inverse Transform3" ); - vmathT3Inverse( &tmpT3_5, &a_Transform3 ); - vmathT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 ); - vmathT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" ); - vmathQNormalize( &tmpQ_0, &a_Quat ); - vmathM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); - vmathT3SetUpper3x3( &a_Transform3, &tmpM3_0 ); - vmathT3OrthoInverse( &tmpT3_7, &a_Transform3 ); - vmathT3Prints( &tmpT3_7, "orthoInverse Transform3" ); - vmathT3OrthoInverse( &tmpT3_8, &a_Transform3 ); - vmathT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 ); - vmathT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test4_aos_cpp.cpp b/Extras/vectormathlibrary/tests/test4_aos_cpp.cpp deleted file mode 100644 index e55bee0e5..000000000 --- a/Extras/vectormathlibrary/tests/test4_aos_cpp.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_AOS_TEST - -#include "vectormath_aos.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Aos; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" ); - print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" ); - print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" ); - print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" ); - print( transpose( a_Matrix3 ), "transpose Matrix3" ); - print( inverse( a_Matrix3 ), "inverse Matrix3" ); - print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" ); - printf("%f\n", getfloat(determinant( a_Matrix3 )) ); - print( outer( a_Vector3, b_Vector3 ), "outer Vector3" ); - print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" ); - print( crossMatrix( a_Vector3 ), "crossMatrix" ); - print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" ); - print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" ); - print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" ); - print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" ); - print( transpose( a_Matrix4 ), "transpose Matrix4" ); - print( inverse( a_Matrix4 ), "inverse Matrix4" ); - print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" ); - a_Matrix4.setRow( 3, Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); - a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); - print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" ); - print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" ); - print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" ); - print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" ); - printf("%f\n", getfloat(determinant( a_Matrix4 )) ); - print( outer( a_Vector4, b_Vector4 ), "outer Vector4" ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - Vector4 tmpV4; - float rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6, pad; - // set a pad value to detect invalid use of padding. - // this will be nan for scalar/ppu implementations, max. float for spu - union { float f; unsigned int u; } tmp; - tmp.u = 0x7fffffff; - pad = tmp.f; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( a_Vector3, pad ); - a_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( b_Vector3, pad ); - b_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( c_Vector3, pad ); - c_Vector3 = tmpV4.getXYZ( ); - tmpV4 = Vector4( d_Vector3, pad ); - d_Vector3 = tmpV4.getXYZ( ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - tmpV4 = Vector4( Vector3( a_Point3 ), pad ); - a_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( b_Point3 ), pad ); - b_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( c_Point3 ), pad ); - c_Point3 = Point3( tmpV4.getXYZ( ) ); - tmpV4 = Vector4( Vector3( d_Point3 ), pad ); - d_Point3 = Point3( tmpV4.getXYZ( ) ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" ); - print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" ); - print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" ); - print( absPerElem( a_Transform3 ), "absPerElem Transform3" ); - print( inverse( a_Transform3 ), "inverse Transform3" ); - print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" ); - a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); - print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" ); - print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test4_reference.txt b/Extras/vectormathlibrary/tests/test4_reference.txt deleted file mode 100644 index 23afd2d67..000000000 --- a/Extras/vectormathlibrary/tests/test4_reference.txt +++ /dev/null @@ -1,524 +0,0 @@ -set Vector3 with floats: ( -0.658344 0.499804 -0.807257 ) -set Vector3 with floats: ( 0.740930 0.154607 0.571599 ) -set Vector3 with floats: ( 0.384388 -0.262467 0.747808 ) -set Vector3 with floats: ( 0.490190 -0.107908 -0.292544 ) -set Vector4 with floats: ( 0.465039 -0.479556 -0.211412 0.553580 ) -set Vector4 with floats: ( 0.690070 0.151576 0.431077 -0.833992 ) -set Vector4 with floats: ( -0.088350 -0.780106 0.090456 -0.218627 ) -set Vector4 with floats: ( 0.137171 0.918133 0.735438 -0.673621 ) -set Point3 with floats: ( -0.448982 -0.479278 0.848189 ) -set Point3 with floats: ( -0.128155 0.578922 -0.744766 ) -set Point3 with floats: ( -0.835589 0.881284 -0.948850 ) -set Point3 with floats: ( -0.691578 -0.235635 -0.690527 ) -set Quat with floats: ( 0.058667 0.753697 -0.138777 -0.472188 ) -set Quat with floats: ( -0.372811 0.540183 -0.785218 0.542085 ) -set Quat with floats: ( 0.410391 -0.562721 0.523588 -0.176574 ) -set Quat with floats: ( 0.297654 0.859913 0.004837 0.374881 ) -set Matrix3 columns: -( -0.658344 0.740930 0.384388 ) -( 0.499804 0.154607 -0.262467 ) -( -0.807257 0.571599 0.747808 ) -set Matrix3 columns: -( 0.490190 -0.658344 0.740930 ) -( -0.107908 0.499804 0.154607 ) -( -0.292544 -0.807257 0.571599 ) -set Matrix4 columns: -( 0.465039 0.690070 -0.088350 0.137171 ) -( -0.479556 0.151576 -0.780106 0.918133 ) -( -0.211412 0.431077 0.090456 0.735438 ) -( 0.553580 -0.833992 -0.218627 -0.673621 ) -set Matrix4 columns: -( 0.137171 0.465039 0.690070 -0.088350 ) -( 0.918133 -0.479556 0.151576 -0.780106 ) -( 0.735438 -0.211412 0.431077 0.090456 ) -( -0.673621 0.553580 -0.833992 -0.218627 ) -set Transform3 columns: -( -0.658344 0.740930 0.384388 0.490190 ) -( 0.499804 0.154607 -0.262467 -0.107908 ) -( -0.807257 0.571599 0.747808 -0.292544 ) -set Transform3 columns: -( 0.490190 -0.658344 0.740930 0.384388 ) -( -0.107908 0.499804 0.154607 -0.262467 ) -( -0.292544 -0.807257 0.571599 0.747808 ) -appendScale Matrix3 Vector3: -( 0.433417 0.370320 -0.310300 ) -( -0.329043 0.077273 0.211879 ) -( 0.531453 0.285687 -0.603673 ) -prependScale Vector3 Matrix3: -( 0.433417 -0.487787 -0.253060 ) -( 0.249804 0.077273 -0.131182 ) -( 0.651663 -0.461427 -0.603673 ) -mulPerElem Matrix3: -( -0.322714 -0.487787 0.284805 ) -( -0.053933 0.077273 -0.040579 ) -( 0.236158 -0.461427 0.427446 ) -absPerElem Matrix3: -( 0.658344 0.740930 0.384388 ) -( 0.499804 0.154607 0.262467 ) -( 0.807257 0.571599 0.747808 ) -transpose Matrix3: -( -0.658344 0.499804 -0.807257 ) -( 0.740930 0.154607 0.571599 ) -( 0.384388 -0.262467 0.747808 ) -inverse Matrix3: -( -1.938491 2.439935 1.852797 ) -( 1.181290 1.328230 -0.141021 ) -( -2.995533 1.618649 3.445122 ) -inverse(Matrix3) * Matrix3: -( 1.000000 0.000000 0.000000 ) -( 0.000000 1.000000 -0.000000 ) -( 0.000000 -0.000000 1.000000 ) --0.137036 -outer Vector3: -( -0.487787 -0.101785 -0.376308 ) -( 0.370320 0.077273 0.285687 ) -( -0.598121 -0.124808 -0.461427 ) -rowMul Vector3: ( 1.334884 -0.871941 -0.987915 ) -crossMatrix: -( 0.000000 0.807257 0.499804 ) -( -0.807257 0.000000 0.658344 ) -( -0.499804 -0.658344 0.000000 ) -crossMatrixMul: -( 0.000000 0.410495 0.161879 ) -( 0.000000 -0.221813 0.182015 ) -( 0.000000 -0.472105 -0.019325 ) -set Vector3 with floats: ( -0.127818 0.216602 0.153117 ) -set Vector3 with floats: ( 0.265243 -0.073149 0.264488 ) -set Vector3 with floats: ( -0.723410 0.921523 -0.711250 ) -set Vector3 with floats: ( -0.106634 -0.350831 0.905168 ) -set Vector4 with floats: ( -0.283632 -0.203584 -0.797437 0.910171 ) -set Vector4 with floats: ( 0.969234 0.151940 0.731827 -0.700248 ) -set Vector4 with floats: ( 0.818301 0.302505 -0.872278 0.909999 ) -set Vector4 with floats: ( 0.932526 0.571087 0.610330 0.142507 ) -set Point3 with floats: ( -0.434829 0.925102 0.158954 ) -set Point3 with floats: ( -0.126283 -0.249128 0.846815 ) -set Point3 with floats: ( -0.942601 0.537720 0.446214 ) -set Point3 with floats: ( 0.181939 -0.148223 0.284286 ) -set Quat with floats: ( 0.493525 -0.861963 -0.893410 0.548627 ) -set Quat with floats: ( 0.407007 -0.757467 -0.393126 -0.850984 ) -set Quat with floats: ( 0.375720 -0.270088 0.458888 -0.610828 ) -set Quat with floats: ( -0.690816 -0.676415 0.664466 0.101874 ) -set Matrix3 columns: -( -0.127818 0.265243 -0.723410 ) -( 0.216602 -0.073149 0.921523 ) -( 0.153117 0.264488 -0.711250 ) -set Matrix3 columns: -( -0.106634 -0.127818 0.265243 ) -( -0.350831 0.216602 -0.073149 ) -( 0.905168 0.153117 0.264488 ) -set Matrix4 columns: -( -0.283632 0.969234 0.818301 0.932526 ) -( -0.203584 0.151940 0.302505 0.571087 ) -( -0.797437 0.731827 -0.872278 0.610330 ) -( 0.910171 -0.700248 0.909999 0.142507 ) -set Matrix4 columns: -( 0.932526 -0.283632 0.969234 0.818301 ) -( 0.571087 -0.203584 0.151940 0.302505 ) -( 0.610330 -0.797437 0.731827 -0.872278 ) -( 0.142507 0.910171 -0.700248 0.909999 ) -set Transform3 columns: -( -0.127818 0.265243 -0.723410 -0.106634 ) -( 0.216602 -0.073149 0.921523 -0.350831 ) -( 0.153117 0.264488 -0.711250 0.905168 ) -set Transform3 columns: -( -0.106634 -0.127818 0.265243 -0.723410 ) -( -0.350831 0.216602 -0.073149 0.921523 ) -( 0.905168 0.153117 0.264488 -0.711250 ) -appendScale Matrix4 Vector3: -( 0.036253 0.209938 0.125296 0.932526 ) -( 0.026022 0.032911 0.046319 0.571087 ) -( 0.101927 0.158515 -0.133561 0.610330 ) -( -0.116336 -0.151675 0.139337 0.142507 ) -prependScale Vector3 Matrix4: -( 0.036253 -0.123886 -0.104594 -0.119194 ) -( -0.044097 0.032911 0.065523 0.123698 ) -( -0.122101 0.112055 -0.133561 0.093452 ) -( 0.910171 -0.700248 0.909999 0.142507 ) -mulPerElem Matrix4: -( -0.264494 -0.274906 0.793125 0.763086 ) -( -0.116264 -0.030933 0.045963 0.172757 ) -( -0.486699 -0.583586 -0.638357 -0.532377 ) -( 0.129706 -0.637346 -0.637225 0.129682 ) -absPerElem Matrix4: -( 0.283632 0.969234 0.818301 0.932526 ) -( 0.203584 0.151940 0.302505 0.571087 ) -( 0.797437 0.731827 0.872278 0.610330 ) -( 0.910171 0.700248 0.909999 0.142507 ) -transpose Matrix4: -( -0.283632 -0.203584 -0.797437 0.910171 ) -( 0.969234 0.151940 0.731827 -0.700248 ) -( 0.818301 0.302505 -0.872278 0.909999 ) -( 0.932526 0.571087 0.610330 0.142507 ) -inverse Matrix4: -( 0.756962 -3.392262 1.563321 1.945501 ) -( 1.235862 -2.616357 0.503558 0.241096 ) -( 0.221503 1.293015 -1.354804 -0.828755 ) -( -0.176291 0.552941 1.140966 1.068388 ) -inverse(Matrix4) * Matrix4: -( 1.000000 0.000000 -0.000000 0.000000 ) -( -0.000000 1.000000 -0.000000 -0.000000 ) -( 0.000000 -0.000000 1.000000 -0.000000 ) -( -0.000000 0.000000 0.000000 1.000000 ) -affineInverse Matrix4: -( -0.477821 -0.877922 0.030662 0.928236 ) -( 0.062087 0.001066 0.998070 -0.667659 ) -( -0.876260 0.478803 0.053999 0.510740 ) -( 0.000000 0.000000 0.000000 1.000000 ) -affineInverse(Matrix4) * Matrix4: -( 1.000000 0.000000 -0.000000 0.000000 ) -( 0.000000 1.000000 0.000000 0.000000 ) -( -0.000000 0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -orthoInverse Matrix4: -( -0.477822 -0.877922 0.030662 0.928237 ) -( 0.062087 0.001066 0.998070 -0.667659 ) -( -0.876260 0.478803 0.053999 0.510740 ) -( 0.000000 0.000000 0.000000 1.000000 ) -orthoInverse(Matrix4) * Matrix4: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 -0.000000 -0.000000 ) -( 0.000000 -0.000000 1.000000 -0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -1.000000 -outer Vector4: -( -0.274906 -0.043095 -0.207570 0.198613 ) -( -0.197320 -0.030933 -0.148988 0.142559 ) -( -0.772903 -0.121163 -0.583586 0.558404 ) -( 0.882169 0.138292 0.666089 -0.637346 ) -set Vector3 with floats: ( -0.365714 0.055473 -0.133556 ) -set Vector3 with floats: ( -0.572643 0.459209 -0.997261 ) -set Vector3 with floats: ( 0.172409 -0.045124 0.879716 ) -set Vector3 with floats: ( 0.524317 -0.744532 -0.970444 ) -set Vector4 with floats: ( -0.000013 0.689543 0.704297 -0.817983 ) -set Vector4 with floats: ( 0.715505 0.577868 0.156952 -0.801022 ) -set Vector4 with floats: ( 0.656335 0.494393 0.816743 0.024285 ) -set Vector4 with floats: ( 0.769132 0.923895 0.133022 -0.052219 ) -set Point3 with floats: ( -0.164886 0.300690 0.760403 ) -set Point3 with floats: ( 0.171869 -0.554976 0.998693 ) -set Point3 with floats: ( -0.681641 0.391195 0.403059 ) -set Point3 with floats: ( 0.972411 0.297195 0.309761 ) -set Quat with floats: ( 0.688408 0.363540 0.940297 -0.336683 ) -set Quat with floats: ( 0.600164 -0.681272 0.726558 0.205513 ) -set Quat with floats: ( -0.160082 0.962714 0.737794 -0.071926 ) -set Quat with floats: ( -0.506313 0.689277 0.686485 0.473013 ) -set Matrix3 columns: -( -0.365714 -0.572643 0.172409 ) -( 0.055473 0.459209 -0.045124 ) -( -0.133556 -0.997261 0.879716 ) -set Matrix3 columns: -( 0.524317 -0.365714 -0.572643 ) -( -0.744532 0.055473 0.459209 ) -( -0.970444 -0.133556 -0.997261 ) -set Matrix4 columns: -( -0.000013 0.715505 0.656335 0.769132 ) -( 0.689543 0.577868 0.494393 0.923895 ) -( 0.704297 0.156952 0.816743 0.133022 ) -( -0.817983 -0.801022 0.024285 -0.052219 ) -set Matrix4 columns: -( 0.769132 -0.000013 0.715505 0.656335 ) -( 0.923895 0.689543 0.577868 0.494393 ) -( 0.133022 0.704297 0.156952 0.816743 ) -( -0.052219 -0.817983 -0.801022 0.024285 ) -set Transform3 columns: -( -0.365714 -0.572643 0.172409 0.524317 ) -( 0.055473 0.459209 -0.045124 -0.744532 ) -( -0.133556 -0.997261 0.879716 -0.970444 ) -set Transform3 columns: -( 0.524317 -0.365714 -0.572643 0.172409 ) -( -0.744532 0.055473 0.459209 -0.045124 ) -( -0.970444 -0.133556 -0.997261 0.879716 ) -appendScale Transform3 Vector3: -( 0.133747 -0.031766 -0.023026 0.524317 ) -( -0.020287 0.025474 0.006027 -0.744532 ) -( 0.048843 -0.055321 -0.117491 -0.970444 ) -prependScale Vector3 Transform3: -( 0.133747 0.209424 -0.063052 -0.191750 ) -( 0.003077 0.025474 -0.002503 -0.041301 ) -( 0.017837 0.133190 -0.117491 0.129609 ) -mulPerElem Transform3: -( -0.191750 0.209424 -0.098729 0.090397 ) -( -0.041301 0.025474 -0.020721 0.033596 ) -( 0.129609 0.133190 -0.877307 -0.853715 ) -absPerElem Transform3: -( 0.365714 0.572643 0.172409 0.524317 ) -( 0.055473 0.459209 0.045124 0.744532 ) -( 0.133556 0.997261 0.879716 0.970444 ) -inverse Transform3: -( -3.394501 -3.137797 0.504313 -0.066988 ) -( 0.404474 2.824531 0.065611 1.954553 ) -( -0.056825 2.725566 1.287672 3.308679 ) -inverse(Transform3) * Transform3: -( 1.000000 -0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 -0.000000 -0.000000 ) -( -0.000000 -0.000000 1.000000 0.000000 ) -orthoInverse Transform3: -( -0.267562 -0.082713 0.959984 1.010315 ) -( 0.706975 -0.693789 0.137268 -0.754017 ) -( 0.654673 0.715412 0.244108 0.426284 ) -orthoInverse(Transform3) * Transform3: -( 1.000000 0.000000 0.000000 -0.000000 ) -( 0.000000 1.000000 0.000000 -0.000000 ) -( 0.000000 0.000000 1.000000 -0.000000 ) -set Vector3 with floats: ( -0.735610 -0.046390 0.568674 ) -set Vector3 with floats: ( -0.004815 0.137637 -0.111879 ) -set Vector3 with floats: ( -0.929543 -0.336303 -0.146740 ) -set Vector3 with floats: ( 0.165140 -0.823874 0.349776 ) -set Vector4 with floats: ( 0.174872 -0.528584 0.489292 0.916708 ) -set Vector4 with floats: ( 0.728511 -0.851140 0.079620 -0.234370 ) -set Vector4 with floats: ( -0.996308 0.433229 -0.892684 -0.957911 ) -set Vector4 with floats: ( 0.517122 0.257921 0.862028 0.095881 ) -set Point3 with floats: ( -0.171933 -0.214078 -0.604841 ) -set Point3 with floats: ( -0.383831 -0.581500 0.222183 ) -set Point3 with floats: ( -0.256120 -0.678699 -0.079553 ) -set Point3 with floats: ( 0.605960 -0.633147 0.435875 ) -set Quat with floats: ( -0.046627 -0.716491 0.267317 -0.514874 ) -set Quat with floats: ( -0.751700 0.742959 -0.793180 0.508814 ) -set Quat with floats: ( -0.238839 0.113471 -0.843523 -0.245250 ) -set Quat with floats: ( 0.250368 0.579243 -0.157280 0.648487 ) -set Matrix3 columns: -( -0.735610 -0.004815 -0.929543 ) -( -0.046390 0.137637 -0.336303 ) -( 0.568674 -0.111879 -0.146740 ) -set Matrix3 columns: -( 0.165140 -0.735610 -0.004815 ) -( -0.823874 -0.046390 0.137637 ) -( 0.349776 0.568674 -0.111879 ) -set Matrix4 columns: -( 0.174872 0.728511 -0.996308 0.517122 ) -( -0.528584 -0.851140 0.433229 0.257921 ) -( 0.489292 0.079620 -0.892684 0.862028 ) -( 0.916708 -0.234370 -0.957911 0.095881 ) -set Matrix4 columns: -( 0.517122 0.174872 0.728511 -0.996308 ) -( 0.257921 -0.528584 -0.851140 0.433229 ) -( 0.862028 0.489292 0.079620 -0.892684 ) -( 0.095881 0.916708 -0.234370 -0.957911 ) -set Transform3 columns: -( -0.735610 -0.004815 -0.929543 0.165140 ) -( -0.046390 0.137637 -0.336303 -0.823874 ) -( 0.568674 -0.111879 -0.146740 0.349776 ) -set Transform3 columns: -( 0.165140 -0.735610 -0.004815 -0.929543 ) -( -0.823874 -0.046390 0.137637 -0.336303 ) -( 0.349776 0.568674 -0.111879 -0.146740 ) -appendScale Matrix3 Vector3: -( 0.541123 0.000223 -0.528607 ) -( 0.034125 -0.006385 -0.191247 ) -( -0.418323 0.005190 -0.083447 ) -prependScale Vector3 Matrix3: -( 0.541123 0.003542 0.683781 ) -( 0.002152 -0.006385 0.015601 ) -( 0.323390 -0.063623 -0.083447 ) -mulPerElem Matrix3: -( -0.121479 0.003542 0.004475 ) -( 0.038220 -0.006385 -0.046288 ) -( 0.198909 -0.063623 0.016417 ) -absPerElem Matrix3: -( 0.735610 0.004815 0.929543 ) -( 0.046390 0.137637 0.336303 ) -( 0.568674 0.111879 0.146740 ) -transpose Matrix3: -( -0.735610 -0.046390 0.568674 ) -( -0.004815 0.137637 -0.111879 ) -( -0.929543 -0.336303 -0.146740 ) -inverse Matrix3: -( -0.518959 0.927036 1.162799 ) -( -1.777555 5.713095 -1.833313 ) -( -0.655903 -0.763218 -0.910706 ) -inverse(Matrix3) * Matrix3: -( 1.000000 0.000000 0.000000 ) -( -0.000000 1.000000 -0.000000 ) -( -0.000000 0.000000 1.000000 ) -0.111420 -outer Vector3: -( 0.003542 -0.101247 0.082299 ) -( 0.000223 -0.006385 0.005190 ) -( -0.002738 0.078270 -0.063623 ) -rowMul Vector3: ( 0.866665 -0.066466 0.615935 ) -crossMatrix: -( 0.000000 -0.568674 -0.046390 ) -( 0.568674 0.000000 0.735610 ) -( 0.046390 -0.735610 0.000000 ) -crossMatrixMul: -( 0.000000 -0.073080 0.198054 ) -( 0.000000 -0.085037 -0.636550 ) -( 0.000000 -0.101470 0.204267 ) -set Vector3 with floats: ( 0.103833 0.456401 -0.022372 ) -set Vector3 with floats: ( -0.475631 -0.004178 -0.020865 ) -set Vector3 with floats: ( -0.016997 0.699144 0.837796 ) -set Vector3 with floats: ( -0.276082 0.091582 0.209064 ) -set Vector4 with floats: ( 0.219317 -0.118359 0.413442 -0.567698 ) -set Vector4 with floats: ( 0.531358 -0.387226 0.572490 -0.820417 ) -set Vector4 with floats: ( 0.797191 0.867178 0.934764 0.237092 ) -set Vector4 with floats: ( -0.866162 -0.773939 0.261311 -0.851570 ) -set Point3 with floats: ( 0.114814 -0.531592 0.223925 ) -set Point3 with floats: ( 0.869105 0.143405 0.148518 ) -set Point3 with floats: ( -0.071136 -0.758292 -0.527633 ) -set Point3 with floats: ( 0.997215 0.114440 0.727558 ) -set Quat with floats: ( -0.425760 0.459888 0.642516 -0.022534 ) -set Quat with floats: ( 0.186095 -0.775679 -0.683401 0.398134 ) -set Quat with floats: ( 0.189642 0.765986 -0.137795 -0.579844 ) -set Quat with floats: ( -0.635647 0.374970 -0.563750 -0.471075 ) -set Matrix3 columns: -( 0.103833 -0.475631 -0.016997 ) -( 0.456401 -0.004178 0.699144 ) -( -0.022372 -0.020865 0.837796 ) -set Matrix3 columns: -( -0.276082 0.103833 -0.475631 ) -( 0.091582 0.456401 -0.004178 ) -( 0.209064 -0.022372 -0.020865 ) -set Matrix4 columns: -( 0.219317 0.531358 0.797191 -0.866162 ) -( -0.118359 -0.387226 0.867178 -0.773939 ) -( 0.413442 0.572490 0.934764 0.261311 ) -( -0.567698 -0.820417 0.237092 -0.851570 ) -set Matrix4 columns: -( -0.866162 0.219317 0.531358 0.797191 ) -( -0.773939 -0.118359 -0.387226 0.867178 ) -( 0.261311 0.413442 0.572490 0.934764 ) -( -0.851570 -0.567698 -0.820417 0.237092 ) -set Transform3 columns: -( 0.103833 -0.475631 -0.016997 -0.276082 ) -( 0.456401 -0.004178 0.699144 0.091582 ) -( -0.022372 -0.020865 0.837796 0.209064 ) -set Transform3 columns: -( -0.276082 0.103833 -0.475631 -0.016997 ) -( 0.091582 0.456401 -0.004178 0.699144 ) -( 0.209064 -0.022372 -0.020865 0.837796 ) -appendScale Matrix4 Vector3: -( 0.022772 0.242513 -0.017835 -0.866162 ) -( -0.012290 -0.176730 -0.019401 -0.773939 ) -( 0.042929 0.261285 -0.020913 0.261311 ) -( -0.058946 -0.374439 -0.005304 -0.851570 ) -prependScale Vector3 Matrix4: -( 0.022772 0.055173 0.082775 -0.089936 ) -( -0.054019 -0.176730 0.395781 -0.353227 ) -( -0.009250 -0.012808 -0.020913 -0.005846 ) -( -0.567698 -0.820417 0.237092 -0.851570 ) -mulPerElem Matrix4: -( -0.189964 0.116536 0.423594 -0.690497 ) -( 0.091603 0.045832 -0.335794 -0.671143 ) -( 0.108037 0.236691 0.535143 0.244264 ) -( 0.483434 0.465749 -0.194514 -0.201900 ) -absPerElem Matrix4: -( 0.219317 0.531358 0.797191 0.866162 ) -( 0.118359 0.387226 0.867178 0.773939 ) -( 0.413442 0.572490 0.934764 0.261311 ) -( 0.567698 0.820417 0.237092 0.851570 ) -transpose Matrix4: -( 0.219317 -0.118359 0.413442 -0.567698 ) -( 0.531358 -0.387226 0.572490 -0.820417 ) -( 0.797191 0.867178 0.934764 0.237092 ) -( -0.866162 -0.773939 0.261311 -0.851570 ) -inverse Matrix4: -( -0.801304 6.311381 -3.640203 -6.038011 ) -( 1.289204 -3.528897 1.571125 2.378011 ) -( -0.220138 -0.375260 1.356762 0.981293 ) -( -0.769143 -0.912151 1.290834 0.833121 ) -inverse(Matrix4) * Matrix4: -( 1.000000 -0.000000 -0.000000 0.000000 ) -( 0.000000 1.000000 -0.000000 0.000000 ) -( -0.000000 0.000000 1.000000 -0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -affineInverse Matrix4: -( -0.548992 -0.521721 -0.653005 -0.708658 ) -( -0.449878 -0.474001 0.756923 -0.954307 ) -( -0.704428 0.709317 0.025512 -0.067847 ) -( 0.000000 0.000000 0.000000 1.000000 ) -affineInverse(Matrix4) * Matrix4: -( 1.000000 0.000000 0.000000 0.000000 ) -( 0.000000 1.000000 -0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 -0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -orthoInverse Matrix4: -( -0.548992 -0.521721 -0.653005 -0.708658 ) -( -0.449878 -0.474001 0.756923 -0.954307 ) -( -0.704428 0.709317 0.025512 -0.067847 ) -( 0.000000 0.000000 0.000000 1.000000 ) -orthoInverse(Matrix4) * Matrix4: -( 1.000000 0.000000 0.000000 -0.000000 ) -( 0.000000 1.000000 -0.000000 0.000000 ) -( 0.000000 -0.000000 1.000000 0.000000 ) -( 0.000000 0.000000 0.000000 1.000000 ) -1.000000 -outer Vector4: -( 0.116536 -0.084925 0.125557 -0.179931 ) -( -0.062891 0.045832 -0.067760 0.097104 ) -( 0.219686 -0.160095 0.236691 -0.339195 ) -( -0.301651 0.219827 -0.325001 0.465749 ) -set Vector3 with floats: ( -0.553800 -0.014688 -0.464365 ) -set Vector3 with floats: ( -0.107890 -0.527503 -0.406423 ) -set Vector3 with floats: ( 0.301261 0.499529 0.385180 ) -set Vector3 with floats: ( -0.150218 0.519112 -0.203209 ) -set Vector4 with floats: ( -0.252017 0.282194 0.067637 0.798376 ) -set Vector4 with floats: ( 0.310782 0.861334 -0.980345 -0.655106 ) -set Vector4 with floats: ( 0.286765 0.532078 0.352671 0.540977 ) -set Vector4 with floats: ( 0.510961 0.791871 -0.564379 0.273199 ) -set Point3 with floats: ( 0.194378 0.244636 -0.269608 ) -set Point3 with floats: ( -0.858162 -0.495023 -0.277798 ) -set Point3 with floats: ( -0.032740 0.007412 -0.420178 ) -set Point3 with floats: ( -0.522577 0.324972 0.795389 ) -set Quat with floats: ( 0.342900 -0.913636 0.675222 0.144053 ) -set Quat with floats: ( -0.632329 -0.947120 -0.049367 0.126333 ) -set Quat with floats: ( -0.664206 0.220879 0.284219 -0.387216 ) -set Quat with floats: ( 0.913568 0.531906 0.271995 -0.862601 ) -set Matrix3 columns: -( -0.553800 -0.107890 0.301261 ) -( -0.014688 -0.527503 0.499529 ) -( -0.464365 -0.406423 0.385180 ) -set Matrix3 columns: -( -0.150218 -0.553800 -0.107890 ) -( 0.519112 -0.014688 -0.527503 ) -( -0.203209 -0.464365 -0.406423 ) -set Matrix4 columns: -( -0.252017 0.310782 0.286765 0.510961 ) -( 0.282194 0.861334 0.532078 0.791871 ) -( 0.067637 -0.980345 0.352671 -0.564379 ) -( 0.798376 -0.655106 0.540977 0.273199 ) -set Matrix4 columns: -( 0.510961 -0.252017 0.310782 0.286765 ) -( 0.791871 0.282194 0.861334 0.532078 ) -( -0.564379 0.067637 -0.980345 0.352671 ) -( 0.273199 0.798376 -0.655106 0.540977 ) -set Transform3 columns: -( -0.553800 -0.107890 0.301261 -0.150218 ) -( -0.014688 -0.527503 0.499529 0.519112 ) -( -0.464365 -0.406423 0.385180 -0.203209 ) -set Transform3 columns: -( -0.150218 -0.553800 -0.107890 0.301261 ) -( 0.519112 -0.014688 -0.527503 0.499529 ) -( -0.203209 -0.464365 -0.406423 0.385180 ) -appendScale Transform3 Vector3: -( 0.306694 0.001585 -0.139895 -0.150218 ) -( 0.008134 0.007748 -0.231964 0.519112 ) -( 0.257165 0.005970 -0.178864 -0.203209 ) -prependScale Vector3 Transform3: -( 0.306694 0.059749 -0.166838 0.083191 ) -( 0.000216 0.007748 -0.007337 -0.007625 ) -( 0.215635 0.188729 -0.178864 0.094363 ) -mulPerElem Transform3: -( 0.083191 0.059749 -0.032503 -0.045255 ) -( -0.007625 0.007748 -0.263503 0.259311 ) -( 0.094363 0.188729 -0.156546 -0.078272 ) -absPerElem Transform3: -( 0.553800 0.107890 0.301261 0.150218 ) -( 0.014688 0.527503 0.499529 0.519112 ) -( 0.464365 0.406423 0.385180 0.203209 ) -inverse Transform3: -( 0.003445 1.703147 -2.211457 -1.332994 ) -( 4.765344 1.545948 -5.732023 -1.251475 ) -( 5.032312 3.684490 -6.118052 -2.399958 ) -inverse(Transform3) * Transform3: -( 1.000000 0.000000 -0.000000 -0.000000 ) -( 0.000000 1.000000 -0.000000 0.000000 ) -( 0.000000 0.000000 1.000000 -0.000000 ) -orthoInverse Transform3: -( -0.806392 -0.302338 0.508256 0.139094 ) -( -0.574608 0.197327 -0.794285 -0.350157 ) -( 0.139850 -0.932552 -0.332848 0.437469 ) -orthoInverse(Transform3) * Transform3: -( 1.000000 0.000000 0.000000 -0.000000 ) -( 0.000000 1.000000 -0.000000 0.000000 ) -( 0.000000 -0.000000 1.000000 0.000000 ) - - __end__ diff --git a/Extras/vectormathlibrary/tests/test4_soa_c.c b/Extras/vectormathlibrary/tests/test4_soa_c.c deleted file mode 100644 index dbd01502a..000000000 --- a/Extras/vectormathlibrary/tests/test4_soa_c.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -void -Matrix3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaMatrix3 tmpM3_0, tmpM3_1, tmpM3_2, tmpM3_3, tmpM3_4, tmpM3_5, tmpM3_6, tmpM3_7, tmpM3_8, tmpM3_9, tmpM3_10; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector3 tmpV3_0; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaM3AppendScale( &tmpM3_0, &a_Matrix3, &a_Vector3 ); - vmathSoaM3Prints( &tmpM3_0, "appendScale Matrix3 Vector3" ); - vmathSoaM3PrependScale( &tmpM3_1, &a_Vector3, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_1, "prependScale Vector3 Matrix3" ); - vmathSoaM3MulPerElem( &tmpM3_2, &a_Matrix3, &b_Matrix3 ); - vmathSoaM3Prints( &tmpM3_2, "mulPerElem Matrix3" ); - vmathSoaM3AbsPerElem( &tmpM3_3, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_3, "absPerElem Matrix3" ); - vmathSoaM3Transpose( &tmpM3_4, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_4, "transpose Matrix3" ); - vmathSoaM3Inverse( &tmpM3_5, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_5, "inverse Matrix3" ); - vmathSoaM3Inverse( &tmpM3_6, &a_Matrix3 ); - vmathSoaM3Mul( &tmpM3_7, &tmpM3_6, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_7, "inverse(Matrix3) * Matrix3" ); - printf("%f\n", getfloat(vmathSoaM3Determinant( &a_Matrix3 )) ); - vmathSoaV3Outer( &tmpM3_8, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &tmpM3_8, "outer Vector3" ); - vmathSoaV3RowMul( &tmpV3_0, &a_Vector3, &a_Matrix3 ); - vmathSoaV3Prints( &tmpV3_0, "rowMul Vector3" ); - vmathSoaV3CrossMatrix( &tmpM3_9, &a_Vector3 ); - vmathSoaM3Prints( &tmpM3_9, "crossMatrix" ); - vmathSoaV3CrossMatrixMul( &tmpM3_10, &a_Vector3, &a_Matrix3 ); - vmathSoaM3Prints( &tmpM3_10, "crossMatrixMul" ); -} - -void -Matrix4_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3; - VmathSoaMatrix4 tmpM4_0, tmpM4_1, tmpM4_2, tmpM4_3, tmpM4_4, tmpM4_5, tmpM4_6, tmpM4_7; - VmathSoaMatrix3 tmpM3_0; - VmathSoaMatrix4 tmpM4_8, tmpM4_9, tmpM4_10, tmpM4_11, tmpM4_12, tmpM4_13, tmpM4_14; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat; - VmathSoaVector4 tmpV4_0; - VmathSoaQuat tmpQ_0; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaM4AppendScale( &tmpM4_0, &a_Matrix4, &a_Vector3 ); - vmathSoaM4Prints( &tmpM4_0, "appendScale Matrix4 Vector3" ); - vmathSoaM4PrependScale( &tmpM4_1, &a_Vector3, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_1, "prependScale Vector3 Matrix4" ); - vmathSoaM4MulPerElem( &tmpM4_2, &a_Matrix4, &b_Matrix4 ); - vmathSoaM4Prints( &tmpM4_2, "mulPerElem Matrix4" ); - vmathSoaM4AbsPerElem( &tmpM4_3, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_3, "absPerElem Matrix4" ); - vmathSoaM4Transpose( &tmpM4_4, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_4, "transpose Matrix4" ); - vmathSoaM4Inverse( &tmpM4_5, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_5, "inverse Matrix4" ); - vmathSoaM4Inverse( &tmpM4_6, &a_Matrix4 ); - vmathSoaM4Mul( &tmpM4_7, &tmpM4_6, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_7, "inverse(Matrix4) * Matrix4" ); - vmathSoaV4MakeFromElems( &tmpV4_0, ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ); - vmathSoaM4SetRow( &a_Matrix4, 3, &tmpV4_0 ); - vmathSoaQNormalize( &tmpQ_0, &a_Quat ); - vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); - vmathSoaM4SetUpper3x3( &a_Matrix4, &tmpM3_0 ); - vmathSoaM4AffineInverse( &tmpM4_8, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_8, "affineInverse Matrix4" ); - vmathSoaM4AffineInverse( &tmpM4_9, &a_Matrix4 ); - vmathSoaM4Mul( &tmpM4_10, &tmpM4_9, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_10, "affineInverse(Matrix4) * Matrix4" ); - vmathSoaM4OrthoInverse( &tmpM4_11, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_11, "orthoInverse Matrix4" ); - vmathSoaM4OrthoInverse( &tmpM4_12, &a_Matrix4 ); - vmathSoaM4Mul( &tmpM4_13, &tmpM4_12, &a_Matrix4 ); - vmathSoaM4Prints( &tmpM4_13, "orthoInverse(Matrix4) * Matrix4" ); - printf("%f\n", getfloat(vmathSoaM4Determinant( &a_Matrix4 )) ); - vmathSoaV4Outer( &tmpM4_14, &a_Vector4, &b_Vector4 ); - vmathSoaM4Prints( &tmpM4_14, "outer Vector4" ); -} - -void -Transform3_methods_test() -{ - VmathSoaMatrix3 a_Matrix3, b_Matrix3; - VmathSoaMatrix4 a_Matrix4, b_Matrix4; - VmathSoaTransform3 a_Transform3, b_Transform3, tmpT3_0, tmpT3_1, tmpT3_2, tmpT3_3, tmpT3_4, tmpT3_5, tmpT3_6; - VmathSoaMatrix3 tmpM3_0; - VmathSoaTransform3 tmpT3_7, tmpT3_8, tmpT3_9; - VmathSoaVector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - VmathSoaVector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - VmathSoaPoint3 a_Point3, b_Point3, c_Point3, d_Point3; - VmathSoaQuat a_Quat, b_Quat, c_Quat, d_Quat, tmpQ_0; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &a_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV3MakeFromElems( &b_Vector3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &c_Vector3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaV3MakeFromElems( &d_Vector3, rndflt1, rndflt2, rndflt3 ); - vmathSoaV3Prints( &a_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &b_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &c_Vector3, "set Vector3 with floats" ); - vmathSoaV3Prints( &d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &a_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaV4MakeFromElems( &b_Vector4, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &c_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaV4MakeFromElems( &d_Vector4, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaV4Prints( &a_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &b_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &c_Vector4, "set Vector4 with floats" ); - vmathSoaV4Prints( &d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &a_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaP3MakeFromElems( &b_Point3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &c_Point3, rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - vmathSoaP3MakeFromElems( &d_Point3, rndflt1, rndflt2, rndflt3 ); - vmathSoaP3Prints( &a_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &b_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &c_Point3, "set Point3 with floats" ); - vmathSoaP3Prints( &d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &a_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - vmathSoaQMakeFromElems( &b_Quat, rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &c_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - vmathSoaQMakeFromElems( &d_Quat, rndflt1, rndflt2, rndflt3, rndflt4 ); - vmathSoaQPrints( &a_Quat, "set Quat with floats" ); - vmathSoaQPrints( &b_Quat, "set Quat with floats" ); - vmathSoaQPrints( &c_Quat, "set Quat with floats" ); - vmathSoaQPrints( &d_Quat, "set Quat with floats" ); - vmathSoaM3MakeFromCols( &a_Matrix3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaM3MakeFromCols( &b_Matrix3, &d_Vector3, &a_Vector3, &b_Vector3 ); - vmathSoaM3Prints( &a_Matrix3, "set Matrix3 columns" ); - vmathSoaM3Prints( &b_Matrix3, "set Matrix3 columns" ); - vmathSoaM4MakeFromCols( &a_Matrix4, &a_Vector4, &b_Vector4, &c_Vector4, &d_Vector4 ); - vmathSoaM4MakeFromCols( &b_Matrix4, &d_Vector4, &a_Vector4, &b_Vector4, &c_Vector4 ); - vmathSoaM4Prints( &a_Matrix4, "set Matrix4 columns" ); - vmathSoaM4Prints( &b_Matrix4, "set Matrix4 columns" ); - vmathSoaT3MakeFromCols( &a_Transform3, &a_Vector3, &b_Vector3, &c_Vector3, &d_Vector3 ); - vmathSoaT3MakeFromCols( &b_Transform3, &d_Vector3, &a_Vector3, &b_Vector3, &c_Vector3 ); - vmathSoaT3Prints( &a_Transform3, "set Transform3 columns" ); - vmathSoaT3Prints( &b_Transform3, "set Transform3 columns" ); - vmathSoaT3AppendScale( &tmpT3_0, &a_Transform3, &a_Vector3 ); - vmathSoaT3Prints( &tmpT3_0, "appendScale Transform3 Vector3" ); - vmathSoaT3PrependScale( &tmpT3_1, &a_Vector3, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_1, "prependScale Vector3 Transform3" ); - vmathSoaT3MulPerElem( &tmpT3_2, &a_Transform3, &b_Transform3 ); - vmathSoaT3Prints( &tmpT3_2, "mulPerElem Transform3" ); - vmathSoaT3AbsPerElem( &tmpT3_3, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_3, "absPerElem Transform3" ); - vmathSoaT3Inverse( &tmpT3_4, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_4, "inverse Transform3" ); - vmathSoaT3Inverse( &tmpT3_5, &a_Transform3 ); - vmathSoaT3Mul( &tmpT3_6, &tmpT3_5, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_6, "inverse(Transform3) * Transform3" ); - vmathSoaQNormalize( &tmpQ_0, &a_Quat ); - vmathSoaM3MakeFromQ( &tmpM3_0, &tmpQ_0 ); - vmathSoaT3SetUpper3x3( &a_Transform3, &tmpM3_0 ); - vmathSoaT3OrthoInverse( &tmpT3_7, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_7, "orthoInverse Transform3" ); - vmathSoaT3OrthoInverse( &tmpT3_8, &a_Transform3 ); - vmathSoaT3Mul( &tmpT3_9, &tmpT3_8, &a_Transform3 ); - vmathSoaT3Prints( &tmpT3_9, "orthoInverse(Transform3) * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/tests/test4_soa_cpp.cpp b/Extras/vectormathlibrary/tests/test4_soa_cpp.cpp deleted file mode 100644 index 3a71aef2e..000000000 --- a/Extras/vectormathlibrary/tests/test4_soa_cpp.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/* - 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. -*/ - -#define _VECTORMATH_SOA_TEST - -#include "vectormath_soa.h" -#include "test.h" - -int iteration = 0; - -using namespace Vectormath; -using namespace Vectormath::Soa; - -void -Matrix3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Matrix3, a_Vector3 ), "appendScale Matrix3 Vector3" ); - print( prependScale( a_Vector3, a_Matrix3 ), "prependScale Vector3 Matrix3" ); - print( mulPerElem( a_Matrix3, b_Matrix3 ), "mulPerElem Matrix3" ); - print( absPerElem( a_Matrix3 ), "absPerElem Matrix3" ); - print( transpose( a_Matrix3 ), "transpose Matrix3" ); - print( inverse( a_Matrix3 ), "inverse Matrix3" ); - print( ( inverse( a_Matrix3 ) * a_Matrix3 ), "inverse(Matrix3) * Matrix3" ); - printf("%f\n", getfloat(determinant( a_Matrix3 )) ); - print( outer( a_Vector3, b_Vector3 ), "outer Vector3" ); - print( rowMul( a_Vector3, a_Matrix3 ), "rowMul Vector3" ); - print( crossMatrix( a_Vector3 ), "crossMatrix" ); - print( crossMatrixMul( a_Vector3, a_Matrix3 ), "crossMatrixMul" ); -} - -void -Matrix4_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Matrix4, a_Vector3 ), "appendScale Matrix4 Vector3" ); - print( prependScale( a_Vector3, a_Matrix4 ), "prependScale Vector3 Matrix4" ); - print( mulPerElem( a_Matrix4, b_Matrix4 ), "mulPerElem Matrix4" ); - print( absPerElem( a_Matrix4 ), "absPerElem Matrix4" ); - print( transpose( a_Matrix4 ), "transpose Matrix4" ); - print( inverse( a_Matrix4 ), "inverse Matrix4" ); - print( ( inverse( a_Matrix4 ) * a_Matrix4 ), "inverse(Matrix4) * Matrix4" ); - a_Matrix4.setRow( 3, Vector4( ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){0.0f,0.0f,0.0f,0.0f}), ((vec_float4){1.0f,1.0f,1.0f,1.0f}) ) ); - a_Matrix4.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); - print( affineInverse( a_Matrix4 ), "affineInverse Matrix4" ); - print( ( affineInverse( a_Matrix4 ) * a_Matrix4 ), "affineInverse(Matrix4) * Matrix4" ); - print( orthoInverse( a_Matrix4 ), "orthoInverse Matrix4" ); - print( ( orthoInverse( a_Matrix4 ) * a_Matrix4 ), "orthoInverse(Matrix4) * Matrix4" ); - printf("%f\n", getfloat(determinant( a_Matrix4 )) ); - print( outer( a_Vector4, b_Vector4 ), "outer Vector4" ); -} - -void -Transform3_methods_test() -{ - Matrix3 a_Matrix3, b_Matrix3; - Matrix4 a_Matrix4, b_Matrix4; - Transform3 a_Transform3, b_Transform3; - Vector3 a_Vector3, b_Vector3, c_Vector3, d_Vector3; - Vector4 a_Vector4, b_Vector4, c_Vector4, d_Vector4; - Point3 a_Point3, b_Point3, c_Point3, d_Point3; - Quat a_Quat, b_Quat, c_Quat, d_Quat; - vec_float4 rndflt1, rndflt2, rndflt3, rndflt4, rndflt5, rndflt6; - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector3 = Vector3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Vector3 = Vector3( rndflt1, rndflt2, rndflt3 ); - print( a_Vector3, "set Vector3 with floats" ); - print( b_Vector3, "set Vector3 with floats" ); - print( c_Vector3, "set Vector3 with floats" ); - print( d_Vector3, "set Vector3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Vector4 = Vector4( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Vector4 = Vector4( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Vector4, "set Vector4 with floats" ); - print( b_Vector4, "set Vector4 with floats" ); - print( c_Vector4, "set Vector4 with floats" ); - print( d_Vector4, "set Vector4 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - a_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Point3 = Point3( rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - c_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - d_Point3 = Point3( rndflt1, rndflt2, rndflt3 ); - print( a_Point3, "set Point3 with floats" ); - print( b_Point3, "set Point3 with floats" ); - print( c_Point3, "set Point3 with floats" ); - print( d_Point3, "set Point3 with floats" ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - a_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - rndflt5 = randfloat(); - rndflt6 = randfloat(); - b_Quat = Quat( rndflt3, rndflt4, rndflt5, rndflt6 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - c_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - rndflt1 = randfloat(); - rndflt2 = randfloat(); - rndflt3 = randfloat(); - rndflt4 = randfloat(); - d_Quat = Quat( rndflt1, rndflt2, rndflt3, rndflt4 ); - print( a_Quat, "set Quat with floats" ); - print( b_Quat, "set Quat with floats" ); - print( c_Quat, "set Quat with floats" ); - print( d_Quat, "set Quat with floats" ); - a_Matrix3 = Matrix3( a_Vector3, b_Vector3, c_Vector3 ); - b_Matrix3 = Matrix3( d_Vector3, a_Vector3, b_Vector3 ); - print( a_Matrix3, "set Matrix3 columns" ); - print( b_Matrix3, "set Matrix3 columns" ); - a_Matrix4 = Matrix4( a_Vector4, b_Vector4, c_Vector4, d_Vector4 ); - b_Matrix4 = Matrix4( d_Vector4, a_Vector4, b_Vector4, c_Vector4 ); - print( a_Matrix4, "set Matrix4 columns" ); - print( b_Matrix4, "set Matrix4 columns" ); - a_Transform3 = Transform3( a_Vector3, b_Vector3, c_Vector3, d_Vector3 ); - b_Transform3 = Transform3( d_Vector3, a_Vector3, b_Vector3, c_Vector3 ); - print( a_Transform3, "set Transform3 columns" ); - print( b_Transform3, "set Transform3 columns" ); - print( appendScale( a_Transform3, a_Vector3 ), "appendScale Transform3 Vector3" ); - print( prependScale( a_Vector3, a_Transform3 ), "prependScale Vector3 Transform3" ); - print( mulPerElem( a_Transform3, b_Transform3 ), "mulPerElem Transform3" ); - print( absPerElem( a_Transform3 ), "absPerElem Transform3" ); - print( inverse( a_Transform3 ), "inverse Transform3" ); - print( ( inverse( a_Transform3 ) * a_Transform3 ), "inverse(Transform3) * Transform3" ); - a_Transform3.setUpper3x3( Matrix3( normalize( a_Quat ) ) ); - print( orthoInverse( a_Transform3 ), "orthoInverse Transform3" ); - print( ( orthoInverse( a_Transform3 ) * a_Transform3 ), "orthoInverse(Transform3) * Transform3" ); -} - -int main() -{ - int i; - printf("\n __begin__ \n"); - for ( i = 0; i < 2; i++ ) { - Matrix3_methods_test(); - Matrix4_methods_test(); - Transform3_methods_test(); - } - printf("\n __end__ \n"); - return 0; -} diff --git a/Extras/vectormathlibrary/vectormath.spec b/Extras/vectormathlibrary/vectormath.spec deleted file mode 100644 index 9507485c1..000000000 --- a/Extras/vectormathlibrary/vectormath.spec +++ /dev/null @@ -1,81 +0,0 @@ -%define lib_version 1.0.1 - -Summary: Vector math library -Name: vectormath -Version: %{lib_version} -Release: 1 -License: BSD -Group: Development/Libraries -Source0: %{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root - -%description -Vector math library. - -%ifarch ppc ppc64 -%define _lib_arch ppu -%endif - -%ifarch i386 x86_64 -%define _lib_arch SSE -%endif - -%if %{undefined _lib_arch} -%define _lib_arch scalar -%endif - -%package -n %{name}-devel -Summary: Vector math library. -Group: Development/Libraries -%ifarch ppc ppc64 -Requires: simdmath-devel -%endif - -%description -n %{name}-devel -Vector math library. - -%ifarch ppc ppc64 -%package -n spu-%{name}-devel -Summary: Vector math library. -Group: Development/Libraries -Requires: spu-simdmath-devel - -%description -n spu-%{name}-devel -Vector math library. -%endif - -%prep -%setup -q - -%build - -%install -rm -rf %{buildroot} - -make ARCH=%{_lib_arch} DESTDIR=%{buildroot} install - -%ifarch ppc ppc64 -make ARCH=spu DESTDIR=%{buildroot} install -%endif - -mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version} -cp README LICENSE doc/*.pdf %{buildroot}/%{_docdir}/%{name}-%{version}/ - - -%clean -rm -rf %{buildroot} - -%files -n %{name}-devel -%defattr(-,root,root,-) -%{_includedir}/* -%{_docdir}/* - -%ifarch ppc ppc64 -%files -n spu-%{name}-devel -%defattr(-,root,root,-) -%{_prefix}/spu/include/* -%endif - -%changelog -* Wed Aug 8 2007 Kazunori Asayama - 1.0.1-1 -- Initial build.